25 {
26 int i,k;
27 double angA=CLHEP::pi/3, angB=CLHEP::pi/4, angC=CLHEP::pi/6;
28 double cosA =std::cos(angA), sinA =std::sin(angA);
29 double cosB =std::cos(angB), sinB =std::sin(angB);
30 double cosC =std::cos(angC), sinC =std::sin(angC);
31
33 assert ( R.
xx() == 1 );
34 assert ( R.
xy() == 0 );
35 assert ( R.
xz() == 0 );
36 assert ( R.
yx() == 0 );
37 assert ( R.
yy() == 1 );
38 assert ( R.
yz() == 0 );
39 assert ( R.
zx() == 0 );
40 assert ( R.
zy() == 0 );
41 assert ( R.
zz() == 1 );
42
43 assert( R.isIdentity() );
44
46 R.rotateX(angA);
47 assert ( R.
xx() == 1 );
48 assert ( R.
xy() == 0 );
49 assert ( R.
xz() == 0 );
50 assert ( R.
yx() == 0 );
51 assert ( R.
yy() == cosA );
52 assert ( R.
yz() ==-sinA );
53 assert ( R.
zx() == 0 );
54 assert ( R.
zy() == sinA );
55 assert ( R.
zz() == cosA );
56
58 R.rotateY(angB);
59 assert ( R.
xx() == cosB );
60 assert ( R.
xy() == 0 );
61 assert ( R.
xz() == sinB );
62 assert ( R.
yx() == 0 );
63 assert ( R.
yy() == 1 );
64 assert ( R.
yz() == 0 );
65 assert ( R.
zx() ==-sinB );
66 assert ( R.
zy() == 0 );
67 assert ( R.
zz() == cosB );
68
70 R.rotateZ(angC);
71 assert ( R.
xx() == cosC );
72 assert ( R.
xy() ==-sinC );
73 assert ( R.
xz() == 0 );
74 assert ( R.
yx() == sinC );
75 assert ( R.
yy() == cosC );
76 assert ( R.
yz() == 0 );
77 assert ( R.
zx() == 0 );
78 assert ( R.
zy() == 0 );
79 assert ( R.
zz() == 1 );
80
82 R.rotateZ(angC);
83 R.rotateY(angB);
84 R.rotateZ(angA);
86
87 assert ( std::abs(RR.xx() - cosA*cosB*cosC + sinA*sinC) <
DEL );
88 assert ( std::abs(RR.xy() + cosA*cosB*sinC + sinA*cosC) <
DEL );
89 assert ( std::abs(RR.xz() - cosA*sinB) <
DEL );
90 assert ( std::abs(RR.yx() - sinA*cosB*cosC - cosA*sinC) <
DEL );
91 assert ( std::abs(RR.yy() + sinA*cosB*sinC - cosA*cosC) <
DEL );
92 assert ( std::abs(RR.yz() - sinA*sinB) <
DEL );
93 assert ( std::abs(RR.zx() + sinB*cosC) <
DEL );
94 assert ( std::abs(RR.zy() - sinB*sinC) <
DEL );
95 assert ( std::abs(RR.zz() - cosB) <
DEL );
96
98 assert ( RR != R );
99 RR = R;
100 assert ( RR == R );
101
102 assert ( R(0,0) == R.
xx() );
103 assert ( R(0,1) == R.
xy() );
104 assert ( R(0,2) == R.
xz() );
105 assert ( R(1,0) == R.
yx() );
106 assert ( R(1,1) == R.
yy() );
107 assert ( R(1,2) == R.
yz() );
108 assert ( R(2,0) == R.
zx() );
109 assert ( R(2,1) == R.
zy() );
110 assert ( R(2,2) == R.
zz() );
111
112 for(i=0; i<3; i++) {
113 for(k=0; k<3; k++) {
114 assert ( RR(i,k) == R[i][k] );
115 }
116 }
117
119 A.rotateZ(angA);
121 C.rotateZ(angC);
122 R = A; R *=
B; R *= C;
123
125 V = R * V;
126 assert ( std::abs(V.x()-R.
xx()-2.*R.
xy()-3.*R.
xz()) <
DEL );
127 assert ( std::abs(V.y()-R.
yx()-2.*R.
yy()-3.*R.
yz()) <
DEL );
128 assert ( std::abs(V.z()-R.
zx()-2.*R.
zy()-3.*R.
zz()) <
DEL );
129
131 assert ( std::abs(RR.xx() - R.
xx()) <
DEL );
132 assert ( std::abs(RR.xy() - R.
xy()) <
DEL );
133 assert ( std::abs(RR.xz() - R.
xz()) <
DEL );
134 assert ( std::abs(RR.yx() - R.
yx()) <
DEL );
135 assert ( std::abs(RR.yy() - R.
yy()) <
DEL );
136 assert ( std::abs(RR.yz() - R.
yz()) <
DEL );
137 assert ( std::abs(RR.zx() - R.
zx()) <
DEL );
138 assert ( std::abs(RR.zy() - R.
zy()) <
DEL );
139 assert ( std::abs(RR.zz() - R.
zz()) <
DEL );
140
141 R = C;
143 R.transform(A);
144 assert ( std::abs(RR.xx() - R.
xx()) <
DEL );
145 assert ( std::abs(RR.xy() - R.
xy()) <
DEL );
146 assert ( std::abs(RR.xz() - R.
xz()) <
DEL );
147 assert ( std::abs(RR.yx() - R.
yx()) <
DEL );
148 assert ( std::abs(RR.yy() - R.
yy()) <
DEL );
149 assert ( std::abs(RR.yz() - R.
yz()) <
DEL );
150 assert ( std::abs(RR.zx() - R.
zx()) <
DEL );
151 assert ( std::abs(RR.zy() - R.
zy()) <
DEL );
152 assert ( std::abs(RR.zz() - R.
zz()) <
DEL );
153
155 for(i=0; i<3; i++) {
156 for(k=0; k<3; k++) {
157 assert ( RR(i,k) == R[k][i] );
158 }
159 }
160
161 R.invert();
162 assert ( RR == R );
163
165 R.rotateAxes(
Vector(RR.xx(), RR.yx(), RR.zx()),
166 Vector(RR.xy(), RR.yy(), RR.zy()),
167 Vector(RR.xz(), RR.yz(), RR.zz()) );
168 assert ( RR == R );
169
170 double ang=CLHEP::twopi/9.;
172 R.rotate(ang, V);
173
175 RR.rotateZ(-(V.phi()));
176 RR.rotateY(-(V.theta()));
177 RR.rotateZ(ang);
178 RR.rotateY(V.theta());
179 RR.rotateZ(V.phi());
180
181 assert ( std::abs(RR.xx() - R.
xx()) <
DEL );
182 assert ( std::abs(RR.xy() - R.
xy()) <
DEL );
183 assert ( std::abs(RR.xz() - R.
xz()) <
DEL );
184 assert ( std::abs(RR.yx() - R.
yx()) <
DEL );
185 assert ( std::abs(RR.yy() - R.
yy()) <
DEL );
186 assert ( std::abs(RR.yz() - R.
yz()) <
DEL );
187 assert ( std::abs(RR.zx() - R.
zx()) <
DEL );
188 assert ( std::abs(RR.zy() - R.
zy()) <
DEL );
189 assert ( std::abs(RR.zz() - R.
zz()) <
DEL );
190
192 R.getAngleAxis(ang, V);
193 assert ( std::abs(ang - CLHEP::twopi/9.) <
DEL );
194 assert ( std::abs(V.x() - Vu.
x()) <
DEL );
195 assert ( std::abs(V.y() - Vu.
y()) <
DEL );
196 assert ( std::abs(V.z() - Vu.
z()) <
DEL );
197
198 assert ( std::abs(RR.phiX()-std::atan2(RR.yx(),RR.xx())) <
DEL );
199 assert ( std::abs(RR.phiY()-std::atan2(RR.yy(),RR.xy())) <
DEL );
200 assert ( std::abs(RR.phiZ()-std::atan2(RR.yz(),RR.xz())) <
DEL );
201
202 assert ( std::abs(RR.thetaX()-std::acos(RR.zx())) <
DEL );
203 assert ( std::abs(RR.thetaY()-std::acos(RR.zy())) <
DEL );
204 assert ( std::abs(RR.thetaZ()-std::acos(RR.zz())) <
DEL );
205
206 return 0;
207}
BasicVector3D< T > unit() const