EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
EGS_RotationMatrix Class Reference

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 $R_x(\alpha) R_y(\beta) R_z(\gamma)$.
 
 EGS_RotationMatrix (EGS_Float phi, EGS_Float theta)
 Constructs a rotation matrix from the angles theta and phi (polar and azimuthal) as $R_z(\phi) R_x(\theta)$.
 
EGS_RotationMatrixoperator= (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 $ R \cdot \vec{v}$.
 
EGS_RotationMatrix operator* (const EGS_RotationMatrix &m) const
 Multiplies the invoking object with m from the right and returns the result.
 
EGS_RotationMatrixoperator*= (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_RotationMatrixinvert ()
 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 $\phi$ with cphi, sphi = $ \cos(\phi), \sin(\phi)$.
 
static EGS_RotationMatrix rotY (EGS_Float cphi, EGS_Float sphi)
 Returns a rotation around the y-axis by the angle $\phi$ with cphi, sphi = $ \cos(\phi), \sin(\phi)$.
 
static EGS_RotationMatrix rotZ (EGS_Float cphi, EGS_Float sphi)
 Returns a rotation around the z-axis by the angle $\phi$ with cphi, sphi = $ \cos(\phi), \sin(\phi)$.
 
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_Vectoroperator*= (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.
 

Detailed Description

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.

Examples:
geometry/egs_box/egs_box.cpp.

Definition at line 64 of file egs_transformations.h.

Constructor & Destructor Documentation

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.

Member Function Documentation

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 $R$ is a rotation matrix if its determinant is unity and if $ R R^T$ is a unity matrix, where $ R^T$ 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: $ R \cdot M \ne R \cdot M$ 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 EGS_RotationMatrix EGS_RotationMatrix::rotV ( EGS_Float  cphi,
EGS_Float  sphi,
const EGS_Vector v 
)
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().

Member Data Documentation

EGS_Float EGS_RotationMatrix::rxx
protected

The 9 rotation matrix coefficients

Definition at line 69 of file egs_transformations.h.

Referenced by EGS_RotationMatrix(), operator*(), operator=(), and operator==().


The documentation for this class was generated from the following file: