ROOT 6.08/07 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 22 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 |
Public Member Functions inherited from TObject | |
TObject () | |
TObject constructor. More... | |
TObject (const TObject &object) | |
TObject copy ctor. More... | |
virtual | ~TObject () |
TObject destructor. More... | |
void | AbstractMethod (const char *method) const |
Use this method to implement an "abstract" method that you don't want to leave purely abstract. More... | |
virtual void | AppendPad (Option_t *option="") |
Append graphics object to current pad. More... | |
virtual void | Browse (TBrowser *b) |
Browse object. May be overridden for another default action. More... | |
virtual const char * | ClassName () const |
Returns name of class to which the object belongs. More... | |
virtual void | Clear (Option_t *="") |
virtual TObject * | Clone (const char *newname="") const |
Make a clone of an object using the Streamer facility. More... | |
virtual Int_t | Compare (const TObject *obj) const |
Compare abstract method. More... | |
virtual void | Copy (TObject &object) const |
Copy this to obj. More... | |
virtual void | Delete (Option_t *option="") |
Delete this object. More... | |
virtual Int_t | DistancetoPrimitive (Int_t px, Int_t py) |
Computes distance from point (px,py) to the object. More... | |
virtual void | Draw (Option_t *option="") |
Default Draw method for all objects. More... | |
virtual void | DrawClass () const |
Draw class inheritance tree of the class to which this object belongs. More... | |
virtual TObject * | DrawClone (Option_t *option="") const |
Draw a clone of this object in the current pad. More... | |
virtual void | Dump () const |
Dump contents of object on stdout. More... | |
virtual void | Error (const char *method, const char *msgfmt,...) const |
Issue error message. More... | |
virtual void | Execute (const char *method, const char *params, Int_t *error=0) |
Execute method on this object with the given parameter string, e.g. More... | |
virtual void | Execute (TMethod *method, TObjArray *params, Int_t *error=0) |
Execute method on this object with parameters stored in the TObjArray. More... | |
virtual void | ExecuteEvent (Int_t event, Int_t px, Int_t py) |
Execute action corresponding to an event at (px,py). More... | |
virtual void | Fatal (const char *method, const char *msgfmt,...) const |
Issue fatal error message. More... | |
virtual TObject * | FindObject (const char *name) const |
Must be redefined in derived classes. More... | |
virtual TObject * | FindObject (const TObject *obj) const |
Must be redefined in derived classes. More... | |
virtual Option_t * | GetDrawOption () const |
Get option used by the graphics system to draw this object. More... | |
virtual const char * | GetIconName () const |
Returns mime type name of object. More... | |
virtual const char * | GetName () const |
Returns name of object. More... | |
virtual char * | GetObjectInfo (Int_t px, Int_t py) const |
Returns string containing info about the object at position (px,py). More... | |
virtual Option_t * | GetOption () const |
virtual const char * | GetTitle () const |
Returns title of object. More... | |
virtual UInt_t | GetUniqueID () const |
Return the unique object id. More... | |
virtual Bool_t | HandleTimer (TTimer *timer) |
Execute action in response of a timer timing out. More... | |
virtual ULong_t | Hash () const |
Return hash value for this object. More... | |
virtual void | Info (const char *method, const char *msgfmt,...) const |
Issue info message. More... | |
virtual Bool_t | InheritsFrom (const char *classname) const |
Returns kTRUE if object inherits from class "classname". More... | |
virtual Bool_t | InheritsFrom (const TClass *cl) const |
Returns kTRUE if object inherits from TClass cl. More... | |
virtual void | Inspect () const |
Dump contents of this object in a graphics canvas. More... | |
void | InvertBit (UInt_t f) |
virtual Bool_t | IsEqual (const TObject *obj) const |
Default equal comparison (objects are equal if they have the same address in memory). More... | |
virtual Bool_t | IsFolder () const |
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects). More... | |
Bool_t | IsOnHeap () const |
virtual Bool_t | IsSortable () const |
Bool_t | IsZombie () const |
virtual void | ls (Option_t *option="") const |
The ls function lists the contents of a class on stdout. More... | |
void | MayNotUse (const char *method) const |
Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary). More... | |
virtual Bool_t | Notify () |
This method must be overridden to handle object notification. More... | |
void | Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const |
Use this method to declare a method obsolete. More... | |
void | operator delete (void *ptr) |
Operator delete. More... | |
void | operator delete[] (void *ptr) |
Operator delete []. More... | |
void * | operator new (size_t sz) |
void * | operator new (size_t sz, void *vp) |
void * | operator new[] (size_t sz) |
void * | operator new[] (size_t sz, void *vp) |
TObject & | operator= (const TObject &rhs) |
TObject assignment operator. More... | |
virtual void | Paint (Option_t *option="") |
This method must be overridden if a class wants to paint itself. More... | |
virtual void | Pop () |
Pop on object drawn in a pad to the top of the display list. More... | |
virtual void | Print (Option_t *option="") const |
This method must be overridden when a class wants to print itself. More... | |
virtual Int_t | Read (const char *name) |
Read contents of object with specified name from the current directory. More... | |
virtual void | RecursiveRemove (TObject *obj) |
Recursively remove this object from a list. More... | |
void | ResetBit (UInt_t f) |
virtual void | SaveAs (const char *filename="", Option_t *option="") const |
Save this object in the file specified by filename. More... | |
virtual void | SavePrimitive (std::ostream &out, Option_t *option="") |
Save a primitive as a C++ statement(s) on output stream "out". More... | |
void | SetBit (UInt_t f, Bool_t set) |
Set or unset the user status bits as specified in f. More... | |
void | SetBit (UInt_t f) |
virtual void | SetDrawOption (Option_t *option="") |
Set drawing option for object. More... | |
virtual void | SetUniqueID (UInt_t uid) |
Set the unique object id. More... | |
virtual void | SysError (const char *method, const char *msgfmt,...) const |
Issue system error message. More... | |
Bool_t | TestBit (UInt_t f) const |
Int_t | TestBits (UInt_t f) const |
virtual void | UseCurrentStyle () |
Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked. More... | |
virtual void | Warning (const char *method, const char *msgfmt,...) const |
Issue warning message. More... | |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) |
Write this object to the current directory. More... | |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) const |
Write this object to the current directory. More... | |
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 Member Functions inherited from TObject | |
virtual void | DoError (int level, const char *location, const char *fmt, va_list va) const |
Interface to ErrorHandler (protected). More... | |
void | MakeZombie () |
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 |
Additional Inherited Members | |
Public Types inherited from TObject | |
enum | { kIsOnHeap = 0x01000000, kNotDeleted = 0x02000000, kZombie = 0x04000000, kBitMask = 0x00ffffff } |
enum | { kSingleKey = BIT(0), kOverwrite = BIT(1), kWriteDelete = BIT(2) } |
enum | EStatusBits { kCanDelete = BIT(0), kMustCleanup = BIT(3), kObjInCanvas = BIT(3), kIsReferenced = BIT(4), kHasUUID = BIT(5), kCannotPick = BIT(6), kNoContextMenu = BIT(8), kInvalidObject = BIT(13) } |
Static Public Member Functions inherited from TObject | |
static Long_t | GetDtorOnly () |
Return destructor only flag. More... | |
static Bool_t | GetObjectStat () |
Get status of object stat flag. More... | |
static void | SetDtorOnly (void *obj) |
Set destructor only flag. More... | |
static void | SetObjectStat (Bool_t stat) |
Turn on/off tracking of objects in the TObjectTable. More... | |
#include <TRotation.h>
TRotation::TRotation | ( | ) |
Constructor.
Definition at line 196 of file TRotation.cxx.
TRotation::TRotation | ( | const TRotation & | m | ) |
Constructor.
Definition at line 203 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 259 of file TRotation.cxx.
|
inlinevirtual |
Definition at line 46 of file TRotation.h.
|
protected |
Constructor.
Definition at line 210 of file TRotation.cxx.
Rotation defined by an angle and a vector.
Definition at line 463 of file TRotation.cxx.
Return phi angle.
Definition at line 579 of file TRotation.cxx.
Get psi angle.
Definition at line 645 of file TRotation.cxx.
Return XTheta.
Definition at line 631 of file TRotation.cxx.
Return YPhi.
Definition at line 624 of file TRotation.cxx.
Return YPsi.
Definition at line 691 of file TRotation.cxx.
Return YTheta.
Definition at line 638 of file TRotation.cxx.
|
inline |
Definition at line 273 of file TRotation.h.
|
inline |
Definition at line 277 of file TRotation.h.
|
inline |
Definition at line 247 of file TRotation.h.
Make the Z axis into a unit variable.
Definition at line 767 of file TRotation.cxx.
|
inline |
Definition at line 241 of file TRotation.h.
Double_t TRotation::operator() | ( | int | i, |
int | j | ||
) | const |
Dereferencing operator const.
Definition at line 219 of file TRotation.cxx.
Definition at line 259 of file TRotation.h.
Multiplication operator.
Definition at line 242 of file TRotation.cxx.
Definition at line 265 of file TRotation.h.
Definition at line 222 of file TRotation.h.
Definition at line 235 of file TRotation.h.
|
inline |
Definition at line 218 of file TRotation.h.
Double_t TRotation::PhiX | ( | ) | const |
Return Phi.
Definition at line 421 of file TRotation.cxx.
Double_t TRotation::PhiY | ( | ) | const |
Return Phi.
Definition at line 428 of file TRotation.cxx.
Double_t TRotation::PhiZ | ( | ) | const |
Return Phi.
Definition at line 435 of file TRotation.cxx.
Rotate along an axis.
Definition at line 325 of file TRotation.cxx.
Definition at line 281 of file TRotation.h.
TRotation & TRotation::RotateAxes | ( | const TVector3 & | newX, |
const TVector3 & | newY, | ||
const TVector3 & | newZ | ||
) |
Rotate axes.
Definition at line 394 of file TRotation.cxx.
Rotate around x.
Definition at line 346 of file TRotation.cxx.
Rotate using the x-convention.
Definition at line 515 of file TRotation.cxx.
Rotate around y.
Definition at line 362 of file TRotation.cxx.
Rotate using the y-convention.
Definition at line 526 of file TRotation.cxx.
Rotate around z.
Definition at line 378 of file TRotation.cxx.
|
inline |
Definition at line 253 of file TRotation.h.
Set X axis.
Definition at line 713 of file TRotation.cxx.
Set X axis.
Definition at line 698 of file TRotation.cxx.
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 488 of file TRotation.cxx.
Set XPhi.
Definition at line 537 of file TRotation.cxx.
Set XPsi.
Definition at line 551 of file TRotation.cxx.
Set XTheta.
Definition at line 544 of file TRotation.cxx.
Set Y axis.
Definition at line 736 of file TRotation.cxx.
Set Y axis.
Definition at line 721 of file TRotation.cxx.
Rotate using the y-convention.
Definition at line 502 of file TRotation.cxx.
Set YPhi.
Definition at line 558 of file TRotation.cxx.
Set YPsi.
Definition at line 572 of file TRotation.cxx.
Set YTheta.
Definition at line 565 of file TRotation.cxx.
Set Z axis.
Definition at line 759 of file TRotation.cxx.
Set Z axis.
Definition at line 744 of file TRotation.cxx.
Double_t TRotation::ThetaX | ( | ) | const |
Return Theta.
Definition at line 442 of file TRotation.cxx.
Double_t TRotation::ThetaY | ( | ) | const |
Return Theta.
Definition at line 449 of file TRotation.cxx.
Double_t TRotation::ThetaZ | ( | ) | const |
Return Theta.
Definition at line 456 of file TRotation.cxx.
Definition at line 269 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.
|
inline |
Definition at line 199 of file TRotation.h.
|
inline |
Definition at line 200 of file TRotation.h.
|
protected |
Definition at line 184 of file TRotation.h.
|
protected |
Definition at line 184 of file TRotation.h.
|
protected |
Definition at line 184 of file TRotation.h.
|
protected |
Definition at line 184 of file TRotation.h.
|
protected |
Definition at line 184 of file TRotation.h.
|
protected |
Definition at line 184 of file TRotation.h.
|
protected |
Definition at line 184 of file TRotation.h.
|
protected |
Definition at line 184 of file TRotation.h.
|
protected |
Definition at line 184 of file TRotation.h.