13 #pragma implementation
24 bool HepRotation::setCols
25 (
const Hep3Vector & u1,
const Hep3Vector & u2,
const Hep3Vector & u3,
27 Hep3Vector & v1, Hep3Vector & v2, Hep3Vector & v3 )
const {
30 std::cerr <<
"HepRotation::setCols() - "
31 <<
"All three cols supplied for a Rotation are parallel --"
32 <<
"\n an arbitrary rotation will be returned" << std::endl;
33 setArbitrarily (u1, v1, v2, v3);
38 v2 = Hep3Vector(u2 - u1u2 * u1).unit();
40 if ( v3.dot(u3) >= 0 ) {
48 void HepRotation::setArbitrarily (
const Hep3Vector & ccolX,
49 Hep3Vector & v1, Hep3Vector & v2, Hep3Vector & v3)
const {
55 v2 = v1.cross(Hep3Vector(0,0,1));
59 v2 = Hep3Vector(1,0,0);
80 double u1u2 = ucolX.
dot(ucolY);
81 double f12 = std::fabs(u1u2);
83 std::cerr <<
"HepRotation::set() - "
84 <<
"col's X and Y supplied for Rotation are not close to orthogonal"
87 double u1u3 = ucolX.
dot(ucolZ);
88 double f13 = std::fabs(u1u3);
90 std::cerr <<
"HepRotation::set() - "
91 <<
"col's X and Z supplied for Rotation are not close to orthogonal"
94 double u2u3 = ucolY.
dot(ucolZ);
95 double f23 = std::fabs(u2u3);
97 std::cerr <<
"HepRotation::set() - "
98 <<
"col's Y and Z supplied for Rotation are not close to orthogonal"
104 if ( (f12 <= f13) && (f12 <= f23) ) {
105 isRotation = setCols ( ucolX, ucolY, ucolZ, u1u2, v1, v2, v3 );
107 std::cerr <<
"HepRotation::set() - "
108 <<
"col's X Y and Z supplied form closer to a reflection than a Rotation "
109 <<
"\n col Z is set to col X cross col Y" << std::endl;
111 }
else if ( f13 <= f23 ) {
112 isRotation = setCols ( ucolZ, ucolX, ucolY, u1u3, v3, v1, v2 );
114 std::cerr <<
"HepRotation::set() - "
115 <<
"col's X Y and Z supplied form closer to a reflection than a Rotation "
116 <<
"\n col Y is set to col Z cross col X" << std::endl;
119 isRotation = setCols ( ucolY, ucolZ, ucolX, u2u3, v2, v3, v1 );
121 std::cerr <<
"HepRotation::set() - "
122 <<
"col's X Y and Z supplied form closer to a reflection than a Rotation "
123 <<
"\n col X is set to col Y cross col Z" << std::endl;
139 set (ccolX, ccolY, ccolZ);
145 set (rrowX, rrowY, rrowZ);
170 std::cerr <<
"HepRotation::rectify() - "
171 <<
"Attempt to rectify a Rotation with determinant <= 0" << std::endl;
174 double di = 1.0 / det;
180 double yx1 = (
ryz * rzx -
ryx *
rzz) * di;
181 double yy1 = (
rzz *
rxx - rzx *
rxz) * di;
184 double zy1 = (rzx *
rxy -
rzy *
rxx) * di;
194 rzx = .5*(rzx + xz1);
199 double del =
delta();