Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
CLHEP::HepRotation Class Reference

#include <Rotation.h>

+ Inheritance diagram for CLHEP::HepRotation:

Classes

class  HepRotation_row
 

Public Member Functions

 HepRotation ()
 
 HepRotation (const HepRotation &m)
 
 HepRotation (const HepRotationX &m)
 
 HepRotation (const HepRotationY &m)
 
 HepRotation (const HepRotationZ &m)
 
HepRotationset (const Hep3Vector &axis, double delta)
 
 HepRotation (const Hep3Vector &axis, double delta)
 
HepRotationset (const HepAxisAngle &ax)
 
 HepRotation (const HepAxisAngle &ax)
 
HepRotationset (double phi, double theta, double psi)
 
 HepRotation (double phi, double theta, double psi)
 
HepRotationset (const HepEulerAngles &e)
 
 HepRotation (const HepEulerAngles &e)
 
 HepRotation (const Hep3Vector &colX, const Hep3Vector &colY, const Hep3Vector &colZ)
 
HepRotationset (const Hep3Vector &colX, const Hep3Vector &colY, const Hep3Vector &colZ)
 
HepRotationsetRows (const Hep3Vector &rowX, const Hep3Vector &rowY, const Hep3Vector &rowZ)
 
HepRotationset (const HepRotationX &r)
 
HepRotationset (const HepRotationY &r)
 
HepRotationset (const HepRotationZ &r)
 
HepRotationoperator= (const HepRotation &r)
 
HepRotationoperator= (const HepRotationX &r)
 
HepRotationoperator= (const HepRotationY &r)
 
HepRotationoperator= (const HepRotationZ &r)
 
HepRotationset (const HepRep3x3 &m)
 
 HepRotation (const HepRep3x3 &m)
 
 ~HepRotation ()
 
Hep3Vector colX () const
 
Hep3Vector colY () const
 
Hep3Vector colZ () const
 
Hep3Vector rowX () const
 
Hep3Vector rowY () const
 
Hep3Vector rowZ () const
 
double xx () const
 
double xy () const
 
double xz () const
 
double yx () const
 
double yy () const
 
double yz () const
 
double zx () const
 
double zy () const
 
double zz () const
 
HepRep3x3 rep3x3 () const
 
const HepRotation_row operator[] (int) const
 
double operator() (int, int) const
 
double getPhi () const
 
double getTheta () const
 
double getPsi () const
 
double phi () const
 
double theta () const
 
double psi () const
 
HepEulerAngles eulerAngles () const
 
double getDelta () const
 
Hep3Vector getAxis () const
 
double delta () const
 
Hep3Vector axis () const
 
HepAxisAngle axisAngle () const
 
void getAngleAxis (double &delta, Hep3Vector &axis) const
 
double phiX () const
 
double phiY () const
 
double phiZ () const
 
double thetaX () const
 
double thetaY () const
 
double thetaZ () const
 
HepLorentzVector col1 () const
 
HepLorentzVector col2 () const
 
HepLorentzVector col3 () const
 
HepLorentzVector col4 () const
 
HepLorentzVector row1 () const
 
HepLorentzVector row2 () const
 
HepLorentzVector row3 () const
 
HepLorentzVector row4 () const
 
double xt () const
 
double yt () const
 
double zt () const
 
double tx () const
 
double ty () const
 
double tz () const
 
double tt () const
 
HepRep4x4 rep4x4 () const
 
void setPhi (double phi)
 
void setTheta (double theta)
 
void setPsi (double psi)
 
void setAxis (const Hep3Vector &axis)
 
void setDelta (double delta)
 
void decompose (HepAxisAngle &rotation, Hep3Vector &boost) const
 
void decompose (Hep3Vector &boost, HepAxisAngle &rotation) const
 
bool isIdentity () const
 
int compare (const HepRotation &r) const
 
bool operator== (const HepRotation &r) const
 
bool operator!= (const HepRotation &r) const
 
bool operator< (const HepRotation &r) const
 
bool operator> (const HepRotation &r) const
 
bool operator<= (const HepRotation &r) const
 
bool operator>= (const HepRotation &r) const
 
double distance2 (const HepRotation &r) const
 
double howNear (const HepRotation &r) const
 
bool isNear (const HepRotation &r, double epsilon=Hep4RotationInterface::tolerance) const
 
double distance2 (const HepBoost &lt) const
 
double distance2 (const HepLorentzRotation &lt) const
 
double howNear (const HepBoost &lt) const
 
double howNear (const HepLorentzRotation &lt) const
 
bool isNear (const HepBoost &lt, double epsilon=Hep4RotationInterface::tolerance) const
 
bool isNear (const HepLorentzRotation &lt, double epsilon=Hep4RotationInterface::tolerance) const
 
double norm2 () const
 
void rectify ()
 
Hep3Vector operator() (const Hep3Vector &p) const
 
Hep3Vector operator* (const Hep3Vector &p) const
 
HepLorentzVector operator() (const HepLorentzVector &w) const
 
HepLorentzVector operator* (const HepLorentzVector &w) const
 
HepRotation operator* (const HepRotation &r) const
 
HepRotation operator* (const HepRotationX &rx) const
 
HepRotation operator* (const HepRotationY &ry) const
 
HepRotation operator* (const HepRotationZ &rz) const
 
HepRotationoperator*= (const HepRotation &r)
 
HepRotationtransform (const HepRotation &r)
 
HepRotationoperator*= (const HepRotationX &r)
 
HepRotationoperator*= (const HepRotationY &r)
 
HepRotationoperator*= (const HepRotationZ &r)
 
HepRotationtransform (const HepRotationX &r)
 
HepRotationtransform (const HepRotationY &r)
 
HepRotationtransform (const HepRotationZ &r)
 
HepRotationrotateX (double delta)
 
HepRotationrotateY (double delta)
 
HepRotationrotateZ (double delta)
 
HepRotationrotate (double delta, const Hep3Vector &axis)
 
HepRotationrotate (double delta, const Hep3Vector *axis)
 
HepRotationrotateAxes (const Hep3Vector &newX, const Hep3Vector &newY, const Hep3Vector &newZ)
 
HepRotation inverse () const
 
HepRotationinvert ()
 
std::ostream & print (std::ostream &os) const
 

Static Public Member Functions

static double getTolerance ()
 
static double setTolerance (double tol)
 

Static Public Attributes

static DLL_API const HepRotation IDENTITY
 

Protected Member Functions

 HepRotation (double mxx, double mxy, double mxz, double myx, double myy, double myz, double mzx, double mzy, double mzz)
 

Protected Attributes

double rxx
 
double rxy
 
double rxz
 
double ryx
 
double ryy
 
double ryz
 
double rzx
 
double rzy
 
double rzz
 

Friends

HepRotation operator* (const HepRotationX &rx, const HepRotation &r)
 
HepRotation operator* (const HepRotationY &ry, const HepRotation &r)
 
HepRotation operator* (const HepRotationZ &rz, const HepRotation &r)
 

Detailed Description

Author

Definition at line 47 of file Rotation.h.

Constructor & Destructor Documentation

◆ HepRotation() [1/12]

CLHEP::HepRotation::HepRotation ( )
inline

Referenced by rotateAxes().

◆ HepRotation() [2/12]

CLHEP::HepRotation::HepRotation ( const HepRotation m)
inline

◆ HepRotation() [3/12]

CLHEP::HepRotation::HepRotation ( const HepRotationX m)
inline

◆ HepRotation() [4/12]

CLHEP::HepRotation::HepRotation ( const HepRotationY m)
inline

◆ HepRotation() [5/12]

CLHEP::HepRotation::HepRotation ( const HepRotationZ m)
inline

◆ HepRotation() [6/12]

CLHEP::HepRotation::HepRotation ( const Hep3Vector axis,
double  delta 
)

Definition at line 54 of file RotationA.cc.

55{
56 set( aaxis, ddelta );
57}
HepRotation & set(const Hep3Vector &axis, double delta)
Definition: RotationA.cc:27

◆ HepRotation() [7/12]

CLHEP::HepRotation::HepRotation ( const HepAxisAngle ax)

Definition at line 61 of file RotationA.cc.

62{
63 set ( ax.axis(), ax.delta() );
64}

◆ HepRotation() [8/12]

CLHEP::HepRotation::HepRotation ( double  phi,
double  theta,
double  psi 
)

Definition at line 57 of file RotationE.cc.

58{
59 set (phi1, theta1, psi1);
60}

◆ HepRotation() [9/12]

CLHEP::HepRotation::HepRotation ( const HepEulerAngles e)

Definition at line 64 of file RotationE.cc.

65{
66 set(e.phi(), e.theta(), e.psi());
67}

◆ HepRotation() [10/12]

CLHEP::HepRotation::HepRotation ( const Hep3Vector colX,
const Hep3Vector colY,
const Hep3Vector colZ 
)

Definition at line 135 of file RotationC.cc.

138{
139 set (ccolX, ccolY, ccolZ);
140}

◆ HepRotation() [11/12]

CLHEP::HepRotation::HepRotation ( const HepRep3x3 m)
inline

◆ ~HepRotation()

CLHEP::HepRotation::~HepRotation ( )
inline

◆ HepRotation() [12/12]

CLHEP::HepRotation::HepRotation ( double  mxx,
double  mxy,
double  mxz,
double  myx,
double  myy,
double  myz,
double  mzx,
double  mzy,
double  mzz 
)
inlineprotected

Member Function Documentation

◆ axis()

Hep3Vector CLHEP::HepRotation::axis ( ) const

Definition at line 79 of file RotationA.cc.

79 {
80
81 // Determine 2*std::sin(delta) times the u components (I call this uX, uY, Uz)
82 // Normalization is not needed; it will be done when returning the 3-Vector
83
84 double Uz = ryx - rxy;
85 double Uy = rxz - rzx;
86 double Ux = rzy - ryz;
87
88 if ( (Uz==0) && (Uy==0) && (Ux==0) ) {
89 if ( rzz>0 ) {
90 return Hep3Vector(0,0,1);
91 } else if ( ryy>0 ) {
92 return Hep3Vector(0,1,0);
93 } else {
94 return Hep3Vector(1,0,0);
95 }
96 } else {
97 return Hep3Vector( Ux, Uy, Uz ).unit();
98 }
99
100} // axis()

Referenced by axisAngle(), rectify(), and setDelta().

◆ axisAngle()

HepAxisAngle CLHEP::HepRotation::axisAngle ( ) const

Definition at line 102 of file RotationA.cc.

102 {
103
104 return HepAxisAngle (axis(), delta());
105
106} // axisAngle()
Hep3Vector axis() const
Definition: RotationA.cc:79
double delta() const
Definition: RotationA.cc:66

Referenced by CLHEP::HepLorentzRotation::decompose(), and decompose().

◆ col1()

HepLorentzVector CLHEP::HepRotation::col1 ( ) const
inline

◆ col2()

HepLorentzVector CLHEP::HepRotation::col2 ( ) const
inline

◆ col3()

HepLorentzVector CLHEP::HepRotation::col3 ( ) const
inline

◆ col4()

HepLorentzVector CLHEP::HepRotation::col4 ( ) const
inline

◆ colX()

◆ colY()

◆ colZ()

◆ compare()

int CLHEP::HepRotation::compare ( const HepRotation r) const

Definition at line 178 of file Rotation.cc.

178 {
179 if (rzz<r.rzz) return -1; else if (rzz>r.rzz) return 1;
180 else if (rzy<r.rzy) return -1; else if (rzy>r.rzy) return 1;
181 else if (rzx<r.rzx) return -1; else if (rzx>r.rzx) return 1;
182 else if (ryz<r.ryz) return -1; else if (ryz>r.ryz) return 1;
183 else if (ryy<r.ryy) return -1; else if (ryy>r.ryy) return 1;
184 else if (ryx<r.ryx) return -1; else if (ryx>r.ryx) return 1;
185 else if (rxz<r.rxz) return -1; else if (rxz>r.rxz) return 1;
186 else if (rxy<r.rxy) return -1; else if (rxy>r.rxy) return 1;
187 else if (rxx<r.rxx) return -1; else if (rxx>r.rxx) return 1;
188 else return 0;
189}

◆ decompose() [1/2]

void CLHEP::HepRotation::decompose ( Hep3Vector boost,
HepAxisAngle rotation 
) const

Definition at line 28 of file RotationP.cc.

28 {
29 boost.set(0,0,0);
30 rotation = axisAngle();
31}
HepAxisAngle axisAngle() const
Definition: RotationA.cc:102

◆ decompose() [2/2]

void CLHEP::HepRotation::decompose ( HepAxisAngle rotation,
Hep3Vector boost 
) const

Definition at line 23 of file RotationP.cc.

23 {
24 boost.set(0,0,0);
25 rotation = axisAngle();
26}

◆ delta()

double CLHEP::HepRotation::delta ( ) const

Definition at line 66 of file RotationA.cc.

66 {
67
68 double cosdelta = (rxx + ryy + rzz - 1.0) / 2.0;
69 if (cosdelta > 1.0) {
70 return 0;
71 } else if (cosdelta < -1.0) {
72 return CLHEP::pi;
73 } else {
74 return std::acos( cosdelta ); // Already safe due to the cosdelta > 1 check
75 }
76
77} // delta()

Referenced by axisAngle(), rectify(), and setAxis().

◆ distance2() [1/3]

double CLHEP::HepRotation::distance2 ( const HepBoost lt) const

Definition at line 39 of file RotationL.cc.

39 {
40 return distance2( HepLorentzRotation(lt));
41}
double distance2(const HepRotation &r) const
Definition: RotationP.cc:33

◆ distance2() [2/3]

double CLHEP::HepRotation::distance2 ( const HepLorentzRotation lt) const

Definition at line 29 of file RotationL.cc.

29 {
30 HepAxisAngle a;
31 Hep3Vector b;
32 lt.decompose(b, a);
33 double bet = b.beta();
34 double bet2 = bet*bet;
35 HepRotation r(a);
36 return bet2/(1-bet2) + distance2(r);
37}

◆ distance2() [3/3]

double CLHEP::HepRotation::distance2 ( const HepRotation r) const

Definition at line 33 of file RotationP.cc.

33 {
34 double sum = rxx * r.rxx + rxy * r.rxy + rxz * r.rxz
35 + ryx * r.ryx + ryy * r.ryy + ryz * r.ryz
36 + rzx * r.rzx + rzy * r.rzy + rzz * r.rzz;
37 double answer = 3.0 - sum;
38 return (answer >= 0 ) ? answer : 0;
39}

Referenced by distance2(), CLHEP::HepLorentzRotation::distance2(), howNear(), isNear(), and CLHEP::HepLorentzRotation::isNear().

◆ eulerAngles()

HepEulerAngles CLHEP::HepRotation::eulerAngles ( ) const

Definition at line 201 of file RotationE.cc.

201 {
202
203 // Please see the mathematical justification in eulerAngleComputations.ps
204
205 double phi1, theta1, psi1;
206 double psiPlusPhi, psiMinusPhi;
207
208 theta1 = safe_acos( rzz );
209
210// if (rzz > 1 || rzz < -1) {
211// std::cerr << "HepRotation::eulerAngles() - "
212// << "HepRotation::eulerAngles() finds | rzz | > 1 " << std::endl;
213// }
214
215 double cosTheta = rzz;
216 if (cosTheta > 1) cosTheta = 1;
217 if (cosTheta < -1) cosTheta = -1;
218
219 if (cosTheta == 1) {
220 psiPlusPhi = std::atan2 ( rxy - ryx, rxx + ryy );
221 psiMinusPhi = 0;
222
223 } else if (cosTheta >= 0) {
224
225 // In this realm, the atan2 expression for psi + phi is numerically stable
226 psiPlusPhi = std::atan2 ( rxy - ryx, rxx + ryy );
227
228 // psi - phi is potentially more subtle, but when unstable it is moot
229 double s1 = -rxy - ryx; // sin (psi-phi) * (1 - cos theta)
230 double c1 = rxx - ryy; // cos (psi-phi) * (1 - cos theta)
231 psiMinusPhi = std::atan2 ( s1, c1 );
232
233 } else if (cosTheta > -1) {
234
235 // In this realm, the atan2 expression for psi - phi is numerically stable
236 psiMinusPhi = std::atan2 ( -rxy - ryx, rxx - ryy );
237
238 // psi + phi is potentially more subtle, but when unstable it is moot
239 double s1 = rxy - ryx; // sin (psi+phi) * (1 + cos theta)
240 double c1 = rxx + ryy; // cos (psi+phi) * (1 + cos theta)
241 psiPlusPhi = std::atan2 ( s1, c1 );
242
243 } else { // cosTheta == -1
244
245 psiMinusPhi = std::atan2 ( -rxy - ryx, rxx - ryy );
246 psiPlusPhi = 0;
247
248 }
249
250 psi1 = .5 * (psiPlusPhi + psiMinusPhi);
251 phi1 = .5 * (psiPlusPhi - psiMinusPhi);
252
253 // Now correct by pi if we have managed to get a value of psiPlusPhi
254 // or psiMinusPhi that was off by 2 pi:
255 correctPsiPhi ( rxz, rzx, ryz, rzy, psi1, phi1 );
256
257 return HepEulerAngles( phi1, theta1, psi1 );
258
259} // eulerAngles()

Referenced by phi(), and psi().

◆ getAngleAxis()

void CLHEP::HepRotation::getAngleAxis ( double &  delta,
Hep3Vector axis 
) const

Definition at line 153 of file Rotation.cc.

153 {
154 double cosa = 0.5*(xx()+yy()+zz()-1);
155 double cosa1 = 1-cosa;
156 if (cosa1 <= 0) {
157 angle = 0;
158 aaxis = Hep3Vector(0,0,1);
159 }else{
160 double x=0, y=0, z=0;
161 if (xx() > cosa) x = std::sqrt((xx()-cosa)/cosa1);
162 if (yy() > cosa) y = std::sqrt((yy()-cosa)/cosa1);
163 if (zz() > cosa) z = std::sqrt((zz()-cosa)/cosa1);
164 if (zy() < yz()) x = -x;
165 if (xz() < zx()) y = -y;
166 if (yx() < xy()) z = -z;
167 angle = (cosa < -1.) ? std::acos(-1.) : std::acos(cosa);
168 aaxis = Hep3Vector(x,y,z);
169 }
170}
double zz() const
double yz() const
double zx() const
double yx() const
double zy() const
double xx() const
double yy() const
double xz() const
double xy() const

◆ getAxis()

Hep3Vector CLHEP::HepRotation::getAxis ( ) const
inline

◆ getDelta()

double CLHEP::HepRotation::getDelta ( ) const
inline

◆ getPhi()

double CLHEP::HepRotation::getPhi ( ) const
inline

◆ getPsi()

double CLHEP::HepRotation::getPsi ( ) const
inline

◆ getTheta()

double CLHEP::HepRotation::getTheta ( ) const
inline

◆ getTolerance()

static double CLHEP::HepRotation::getTolerance ( )
inlinestatic

◆ howNear() [1/3]

double CLHEP::HepRotation::howNear ( const HepBoost lt) const

Definition at line 47 of file RotationL.cc.

47 {
48 return std::sqrt( distance2( lt ) );
49}

◆ howNear() [2/3]

double CLHEP::HepRotation::howNear ( const HepLorentzRotation lt) const

Definition at line 43 of file RotationL.cc.

43 {
44 return std::sqrt( distance2( lt ) );
45}

◆ howNear() [3/3]

double CLHEP::HepRotation::howNear ( const HepRotation r) const

Definition at line 41 of file RotationP.cc.

41 {
42 return std::sqrt( distance2( r ) );
43}

◆ inverse()

◆ invert()

HepRotation & CLHEP::HepRotation::invert ( )
inline

Referenced by setRows().

◆ isIdentity()

bool CLHEP::HepRotation::isIdentity ( ) const

Definition at line 172 of file Rotation.cc.

172 {
173 return (rxx == 1.0 && rxy == 0.0 && rxz == 0.0 &&
174 ryx == 0.0 && ryy == 1.0 && ryz == 0.0 &&
175 rzx == 0.0 && rzy == 0.0 && rzz == 1.0) ? true : false;
176}

Referenced by G4GMocrenFileSceneHandler::AddSolid().

◆ isNear() [1/3]

bool CLHEP::HepRotation::isNear ( const HepBoost lt,
double  epsilon = Hep4RotationInterface::tolerance 
) const

Definition at line 56 of file RotationL.cc.

57 {
58 return distance2( lt ) <= epsilon*epsilon;
59}

◆ isNear() [2/3]

bool CLHEP::HepRotation::isNear ( const HepLorentzRotation lt,
double  epsilon = Hep4RotationInterface::tolerance 
) const

Definition at line 51 of file RotationL.cc.

52 {
53 return distance2( lt ) <= epsilon*epsilon;
54}

◆ isNear() [3/3]

bool CLHEP::HepRotation::isNear ( const HepRotation r,
double  epsilon = Hep4RotationInterface::tolerance 
) const

Definition at line 45 of file RotationP.cc.

46 {
47 return distance2( r ) <= epsilon*epsilon;
48}

◆ norm2()

◆ operator!=()

bool CLHEP::HepRotation::operator!= ( const HepRotation r) const
inline

◆ operator()() [1/3]

Hep3Vector CLHEP::HepRotation::operator() ( const Hep3Vector p) const
inline

◆ operator()() [2/3]

HepLorentzVector CLHEP::HepRotation::operator() ( const HepLorentzVector w) const
inline

◆ operator()() [3/3]

double CLHEP::HepRotation::operator() ( int  i,
int  j 
) const

Definition at line 28 of file Rotation.cc.

28 {
29 if (i == 0) {
30 if (j == 0) { return xx(); }
31 if (j == 1) { return xy(); }
32 if (j == 2) { return xz(); }
33 } else if (i == 1) {
34 if (j == 0) { return yx(); }
35 if (j == 1) { return yy(); }
36 if (j == 2) { return yz(); }
37 } else if (i == 2) {
38 if (j == 0) { return zx(); }
39 if (j == 1) { return zy(); }
40 if (j == 2) { return zz(); }
41 }
42 std::cerr << "HepRotation subscripting: bad indices "
43 << "(" << i << "," << j << ")" << std::endl;
44 return 0.0;
45}

◆ operator*() [1/6]

Hep3Vector CLHEP::HepRotation::operator* ( const Hep3Vector p) const
inline

◆ operator*() [2/6]

HepLorentzVector CLHEP::HepRotation::operator* ( const HepLorentzVector w) const
inline

◆ operator*() [3/6]

HepRotation CLHEP::HepRotation::operator* ( const HepRotation r) const
inline

◆ operator*() [4/6]

HepRotation CLHEP::HepRotation::operator* ( const HepRotationX rx) const
inline

◆ operator*() [5/6]

HepRotation CLHEP::HepRotation::operator* ( const HepRotationY ry) const
inline

◆ operator*() [6/6]

HepRotation CLHEP::HepRotation::operator* ( const HepRotationZ rz) const
inline

◆ operator*=() [1/4]

HepRotation & CLHEP::HepRotation::operator*= ( const HepRotation r)
inline

◆ operator*=() [2/4]

HepRotation & CLHEP::HepRotation::operator*= ( const HepRotationX r)
inline

◆ operator*=() [3/4]

HepRotation & CLHEP::HepRotation::operator*= ( const HepRotationY r)
inline

◆ operator*=() [4/4]

HepRotation & CLHEP::HepRotation::operator*= ( const HepRotationZ r)
inline

◆ operator<()

bool CLHEP::HepRotation::operator< ( const HepRotation r) const
inline

◆ operator<=()

bool CLHEP::HepRotation::operator<= ( const HepRotation r) const
inline

◆ operator=() [1/4]

HepRotation & CLHEP::HepRotation::operator= ( const HepRotation r)
inline

◆ operator=() [2/4]

HepRotation & CLHEP::HepRotation::operator= ( const HepRotationX r)
inline

◆ operator=() [3/4]

HepRotation & CLHEP::HepRotation::operator= ( const HepRotationY r)
inline

◆ operator=() [4/4]

HepRotation & CLHEP::HepRotation::operator= ( const HepRotationZ r)
inline

◆ operator==()

bool CLHEP::HepRotation::operator== ( const HepRotation r) const
inline

◆ operator>()

bool CLHEP::HepRotation::operator> ( const HepRotation r) const
inline

◆ operator>=()

bool CLHEP::HepRotation::operator>= ( const HepRotation r) const
inline

◆ operator[]()

const HepRotation_row CLHEP::HepRotation::operator[] ( int  ) const
inline

◆ phi()

double CLHEP::HepRotation::phi ( ) const

Definition at line 70 of file RotationE.cc.

70 {
71
72 double s2 = 1.0 - rzz*rzz;
73 if (s2 < 0) {
74 std::cerr << "HepRotation::phi() - "
75 << "HepRotation::phi() finds | rzz | > 1 " << std::endl;
76 s2 = 0;
77 }
78 const double sinTheta = std::sqrt( s2 );
79
80 if (sinTheta < .01) { // For theta close to 0 or PI, use the more stable
81 // algorithm to get all three Euler angles
82 HepEulerAngles ea = eulerAngles();
83 return ea.phi();
84 }
85
86 const double cscTheta = 1/sinTheta;
87 double cosabsphi = - rzy * cscTheta;
88 if ( std::fabs(cosabsphi) > 1 ) { // NaN-proofing
89 std::cerr << "HepRotation::phi() - "
90 << "HepRotation::phi() finds | cos phi | > 1 " << std::endl;
91 cosabsphi = 1;
92 }
93 const double absPhi = std::acos ( cosabsphi );
94 if (rzx > 0) {
95 return absPhi;
96 } else if (rzx < 0) {
97 return -absPhi;
98 } else {
99 return (rzy < 0) ? 0 : CLHEP::pi;
100 }
101
102} // phi()
HepEulerAngles eulerAngles() const
Definition: RotationE.cc:201

Referenced by setPsi(), and setTheta().

◆ phiX()

double CLHEP::HepRotation::phiX ( ) const

Definition at line 129 of file Rotation.cc.

129 {
130 return (yx() == 0.0 && xx() == 0.0) ? 0.0 : std::atan2(yx(),xx());
131}

Referenced by G4HepRepFileSceneHandler::AddSolid(), G4tgbGeometryDumper::DumpRotationMatrix(), and operator<<().

◆ phiY()

double CLHEP::HepRotation::phiY ( ) const

Definition at line 133 of file Rotation.cc.

133 {
134 return (yy() == 0.0 && xy() == 0.0) ? 0.0 : std::atan2(yy(),xy());
135}

Referenced by G4HepRepFileSceneHandler::AddSolid(), G4tgbGeometryDumper::DumpRotationMatrix(), and operator<<().

◆ phiZ()

double CLHEP::HepRotation::phiZ ( ) const

Definition at line 137 of file Rotation.cc.

137 {
138 return (yz() == 0.0 && xz() == 0.0) ? 0.0 : std::atan2(yz(),xz());
139}

Referenced by G4HepRepFileSceneHandler::AddSolid(), G4tgbGeometryDumper::DumpRotationMatrix(), and operator<<().

◆ print()

std::ostream & CLHEP::HepRotation::print ( std::ostream &  os) const

Definition at line 21 of file RotationIO.cc.

21 {
22 os << "\n [ ( " <<
23 std::setw(11) << std::setprecision(6) << xx() << " " <<
24 std::setw(11) << std::setprecision(6) << xy() << " " <<
25 std::setw(11) << std::setprecision(6) << xz() << ")\n"
26 << " ( " <<
27 std::setw(11) << std::setprecision(6) << yx() << " " <<
28 std::setw(11) << std::setprecision(6) << yy() << " " <<
29 std::setw(11) << std::setprecision(6) << yz() << ")\n"
30 << " ( " <<
31 std::setw(11) << std::setprecision(6) << zx() << " " <<
32 std::setw(11) << std::setprecision(6) << zy() << " " <<
33 std::setw(11) << std::setprecision(6) << zz() << ") ]\n";
34 return os;
35}

Referenced by G4ReflectedSolid::StreamInfo(), and G4DisplacedSolid::StreamInfo().

◆ psi()

double CLHEP::HepRotation::psi ( ) const

Definition at line 110 of file RotationE.cc.

110 {
111
112 double sinTheta;
113 if ( std::fabs(rzz) > 1 ) { // NaN-proofing
114 std::cerr << "HepRotation::psi() - "
115 << "HepRotation::psi() finds | rzz | > 1" << std::endl;
116 sinTheta = 0;
117 } else {
118 sinTheta = std::sqrt( 1.0 - rzz*rzz );
119 }
120
121 if (sinTheta < .01) { // For theta close to 0 or PI, use the more stable
122 // algorithm to get all three Euler angles
123 HepEulerAngles ea = eulerAngles();
124 return ea.psi();
125 }
126
127 const double cscTheta = 1/sinTheta;
128 double cosabspsi = ryz * cscTheta;
129 if ( std::fabs(cosabspsi) > 1 ) { // NaN-proofing
130 std::cerr << "HepRotation::psi() - "
131 << "HepRotation::psi() finds | cos psi | > 1" << std::endl;
132 cosabspsi = 1;
133 }
134 const double absPsi = std::acos ( cosabspsi );
135 if (rxz > 0) {
136 return absPsi;
137 } else if (rxz < 0) {
138 return -absPsi;
139 } else {
140 return (ryz > 0) ? 0 : CLHEP::pi;
141 }
142
143} // psi()

Referenced by setPhi(), and setTheta().

◆ rectify()

void CLHEP::HepRotation::rectify ( )

Definition at line 152 of file RotationC.cc.

152 {
153 // Assuming the representation of this is close to a true Rotation,
154 // but may have drifted due to round-off error from many operations,
155 // this forms an "exact" orthonormal matrix for the rotation again.
156
157 // The first step is to average with the transposed inverse. This
158 // will correct for small errors such as those occuring when decomposing
159 // a LorentzTransformation. Then we take the bull by the horns and
160 // formally extract the axis and delta (assuming the Rotation were true)
161 // and re-setting the rotation according to those.
162
163 double det = rxx * ryy * rzz +
164 rxy * ryz * rzx +
165 rxz * ryx * rzy -
166 rxx * ryz * rzy -
167 rxy * ryx * rzz -
168 rxz * ryy * rzx ;
169 if (det <= 0) {
170 std::cerr << "HepRotation::rectify() - "
171 << "Attempt to rectify a Rotation with determinant <= 0" << std::endl;
172 return;
173 }
174 double di = 1.0 / det;
175
176 // xx, xy, ... are components of inverse matrix:
177 double xx1 = (ryy * rzz - ryz * rzy) * di;
178 double xy1 = (rzy * rxz - rzz * rxy) * di;
179 double xz1 = (rxy * ryz - rxz * ryy) * di;
180 double yx1 = (ryz * rzx - ryx * rzz) * di;
181 double yy1 = (rzz * rxx - rzx * rxz) * di;
182 double yz1 = (rxz * ryx - rxx * ryz) * di;
183 double zx1 = (ryx * rzy - ryy * rzx) * di;
184 double zy1 = (rzx * rxy - rzy * rxx) * di;
185 double zz1 = (rxx * ryy - rxy * ryx) * di;
186
187 // Now average with the TRANSPOSE of that:
188 rxx = .5*(rxx + xx1);
189 rxy = .5*(rxy + yx1);
190 rxz = .5*(rxz + zx1);
191 ryx = .5*(ryx + xy1);
192 ryy = .5*(ryy + yy1);
193 ryz = .5*(ryz + zy1);
194 rzx = .5*(rzx + xz1);
195 rzy = .5*(rzy + yz1);
196 rzz = .5*(rzz + zz1);
197
198 // Now force feed this improved rotation
199 double del = delta();
200 Hep3Vector u = axis();
201 u = u.unit(); // Because if the rotation is inexact, then the
202 // axis() returned will not have length 1!
203 set(u, del);
204
205} // rectify()

Referenced by CLHEP::HepLorentzRotation::decompose(), and CLHEP::HepLorentzRotation::rectify().

◆ rep3x3()

HepRep3x3 CLHEP::HepRotation::rep3x3 ( ) const
inline

◆ rep4x4()

HepRep4x4 CLHEP::HepRotation::rep4x4 ( ) const
inline

◆ rotate() [1/2]

HepRotation & CLHEP::HepRotation::rotate ( double  delta,
const Hep3Vector axis 
)

Definition at line 47 of file Rotation.cc.

47 {
48 if (a != 0.0) {
49 double ll = aaxis.mag();
50 if (ll == 0.0) {
51 std::cerr << "HepRotation::rotate() - "
52 << "HepRotation: zero axis" << std::endl;
53 }else{
54 double sa = std::sin(a), ca = std::cos(a);
55 double dx = aaxis.x()/ll, dy = aaxis.y()/ll, dz = aaxis.z()/ll;
56 HepRotation m1(
57 ca+(1-ca)*dx*dx, (1-ca)*dx*dy-sa*dz, (1-ca)*dx*dz+sa*dy,
58 (1-ca)*dy*dx+sa*dz, ca+(1-ca)*dy*dy, (1-ca)*dy*dz-sa*dx,
59 (1-ca)*dz*dx-sa*dy, (1-ca)*dz*dy+sa*dx, ca+(1-ca)*dz*dz );
60 transform(m1);
61 }
62 }
63 return *this;
64}
HepRotation & transform(const HepRotation &r)

Referenced by G4tgbPlaceParamCircle::ComputeTransformation(), and CLHEP::Hep3Vector::rotate().

◆ rotate() [2/2]

HepRotation & CLHEP::HepRotation::rotate ( double  delta,
const Hep3Vector axis 
)
inline

◆ rotateAxes()

HepRotation & CLHEP::HepRotation::rotateAxes ( const Hep3Vector newX,
const Hep3Vector newY,
const Hep3Vector newZ 
)

Definition at line 105 of file Rotation.cc.

107 {
108 double del = 0.001;
109 Hep3Vector w = newX.cross(newY);
110
111 if (std::abs(newZ.x()-w.x()) > del ||
112 std::abs(newZ.y()-w.y()) > del ||
113 std::abs(newZ.z()-w.z()) > del ||
114 std::abs(newX.mag2()-1.) > del ||
115 std::abs(newY.mag2()-1.) > del ||
116 std::abs(newZ.mag2()-1.) > del ||
117 std::abs(newX.dot(newY)) > del ||
118 std::abs(newY.dot(newZ)) > del ||
119 std::abs(newZ.dot(newX)) > del) {
120 std::cerr << "HepRotation::rotateAxes: bad axis vectors" << std::endl;
121 return *this;
122 }else{
123 return transform(HepRotation(newX.x(), newY.x(), newZ.x(),
124 newX.y(), newY.y(), newZ.y(),
125 newX.z(), newY.z(), newZ.z()));
126 }
127}

Referenced by G4PlacedSolid::G4PlacedSolid().

◆ rotateX()

HepRotation & CLHEP::HepRotation::rotateX ( double  delta)

Definition at line 66 of file Rotation.cc.

66 {
67 double c1 = std::cos(a);
68 double s1 = std::sin(a);
69 double x1 = ryx, y1 = ryy, z1 = ryz;
70 ryx = c1*x1 - s1*rzx;
71 ryy = c1*y1 - s1*rzy;
72 ryz = c1*z1 - s1*rzz;
73 rzx = s1*x1 + c1*rzx;
74 rzy = s1*y1 + c1*rzy;
75 rzz = s1*z1 + c1*rzz;
76 return *this;
77}

Referenced by G4tgbRotationMatrix::BuildG4RotMatrixFrom3(), G4tgrUtils::GetRotationFromDirection(), G4GDMLReadDefine::GetRotationMatrix(), G4GDMLReadParamvol::ParametersRead(), and G4VScoringMesh::RotateX().

◆ rotateY()

HepRotation & CLHEP::HepRotation::rotateY ( double  delta)

Definition at line 79 of file Rotation.cc.

79 {
80 double c1 = std::cos(a);
81 double s1 = std::sin(a);
82 double x1 = rzx, y1 = rzy, z1 = rzz;
83 rzx = c1*x1 - s1*rxx;
84 rzy = c1*y1 - s1*rxy;
85 rzz = c1*z1 - s1*rxz;
86 rxx = s1*x1 + c1*rxx;
87 rxy = s1*y1 + c1*rxy;
88 rxz = s1*z1 + c1*rxz;
89 return *this;
90}

Referenced by G4INCLXXInterface::ApplyYourself(), G4tgbRotationMatrix::BuildG4RotMatrixFrom3(), G4NeutronBetaDecayChannel::DecayIt(), G4tgrUtils::GetRotationFromDirection(), G4GDMLReadDefine::GetRotationMatrix(), G4GDMLReadParamvol::ParametersRead(), and G4VScoringMesh::RotateY().

◆ rotateZ()

◆ row1()

HepLorentzVector CLHEP::HepRotation::row1 ( ) const
inline

◆ row2()

HepLorentzVector CLHEP::HepRotation::row2 ( ) const
inline

◆ row3()

HepLorentzVector CLHEP::HepRotation::row3 ( ) const
inline

◆ row4()

HepLorentzVector CLHEP::HepRotation::row4 ( ) const
inline

◆ rowX()

Hep3Vector CLHEP::HepRotation::rowX ( ) const
inline

◆ rowY()

Hep3Vector CLHEP::HepRotation::rowY ( ) const
inline

◆ rowZ()

Hep3Vector CLHEP::HepRotation::rowZ ( ) const
inline

◆ set() [1/9]

HepRotation & CLHEP::HepRotation::set ( const Hep3Vector axis,
double  delta 
)

Definition at line 27 of file RotationA.cc.

27 {
28
29 register double sinDelta = std::sin(ddelta), cosDelta = std::cos(ddelta);
30 register double oneMinusCosDelta = 1.0 - cosDelta;
31
32 Hep3Vector u = aaxis.unit();
33
34 register double uX = u.getX();
35 register double uY = u.getY();
36 register double uZ = u.getZ();
37
38 rxx = oneMinusCosDelta * uX * uX + cosDelta;
39 rxy = oneMinusCosDelta * uX * uY - sinDelta * uZ;
40 rxz = oneMinusCosDelta * uX * uZ + sinDelta * uY;
41
42 ryx = oneMinusCosDelta * uY * uX + sinDelta * uZ;
43 ryy = oneMinusCosDelta * uY * uY + cosDelta;
44 ryz = oneMinusCosDelta * uY * uZ - sinDelta * uX;
45
46 rzx = oneMinusCosDelta * uZ * uX - sinDelta * uY;
47 rzy = oneMinusCosDelta * uZ * uY + sinDelta * uX;
48 rzz = oneMinusCosDelta * uZ * uZ + cosDelta;
49
50 return *this;
51
52} // HepRotation::set(axis, delta)

Referenced by G4MuonDecayChannel::DecayIt(), CLHEP::HepLorentzRotation::decompose(), HepRotation(), rectify(), set(), setAxis(), setDelta(), setPhi(), setPsi(), setRows(), and setTheta().

◆ set() [2/9]

HepRotation & CLHEP::HepRotation::set ( const Hep3Vector colX,
const Hep3Vector colY,
const Hep3Vector colZ 
)

Definition at line 73 of file RotationC.cc.

75 {
76 Hep3Vector ucolX = ccolX.unit();
77 Hep3Vector ucolY = ccolY.unit();
78 Hep3Vector ucolZ = ccolZ.unit();
79
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"
85 << std::endl;
86 }
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"
92 << std::endl;
93 }
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"
99 << std::endl;
100 }
101
102 Hep3Vector v1, v2, v3;
103 bool isRotation;
104 if ( (f12 <= f13) && (f12 <= f23) ) {
105 isRotation = setCols ( ucolX, ucolY, ucolZ, u1u2, v1, v2, v3 );
106 if ( !isRotation ) {
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;
110 }
111 } else if ( f13 <= f23 ) {
112 isRotation = setCols ( ucolZ, ucolX, ucolY, u1u3, v3, v1, v2 );
113 if ( !isRotation ) {
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;
117 }
118 } else {
119 isRotation = setCols ( ucolY, ucolZ, ucolX, u2u3, v2, v3, v1 );
120 if ( !isRotation ) {
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;
124 }
125 }
126
127 rxx = v1.x(); ryx = v1.y(); rzx = v1.z();
128 rxy = v2.x(); ryy = v2.y(); rzy = v2.z();
129 rxz = v3.x(); ryz = v3.y(); rzz = v3.z();
130
131 return *this;
132
133} // HepRotation::set(colX, colY, colZ)
static DLL_API double tolerance

◆ set() [3/9]

HepRotation & CLHEP::HepRotation::set ( const HepAxisAngle ax)

Definition at line 58 of file RotationA.cc.

58 {
59 return set ( ax.axis(), ax.delta() );
60}

◆ set() [4/9]

HepRotation & CLHEP::HepRotation::set ( const HepEulerAngles e)

Definition at line 61 of file RotationE.cc.

61 {
62 return set(e.phi(), e.theta(), e.psi());
63}

◆ set() [5/9]

HepRotation & CLHEP::HepRotation::set ( const HepRep3x3 m)
inline

◆ set() [6/9]

HepRotation & CLHEP::HepRotation::set ( const HepRotationX r)
inline

◆ set() [7/9]

HepRotation & CLHEP::HepRotation::set ( const HepRotationY r)
inline

◆ set() [8/9]

HepRotation & CLHEP::HepRotation::set ( const HepRotationZ r)
inline

◆ set() [9/9]

HepRotation & CLHEP::HepRotation::set ( double  phi,
double  theta,
double  psi 
)

Definition at line 35 of file RotationE.cc.

35 {
36
37 register double sinPhi = std::sin( phi1 ), cosPhi = std::cos( phi1 );
38 register double sinTheta = std::sin( theta1 ), cosTheta = std::cos( theta1 );
39 register double sinPsi = std::sin( psi1 ), cosPsi = std::cos( psi1 );
40
41 rxx = cosPsi * cosPhi - cosTheta * sinPhi * sinPsi;
42 rxy = cosPsi * sinPhi + cosTheta * cosPhi * sinPsi;
43 rxz = sinPsi * sinTheta;
44
45 ryx = - sinPsi * cosPhi - cosTheta * sinPhi * cosPsi;
46 ryy = - sinPsi * sinPhi + cosTheta * cosPhi * cosPsi;
47 ryz = cosPsi * sinTheta;
48
49 rzx = sinTheta * sinPhi;
50 rzy = - sinTheta * cosPhi;
51 rzz = cosTheta;
52
53 return *this;
54
55} // Rotation::set(phi, theta, psi)

◆ setAxis()

void CLHEP::HepRotation::setAxis ( const Hep3Vector axis)

Definition at line 109 of file RotationA.cc.

109 {
110 set ( aaxis, delta() );
111}

◆ setDelta()

void CLHEP::HepRotation::setDelta ( double  delta)

Definition at line 113 of file RotationA.cc.

113 {
114 set ( axis(), ddelta );
115}

◆ setPhi()

void CLHEP::HepRotation::setPhi ( double  phi)

Definition at line 262 of file RotationE.cc.

262 {
263 set ( phi1, theta(), psi() );
264}
double psi() const
Definition: RotationE.cc:110
double theta() const
Definition: RotationE.cc:104

Referenced by G4GMocrenTouchable::GetRotation().

◆ setPsi()

void CLHEP::HepRotation::setPsi ( double  psi)

Definition at line 270 of file RotationE.cc.

270 {
271 set ( phi(), theta(), psi1 );
272}
double phi() const
Definition: RotationE.cc:70

◆ setRows()

HepRotation & CLHEP::HepRotation::setRows ( const Hep3Vector rowX,
const Hep3Vector rowY,
const Hep3Vector rowZ 
)

Definition at line 142 of file RotationC.cc.

144 {
145 set (rrowX, rrowY, rrowZ);
146 invert();
147 return *this;
148}
HepRotation & invert()

◆ setTheta()

void CLHEP::HepRotation::setTheta ( double  theta)

Definition at line 266 of file RotationE.cc.

266 {
267 set ( phi(), theta1, psi() );
268}

◆ setTolerance()

static double CLHEP::HepRotation::setTolerance ( double  tol)
inlinestatic

◆ theta()

double CLHEP::HepRotation::theta ( ) const

Definition at line 104 of file RotationE.cc.

104 {
105
106 return safe_acos( rzz );
107
108} // theta()

Referenced by setPhi(), and setPsi().

◆ thetaX()

double CLHEP::HepRotation::thetaX ( ) const

Definition at line 141 of file Rotation.cc.

141 {
142 return safe_acos(zx());
143}

Referenced by G4tgbGeometryDumper::DumpRotationMatrix(), and operator<<().

◆ thetaY()

double CLHEP::HepRotation::thetaY ( ) const

Definition at line 145 of file Rotation.cc.

145 {
146 return safe_acos(zy());
147}

Referenced by G4tgbGeometryDumper::DumpRotationMatrix(), and operator<<().

◆ thetaZ()

double CLHEP::HepRotation::thetaZ ( ) const

Definition at line 149 of file Rotation.cc.

149 {
150 return safe_acos(zz());
151}

Referenced by G4tgbGeometryDumper::DumpRotationMatrix(), and operator<<().

◆ transform() [1/4]

HepRotation & CLHEP::HepRotation::transform ( const HepRotation r)
inline

Referenced by rotate(), and rotateAxes().

◆ transform() [2/4]

HepRotation & CLHEP::HepRotation::transform ( const HepRotationX r)
inline

◆ transform() [3/4]

HepRotation & CLHEP::HepRotation::transform ( const HepRotationY r)
inline

◆ transform() [4/4]

HepRotation & CLHEP::HepRotation::transform ( const HepRotationZ r)
inline

◆ tt()

double CLHEP::HepRotation::tt ( ) const
inline

Referenced by CLHEP::operator*().

◆ tx()

double CLHEP::HepRotation::tx ( ) const
inline

Referenced by CLHEP::operator*().

◆ ty()

double CLHEP::HepRotation::ty ( ) const
inline

Referenced by CLHEP::operator*().

◆ tz()

double CLHEP::HepRotation::tz ( ) const
inline

Referenced by CLHEP::operator*().

◆ xt()

double CLHEP::HepRotation::xt ( ) const
inline

Referenced by CLHEP::operator*().

◆ xx()

◆ xy()

◆ xz()

◆ yt()

double CLHEP::HepRotation::yt ( ) const
inline

Referenced by CLHEP::operator*().

◆ yx()

◆ yy()

◆ yz()

◆ zt()

double CLHEP::HepRotation::zt ( ) const
inline

Referenced by CLHEP::operator*().

◆ zx()

◆ zy()

◆ zz()

Friends And Related Function Documentation

◆ operator* [1/3]

HepRotation operator* ( const HepRotationX rx,
const HepRotation r 
)
friend

◆ operator* [2/3]

HepRotation operator* ( const HepRotationY ry,
const HepRotation r 
)
friend

◆ operator* [3/3]

HepRotation operator* ( const HepRotationZ rz,
const HepRotation r 
)
friend

Member Data Documentation

◆ IDENTITY

const HepRotation CLHEP::HepRotation::IDENTITY
static

Definition at line 369 of file Rotation.h.

Referenced by G4VScoringMesh::GetRotationMatrix(), and G4AssemblyVolume::MakeImprint().

◆ rxx

◆ rxy

◆ rxz

◆ ryx

◆ ryy

◆ ryz

◆ rzx

◆ rzy

◆ rzz


The documentation for this class was generated from the following files: