Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGLMatrix Class Reference

16 component (4x4) transform matrix - column MAJOR as per GL.

Provides limited support for adjusting the translation, scale and rotation components.

This is part of collection of simple utility classes for GL only in TGLUtil.h/cxx. These provide const and non-const accessors Arr() & CArr() to a GL compatible internal field - so can be used directly with OpenGL C API calls - which TVector3 etc cannot (easily). They are not intended to be fully featured just provide minimum required.

Definition at line 597 of file TGLUtil.h.

Public Member Functions

 TGLMatrix ()
 Construct default identity matrix:
 
 TGLMatrix (const Double_t vals[16])
 Construct matrix using the 16 Double_t 'vals' passed, ordering is maintained - i.e.
 
 TGLMatrix (const TGLMatrix &other)
 Construct matrix from 'other'.
 
 TGLMatrix (const TGLVertex3 &origin, const TGLVector3 &zAxis)
 Construct matrix which when applied puts local origin at 'origin' and the local Z axis in direction 'z'.
 
 TGLMatrix (const TGLVertex3 &origin, const TGLVector3 &zAxis, const TGLVector3 &xAxis)
 Construct matrix which when applied puts local origin at 'origin' and the local Z axis in direction 'z'.
 
 TGLMatrix (const TGLVertex3 &translation)
 Construct matrix with translation components x,y,z:
 
 TGLMatrix (Double_t x, Double_t y, Double_t z)
 Construct matrix with translation components x,y,z:
 
virtual ~TGLMatrix ()
 Destroy matrix object.
 
Double_tArr ()
 
const Double_tCArr () const
 
void Dump () const
 Output 16 matrix components to std::cout.
 
TGLVector3 GetBaseVec (Int_t b) const
 
void GetBaseVec (Int_t b, Double_t *x) const
 
void GetBaseVec (Int_t b, TGLVector3 &v) const
 
TGLVector3 GetScale () const
 Get local axis scaling factors.
 
TGLVector3 GetTranslation () const
 Return the translation component of matrix.
 
Double_t Invert ()
 Invert the matrix, returns determinant.
 
virtual TClassIsA () const
 
Bool_t IsScalingForRender () const
 Return true if matrix is to be considered a scaling matrix for rendering.
 
void Move3LF (Double_t x, Double_t y, Double_t z)
 Translate in local frame along all base vectors simultaneously.
 
void MoveLF (Int_t ai, Double_t amount)
 Translate in local frame.
 
TGLVector3 Multiply (const TGLVector3 &v, Double_t w=1) const
 Multiply vector.
 
void MultiplyIP (TGLVector3 &v, Double_t w=1) const
 Multiply vector in-place.
 
void MultLeft (const TGLMatrix &lhs)
 Multiply with matrix lhs on left.
 
void MultRight (const TGLMatrix &rhs)
 Multiply with matrix rhs on right.
 
TGLMatrixoperator*= (const TGLMatrix &rhs)
 
TGLMatrixoperator= (const TGLMatrix &rhs)
 
Double_toperator[] (Int_t index)
 
Double_t operator[] (Int_t index) const
 
TGLVector3 Rotate (const TGLVector3 &v) const
 Rotate vector. Translation is not applied.
 
void Rotate (const TGLVertex3 &pivot, const TGLVector3 &axis, Double_t angle)
 Update matrix so resulting transform has been rotated about 'pivot' (in parent frame), round vector 'axis', through 'angle' (radians) Equivalent to glRotate function, but with addition of translation and compounded on top of existing.
 
void RotateIP (TGLVector3 &v) const
 Rotate vector in-place. Translation is not applied.
 
void RotateLF (Int_t i1, Int_t i2, Double_t amount)
 Rotate in local frame.
 
void RotatePF (Int_t i1, Int_t i2, Double_t amount)
 Rotate in parent frame. Does optimised version of MultLeft.
 
void Scale (const TGLVector3 &scale)
 Set matrix axis scales to 'scale'.
 
void Set (const Double_t vals[16])
 Set matrix using the 16 Double_t 'vals' passed, ordering is maintained - i.e.
 
void Set (const TGLVertex3 &origin, const TGLVector3 &zAxis, const TGLVector3 &xAxis=nullptr)
 Set matrix which when applied puts local origin at 'origin' and the local Z axis in direction 'z'.
 
void SetBaseVec (Int_t b, const TGLVector3 &v)
 
void SetBaseVec (Int_t b, Double_t *x)
 
void SetBaseVec (Int_t b, Double_t x, Double_t y, Double_t z)
 
void SetIdentity ()
 Set matrix to identity.
 
void SetTranslation (const TGLVertex3 &translation)
 Set matrix translation components x,y,z.
 
void SetTranslation (Double_t x, Double_t y, Double_t z)
 Set matrix translation components x,y,z.
 
virtual void Streamer (TBuffer &)
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
void TransformVertex (TGLVertex3 &vertex) const
 Transform passed 'vertex' by this matrix - converts local frame to parent.
 
void Translate (const TGLVector3 &vect)
 Shift matrix translation components by 'vect' in parent frame.
 
void Transpose3x3 ()
 Transpose the top left 3x3 matrix component along major diagonal Supported as currently incompatibility between TGeo and GL matrix layouts for this 3x3 only.
 

Static Public Member Functions

static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 

Private Member Functions

Bool_t ValidIndex (UInt_t index) const
 

Private Attributes

Double_t fVals [16]
 

#include <TGLUtil.h>

Constructor & Destructor Documentation

◆ TGLMatrix() [1/7]

TGLMatrix::TGLMatrix ( )

Construct default identity matrix:

1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1

Definition at line 606 of file TGLUtil.cxx.

◆ TGLMatrix() [2/7]

TGLMatrix::TGLMatrix ( Double_t  x,
Double_t  y,
Double_t  z 
)

Construct matrix with translation components x,y,z:

1 0 0 x 0 1 0 y 0 0 1 z 0 0 0 1

Definition at line 619 of file TGLUtil.cxx.

◆ TGLMatrix() [3/7]

TGLMatrix::TGLMatrix ( const TGLVertex3 translation)

Construct matrix with translation components x,y,z:

1 0 0 translation.X() 0 1 0 translation.Y() 0 0 1 translation.Z() 0 0 0 1

Definition at line 633 of file TGLUtil.cxx.

◆ TGLMatrix() [4/7]

TGLMatrix::TGLMatrix ( const TGLVertex3 origin,
const TGLVector3 zAxis,
const TGLVector3 xAxis 
)

Construct matrix which when applied puts local origin at 'origin' and the local Z axis in direction 'z'.

Both 'origin' and 'zAxisVec' are expressed in the parent frame

Definition at line 668 of file TGLUtil.cxx.

◆ TGLMatrix() [5/7]

TGLMatrix::TGLMatrix ( const TGLVertex3 origin,
const TGLVector3 zAxis 
)

Construct matrix which when applied puts local origin at 'origin' and the local Z axis in direction 'z'.

Both 'origin' and 'zAxisVec' are expressed in the parent frame

Definition at line 644 of file TGLUtil.cxx.

◆ TGLMatrix() [6/7]

TGLMatrix::TGLMatrix ( const Double_t  vals[16])

Construct matrix using the 16 Double_t 'vals' passed, ordering is maintained - i.e.

should be column major as we are

Definition at line 679 of file TGLUtil.cxx.

◆ TGLMatrix() [7/7]

TGLMatrix::TGLMatrix ( const TGLMatrix other)

Construct matrix from 'other'.

Definition at line 687 of file TGLUtil.cxx.

◆ ~TGLMatrix()

TGLMatrix::~TGLMatrix ( )
virtual

Destroy matrix object.

Definition at line 695 of file TGLUtil.cxx.

Member Function Documentation

◆ Arr()

Double_t * TGLMatrix::Arr ( )
inline

Definition at line 665 of file TGLUtil.h.

◆ CArr()

const Double_t * TGLMatrix::CArr ( ) const
inline

Definition at line 664 of file TGLUtil.h.

◆ Class()

static TClass * TGLMatrix::Class ( )
static
Returns
TClass describing this class

◆ Class_Name()

static const char * TGLMatrix::Class_Name ( )
static
Returns
Name of this class

◆ Class_Version()

static constexpr Version_t TGLMatrix::Class_Version ( )
inlinestaticconstexpr
Returns
Version of this class

Definition at line 669 of file TGLUtil.h.

◆ DeclFileName()

static const char * TGLMatrix::DeclFileName ( )
inlinestatic
Returns
Name of the file containing the class declaration

Definition at line 669 of file TGLUtil.h.

◆ Dump()

void TGLMatrix::Dump ( ) const

Output 16 matrix components to std::cout.

0 4 8 12 1 5 9 13 2 6 10 14 3 7 11 15

Definition at line 1132 of file TGLUtil.cxx.

◆ GetBaseVec() [1/3]

TGLVector3 TGLMatrix::GetBaseVec ( Int_t  b) const
inline

Definition at line 754 of file TGLUtil.h.

◆ GetBaseVec() [2/3]

void TGLMatrix::GetBaseVec ( Int_t  b,
Double_t x 
) const
inline

Definition at line 767 of file TGLUtil.h.

◆ GetBaseVec() [3/3]

void TGLMatrix::GetBaseVec ( Int_t  b,
TGLVector3 v 
) const
inline

Definition at line 760 of file TGLUtil.h.

◆ GetScale()

TGLVector3 TGLMatrix::GetScale ( ) const

Get local axis scaling factors.

Definition at line 1099 of file TGLUtil.cxx.

◆ GetTranslation()

TGLVector3 TGLMatrix::GetTranslation ( ) const

Return the translation component of matrix.

Definition at line 794 of file TGLUtil.cxx.

◆ Invert()

Double_t TGLMatrix::Invert ( )

Invert the matrix, returns determinant.

Copied from TMatrixFCramerInv.

Definition at line 971 of file TGLUtil.cxx.

◆ IsA()

virtual TClass * TGLMatrix::IsA ( ) const
inlinevirtual
Returns
TClass describing current object

Definition at line 669 of file TGLUtil.h.

◆ IsScalingForRender()

Bool_t TGLMatrix::IsScalingForRender ( ) const

Return true if matrix is to be considered a scaling matrix for rendering.

Definition at line 1111 of file TGLUtil.cxx.

◆ Move3LF()

void TGLMatrix::Move3LF ( Double_t  x,
Double_t  y,
Double_t  z 
)

Translate in local frame along all base vectors simultaneously.

Definition at line 822 of file TGLUtil.cxx.

◆ MoveLF()

void TGLMatrix::MoveLF ( Int_t  ai,
Double_t  amount 
)

Translate in local frame.

i1, i2 are axes indices: 1 ~ x, 2 ~ y, 3 ~ z.

Definition at line 813 of file TGLUtil.cxx.

◆ Multiply()

TGLVector3 TGLMatrix::Multiply ( const TGLVector3 v,
Double_t  w = 1 
) const

Multiply vector.

Definition at line 1049 of file TGLUtil.cxx.

◆ MultiplyIP()

void TGLMatrix::MultiplyIP ( TGLVector3 v,
Double_t  w = 1 
) const

Multiply vector in-place.

Definition at line 1075 of file TGLUtil.cxx.

◆ MultLeft()

void TGLMatrix::MultLeft ( const TGLMatrix lhs)

Multiply with matrix lhs on left.

Definition at line 718 of file TGLUtil.cxx.

◆ MultRight()

void TGLMatrix::MultRight ( const TGLMatrix rhs)

Multiply with matrix rhs on right.

Definition at line 702 of file TGLUtil.cxx.

◆ operator*=()

TGLMatrix & TGLMatrix::operator*= ( const TGLMatrix rhs)
inline

Definition at line 623 of file TGLUtil.h.

◆ operator=()

TGLMatrix & TGLMatrix::operator= ( const TGLMatrix rhs)
inline

Definition at line 673 of file TGLUtil.h.

◆ operator[]() [1/2]

Double_t & TGLMatrix::operator[] ( Int_t  index)
inline

Definition at line 683 of file TGLUtil.h.

◆ operator[]() [2/2]

Double_t TGLMatrix::operator[] ( Int_t  index) const
inline

Definition at line 694 of file TGLUtil.h.

◆ Rotate() [1/2]

TGLVector3 TGLMatrix::Rotate ( const TGLVector3 v) const

Rotate vector. Translation is not applied.

Definition at line 1062 of file TGLUtil.cxx.

◆ Rotate() [2/2]

void TGLMatrix::Rotate ( const TGLVertex3 pivot,
const TGLVector3 axis,
Double_t  angle 
)

Update matrix so resulting transform has been rotated about 'pivot' (in parent frame), round vector 'axis', through 'angle' (radians) Equivalent to glRotate function, but with addition of translation and compounded on top of existing.

Definition at line 870 of file TGLUtil.cxx.

◆ RotateIP()

void TGLMatrix::RotateIP ( TGLVector3 v) const

Rotate vector in-place. Translation is not applied.

Definition at line 1087 of file TGLUtil.cxx.

◆ RotateLF()

void TGLMatrix::RotateLF ( Int_t  i1,
Int_t  i2,
Double_t  amount 
)

Rotate in local frame.

Does optimised version of MultRight. i1, i2 are axes indices: 1 ~ x, 2 ~ y, 3 ~ z.

Definition at line 897 of file TGLUtil.cxx.

◆ RotatePF()

void TGLMatrix::RotatePF ( Int_t  i1,
Int_t  i2,
Double_t  amount 
)

Rotate in parent frame. Does optimised version of MultLeft.

Definition at line 914 of file TGLUtil.cxx.

◆ Scale()

void TGLMatrix::Scale ( const TGLVector3 scale)

Set matrix axis scales to 'scale'.

Note - this really sets the overall (total) scaling for each axis - it does NOT apply compounded scale on top of existing one

Definition at line 834 of file TGLUtil.cxx.

◆ Set() [1/2]

void TGLMatrix::Set ( const Double_t  vals[16])

Set matrix using the 16 Double_t 'vals' passed, ordering is maintained - i.e.

should be column major.

Definition at line 755 of file TGLUtil.cxx.

◆ Set() [2/2]

void TGLMatrix::Set ( const TGLVertex3 origin,
const TGLVector3 zAxis,
const TGLVector3 xAxis = nullptr 
)

Set matrix which when applied puts local origin at 'origin' and the local Z axis in direction 'z'.

Both 'origin' and 'z' are expressed in the parent frame

Definition at line 736 of file TGLUtil.cxx.

◆ SetBaseVec() [1/3]

void TGLMatrix::SetBaseVec ( Int_t  b,
const TGLVector3 v 
)
inline

Definition at line 740 of file TGLUtil.h.

◆ SetBaseVec() [2/3]

void TGLMatrix::SetBaseVec ( Int_t  b,
Double_t x 
)
inline

Definition at line 747 of file TGLUtil.h.

◆ SetBaseVec() [3/3]

void TGLMatrix::SetBaseVec ( Int_t  b,
Double_t  x,
Double_t  y,
Double_t  z 
)
inline

Definition at line 733 of file TGLUtil.h.

◆ SetIdentity()

void TGLMatrix::SetIdentity ( )

Set matrix to identity.

Definition at line 765 of file TGLUtil.cxx.

◆ SetTranslation() [1/2]

void TGLMatrix::SetTranslation ( const TGLVertex3 translation)

Set matrix translation components x,y,z.

Definition at line 784 of file TGLUtil.cxx.

◆ SetTranslation() [2/2]

void TGLMatrix::SetTranslation ( Double_t  x,
Double_t  y,
Double_t  z 
)

Set matrix translation components x,y,z.

Definition at line 776 of file TGLUtil.cxx.

◆ Streamer()

virtual void TGLMatrix::Streamer ( TBuffer )
virtual

◆ StreamerNVirtual()

void TGLMatrix::StreamerNVirtual ( TBuffer ClassDef_StreamerNVirtual_b)
inline

Definition at line 669 of file TGLUtil.h.

◆ TransformVertex()

void TGLMatrix::TransformVertex ( TGLVertex3 vertex) const

Transform passed 'vertex' by this matrix - converts local frame to parent.

Definition at line 933 of file TGLUtil.cxx.

◆ Translate()

void TGLMatrix::Translate ( const TGLVector3 vect)

Shift matrix translation components by 'vect' in parent frame.

Definition at line 802 of file TGLUtil.cxx.

◆ Transpose3x3()

void TGLMatrix::Transpose3x3 ( )

Transpose the top left 3x3 matrix component along major diagonal Supported as currently incompatibility between TGeo and GL matrix layouts for this 3x3 only.

To be resolved.

Definition at line 947 of file TGLUtil.cxx.

◆ ValidIndex()

Bool_t TGLMatrix::ValidIndex ( UInt_t  index) const
inlineprivate

Definition at line 604 of file TGLUtil.h.

Member Data Documentation

◆ fVals

Double_t TGLMatrix::fVals[16]
private

Definition at line 601 of file TGLUtil.h.

Libraries for TGLMatrix:

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