11 #ifndef ROOT_TRotation
12 #define ROOT_TRotation
20 class TRotation :
public TObject {
26 inline TRotationRow(
const TRotation &,
int);
27 inline TRotationRow(
const TRotationRow &);
28 inline TRotationRow & operator=(
const TRotationRow &);
29 inline Double_t operator [] (
int)
const;
31 const TRotation * fRR;
40 TRotation(
const TRotation &);
41 TRotation(
const TQuaternion &);
44 virtual ~TRotation() {;};
46 inline Double_t XX()
const;
47 inline Double_t XY()
const;
48 inline Double_t XZ()
const;
49 inline Double_t YX()
const;
50 inline Double_t YY()
const;
51 inline Double_t YZ()
const;
52 inline Double_t ZX()
const;
53 inline Double_t ZY()
const;
54 inline Double_t ZZ()
const;
57 inline TRotationRow operator [] (
int)
const;
60 Double_t operator () (
int,
int)
const;
63 inline TRotation & operator = (
const TRotation &);
66 inline Bool_t operator == (
const TRotation &)
const;
67 inline Bool_t operator != (
const TRotation &)
const;
70 inline Bool_t IsIdentity()
const;
73 inline TVector3 operator * (
const TVector3 &)
const;
76 TRotation operator * (
const TRotation &)
const;
77 inline TRotation & operator *= (
const TRotation &);
78 inline TRotation & Transform(
const TRotation &);
82 inline TRotation Inverse()
const;
85 inline TRotation & Invert();
88 TRotation & RotateX(Double_t);
91 TRotation & RotateY(Double_t);
94 TRotation & RotateZ(Double_t);
97 TRotation & Rotate(Double_t,
const TVector3 &);
98 inline TRotation & Rotate(Double_t,
const TVector3 *);
101 TRotation & RotateAxes(
const TVector3 & newX,
102 const TVector3 & newY,
103 const TVector3 & newZ);
106 Double_t PhiX()
const;
107 Double_t PhiY()
const;
108 Double_t PhiZ()
const;
109 Double_t ThetaX()
const;
110 Double_t ThetaY()
const;
111 Double_t ThetaZ()
const;
114 void AngleAxis(Double_t &, TVector3 &)
const;
117 inline TRotation & SetToIdentity();
120 TRotation & SetXEulerAngles(Double_t phi, Double_t theta, Double_t psi);
121 void SetXPhi(Double_t);
122 void SetXTheta(Double_t);
123 void SetXPsi(Double_t);
130 TRotation & RotateXEulerAngles(Double_t phi, Double_t theta, Double_t psi);
134 Double_t GetXPhi(
void)
const;
135 Double_t GetXTheta(
void)
const;
136 Double_t GetXPsi(
void)
const;
140 TRotation & SetYEulerAngles(Double_t phi, Double_t theta, Double_t psi);
141 void SetYPhi(Double_t);
142 void SetYTheta(Double_t);
143 void SetYPsi(Double_t);
150 TRotation & RotateYEulerAngles(Double_t phi, Double_t theta, Double_t psi);
154 Double_t GetYPhi(
void)
const;
155 Double_t GetYTheta(
void)
const;
156 Double_t GetYPsi(
void)
const;
160 TRotation & SetXAxis(
const TVector3& axis);
161 TRotation & SetXAxis(
const TVector3& axis,
const TVector3& xyPlane);
162 TRotation & SetYAxis(
const TVector3& axis);
163 TRotation & SetYAxis(
const TVector3& axis,
const TVector3& yzPlane);
164 TRotation & SetZAxis(
const TVector3& axis);
165 TRotation & SetZAxis(
const TVector3& axis,
const TVector3& zxPlane);
170 void MakeBasis(TVector3& xAxis, TVector3& yAxis, TVector3& zAxis)
const;
178 TRotation(Double_t, Double_t, Double_t, Double_t, Double_t,
179 Double_t, Double_t, Double_t, Double_t);
182 Double_t fxx, fxy, fxz, fyx, fyy, fyz, fzx, fzy, fzz;
185 ClassDef(TRotation,1)
190 inline Double_t TRotation::XX()
const {
return fxx; }
191 inline Double_t TRotation::XY()
const {
return fxy; }
192 inline Double_t TRotation::XZ()
const {
return fxz; }
193 inline Double_t TRotation::YX()
const {
return fyx; }
194 inline Double_t TRotation::YY()
const {
return fyy; }
195 inline Double_t TRotation::YZ()
const {
return fyz; }
196 inline Double_t TRotation::ZX()
const {
return fzx; }
197 inline Double_t TRotation::ZY()
const {
return fzy; }
198 inline Double_t TRotation::ZZ()
const {
return fzz; }
200 inline TRotation::TRotationRow::TRotationRow
201 (
const TRotation & r,
int i) : fRR(&r), fII(i) {}
203 inline TRotation::TRotationRow::TRotationRow
204 (
const TRotationRow & rr) : fRR(rr.fRR), fII(rr.fII) {}
206 inline TRotation::TRotationRow & TRotation::TRotationRow::operator = (
const TRotation::TRotationRow & rr) {
212 inline Double_t TRotation::TRotationRow::operator [] (
int jj)
const {
213 return fRR->operator()(fII,jj);
216 inline TRotation::TRotationRow TRotation::operator [] (
int i)
const {
217 return TRotationRow(*
this, i);
220 inline TRotation & TRotation::operator = (
const TRotation & m) {
233 inline Bool_t TRotation::operator == (
const TRotation& m)
const {
234 return (fxx == m.fxx && fxy == m.fxy && fxz == m.fxz &&
235 fyx == m.fyx && fyy == m.fyy && fyz == m.fyz &&
236 fzx == m.fzx && fzy == m.fzy && fzz == m.fzz) ? kTRUE : kFALSE;
239 inline Bool_t TRotation::operator != (
const TRotation &m)
const {
240 return (fxx != m.fxx || fxy != m.fxy || fxz != m.fxz ||
241 fyx != m.fyx || fyy != m.fyy || fyz != m.fyz ||
242 fzx != m.fzx || fzy != m.fzy || fzz != m.fzz) ? kTRUE : kFALSE;
245 inline Bool_t TRotation::IsIdentity()
const {
246 return (fxx == 1.0 && fxy == 0.0 && fxz == 0.0 &&
247 fyx == 0.0 && fyy == 1.0 && fyz == 0.0 &&
248 fzx == 0.0 && fzy == 0.0 && fzz == 1.0) ? kTRUE : kFALSE;
251 inline TRotation & TRotation::SetToIdentity() {
252 fxx = fyy = fzz = 1.0;
253 fxy = fxz = fyx = fyz = fzx = fzy = 0.0;
257 inline TVector3 TRotation::operator * (
const TVector3 & p)
const {
258 return TVector3(fxx*p.X() + fxy*p.Y() + fxz*p.Z(),
259 fyx*p.X() + fyy*p.Y() + fyz*p.Z(),
260 fzx*p.X() + fzy*p.Y() + fzz*p.Z());
263 inline TRotation & TRotation::operator *= (
const TRotation & m) {
264 return *
this = operator * (m);
267 inline TRotation & TRotation::Transform(
const TRotation & m) {
268 return *
this = m.operator * (*this);
271 inline TRotation TRotation::Inverse()
const {
272 return TRotation(fxx, fyx, fzx, fxy, fyy, fzy, fxz, fyz, fzz);
275 inline TRotation & TRotation::Invert() {
276 return *
this=Inverse();
279 inline TRotation & TRotation::Rotate(Double_t psi,
const TVector3 * p) {
280 return Rotate(psi, *p);