Loading...
Searching...
No Matches
SBDTypePhysicalMatrix33< Quantity > Class Template Reference

This template class is used to describe 3x3 physical matrices. More...

Useful functions

Quantity m [3][3]
 The components of the physical matrix.
 
static const SBDTypePhysicalMatrix33< Quantity > zero
 The zero physical matrix.
 
static const SBDTypePhysicalMatrix33< Quantity > identity
 The identity physical matrix.
 
Quantity trace () const
 Returns the trace m[0][0] + m[1][1] + m[2][2] of this physical matrix.
 
void print () const
 Prints this physical matrix.
 
void setIdentity ()
 Sets this physical matrix to the identity matrix.
 
void setZero ()
 Sets this physical matrix to zero.
 
SBDTypePhysicalMatrix33< Quantity > transpose () const
 Returns the transpose of this physical matrix.
 
void toQuaternion (SBQuantity::dimensionless &w, SBQuantity::dimensionless &x, SBQuantity::dimensionless &y, SBQuantity::dimensionless &z) const
 Computes the quaternion [ w x y z ] corresponding to this physical matrix.
 
void toRotationVector (SBVector3 &rotationVector) const
 Computes the rotation vector corresponding to this dimensionless physical matrix.
 
void orthonormalize ()
 Orthonormalizes this dimensionless physical matrix.
 
void quasiStaticUpdate (const SBQuantity::dimensionless &wx, const SBQuantity::dimensionless &wy, const SBQuantity::dimensionless &wz, SBQuantity::dimensionless &rotAngle, SBVector3 &rotAxis, SBDTypePhysicalMatrix33< Quantity > &rotA, SBDTypePhysicalMatrix33< Quantity > &rotB, SBDTypePhysicalMatrix33< Quantity > &rotC)
 Performs a quasi-static update of this dimensionless physical matrix using the rotation vector [ wx wy wz ].
 
void computeEulerDecompositionZYZ (SBQuantity::dimensionless &phi, SBQuantity::dimensionless &theta, SBQuantity::dimensionless &psi)
 Computes a ZYZ Euler decomposition of this physical matrix.
 
void revoluteJointZAxisMatrix (const SBVector3 &axis)
 Sets this physical matrix to an orthonormal matrix whose third column is axis.
 
void diagonalize (SBDTypePhysicalVector3< Quantity > &ev, SBDTypePhysicalMatrix33< SBQuantity::dimensionless > &p)
 Computes the eigenvalues ev and the eigenvectors p of this physical matrix.
 
SBQuantityProduct3< Quantity, Quantity, Quantity >::Type det () const
 Returns the determinant of this physical matrix.
 
Quantity norm () const
 Returns the 2-norm of this physical matrix.
 
Quantity cosphi () const
 Returns the cosine of the rotation angle of this rotation matrix.
 
SBDTypePhysicalMatrix33< typename SBQuantityInverse< Quantity >::Type > inverse () const
 Returns the inverse of this physical matrix.
 
void makeEulerRotationZYZ (const SBQuantity::dimensionless &phi, const SBQuantity::dimensionless &theta, const SBQuantity::dimensionless &psi)
 This function sets this physical matrix from ZYZ Euler angles phi, theta and psi.
 
void swapColumns (unsigned int i, unsigned int j)
 Swaps columns i and j.
 
void swapRows (unsigned int i, unsigned int j)
 Swaps rows i and j.
 
static SBDTypePhysicalMatrix33< SBQuantity::dimensionlessfromQuaternion (const SBQuantity::dimensionless &w, const SBQuantity::dimensionless &x, const SBQuantity::dimensionless &y, const SBQuantity::dimensionless &z)
 Returns the dimensionless physical matrix corresponding to quaternion [ w x y z ].
 
static SBDTypePhysicalMatrix33< SBQuantity::dimensionlessfromAxisAngle (const SBVector3 &axis, const SBQuantity::dimensionless &angle)
 Returns the dimensionless physical matrix corresponding to rotation axis axis and rotation angle angle (in radians)
 
static SBDTypePhysicalMatrix33< SBQuantity::dimensionlessfromAxisAnglePi (const SBVector3 &axis)
 Returns the dimensionless physical matrix corresponding to rotation axis axis and a rotation angle equal to Pi.
 
static SBDTypePhysicalMatrix33< SBQuantity::dimensionlessfromAlignment (const SBVector3 &from, const SBVector3 &to)
 Returns the dimensionless physical matrix that transforms vector from into vector to. Precisely, left-multiplying vector from by the resulting matrix produces vector to.
 

Constructors

 SBDTypePhysicalMatrix33 ()
 Constructs a physical matrix with all components set to zero.
 
 SBDTypePhysicalMatrix33 (const SBDTypePhysicalVector3< Quantity > &d)
 Constructs the diagonal physical matrix with diagonal [ d.v[0] d.v[1] d.v[2] ].
 
 SBDTypePhysicalMatrix33 (const SBDTypePhysicalVector3< Quantity > &c0, const SBDTypePhysicalVector3< Quantity > &c1, const SBDTypePhysicalVector3< Quantity > &c2)
 Constructs the physical matrix with columns c0, c1 and c2.
 
 SBDTypePhysicalMatrix33 (const Quantity &v)
 Constructs the physical matrix with all components set to v.
 
 SBDTypePhysicalMatrix33 (Quantity mat[3][3])
 Constructs the physical matrix from the quantity array mat.
 
 SBDTypePhysicalMatrix33 (const Quantity &m00, const Quantity &m01, const Quantity &m02, const Quantity &m10, const Quantity &m11, const Quantity &m12, const Quantity &m20, const Quantity &m21, const Quantity &m22)
 Constructs the physical matrix from components m00, m01, m02, m10, m11, m12, m20, m21 and m22.
 
 SBDTypePhysicalMatrix33 (double d)
 Constructs the dimensionless physical matrix with all components set to d.
 
 SBDTypePhysicalMatrix33 (double mat[3][3])
 Constructs the dimensionless physical matrix from double array mat.
 
 SBDTypePhysicalMatrix33 (double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
 Constructs the dimensionless physical matrix from components m00, m01, m02, m10, m11, m12, m20, m21 and m22.
 
 SBDTypePhysicalMatrix33 (const SBDTypePhysicalMatrix33< Quantity > &mat)
 Copy constructor.
 

Serialization

void serialize (SBCSerializer *serializer, const SBVersionNumber &sdkVersionNumber=SB_SDK_VERSION_NUMBER) const
 Serializes the physical matrix using the provided serializer.
 
void unserialize (SBCSerializer *serializer, const SBVersionNumber &sdkVersionNumber=SB_SDK_VERSION_NUMBER)
 Unserializes the physical matrix using the provided serializer.
 

Accessors

SBDTypePhysicalVector3< Quantity > getE1 () const
 Returns the first column of this physical matrix.
 
void setE1 (const SBDTypePhysicalVector3< Quantity > &v)
 Sets the first column of this physical matrix.
 
SBDTypePhysicalVector3< Quantity > getE2 () const
 Returns the second column of this physical matrix.
 
void setE2 (const SBDTypePhysicalVector3< Quantity > &v)
 Sets the second column of this physical matrix.
 
SBDTypePhysicalVector3< Quantity > getE3 () const
 Returns the third column of this physical matrix.
 
void setE3 (const SBDTypePhysicalVector3< Quantity > &v)
 Sets the third column of this physical matrix.
 
SBDTypePhysicalMatrix33< SBQuantity::dimensionlessgetValue () const
 Returns a dimensionless physical matrix whose components are equal to those of this physical matrix.
 
void setValue (const SBDTypePhysicalMatrix33< SBQuantity::dimensionless > &u)
 Sets the components of this physical matrix equal to those of the dimensionless physical matrix u.
 

Operators

SBDTypePhysicalMatrix33< Quantity > & operator= (const SBDTypePhysicalMatrix33< Quantity > &mat)
 Copy assignment.
 
SBDTypePhysicalMatrix33< Quantity > operator+ (const SBDTypePhysicalMatrix33< Quantity > &mat) const
 Returns the sum of this physical matrix with physical matrix mat.
 
SBDTypePhysicalMatrix33< Quantity > operator- (const SBDTypePhysicalMatrix33< Quantity > &mat) const
 Returns the difference of this physical matrix with physical matrix mat.
 
template<typename QuantityB >
SBDTypePhysicalMatrix33< typename SBQuantityProduct2< Quantity, QuantityB >::Type > operator* (const SBDTypePhysicalMatrix33< QuantityB > &mat) const
 Returns the product of this physical matrix with physical matrix mat.
 
SBDTypePhysicalMatrix33< Quantity > operator* (double d) const
 Returns the product of this physical matrix with double d.
 
SBDTypePhysicalMatrix33< Quantity > operator/ (double d) const
 Returns the division of this physical matrix by double d.
 
void operator+= (const SBDTypePhysicalMatrix33< Quantity > &mat)
 Adds physical matrix mat to this physical matrix.
 
void operator-= (const SBDTypePhysicalMatrix33< Quantity > &mat)
 Subtracts physical matrix mat from this physical matrix.
 
SBDTypePhysicalMatrix33< Quantity > operator- () const
 Returns the opposite of this physical matrix.
 
template<typename QuantityB >
SBDTypePhysicalMatrix33< Quantity > & operator*= (QuantityB d)
 Multiplies this physical matrix with physical quantity d.
 
template<typename QuantityB >
SBDTypePhysicalMatrix33< Quantity > & operator/= (QuantityB d)
 Divides this physical matrix by physical quantity d.
 
template<typename QuantityB >
SBDTypePhysicalVector3< typename SBQuantityProduct2< Quantity, QuantityB >::Type > operator* (const SBDTypePhysicalVector3< QuantityB > &v) const
 Returns the product of this physical matrix with physical vector v.
 
bool operator== (const SBDTypePhysicalMatrix33< Quantity > &mat) const
 Returns true if this physical matrix is equal to physical matrix mat (component-wise)
 
bool operator!= (const SBDTypePhysicalMatrix33< Quantity > &mat) const
 Returns true if this physical matrix is different from physical matrix mat (component-wise)
 

Detailed Description

template<typename Quantity>
class SBDTypePhysicalMatrix33< Quantity >
Template Parameters
QuantityThe quantity type of the physical matrix

This template class describes 3x3 physical matrices.

Physical matrices are physical quantities, and thus use SAMSON's unit system. In a physical matrix (e.g. an inertia tensor), all components have the same unit, so that physical matrices are defined by only one unit, and the SBDTypePhysicalMatrix33 template class is parameterized by only one type: Quantity.

Most of the time, developers of SAMSON Extensions do not have to use this template, but may directly use some predefined types that correspond to specific instantiations of this template class, e.g. SBMatrix33 (dimensionless matrix), SBMass33 (mass matrix), SBInertiaTensor33 (inertia tensor), etc.

Dimensionless 3x3 matrices (SBMatrix33) are especially useful since they are used to represent 3D reference frames, rotation matrices, rigid-body transforms, etc.

Short name: SBPhysicalMatrix33

See also
SAMSON's unit system
The SBDType library
SBDTypePhysicalVector3
SBDTypeSpatialTransform

Member Function Documentation

◆ computeEulerDecompositionZYZ()

template<typename Quantity >
void SBDTypePhysicalMatrix33< Quantity >::computeEulerDecompositionZYZ ( SBQuantity::dimensionless phi,
SBQuantity::dimensionless theta,
SBQuantity::dimensionless psi 
)
inline
Parameters
phiThe first Z rotation angle
thetaThe Y rotation angle
psiThe second Z rotation angle

This function computes a ZYZ Euler decomposition of this physical matrix:

\(\mathbf{M}=\mathbf{R}(z,psi)\mathbf{R}(y,theta)\mathbf{R}(z,phi)\)

where \(\mathbf{M}\) denotes this physical matrix, \(\mathbf{R}(z,phi)\) denotes the first rotation around the Z axis, \(\mathbf{R}(y,theta)\) denotes the rotation around the Y axis, and \(\mathbf{R}(z,psi)\) denotes the second rotation around the Z axis.

Note that this function may only be used with dimensionless physical matrices.

◆ cosphi()

template<typename Quantity >
Quantity SBDTypePhysicalMatrix33< Quantity >::cosphi ( ) const
inline

This function assumes this physical matrix is a rotation matrix, and returns the cosine of the corresponding rotation angle

◆ diagonalize()

template<typename Quantity >
void SBDTypePhysicalMatrix33< Quantity >::diagonalize ( SBDTypePhysicalVector3< Quantity > &  ev,
SBDTypePhysicalMatrix33< SBQuantity::dimensionless > &  p 
)
inline
Parameters
evStores the eigenvalues when this function returns
pStores the eigenvectors when this function returns

This function computes the eigenvalues ev and the eigenvectors p of this physical matrix. Note that the eigenvalues have the same units as the physical matrix, while the eigenvectors are stored in a dimensionless matrix.

See also
SAMSON's unit system

◆ inverse()

template<typename Quantity >
SBDTypePhysicalMatrix33< typename SBQuantityInverse< Quantity >::Type > SBDTypePhysicalMatrix33< Quantity >::inverse ( ) const
inline

This function assumes the physical matrix is invertible and returns its inverse.

◆ makeEulerRotationZYZ()

template<typename Quantity >
void SBDTypePhysicalMatrix33< Quantity >::makeEulerRotationZYZ ( const SBQuantity::dimensionless phi,
const SBQuantity::dimensionless theta,
const SBQuantity::dimensionless psi 
)
inline
Parameters
phiThe first Z rotation angle
thetaThe Y rotation angle
psiThe second Z rotation angle

This function sets this physical matrix from ZYZ Euler angles:

\(\mathbf{M}=\mathbf{R}(z,psi)\mathbf{R}(y,theta)\mathbf{R}(z,phi)\)

where \(\mathbf{M}\) denotes this physical matrix, \(\mathbf{R}(z,phi)\) denotes the first rotation around the Z axis, \(\mathbf{R}(y,theta)\) denotes the rotation around the Y axis, and \(\mathbf{R}(z,psi)\) denotes the second rotation around the Z axis.

Note that this function may only be used with dimensionless physical matrices.

◆ operator*=()

template<typename Quantity >
template<typename QuantityB >
SBDTypePhysicalMatrix33< Quantity > & SBDTypePhysicalMatrix33< Quantity >::operator*= ( QuantityB  d)
inline
Parameters
dA dimensionless physical quantity or a numeric type (i.e. int, float, double, etc)

◆ operator/=()

template<typename Quantity >
template<typename QuantityB >
SBDTypePhysicalMatrix33< Quantity > & SBDTypePhysicalMatrix33< Quantity >::operator/= ( QuantityB  d)
inline
Parameters
dA dimensionless physical quantity or a numeric type (i.e. int, float, double, etc)

◆ quasiStaticUpdate()

template<typename Quantity >
void SBDTypePhysicalMatrix33< Quantity >::quasiStaticUpdate ( const SBQuantity::dimensionless wx,
const SBQuantity::dimensionless wy,
const SBQuantity::dimensionless wz,
SBQuantity::dimensionless rotAngle,
SBVector3 rotAxis,
SBDTypePhysicalMatrix33< Quantity > &  rotA,
SBDTypePhysicalMatrix33< Quantity > &  rotB,
SBDTypePhysicalMatrix33< Quantity > &  rotC 
)
inline
Parameters
wxThe first component of the rotation vector
wyThe second component of the rotation vector
wzThe third component of the rotation vector
rotAngleThe rotation angle
rotAxisThe rotation axis
rotAThe rotation axis
rotBThe rotation axis
rotCThe rotation axis

This function performs a quasi-static update of this dimensionless physical matrix using the rotation vector [ wx wy wz ]. During the update, The rotation vector [ wx wy wz ] is converted to a rotation angle and rotation axis, respectively stored into rotAngle and rotAxis. If \(\mathbf{M}\) denotes the original matrix, the final matrix is \(\cos(w)\mathbf{A}+\sin(w)\mathbf{B}+\mathbf{C}\), where \(\mathbf{A}\), \(\mathbf{B}\) and \(\mathbf{C}\) are physical matrices computed from \(\mathbf{M}\) and the rotation axis \(\mathbf{v}\), and \(w\) is the rotation angle:

  • \(\mathbf{A}=(\mathbf{I}-\mathbf{v}\mathbf{v}^T)\mathbf{M}\)
  • \(\mathbf{B}=\tilde{\mathbf{v}}\mathbf{M}\)
  • \(\mathbf{C}=\mathbf{v}\mathbf{v}^T\mathbf{M}\)

where \(\tilde{\mathbf{v}}\) is the matrix such that \(\tilde{\mathbf{v}}\mathbf{x}=\mathbf{v}\times\mathbf{x}\) for any \(\mathbf{x}\).

When the function returns, \(\mathbf{A}\), \(\mathbf{B}\) and \(\mathbf{C}\) are stored into rotA, rotB and rotC, respectively.

Note that this function may only be used with dimensionless physical matrices.