00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef ROOT_TRotation
00012 #define ROOT_TRotation
00013
00014 #include "TObject.h"
00015
00016 #ifndef ROOT_TVector3
00017 #include "TVector3.h"
00018 #endif
00019
00020 class TQuaternion;
00021
00022 class TRotation : public TObject {
00023
00024 public:
00025
00026 class TRotationRow {
00027 public:
00028 inline TRotationRow(const TRotation &, int);
00029 inline TRotationRow(const TRotationRow &);
00030 inline TRotationRow & operator=(const TRotationRow &);
00031 inline Double_t operator [] (int) const;
00032 private:
00033 const TRotation * fRR;
00034
00035 int fII;
00036 };
00037
00038
00039 TRotation();
00040
00041
00042 TRotation(const TRotation &);
00043 TRotation(const TQuaternion &);
00044
00045
00046 virtual ~TRotation() {;};
00047
00048 inline Double_t XX() const;
00049 inline Double_t XY() const;
00050 inline Double_t XZ() const;
00051 inline Double_t YX() const;
00052 inline Double_t YY() const;
00053 inline Double_t YZ() const;
00054 inline Double_t ZX() const;
00055 inline Double_t ZY() const;
00056 inline Double_t ZZ() const;
00057
00058
00059 inline TRotationRow operator [] (int) const;
00060
00061
00062 Double_t operator () (int, int) const;
00063
00064
00065 inline TRotation & operator = (const TRotation &);
00066
00067
00068 inline Bool_t operator == (const TRotation &) const;
00069 inline Bool_t operator != (const TRotation &) const;
00070
00071
00072 inline Bool_t IsIdentity() const;
00073
00074
00075 inline TVector3 operator * (const TVector3 &) const;
00076
00077
00078 TRotation operator * (const TRotation &) const;
00079 inline TRotation & operator *= (const TRotation &);
00080 inline TRotation & Transform(const TRotation &);
00081
00082
00083
00084 inline TRotation Inverse() const;
00085
00086
00087 inline TRotation & Invert();
00088
00089
00090 TRotation & RotateX(Double_t);
00091
00092
00093 TRotation & RotateY(Double_t);
00094
00095
00096 TRotation & RotateZ(Double_t);
00097
00098
00099 TRotation & Rotate(Double_t, const TVector3 &);
00100 inline TRotation & Rotate(Double_t, const TVector3 *);
00101
00102
00103 TRotation & RotateAxes(const TVector3 & newX,
00104 const TVector3 & newY,
00105 const TVector3 & newZ);
00106
00107
00108 Double_t PhiX() const;
00109 Double_t PhiY() const;
00110 Double_t PhiZ() const;
00111 Double_t ThetaX() const;
00112 Double_t ThetaY() const;
00113 Double_t ThetaZ() const;
00114
00115
00116 void AngleAxis(Double_t &, TVector3 &) const;
00117
00118
00119 inline TRotation & SetToIdentity();
00120
00121
00122 TRotation & SetXEulerAngles(Double_t phi, Double_t theta, Double_t psi);
00123 void SetXPhi(Double_t);
00124 void SetXTheta(Double_t);
00125 void SetXPsi(Double_t);
00126
00127
00128
00129
00130
00131
00132 TRotation & RotateXEulerAngles(Double_t phi, Double_t theta, Double_t psi);
00133
00134
00135
00136 Double_t GetXPhi(void) const;
00137 Double_t GetXTheta(void) const;
00138 Double_t GetXPsi(void) const;
00139
00140
00141
00142 TRotation & SetYEulerAngles(Double_t phi, Double_t theta, Double_t psi);
00143 void SetYPhi(Double_t);
00144 void SetYTheta(Double_t);
00145 void SetYPsi(Double_t);
00146
00147
00148
00149
00150
00151
00152 TRotation & RotateYEulerAngles(Double_t phi, Double_t theta, Double_t psi);
00153
00154
00155
00156 Double_t GetYPhi(void) const;
00157 Double_t GetYTheta(void) const;
00158 Double_t GetYPsi(void) const;
00159
00160
00161
00162 TRotation & SetXAxis(const TVector3& axis);
00163 TRotation & SetXAxis(const TVector3& axis, const TVector3& xyPlane);
00164 TRotation & SetYAxis(const TVector3& axis);
00165 TRotation & SetYAxis(const TVector3& axis, const TVector3& yzPlane);
00166 TRotation & SetZAxis(const TVector3& axis);
00167 TRotation & SetZAxis(const TVector3& axis, const TVector3& zxPlane);
00168
00169
00170
00171
00172 void MakeBasis(TVector3& xAxis, TVector3& yAxis, TVector3& zAxis) const;
00173
00174
00175
00176
00177
00178 protected:
00179
00180 TRotation(Double_t, Double_t, Double_t, Double_t, Double_t,
00181 Double_t, Double_t, Double_t, Double_t);
00182
00183
00184 Double_t fxx, fxy, fxz, fyx, fyy, fyz, fzx, fzy, fzz;
00185
00186
00187 ClassDef(TRotation,1)
00188
00189 };
00190
00191
00192 inline Double_t TRotation::XX() const { return fxx; }
00193 inline Double_t TRotation::XY() const { return fxy; }
00194 inline Double_t TRotation::XZ() const { return fxz; }
00195 inline Double_t TRotation::YX() const { return fyx; }
00196 inline Double_t TRotation::YY() const { return fyy; }
00197 inline Double_t TRotation::YZ() const { return fyz; }
00198 inline Double_t TRotation::ZX() const { return fzx; }
00199 inline Double_t TRotation::ZY() const { return fzy; }
00200 inline Double_t TRotation::ZZ() const { return fzz; }
00201
00202 inline TRotation::TRotationRow::TRotationRow
00203 (const TRotation & r, int i) : fRR(&r), fII(i) {}
00204
00205 inline TRotation::TRotationRow::TRotationRow
00206 (const TRotationRow & rr) : fRR(rr.fRR), fII(rr.fII) {}
00207
00208 inline TRotation::TRotationRow & TRotation::TRotationRow::operator = (const TRotation::TRotationRow & rr) {
00209 fRR = rr.fRR;
00210 fII = rr.fII;
00211 return *this;
00212 }
00213
00214 inline Double_t TRotation::TRotationRow::operator [] (int jj) const {
00215 return fRR->operator()(fII,jj);
00216 }
00217
00218 inline TRotation::TRotationRow TRotation::operator [] (int i) const {
00219 return TRotationRow(*this, i);
00220 }
00221
00222 inline TRotation & TRotation::operator = (const TRotation & m) {
00223 fxx = m.fxx;
00224 fxy = m.fxy;
00225 fxz = m.fxz;
00226 fyx = m.fyx;
00227 fyy = m.fyy;
00228 fyz = m.fyz;
00229 fzx = m.fzx;
00230 fzy = m.fzy;
00231 fzz = m.fzz;
00232 return *this;
00233 }
00234
00235 inline Bool_t TRotation::operator == (const TRotation& m) const {
00236 return (fxx == m.fxx && fxy == m.fxy && fxz == m.fxz &&
00237 fyx == m.fyx && fyy == m.fyy && fyz == m.fyz &&
00238 fzx == m.fzx && fzy == m.fzy && fzz == m.fzz) ? kTRUE : kFALSE;
00239 }
00240
00241 inline Bool_t TRotation::operator != (const TRotation &m) const {
00242 return (fxx != m.fxx || fxy != m.fxy || fxz != m.fxz ||
00243 fyx != m.fyx || fyy != m.fyy || fyz != m.fyz ||
00244 fzx != m.fzx || fzy != m.fzy || fzz != m.fzz) ? kTRUE : kFALSE;
00245 }
00246
00247 inline Bool_t TRotation::IsIdentity() const {
00248 return (fxx == 1.0 && fxy == 0.0 && fxz == 0.0 &&
00249 fyx == 0.0 && fyy == 1.0 && fyz == 0.0 &&
00250 fzx == 0.0 && fzy == 0.0 && fzz == 1.0) ? kTRUE : kFALSE;
00251 }
00252
00253 inline TRotation & TRotation::SetToIdentity() {
00254 fxx = fyy = fzz = 1.0;
00255 fxy = fxz = fyx = fyz = fzx = fzy = 0.0;
00256 return *this;
00257 }
00258
00259 inline TVector3 TRotation::operator * (const TVector3 & p) const {
00260 return TVector3(fxx*p.X() + fxy*p.Y() + fxz*p.Z(),
00261 fyx*p.X() + fyy*p.Y() + fyz*p.Z(),
00262 fzx*p.X() + fzy*p.Y() + fzz*p.Z());
00263 }
00264
00265 inline TRotation & TRotation::operator *= (const TRotation & m) {
00266 return *this = operator * (m);
00267 }
00268
00269 inline TRotation & TRotation::Transform(const TRotation & m) {
00270 return *this = m.operator * (*this);
00271 }
00272
00273 inline TRotation TRotation::Inverse() const {
00274 return TRotation(fxx, fyx, fzx, fxy, fyy, fzy, fxz, fyz, fzz);
00275 }
00276
00277 inline TRotation & TRotation::Invert() {
00278 return *this=Inverse();
00279 }
00280
00281 inline TRotation & TRotation::Rotate(Double_t psi, const TVector3 * p) {
00282 return Rotate(psi, *p);
00283 }
00284
00285
00286
00287 #endif