Geant4-11
Data Structures | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Friends
CLHEP::HepRotation Class Reference

#include <Rotation.h>

Inheritance diagram for CLHEP::HepRotation:
G3toG4RotationMatrix

Data Structures

class  HepRotation_row
 

Public Member Functions

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

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
 

Private Member Functions

void setArbitrarily (const Hep3Vector &colX, Hep3Vector &v1, Hep3Vector &v2, Hep3Vector &v3) const
 
bool setCols (const Hep3Vector &u1, const Hep3Vector &u2, const Hep3Vector &u3, double u1u2, Hep3Vector &v1, Hep3Vector &v2, Hep3Vector &v3) const
 

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 42 of file Rotation.h.

Constructor & Destructor Documentation

◆ HepRotation() [1/13]

CLHEP::HepRotation::HepRotation ( )
inline

Referenced by rotateAxes().

◆ HepRotation() [2/13]

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

◆ HepRotation() [3/13]

CLHEP::HepRotation::HepRotation ( HepRotation &&  m)
inlinedefault

◆ HepRotation() [4/13]

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

◆ HepRotation() [5/13]

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

◆ HepRotation() [6/13]

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

◆ HepRotation() [7/13]

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

Definition at line 50 of file RotationA.cc.

51{
52 set( aaxis, ddelta );
53}
HepRotation & set(const Hep3Vector &axis, double delta)
Definition: RotationA.cc:23

References set().

◆ HepRotation() [8/13]

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

Definition at line 57 of file RotationA.cc.

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

References CLHEP::HepAxisAngle::axis(), CLHEP::HepAxisAngle::delta(), and set().

◆ HepRotation() [9/13]

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

Definition at line 54 of file RotationE.cc.

55{
56 set (phi1, theta1, psi1);
57}

References set().

◆ HepRotation() [10/13]

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

Definition at line 61 of file RotationE.cc.

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

References CLHEP::HepEulerAngles::phi(), CLHEP::HepEulerAngles::psi(), set(), and CLHEP::HepEulerAngles::theta().

◆ HepRotation() [11/13]

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

Definition at line 132 of file RotationC.cc.

135{
136 set (ccolX, ccolY, ccolZ);
137}

References set().

◆ HepRotation() [12/13]

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

◆ ~HepRotation()

CLHEP::HepRotation::~HepRotation ( )
inline

◆ HepRotation() [13/13]

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 75 of file RotationA.cc.

75 {
76
77 const double eps = 1e-15;
78
79 double Ux = rzy - ryz;
80 double Uy = rxz - rzx;
81 double Uz = ryx - rxy;
82 if (std::abs(Ux) < eps && std::abs(Uy) < eps && std::abs(Uz) < eps) {
83
84 double cosdelta = (rxx + ryy + rzz - 1.0) / 2.0;
85 if (cosdelta > 0.0) return Hep3Vector(0,0,1); // angle = 0, any axis is good
86
87 double mxx = (rxx + 1)/2;
88 double myy = (ryy + 1)/2;
89 double mzz = (rzz + 1)/2;
90 double mxy = (rxy + ryx)/4;
91 double mxz = (rxz + rzx)/4;
92 double myz = (ryz + rzy)/4;
93 double x, y, z;
94
95 if (mxx > ryy && mxx > rzz) {
96 x = std::sqrt(mxx);
97 if (rzy - ryz < 0) x = -x;
98 y = mxy/x;
99 z = mxz/x;
100 return Hep3Vector( x, y, z ).unit();
101 } else if (myy > mzz) {
102 y = std::sqrt(myy);
103 if (rxz - rzx < 0) y = -y;
104 x = mxy/y;
105 z = myz/y;
106 return Hep3Vector( x, y, z ).unit();
107 } else {
108 z = std::sqrt(mzz);
109 if (ryx - rxy < 0) z = -z;
110 x = mxz/z;
111 y = myz/z;
112 return Hep3Vector( x, y, z ).unit();
113 }
114 } else {
115 return Hep3Vector( Ux, Uy, Uz ).unit();
116 }
117
118} // axis()
static const G4double eps

References eps, rxx, rxy, rxz, ryx, ryy, ryz, rzx, rzy, rzz, and CLHEP::Hep3Vector::unit().

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

◆ axisAngle()

HepAxisAngle CLHEP::HepRotation::axisAngle ( ) const

Definition at line 120 of file RotationA.cc.

120 {
121
122 return HepAxisAngle (axis(), delta());
123
124} // axisAngle()
Hep3Vector axis() const
Definition: RotationA.cc:75
double delta() const
Definition: RotationA.cc:62

References axis(), and delta().

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()

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

◆ colY()

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

◆ colZ()

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

◆ compare()

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

Definition at line 173 of file Rotation.cc.

173 {
174 if (rzz<r.rzz) return -1; else if (rzz>r.rzz) return 1;
175 else if (rzy<r.rzy) return -1; else if (rzy>r.rzy) return 1;
176 else if (rzx<r.rzx) return -1; else if (rzx>r.rzx) return 1;
177 else if (ryz<r.ryz) return -1; else if (ryz>r.ryz) return 1;
178 else if (ryy<r.ryy) return -1; else if (ryy>r.ryy) return 1;
179 else if (ryx<r.ryx) return -1; else if (ryx>r.ryx) return 1;
180 else if (rxz<r.rxz) return -1; else if (rxz>r.rxz) return 1;
181 else if (rxy<r.rxy) return -1; else if (rxy>r.rxy) return 1;
182 else if (rxx<r.rxx) return -1; else if (rxx>r.rxx) return 1;
183 else return 0;
184}

References rxx, rxy, rxz, ryx, ryy, ryz, rzx, rzy, and rzz.

Referenced by export_G4ThreeVector().

◆ decompose() [1/2]

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

Definition at line 24 of file RotationP.cc.

24 {
25 boost.set(0,0,0);
26 rotation = axisAngle();
27}
HepAxisAngle axisAngle() const
Definition: RotationA.cc:120

References axisAngle(), and CLHEP::Hep3Vector::set().

◆ decompose() [2/2]

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

Definition at line 19 of file RotationP.cc.

19 {
20 boost.set(0,0,0);
21 rotation = axisAngle();
22}

References axisAngle(), and CLHEP::Hep3Vector::set().

◆ delta()

double CLHEP::HepRotation::delta ( ) const

Definition at line 62 of file RotationA.cc.

62 {
63
64 double cosdelta = (rxx + ryy + rzz - 1.0) / 2.0;
65 if (cosdelta > 1.0) {
66 return 0;
67 } else if (cosdelta < -1.0) {
68 return CLHEP::pi;
69 } else {
70 return std::acos( cosdelta ); // Already safe due to the cosdelta > 1 check
71 }
72
73} // delta()
static constexpr double pi
Definition: SystemOfUnits.h:55

References CLHEP::pi, rxx, ryy, and rzz.

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

◆ distance2() [1/3]

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

Definition at line 35 of file RotationL.cc.

35 {
36 return distance2( HepLorentzRotation(lt));
37}
double distance2(const HepRotation &r) const
Definition: RotationP.cc:29

References distance2().

◆ distance2() [2/3]

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

Definition at line 25 of file RotationL.cc.

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

References CLHEP::Hep3Vector::beta(), CLHEP::HepLorentzRotation::decompose(), and distance2().

◆ distance2() [3/3]

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

Definition at line 29 of file RotationP.cc.

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

References rxx, rxy, rxz, ryx, ryy, ryz, rzx, rzy, and rzz.

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

◆ eulerAngles()

HepEulerAngles CLHEP::HepRotation::eulerAngles ( ) const

Definition at line 198 of file RotationE.cc.

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

References CLHEP::correctPsiPhi(), rxx, rxy, rxz, ryx, ryy, ryz, rzx, rzy, rzz, and CLHEP::safe_acos().

Referenced by phi(), and psi().

◆ getAngleAxis()

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

Definition at line 148 of file Rotation.cc.

148 {
149 double cosa = 0.5*(xx()+yy()+zz()-1);
150 double cosa1 = 1-cosa;
151 if (cosa1 <= 0) {
152 angle = 0;
153 aaxis = Hep3Vector(0,0,1);
154 }else{
155 double x=0, y=0, z=0;
156 if (xx() > cosa) x = std::sqrt((xx()-cosa)/cosa1);
157 if (yy() > cosa) y = std::sqrt((yy()-cosa)/cosa1);
158 if (zz() > cosa) z = std::sqrt((zz()-cosa)/cosa1);
159 if (zy() < yz()) x = -x;
160 if (xz() < zx()) y = -y;
161 if (yx() < xy()) z = -z;
162 angle = (cosa < -1.) ? std::acos(-1.) : std::acos(cosa);
163 aaxis = Hep3Vector(x,y,z);
164 }
165}
static const G4double angle[DIMMOTT]
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

References angle, xx(), xy(), xz(), yx(), yy(), yz(), zx(), zy(), and zz().

◆ getAxis()

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

Referenced by export_G4RotationMatrix().

◆ getDelta()

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

Referenced by export_G4RotationMatrix().

◆ getPhi()

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

◆ getPsi()

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

Referenced by export_G4RotationMatrix().

◆ getTheta()

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

◆ getTolerance()

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

Referenced by export_G4ThreeVector().

◆ howNear() [1/3]

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

Definition at line 43 of file RotationL.cc.

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

References distance2().

◆ howNear() [2/3]

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

Definition at line 39 of file RotationL.cc.

39 {
40 return std::sqrt( distance2( lt ) );
41}

References distance2().

◆ howNear() [3/3]

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

Definition at line 37 of file RotationP.cc.

37 {
38 return std::sqrt( distance2( r ) );
39}

References distance2().

Referenced by export_G4ThreeVector(), and export_G4TwoVector().

◆ inverse()

HepRotation CLHEP::HepRotation::inverse ( ) const
inline

◆ invert()

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

◆ isIdentity()

bool CLHEP::HepRotation::isIdentity ( ) const

Definition at line 167 of file Rotation.cc.

167 {
168 return (rxx == 1.0 && rxy == 0.0 && rxz == 0.0 &&
169 ryx == 0.0 && ryy == 1.0 && ryz == 0.0 &&
170 rzx == 0.0 && rzy == 0.0 && rzz == 1.0) ? true : false;
171}

References rxx, rxy, rxz, ryx, ryy, ryz, rzx, rzy, and rzz.

Referenced by G4GMocrenFileSceneHandler::AddSolid(), export_G4RotationMatrix(), and G4PVPlacement::NewPtrRotMatrix().

◆ isNear() [1/3]

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

Definition at line 52 of file RotationL.cc.

53 {
54 return distance2( lt ) <= epsilon*epsilon;
55}
G4double epsilon(G4double density, G4double temperature)

References distance2(), and epsilon().

◆ isNear() [2/3]

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

Definition at line 47 of file RotationL.cc.

48 {
49 return distance2( lt ) <= epsilon*epsilon;
50}

References distance2(), and epsilon().

◆ isNear() [3/3]

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

Definition at line 41 of file RotationP.cc.

42 {
43 return distance2( r ) <= epsilon*epsilon;
44}

References distance2(), and epsilon().

Referenced by export_G4ThreeVector(), and export_G4TwoVector().

◆ norm2()

double CLHEP::HepRotation::norm2 ( ) const

◆ 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 23 of file Rotation.cc.

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

References xx(), xy(), xz(), yx(), yy(), yz(), zx(), zy(), and zz().

◆ 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/5]

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

◆ operator=() [2/5]

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

◆ operator=() [3/5]

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

◆ operator=() [4/5]

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

◆ operator=() [5/5]

HepRotation & CLHEP::HepRotation::operator= ( HepRotation &&  r)
inlinedefault

◆ 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 67 of file RotationE.cc.

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

References eulerAngles(), CLHEP::HepEulerAngles::phi(), CLHEP::pi, rzx, rzy, and rzz.

Referenced by export_G4RotationMatrix(), export_G4ThreeVector(), export_G4TwoVector(), setPsi(), and setTheta().

◆ phiX()

double CLHEP::HepRotation::phiX ( ) const

Definition at line 124 of file Rotation.cc.

124 {
125 return (yx() == 0.0 && xx() == 0.0) ? 0.0 : std::atan2(yx(),xx());
126}

References xx(), and yx().

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

◆ phiY()

double CLHEP::HepRotation::phiY ( ) const

Definition at line 128 of file Rotation.cc.

128 {
129 return (yy() == 0.0 && xy() == 0.0) ? 0.0 : std::atan2(yy(),xy());
130}

References xy(), and yy().

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

◆ phiZ()

double CLHEP::HepRotation::phiZ ( ) const

Definition at line 132 of file Rotation.cc.

132 {
133 return (yz() == 0.0 && xz() == 0.0) ? 0.0 : std::atan2(yz(),xz());
134}

References xz(), and yz().

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

◆ print()

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

Definition at line 17 of file RotationIO.cc.

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

References xx(), xy(), xz(), yx(), yy(), yz(), zx(), zy(), and zz().

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

◆ psi()

double CLHEP::HepRotation::psi ( ) const

Definition at line 107 of file RotationE.cc.

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

References eulerAngles(), CLHEP::pi, CLHEP::HepEulerAngles::psi(), rxz, ryz, and rzz.

Referenced by export_G4RotationMatrix(), setPhi(), and setTheta().

◆ rectify()

void CLHEP::HepRotation::rectify ( )

Definition at line 149 of file RotationC.cc.

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

References axis(), delta(), rxx, rxy, rxz, ryx, ryy, ryz, rzx, rzy, rzz, set(), and CLHEP::Hep3Vector::unit().

Referenced by CLHEP::HepLorentzRotation::decompose(), G4GDMLWriteDefine::GetAngles(), G4GDMLReadDefine::GetRotationMatrix(), 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 42 of file Rotation.cc.

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

References CLHEP::Hep3Vector::mag(), transform(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by G4tgbPlaceParamCircle::ComputeTransformation(), export_G4TwoVector(), 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 100 of file Rotation.cc.

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

References CLHEP::Hep3Vector::cross(), CLHEP::Hep3Vector::dot(), HepRotation(), CLHEP::Hep3Vector::mag2(), transform(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by export_G4RotationMatrix().

◆ rotateX()

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

Definition at line 61 of file Rotation.cc.

61 {
62 double c1 = std::cos(a);
63 double s1 = std::sin(a);
64 double x1 = ryx, y1 = ryy, z1 = ryz;
65 ryx = c1*x1 - s1*rzx;
66 ryy = c1*y1 - s1*rzy;
67 ryz = c1*z1 - s1*rzz;
68 rzx = s1*x1 + c1*rzx;
69 rzy = s1*y1 + c1*rzy;
70 rzz = s1*z1 + c1*rzz;
71 return *this;
72}

References ryx, ryy, ryz, rzx, rzy, and rzz.

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

◆ rotateY()

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

Definition at line 74 of file Rotation.cc.

74 {
75 double c1 = std::cos(a);
76 double s1 = std::sin(a);
77 double x1 = rzx, y1 = rzy, z1 = rzz;
78 rzx = c1*x1 - s1*rxx;
79 rzy = c1*y1 - s1*rxy;
80 rzz = c1*z1 - s1*rxz;
81 rxx = s1*x1 + c1*rxx;
82 rxy = s1*y1 + c1*rxy;
83 rxz = s1*z1 + c1*rxz;
84 return *this;
85}

References rxx, rxy, rxz, rzx, rzy, and rzz.

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

◆ rotateZ()

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

◆ 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 23 of file RotationA.cc.

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

References CLHEP::Hep3Vector::getX(), CLHEP::Hep3Vector::getY(), CLHEP::Hep3Vector::getZ(), rxx, rxy, rxz, ryx, ryy, ryz, rzx, rzy, rzz, and CLHEP::Hep3Vector::unit().

Referenced by G4MuonDecayChannel::DecayIt(), CLHEP::HepLorentzRotation::decompose(), export_G4ThreeVector(), export_G4TwoVector(), 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 70 of file RotationC.cc.

72 {
73 Hep3Vector ucolX = ccolX.unit();
74 Hep3Vector ucolY = ccolY.unit();
75 Hep3Vector ucolZ = ccolZ.unit();
76
77 double u1u2 = ucolX.dot(ucolY);
78 double f12 = std::fabs(u1u2);
80 std::cerr << "HepRotation::set() - "
81 << "col's X and Y supplied for Rotation are not close to orthogonal"
82 << std::endl;
83 }
84 double u1u3 = ucolX.dot(ucolZ);
85 double f13 = std::fabs(u1u3);
87 std::cerr << "HepRotation::set() - "
88 << "col's X and Z supplied for Rotation are not close to orthogonal"
89 << std::endl;
90 }
91 double u2u3 = ucolY.dot(ucolZ);
92 double f23 = std::fabs(u2u3);
94 std::cerr << "HepRotation::set() - "
95 << "col's Y and Z supplied for Rotation are not close to orthogonal"
96 << std::endl;
97 }
98
99 Hep3Vector v1, v2, v3;
100 bool isRotation;
101 if ( (f12 <= f13) && (f12 <= f23) ) {
102 isRotation = setCols ( ucolX, ucolY, ucolZ, u1u2, v1, v2, v3 );
103 if ( !isRotation ) {
104 std::cerr << "HepRotation::set() - "
105 << "col's X Y and Z supplied form closer to a reflection than a Rotation "
106 << "\n col Z is set to col X cross col Y" << std::endl;
107 }
108 } else if ( f13 <= f23 ) {
109 isRotation = setCols ( ucolZ, ucolX, ucolY, u1u3, v3, v1, v2 );
110 if ( !isRotation ) {
111 std::cerr << "HepRotation::set() - "
112 << "col's X Y and Z supplied form closer to a reflection than a Rotation "
113 << "\n col Y is set to col Z cross col X" << std::endl;
114 }
115 } else {
116 isRotation = setCols ( ucolY, ucolZ, ucolX, u2u3, v2, v3, v1 );
117 if ( !isRotation ) {
118 std::cerr << "HepRotation::set() - "
119 << "col's X Y and Z supplied form closer to a reflection than a Rotation "
120 << "\n col X is set to col Y cross col Z" << std::endl;
121 }
122 }
123
124 rxx = v1.x(); ryx = v1.y(); rzx = v1.z();
125 rxy = v2.x(); ryy = v2.y(); rzy = v2.z();
126 rxz = v3.x(); ryz = v3.y(); rzz = v3.z();
127
128 return *this;
129
130} // HepRotation::set(colX, colY, colZ)
static DLL_API double tolerance
bool setCols(const Hep3Vector &u1, const Hep3Vector &u2, const Hep3Vector &u3, double u1u2, Hep3Vector &v1, Hep3Vector &v2, Hep3Vector &v3) const
Definition: RotationC.cc:22

References CLHEP::Hep3Vector::dot(), rxx, rxy, rxz, ryx, ryy, ryz, rzx, rzy, rzz, setCols(), CLHEP::Hep4RotationInterface::tolerance, CLHEP::Hep3Vector::unit(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

◆ set() [3/9]

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

Definition at line 54 of file RotationA.cc.

54 {
55 return set ( ax.axis(), ax.delta() );
56}

References CLHEP::HepAxisAngle::axis(), CLHEP::HepAxisAngle::delta(), and set().

◆ set() [4/9]

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

Definition at line 58 of file RotationE.cc.

58 {
59 return set(e.phi(), e.theta(), e.psi());
60}

References CLHEP::HepEulerAngles::phi(), CLHEP::HepEulerAngles::psi(), set(), and CLHEP::HepEulerAngles::theta().

◆ 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 32 of file RotationE.cc.

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

References rxx, rxy, rxz, ryx, ryy, ryz, rzx, rzy, and rzz.

◆ setArbitrarily()

void CLHEP::HepRotation::setArbitrarily ( const Hep3Vector colX,
Hep3Vector v1,
Hep3Vector v2,
Hep3Vector v3 
) const
private

Definition at line 45 of file RotationC.cc.

46 {
47
48 // We have all three col's parallel. Warnings already been given;
49 // this just supplies a result which is a valid rotation.
50
51 v1 = ccolX.unit();
52 v2 = v1.cross(Hep3Vector(0,0,1));
53 if (v2.mag2() != 0) {
54 v2 = v2.unit();
55 } else {
56 v2 = Hep3Vector(1,0,0);
57 }
58 v3 = v1.cross(v2);
59
60 return;
61
62} // HepRotation::setArbitrarily

References CLHEP::Hep3Vector::cross(), CLHEP::Hep3Vector::mag2(), and CLHEP::Hep3Vector::unit().

Referenced by setCols().

◆ setAxis()

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

Definition at line 127 of file RotationA.cc.

127 {
128 set ( aaxis, delta() );
129}

References delta(), and set().

Referenced by export_G4RotationMatrix().

◆ setCols()

bool CLHEP::HepRotation::setCols ( const Hep3Vector u1,
const Hep3Vector u2,
const Hep3Vector u3,
double  u1u2,
Hep3Vector v1,
Hep3Vector v2,
Hep3Vector v3 
) const
private

Definition at line 21 of file RotationC.cc.

24 {
25
26 if ( (1-std::fabs(u1u2)) <= Hep4RotationInterface::tolerance ) {
27 std::cerr << "HepRotation::setCols() - "
28 << "All three cols supplied for a Rotation are parallel --"
29 << "\n an arbitrary rotation will be returned" << std::endl;
30 setArbitrarily (u1, v1, v2, v3);
31 return true;
32 }
33
34 v1 = u1;
35 v2 = Hep3Vector(u2 - u1u2 * u1).unit();
36 v3 = v1.cross(v2);
37 if ( v3.dot(u3) >= 0 ) {
38 return true;
39 } else {
40 return false; // looks more like a reflection in this case!
41 }
42
43} // HepRotation::setCols
void setArbitrarily(const Hep3Vector &colX, Hep3Vector &v1, Hep3Vector &v2, Hep3Vector &v3) const
Definition: RotationC.cc:45

References CLHEP::Hep3Vector::cross(), CLHEP::Hep3Vector::dot(), setArbitrarily(), CLHEP::Hep4RotationInterface::tolerance, and CLHEP::Hep3Vector::unit().

Referenced by set().

◆ setDelta()

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

Definition at line 131 of file RotationA.cc.

131 {
132 set ( axis(), ddelta );
133}

References axis(), and set().

Referenced by export_G4RotationMatrix().

◆ setPhi()

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

Definition at line 259 of file RotationE.cc.

259 {
260 set ( phi1, theta(), psi() );
261}
double psi() const
Definition: RotationE.cc:107
double theta() const
Definition: RotationE.cc:101

References psi(), set(), and theta().

Referenced by export_G4RotationMatrix(), export_G4ThreeVector(), export_G4TwoVector(), and G4GMocrenTouchable::GetRotation().

◆ setPsi()

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

Definition at line 267 of file RotationE.cc.

267 {
268 set ( phi(), theta(), psi1 );
269}
double phi() const
Definition: RotationE.cc:67

References phi(), set(), and theta().

Referenced by export_G4RotationMatrix().

◆ setRows()

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

Definition at line 139 of file RotationC.cc.

141 {
142 set (rrowX, rrowY, rrowZ);
143 invert();
144 return *this;
145}
HepRotation & invert()

References invert(), and set().

◆ setTheta()

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

Definition at line 263 of file RotationE.cc.

263 {
264 set ( phi(), theta1, psi() );
265}

References phi(), psi(), and set().

Referenced by export_G4RotationMatrix(), and export_G4ThreeVector().

◆ setTolerance()

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

Referenced by export_G4ThreeVector().

◆ theta()

double CLHEP::HepRotation::theta ( ) const

Definition at line 101 of file RotationE.cc.

101 {
102
103 return safe_acos( rzz );
104
105} // theta()

References rzz, and CLHEP::safe_acos().

Referenced by export_G4RotationMatrix(), setPhi(), and setPsi().

◆ thetaX()

double CLHEP::HepRotation::thetaX ( ) const

Definition at line 136 of file Rotation.cc.

136 {
137 return safe_acos(zx());
138}

References CLHEP::safe_acos(), and zx().

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

◆ thetaY()

double CLHEP::HepRotation::thetaY ( ) const

Definition at line 140 of file Rotation.cc.

140 {
141 return safe_acos(zy());
142}

References CLHEP::safe_acos(), and zy().

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

◆ thetaZ()

double CLHEP::HepRotation::thetaZ ( ) const

Definition at line 144 of file Rotation.cc.

144 {
145 return safe_acos(zz());
146}

References CLHEP::safe_acos(), and zz().

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

◆ transform() [1/4]

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

◆ 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()

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

◆ xy()

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

◆ xz()

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

◆ yt()

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

Referenced by CLHEP::operator*().

◆ yx()

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

◆ yy()

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

◆ yz()

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

◆ zt()

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

Referenced by CLHEP::operator*().

◆ zx()

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

◆ zy()

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

◆ zz()

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

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

Field Documentation

◆ IDENTITY

const HepRotation CLHEP::HepRotation::IDENTITY
static

◆ rxx

double CLHEP::HepRotation::rxx
protected

◆ rxy

double CLHEP::HepRotation::rxy
protected

◆ rxz

double CLHEP::HepRotation::rxz
protected

◆ ryx

double CLHEP::HepRotation::ryx
protected

◆ ryy

double CLHEP::HepRotation::ryy
protected

◆ ryz

double CLHEP::HepRotation::ryz
protected

◆ rzx

double CLHEP::HepRotation::rzx
protected

◆ rzy

double CLHEP::HepRotation::rzy
protected

◆ rzz

double CLHEP::HepRotation::rzz
protected

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