5 * Revision 1.1.1.1 1995/10/24 10:20:23 cernlib
9 #include "geant321/pilot.h"
10 *CMZ : 3.21/02 29/03/94 15.41.26 by S.Giani
12 SUBROUTINE GDFR3D(X,NPOINT,U,V)
14 C. ******************************************************************
16 C. * Routine to convert the N 3D points given by array X *
17 C. * to the 2D points in U and V *
19 C. * If IGMR=1 then 3D points are not projected onto *
20 C. * U-V plane but used to build the APOLLO-GMR 3D structure *
22 C. * ITR3D = 0 for standard projection; *
23 C. * <> 0 for rotation + projection i.e. R-Z projection *
24 C. * with sign of R located in ITRSGN [ITR3D] *
27 C. * Steps from 3D to 2D when NPOINT>0 : *
29 C. * a) for volumes (IOBJ=1) : *
30 C. * transformation of the 3D point (x',y',z') in DRS *
31 C. * (Daughter Reference System) into the 3D point (x,y,z) *
32 C. * in MARS (MAster Reference System); *
34 C. * for tracks/hits (IOBJ<>1) after GDRVOL with NRS<>0 : *
35 C. * transformation of the 3D point (x',y',z') in MARS *
36 C. * into the 3D point (x,y,z) in DRS; *
38 C. * for tracks/hits (IOBJ<>1) after GDRAW/GDRAWC : *
41 C. * b) transformation of the 3D point (x,y,z) in MARS/DRS *
42 C. * into the 3D point (xx,yy,zz) in PRS (Projection *
43 C. * Reference System); PRS has its z axis along *
44 C. * the observer's line of sight (going to into the eye) *
46 C. * c) transformation of the 3D point (xx,yy,zz) in PRS *
47 C. * into the 2D point (u,v) in the plane normal to the *
48 C. * observer's line of sight; at that stage if ITR3D=0 *
49 C. * (standard projection) then u=xx and v=yy, *
50 C. * but if ITR3D <> 0 (rotation + projection i.e. R-Z) *
51 C. * then the 3D point (xx,yy,zz) in PRS is rotated along *
52 C. * xx axis until it is onto the xx-yy plane and finally *
53 C. * u=xx (unchanged by the rotation) and v=yy *
55 C. * ==>Called by : <USER>, GDAHIT, GDARC, GDAXIS, GDCIRC, *
56 C. * GDCIRR, GDCIRY, GDCUT, GDCXYZ, GDLINE, *
57 C. * GDPART, GDRECT, GDSURF, GDXYZ *
58 C. * Authors : R.Brun, P.Zanarini ********* *
60 C. ******************************************************************
62 #include "geant321/gcvolu.inc"
63 #include "geant321/gcdraw.inc"
64 DIMENSION XC(3),XYZ(3),VL(3),VM(3),VN(3),X(3,1),U(1),V(1)
69 C. ------------------------------------------------------------------
71 CALL UCTOH('PERS',IPERS,4,4)
73 IF(NPOINT.EQ.0)GO TO 100
75 IF(NPOINT.LT.0)N=-NPOINT
76 IF(NGVIEW.NE.0) GO TO 40
78 C First call compute the rotation matrix
80 PH = ABS(MOD(GPHI,360.))
81 THET = ABS(MOD(GTHETA,360.))
82 IF(THET.LE.180.)GO TO 10
86 10 ST = SIN(THET * 0.017453)
87 CT = COS(THET * 0.017453)
88 SP = SIN(PH * 0.017453)
89 CP = COS(PH * 0.017453)
97 IF(ABS(VN(2)).GT.0.99999)GO TO 20
103 C Define new lambda axis
113 C Special case when observer line of sight is along mu:
114 C in this case one chooses arbitrarily the vertical axis of
115 C plane of projection as the lambda axis and the horizontal
130 C Begin of a call with viewing tranformation unchanged (NGVI
134 IF (NPOINT.LT.0) THEN
136 C NPOINT < 0 : X is in MARS
144 C Transform X (MARS) in XYZ (PRS)
145 C i.e. project onto U,V,W
147 XYZ(1)=X(1,I)*VL(1)+X(2,I)*VL(2)+X(3,I)*VL(3)
148 XYZ(2)=X(1,I)*VM(1)+X(2,I)*VM(2)+X(3,I)*VM(3)
149 XYZ(3)=X(1,I)*VN(1)+X(2,I)*VN(2)+X(3,I)*VN(3)
155 C NPOINT > 0 and IOBJ <> 1 : X belongs to a track or hit or
156 C so it must be transformed from MARS to last DRS used by GD
157 C (otherwise GTRAN0 and GRMAT0 are the unitary transformatio
158 C and X is still expressed in MARS)
160 CALL GTRNSF(X(1,I),GTRAN0,GRMAT0,XC)
164 C NPOINT > 0 and IOBJ = 1 : X belongs to a volume,
165 C so it must be transformed from DRS to MARS
167 CALL GINROT(X(1,I),GRMAT(1,NLEVEL),XC)
169 60 XC(J)=XC(J)+GTRAN(J,NLEVEL)
179 C Transform XC (MARS or DRS) in XYZ (PRS)
180 C i.e. project onto U,V,W
182 XYZ(1)=XC(1)*VL(1)+XC(2)*VL(2)+XC(3)*VL(3)
183 XYZ(2)=XC(1)*VM(1)+XC(2)*VM(2)+XC(3)*VM(3)
184 XYZ(3)=XC(1)*VN(1)+XC(2)*VN(2)+XC(3)*VN(3)
188 C Scale, shift and rotate in in U and V
194 IF (ITR3D.NE.0) CALL GDTHRZ(XYZ)
196 C Perspective projection ?
198 IF (IPRJ.EQ.IPERS) THEN
199 IF (XYZ(3).GE.DPERS) XYZ(3)=DPERS-0.0001
200 XYZ(1)=XYZ(1)*DPERS/(DPERS-XYZ(3))
201 XYZ(2)=XYZ(2)*DPERS/(DPERS-XYZ(3))
206 U(I)=GU0+UU*COSPSI-VV*SINPSI
207 V(I)=GV0+UU*SINPSI+VV*COSPSI
211 U(I)=U(I)*GZUA+GZUB+GZUC
212 V(I)=V(I)*GZVA+GZVB+GZVC
216 IF (IGMR.EQ.1) CALL GM3POL(XP,N)