13 #pragma implementation
16 #include "CLHEP/Vector/defs.h"
17 #include "CLHEP/Vector/Rotation.h"
18 #include "CLHEP/Vector/ZMxpv.h"
26 bool HepRotation::setCols
27 (
const Hep3Vector & u1,
const Hep3Vector & u2,
const Hep3Vector & u3,
29 Hep3Vector & v1, Hep3Vector & v2, Hep3Vector & v3 )
const {
33 "All three cols supplied for a Rotation are parallel --"
34 "\n an arbitrary rotation will be returned"));
35 setArbitrarily (u1, v1, v2, v3);
40 v2 = Hep3Vector(u2 - u1u2 * u1).unit();
42 if ( v3.dot(u3) >= 0 ) {
50 void HepRotation::setArbitrarily (
const Hep3Vector & ccolX,
51 Hep3Vector & v1, Hep3Vector & v2, Hep3Vector & v3)
const {
57 v2 = v1.cross(Hep3Vector(0,0,1));
61 v2 = Hep3Vector(1,0,0);
82 double u1u2 = ucolX.
dot(ucolY);
83 double f12 = std::fabs(u1u2);
86 "col's X and Y supplied for Rotation are not close to orthogonal"));
88 double u1u3 = ucolX.
dot(ucolZ);
89 double f13 = std::fabs(u1u3);
92 "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);
98 "col's Y and Z supplied for Rotation are not close to orthogonal"));
103 if ( (f12 <= f13) && (f12 <= f23) ) {
104 isRotation = setCols ( ucolX, ucolY, ucolZ, u1u2, v1, v2, v3 );
107 "col's X Y and Z supplied form closer to a reflection than a Rotation "
108 "\n col Z is set to col X cross col Y"));
110 }
else if ( f13 <= f23 ) {
111 isRotation = setCols ( ucolZ, ucolX, ucolY, u1u3, v3, v1, v2 );
114 "col's X Y and Z supplied form closer to a reflection than a Rotation "
115 "\n col Y is set to col Z cross col X"));
118 isRotation = setCols ( ucolY, ucolZ, ucolX, u2u3, v2, v3, v1 );
121 "col's X Y and Z supplied form closer to a reflection than a Rotation "
122 "\n col X is set to col Y cross col Z"));
138 set (ccolX, ccolY, ccolZ);
144 set (rrowX, rrowY, rrowZ);
171 "Attempt to rectify a Rotation with determinant <= 0\n"));
174 double di = 1.0 / det;
199 double del =
delta();
double dot(const Hep3Vector &) const
HepRotation & setRows(const Hep3Vector &rowX, const Hep3Vector &rowY, const Hep3Vector &rowZ)
HepRotation & set(const Hep3Vector &axis, double delta)