source: trunk/src/px_XYZ.m @ 92

Last change on this file since 92 was 92, checked in by gostiaux, 14 years ago

Plotting vectors centered on the middle of the arrow. Apparently this does not create any bug.

File size: 1.3 KB
Line 
1
2function [X,Y]=px_XYZ(Calib,Xphys,Yphys,Zphys)
3X=[];%default
4Y=[];
5% if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'PlanePos')&length(Calib.PlanePos)>=Z
6%     Zindex=Z;
7%     planepos=Calib.PlanePos{Zindex};
8%     zphys=planepos(3);%A GENERALISER CAS AVEC ANGLE
9% else
10%     zphys=0;
11% end
12if ~exist('Zphys','var')
13    Zphys=0;
14end
15if ~isfield(Calib,'f')
16    Calib.f=1;
17end
18if ~isfield(Calib,'kappa1')
19    Calib.kappa1=0;
20end
21if ~isfield(Calib,'sx')
22    Calib.sx=1;
23end
24if ~isfield(Calib,'dpx')
25    Calib.dpx=1;
26end
27if ~isfield(Calib,'dpy')
28    Calib.dpy=1;
29end
30if ~isfield(Calib,'Cx')
31    Calib.Cx=0;
32end
33if ~isfield(Calib,'Cy')
34    Calib.Cy=0;
35end
36%%%%%%%%%%%%%
37if isfield(Calib,'R')
38    R=(Calib.R)';
39    xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx;
40    yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Ty;
41    zc=R(7)*Xphys+R(8)*Yphys+R(9)*Zphys+Calib.Tz;
42%undistorted image coordinates
43    Xu=Calib.f*xc./zc;
44    Yu=Calib.f*yc./zc;
45%distorted image coordinates
46    distortion=(Calib.kappa1)*(Xu.*Xu+Yu.*Yu)+1; %A REVOIR
47% distortion=1;
48    Xd=Xu./distortion;
49    Yd=Yu./distortion;
50%pixel coordinates
51    X=Xd*Calib.sx/Calib.dpx+Calib.Cx;
52    Y=Yd/Calib.dpy+Calib.Cy;
53
54elseif isfield(Calib,'Pxcmx')&isfield(Calib,'Pxcmy')%old calib 
55        X=Xphys*Calib.Pxcmx;
56        Y=Yphys*Calib.Pxcmy;
57end
58
59
60
Note: See TracBrowser for help on using the repository browser.