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