ROOT 6.13/01 Reference Guide |
The TRotation class describes a rotation of objects of the TVector3 class.
It is a 3*3 matrix of Double_t:
It describes a so called active rotation, i.e. rotation of objects inside a static system of coordinates. In case you want to rotate the frame and want to know the coordinates of objects in the rotated system, you should apply the inverse rotation to the objects. If you want to transform coordinates from the rotated frame to the original frame you have to apply the direct transformation.
A rotation around a specified axis means counterclockwise rotation around the positive direction of the axis.
There is no direct way to set the matrix elements - to ensure that a TRotation object always describes a real rotation. But you can get the values by the member functions XX()..ZZ() or the (,) operator:
The following matrices describe counterclockwise rotations around coordinate axes
and are implemented as member functions RotateX(), RotateY() and RotateZ():
The member function Rotate() allows to rotate around an arbitrary vector (not necessary a unit one) and returns the result.
It is possible to find a unit vector and an angle, which describe the same rotation as the current one:
Member function RotateAxes() adds a rotation of local axes to the current rotation and returns the result:
Member functions ThetaX(), ThetaY(), ThetaZ(), PhiX(), PhiY(),PhiZ() return azimuth and polar angles of the rotated axes:
The member function SetToIdentity() will set the rotation object to the identity (no rotation).
With a minor caveat, the Euler angles of the rotation may be set using SetXEulerAngles() or individually set with SetXPhi(), SetXTheta(), and SetXPsi(). These routines set the Euler angles using the X-convention which is defined by a rotation about the Z-axis, about the new X-axis, and about the new Z-axis. This is the convention used in Landau and Lifshitz, Goldstein and other common physics texts. The Y-convention Euler angles can be set with SetYEulerAngles(), SetYPhi(), SetYTheta(), and SetYPsi(). The caveat is that Euler angles usually define the rotation of the new coordinate system with respect to the original system, however, the TRotation class specifies the rotation of the object in the original system (an active rotation). To recover the usual Euler rotations (ie. rotate the system not the object), you must take the inverse of the rotation.
The member functions SetXAxis(), SetYAxis(), and SetZAxis() will create a rotation which rotates the requested axis of the object to be parallel to a vector. If used with one argument, the rotation about that axis is arbitrary. If used with two arguments, the second variable defines the XY, YZ, or ZX respectively.
The operator * has been implemented in a way that follows the mathematical notation of a product of the two matrices which describe the two consecutive rotations. Therefore the second rotation should be placed first:
The TRotation class provides an operator * which allows to express a rotation of a TVector3 analog to the mathematical notation
e.g.:
You can also use the Transform() member function or the operator *= of the TVector3 class:
Definition at line 20 of file TRotation.h.
Classes | |
class | TRotationRow |
Public Member Functions | |
TRotation () | |
Constructor. More... | |
TRotation (const TRotation &) | |
Constructor. More... | |
TRotation (const TQuaternion &) | |
Constructor for a rotation based on a Quaternion if magnitude of quaternion is null, creates identity rotation if quaternion is non-unit, creates rotation corresponding to the normalized (unit) quaternion. More... | |
virtual | ~TRotation () |
void | AngleAxis (Double_t &, TVector3 &) const |
Rotation defined by an angle and a vector. More... | |
Double_t | GetXPhi (void) const |
Return phi angle. More... | |
Double_t | GetXPsi (void) const |
Get psi angle. More... | |
Double_t | GetXTheta (void) const |
Return XTheta. More... | |
Double_t | GetYPhi (void) const |
Return YPhi. More... | |
Double_t | GetYPsi (void) const |
Return YPsi. More... | |
Double_t | GetYTheta (void) const |
Return YTheta. More... | |
TRotation | Inverse () const |
TRotation & | Invert () |
Bool_t | IsIdentity () const |
void | MakeBasis (TVector3 &xAxis, TVector3 &yAxis, TVector3 &zAxis) const |
Make the Z axis into a unit variable. More... | |
Bool_t | operator!= (const TRotation &) const |
Double_t | operator() (int, int) const |
Dereferencing operator const. More... | |
TVector3 | operator* (const TVector3 &) const |
TRotation | operator* (const TRotation &) const |
Multiplication operator. More... | |
TRotation & | operator*= (const TRotation &) |
TRotation & | operator= (const TRotation &) |
Bool_t | operator== (const TRotation &) const |
TRotationRow | operator[] (int) const |
Double_t | PhiX () const |
Return Phi. More... | |
Double_t | PhiY () const |
Return Phi. More... | |
Double_t | PhiZ () const |
Return Phi. More... | |
TRotation & | Rotate (Double_t, const TVector3 &) |
Rotate along an axis. More... | |
TRotation & | Rotate (Double_t, const TVector3 *) |
TRotation & | RotateAxes (const TVector3 &newX, const TVector3 &newY, const TVector3 &newZ) |
Rotate axes. More... | |
TRotation & | RotateX (Double_t) |
Rotate around x. More... | |
TRotation & | RotateXEulerAngles (Double_t phi, Double_t theta, Double_t psi) |
Rotate using the x-convention. More... | |
TRotation & | RotateY (Double_t) |
Rotate around y. More... | |
TRotation & | RotateYEulerAngles (Double_t phi, Double_t theta, Double_t psi) |
Rotate using the y-convention. More... | |
TRotation & | RotateZ (Double_t) |
Rotate around z. More... | |
TRotation & | SetToIdentity () |
TRotation & | SetXAxis (const TVector3 &axis) |
Set X axis. More... | |
TRotation & | SetXAxis (const TVector3 &axis, const TVector3 &xyPlane) |
Set X axis. More... | |
TRotation & | SetXEulerAngles (Double_t phi, Double_t theta, Double_t psi) |
Rotate using the x-convention (Landau and Lifshitz, Goldstein, &c) by doing the explicit rotations. More... | |
void | SetXPhi (Double_t) |
Set XPhi. More... | |
void | SetXPsi (Double_t) |
Set XPsi. More... | |
void | SetXTheta (Double_t) |
Set XTheta. More... | |
TRotation & | SetYAxis (const TVector3 &axis) |
Set Y axis. More... | |
TRotation & | SetYAxis (const TVector3 &axis, const TVector3 &yzPlane) |
Set Y axis. More... | |
TRotation & | SetYEulerAngles (Double_t phi, Double_t theta, Double_t psi) |
Rotate using the y-convention. More... | |
void | SetYPhi (Double_t) |
Set YPhi. More... | |
void | SetYPsi (Double_t) |
Set YPsi. More... | |
void | SetYTheta (Double_t) |
Set YTheta. More... | |
TRotation & | SetZAxis (const TVector3 &axis) |
Set Z axis. More... | |
TRotation & | SetZAxis (const TVector3 &axis, const TVector3 &zxPlane) |
Set Z axis. More... | |
Double_t | ThetaX () const |
Return Theta. More... | |
Double_t | ThetaY () const |
Return Theta. More... | |
Double_t | ThetaZ () const |
Return Theta. More... | |
TRotation & | Transform (const TRotation &) |
Double_t | XX () const |
Double_t | XY () const |
Double_t | XZ () const |
Double_t | YX () const |
Double_t | YY () const |
Double_t | YZ () const |
Double_t | ZX () const |
Double_t | ZY () const |
Double_t | ZZ () const |
Protected Member Functions | |
TRotation (Double_t, Double_t, Double_t, Double_t, Double_t, Double_t, Double_t, Double_t, Double_t) | |
Constructor. More... | |
Protected Attributes | |
Double_t | fxx |
Double_t | fxy |
Double_t | fxz |
Double_t | fyx |
Double_t | fyy |
Double_t | fyz |
Double_t | fzx |
Double_t | fzy |
Double_t | fzz |
#include <TRotation.h>
TRotation::TRotation | ( | ) |
Constructor.
Definition at line 195 of file TRotation.cxx.
TRotation::TRotation | ( | const TRotation & | m | ) |
Constructor.
Definition at line 202 of file TRotation.cxx.
TRotation::TRotation | ( | const TQuaternion & | Q | ) |
Constructor for a rotation based on a Quaternion if magnitude of quaternion is null, creates identity rotation if quaternion is non-unit, creates rotation corresponding to the normalized (unit) quaternion.
Definition at line 258 of file TRotation.cxx.
|
inlinevirtual |
Definition at line 44 of file TRotation.h.
|
protected |
Constructor.
Definition at line 209 of file TRotation.cxx.
void TRotation::AngleAxis | ( | Double_t & | angle, |
TVector3 & | axis | ||
) | const |
Rotation defined by an angle and a vector.
Definition at line 462 of file TRotation.cxx.
Double_t TRotation::GetXPhi | ( | void | ) | const |
Return phi angle.
Definition at line 578 of file TRotation.cxx.
Double_t TRotation::GetXPsi | ( | void | ) | const |
Get psi angle.
Definition at line 644 of file TRotation.cxx.
Double_t TRotation::GetXTheta | ( | void | ) | const |
Return XTheta.
Definition at line 630 of file TRotation.cxx.
Double_t TRotation::GetYPhi | ( | void | ) | const |
Return YPhi.
Definition at line 623 of file TRotation.cxx.
Double_t TRotation::GetYPsi | ( | void | ) | const |
Return YPsi.
Definition at line 690 of file TRotation.cxx.
Double_t TRotation::GetYTheta | ( | void | ) | const |
Return YTheta.
Definition at line 637 of file TRotation.cxx.
|
inline |
Definition at line 271 of file TRotation.h.
|
inline |
Definition at line 275 of file TRotation.h.
|
inline |
Definition at line 245 of file TRotation.h.
Make the Z axis into a unit variable.
Definition at line 766 of file TRotation.cxx.
|
inline |
Definition at line 239 of file TRotation.h.
Double_t TRotation::operator() | ( | int | i, |
int | j | ||
) | const |
Dereferencing operator const.
Definition at line 218 of file TRotation.cxx.
Definition at line 257 of file TRotation.h.
Multiplication operator.
Definition at line 241 of file TRotation.cxx.
Definition at line 263 of file TRotation.h.
Definition at line 220 of file TRotation.h.
|
inline |
Definition at line 233 of file TRotation.h.
|
inline |
Definition at line 216 of file TRotation.h.
Double_t TRotation::PhiX | ( | ) | const |
Return Phi.
Definition at line 420 of file TRotation.cxx.
Double_t TRotation::PhiY | ( | ) | const |
Return Phi.
Definition at line 427 of file TRotation.cxx.
Double_t TRotation::PhiZ | ( | ) | const |
Return Phi.
Definition at line 434 of file TRotation.cxx.
Rotate along an axis.
Definition at line 324 of file TRotation.cxx.
Definition at line 279 of file TRotation.h.
TRotation & TRotation::RotateAxes | ( | const TVector3 & | newX, |
const TVector3 & | newY, | ||
const TVector3 & | newZ | ||
) |
Rotate axes.
Definition at line 393 of file TRotation.cxx.
TRotation & TRotation::RotateX | ( | Double_t | a | ) |
Rotate around x.
Definition at line 345 of file TRotation.cxx.
TRotation & TRotation::RotateXEulerAngles | ( | Double_t | phi, |
Double_t | theta, | ||
Double_t | psi | ||
) |
Rotate using the x-convention.
Definition at line 514 of file TRotation.cxx.
TRotation & TRotation::RotateY | ( | Double_t | a | ) |
Rotate around y.
Definition at line 361 of file TRotation.cxx.
TRotation & TRotation::RotateYEulerAngles | ( | Double_t | phi, |
Double_t | theta, | ||
Double_t | psi | ||
) |
Rotate using the y-convention.
Definition at line 525 of file TRotation.cxx.
TRotation & TRotation::RotateZ | ( | Double_t | a | ) |
Rotate around z.
Definition at line 377 of file TRotation.cxx.
|
inline |
Definition at line 251 of file TRotation.h.
Set X axis.
Definition at line 712 of file TRotation.cxx.
Set X axis.
Definition at line 697 of file TRotation.cxx.
TRotation & TRotation::SetXEulerAngles | ( | Double_t | phi, |
Double_t | theta, | ||
Double_t | psi | ||
) |
Rotate using the x-convention (Landau and Lifshitz, Goldstein, &c) by doing the explicit rotations.
This is slightly less efficient than directly applying the rotation, but makes the code much clearer. My presumption is that this code is not going to be a speed bottle neck.
Definition at line 487 of file TRotation.cxx.
void TRotation::SetXPhi | ( | Double_t | phi | ) |
Set XPhi.
Definition at line 536 of file TRotation.cxx.
void TRotation::SetXPsi | ( | Double_t | psi | ) |
Set XPsi.
Definition at line 550 of file TRotation.cxx.
void TRotation::SetXTheta | ( | Double_t | theta | ) |
Set XTheta.
Definition at line 543 of file TRotation.cxx.
Set Y axis.
Definition at line 735 of file TRotation.cxx.
Set Y axis.
Definition at line 720 of file TRotation.cxx.
TRotation & TRotation::SetYEulerAngles | ( | Double_t | phi, |
Double_t | theta, | ||
Double_t | psi | ||
) |
Rotate using the y-convention.
Definition at line 501 of file TRotation.cxx.
void TRotation::SetYPhi | ( | Double_t | phi | ) |
Set YPhi.
Definition at line 557 of file TRotation.cxx.
void TRotation::SetYPsi | ( | Double_t | psi | ) |
Set YPsi.
Definition at line 571 of file TRotation.cxx.
void TRotation::SetYTheta | ( | Double_t | theta | ) |
Set YTheta.
Definition at line 564 of file TRotation.cxx.
Set Z axis.
Definition at line 758 of file TRotation.cxx.
Set Z axis.
Definition at line 743 of file TRotation.cxx.
Double_t TRotation::ThetaX | ( | ) | const |
Return Theta.
Definition at line 441 of file TRotation.cxx.
Double_t TRotation::ThetaY | ( | ) | const |
Return Theta.
Definition at line 448 of file TRotation.cxx.
Double_t TRotation::ThetaZ | ( | ) | const |
Return Theta.
Definition at line 455 of file TRotation.cxx.
Definition at line 267 of file TRotation.h.
|
inline |
Definition at line 190 of file TRotation.h.
|
inline |
Definition at line 191 of file TRotation.h.
|
inline |
Definition at line 192 of file TRotation.h.
|
inline |
Definition at line 193 of file TRotation.h.
|
inline |
Definition at line 194 of file TRotation.h.
|
inline |
Definition at line 195 of file TRotation.h.
|
inline |
Definition at line 196 of file TRotation.h.
|
inline |
Definition at line 197 of file TRotation.h.
|
inline |
Definition at line 198 of file TRotation.h.
|
protected |
Definition at line 182 of file TRotation.h.
|
protected |
Definition at line 182 of file TRotation.h.
|
protected |
Definition at line 182 of file TRotation.h.
|
protected |
Definition at line 182 of file TRotation.h.
|
protected |
Definition at line 182 of file TRotation.h.
|
protected |
Definition at line 182 of file TRotation.h.
|
protected |
Definition at line 182 of file TRotation.h.
|
protected |
Definition at line 182 of file TRotation.h.
|
protected |
Definition at line 182 of file TRotation.h.