5 * Revision 1.1.1.1 1995/10/24 10:20:21 cernlib
9 #include "geant321/pilot.h"
10 *CMZ : 3.21/03 29/08/94 11.37.51 by S.Giani
13 SUBROUTINE GDCGVW (VPAR,VMA)
15 C. ******************************************************************
17 C. * Subroutine evaluates the Viewing Matrix from Viewing Angles *
19 C. * Input Parameters: *
21 C. * VPAR(3) : Viewing Angles (VPAR(1)=THETA, VPAR(2)=PHI, *
24 C. * Output Parameters: *
26 C. * VMA(4,3): Viewing Matrix *
28 C. * ==>Called by : GDINIT,GDRAW *
30 C. * Author : J.Salt ********* *
32 C. ******************************************************************
34 #include "geant321/gcdraw.inc"
35 #include "geant321/gconsp.inc"
37 DIMENSION VPAR(3),AMTR(4,4),VMA(4,3)
38 DIMENSION VL(3),VM(3),VN(3)
40 *.______________________________________
50 * Normalise theta, phi and psi angles to [0-360] range
52 THETA = MOD(ABS(VPAR(1)),180.)
53 PHI = MOD(ABS(VPAR(2)),360.)
54 PSI = MOD(ABS(VPAR(3)),360.)
56 * Ensure theta is in the range [0-180]
58 IF (THETA.GT.180.) THEN
62 SINPSI = SIN(PSI * DEGRAD)
63 COSPSI = COS(PSI * DEGRAD)
64 ST = SIN(THETA * DEGRAD)
65 CT = COS(THETA * DEGRAD)
66 SP = SIN(PHI * DEGRAD)
67 CP = COS(PHI * DEGRAD)
78 IF (ABS(VN(2)).LT.0.99999) THEN
80 * Y-axis is default mu axis (view up vector)
86 * Define new lambda axis
88 VL(1)=VM(2)*VN(3)-VM(3)*VN(2)
89 VL(2)=VM(3)*VN(1)-VM(1)*VN(3)
90 VL(3)=VM(1)*VN(2)-VM(2)*VN(1)
91 VAVL=SQRT(VL(1)**2+VL(2)**2+VL(3)**2)
98 VM(1)=VN(2)*VL(3)-VN(3)*VL(2)
99 VM(2)=VN(3)*VL(1)-VN(1)*VL(3)
100 VM(3)=VN(1)*VL(2)-VN(2)*VL(1)
104 * Special case when observer line of sight is along mu:
105 * in this case one chooses arbitrarily the vertical axis of the
106 * plane of projection as the lambda axis and the horizontal axis
117 * Get the view up vector by rotating the mu axis
118 * PSI degrees in the view plane (= mu-nu plane)
120 VUPX = COSPSI * VM(1) + SINPSI * VL(1)
121 VUPY = COSPSI * VM(2) + SINPSI * VL(2)
122 VUPZ = COSPSI * VM(3) + SINPSI * VL(3)
124 * Values for View Reference Point in NDC (CSw =1)
133 * Evaluate view matrix
135 CALL GDCGEM(VRPX,VRPY,VRPZ,VUPX,VUPY, VUPZ,VPNX, VPNY,VPNZ,IERR,
140 VMA(1,1)=AMTR(1,1)*GSCU
141 VMA(2,1)=AMTR(1,2)*GSCU
142 VMA(3,1)=AMTR(1,3)*GSCU
145 VMA(1,2)=AMTR(2,1)*GSCV
146 VMA(2,2)=AMTR(2,2)*GSCV
147 VMA(3,2)=AMTR(2,3)*GSCV