EGSnrc C++ class library
Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
|
A class for vector rotations. More...
#include <egs_transformations.h>
Public Member Functions | |
EGS_RotationMatrix () | |
Default constructor, results in a unit matrix object. | |
EGS_RotationMatrix (EGS_Float xx, EGS_Float xy, EGS_Float xz, EGS_Float yx, EGS_Float yy, EGS_Float yz, EGS_Float zx, EGS_Float zy, EGS_Float zz) | |
Construct a rotation matrix object from 9 floating point numbers. | |
EGS_RotationMatrix (const EGS_RotationMatrix &m) | |
Copy constructor. | |
bool | isRotation () const |
Is this object a real rotation matrix? More... | |
EGS_RotationMatrix (const EGS_Vector &v) | |
Create a rotation matrix from the vector v. More... | |
EGS_RotationMatrix (EGS_Float alpha, EGS_Float beta, EGS_Float gamma) | |
Constructs a rotation matrix from rotation angles around the x-, y-, and z-axis as . | |
EGS_RotationMatrix (EGS_Float phi, EGS_Float theta) | |
Constructs a rotation matrix from the angles theta and phi (polar and azimuthal) as . | |
EGS_RotationMatrix & | operator= (const EGS_RotationMatrix &m) |
Assignment operator. | |
bool | operator== (const EGS_RotationMatrix &m) |
Comparison operator. | |
bool | isI () const |
Returns true , if this object is approximately the unit matrix, false otherwise. | |
EGS_Vector | operator* (const EGS_Vector &v) const |
Returns the rotated a vector . | |
EGS_RotationMatrix | operator* (const EGS_RotationMatrix &m) const |
Multiplies the invoking object with m from the right and returns the result. | |
EGS_RotationMatrix & | operator*= (const EGS_RotationMatrix &m) |
Multiplies the invoking object with m from the right and assigns the resulting matrix to the invoking object returning a reference to it. | |
void | multiply (const EGS_RotationMatrix &m) |
Multiplies the invoking object with m from the left and returns the result. More... | |
EGS_RotationMatrix | inverse () const |
Returns the inverse matrix. More... | |
EGS_RotationMatrix | T () |
Returns the transposed matrix. | |
EGS_RotationMatrix & | invert () |
Inverts the matrix and returns a reference to it. | |
EGS_Float | det () const |
Calculates and returns the determinant of the matrix. | |
EGS_Float | xx () const |
EGS_Float | xy () const |
EGS_Float | xz () const |
EGS_Float | yx () const |
EGS_Float | yy () const |
EGS_Float | yz () const |
EGS_Float | zx () const |
EGS_Float | zy () const |
EGS_Float | zz () const |
Static Public Member Functions | |
static EGS_RotationMatrix | rotX (EGS_Float cphi, EGS_Float sphi) |
Returns a rotation around the x-axis by the angle with cphi, sphi = . | |
static EGS_RotationMatrix | rotY (EGS_Float cphi, EGS_Float sphi) |
Returns a rotation around the y-axis by the angle with cphi, sphi = . | |
static EGS_RotationMatrix | rotZ (EGS_Float cphi, EGS_Float sphi) |
Returns a rotation around the z-axis by the angle with cphi, sphi = . | |
static EGS_RotationMatrix | rotX (EGS_Float phi) |
Returns a rotation around the x-axis by the angle phi. | |
static EGS_RotationMatrix | rotY (EGS_Float phi) |
Returns a rotation around the y-axis by the angle phi. | |
static EGS_RotationMatrix | rotZ (EGS_Float phi) |
Returns a rotation around the z-axis by the angle phi. | |
static EGS_RotationMatrix | rotV (EGS_Float phi, const EGS_Vector &v) |
Returns a rotation by the angle phi around the axis defined by the vector v. | |
static EGS_RotationMatrix | rotV (EGS_Float cphi, EGS_Float sphi, const EGS_Vector &v) |
Protected Attributes | |
EGS_Float | rxx |
EGS_Float | rxy |
EGS_Float | rxz |
EGS_Float | ryx |
EGS_Float | ryy |
EGS_Float | ryz |
EGS_Float | rzx |
EGS_Float | rzy |
EGS_Float | rzz |
Friends | |
EGS_Vector | operator* (const EGS_Vector &v, const EGS_RotationMatrix &m) |
Multiplies the invoking vector v from the right with the matrix m and returns the result. | |
EGS_Vector & | operator*= (EGS_Vector &v, const EGS_RotationMatrix &m) |
Multiplies the invoking vector v from the right with the matrix m and assigns the result to the invoking vector. Returns a reference to the resulting vector. | |
A class for vector rotations.
A rotation matrix object can be constructed by explicitely giving the 9 coefficients of the 3x3 rotation matrix, from angles of rotation around the x-,y- and z-axis, from polar/azimuthal angles of rotations and from a given vector. The EGS_RotationMatrix class provides functions for matrix multiplication, vector rotation, determination of the determinant, etc.
Definition at line 64 of file egs_transformations.h.
EGS_RotationMatrix::EGS_RotationMatrix | ( | const EGS_Vector & | v | ) |
Create a rotation matrix from the vector v.
This constructs a matrix which, when applied to the vector v, transforms it into a vector along the z-axis. Why z-axis? Well, it has to be one of the axis and in physics things usually happen along the z-axis!
Definition at line 148 of file egs_transformations.h.
References egsFatal, epsilon, EGS_Vector::x, EGS_Vector::y, and EGS_Vector::z.
bool EGS_RotationMatrix::isRotation | ( | ) | const |
Is this object a real rotation matrix?
Returns true if the object is a real rotation matrix, false otherwise. A 3x3 matrix is a rotation matrix if its determinant is unity and if is a unity matrix, where is the transposed matrix.
Definition at line 127 of file egs_transformations.h.
References epsilon, and isI().
Referenced by EGS_AffineTransform::getTransformation().
void EGS_RotationMatrix::multiply | ( | const EGS_RotationMatrix & | m | ) |
Multiplies the invoking object with m from the left and returns the result.
Note: and therefore one needs to distinguish between multiplication from the right as in operator*() and multiplication from the left.
Definition at line 272 of file egs_transformations.h.
EGS_RotationMatrix EGS_RotationMatrix::inverse | ( | ) | const |
Returns the inverse matrix.
Note that the implementation simply assumes that the matrix is a real rotation matrix and therefore returns the transposed matrix.
Definition at line 281 of file egs_transformations.h.
Referenced by EGS_AffineTransform::getTransformation(), and rotV().
|
static |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 346 of file egs_transformations.h.
References inverse().
|
protected |
The 9 rotation matrix coefficients
Definition at line 69 of file egs_transformations.h.
Referenced by EGS_RotationMatrix(), operator*(), operator=(), and operator==().