|
World of Rigid Bodies (WoRB)
|
Encapsulates a quaternionic tensor (q-tensor) as a 4x4 row-major matrix. More...
#include <QTensor.h>

Data Structures | |
| struct | Components |
| Represents tensor components in a column-major order. More... | |
Public Member Functions | |
Indexing operators | |
| double & | operator[] (unsigned index) |
Components setters | |
| QTensor & | SetComponents (double valueForAllComponents) |
| Sets all components to the same value. | |
| QTensor & | SetColumnVectors (const Quaternion &v1, const Quaternion &v2, const Quaternion &v3) |
| Sets the q-tensor values from the given three vector components. | |
| QTensor & | SetSkewSymmetric (const Quaternion &q) |
| Sets the matrix to be a skew symmetric matrix based on the given quaternion. | |
| QTensor & | SetLeftMultiplier (const Quaternion &q) |
| Sets the q-tensor to represent a "left-multiplier quaternion" matrix L(q). | |
| QTensor & | SetRightMultiplier (const Quaternion &q) |
| Sets the q-tensor to represent a "right-multiplier quaternion" matrix R(q). | |
| QTensor & | SetFromOrientationAndPosition (const Quaternion &q, const Quaternion &translate) |
| Creates a transform matrix from a position and orientation. | |
Components getters | |
| Quaternion | Row (unsigned i) const |
| Gets a quaternion representing one row in the matrix. | |
| Quaternion | Column (unsigned j) const |
| Gets a quaternion representing one unit base vector (axis). | |
| void | GetGLTransform (double d[Length]) const |
| Gets an OpenGL transform representing a combined translation and rotation. | |
Unary operations | |
| QTensor | operator- () const |
| Flips signs of all the components of the matrix. | |
Binary operations | |
| QTensor | operator+ (const QTensor &T) |
| Does a component-wise addition of this matrix and other matrix. | |
| QTensor & | operator+= (const QTensor &T) |
| Does a component-wise addition of this matrix and other matrix. | |
| QTensor | operator- (const QTensor &T) |
| Does a component-wise subtraction of this matrix and other matrix. | |
| QTensor & | operator-= (const QTensor &T) |
| Does a component-wise subtraction of this matrix and other matrix. | |
| QTensor | operator* (double scalar) const |
| Multiplies this matrix by the given scalar. | |
| QTensor & | operator*= (double scalar) |
| Multiplies this matrix by the given scalar. | |
| Quaternion | operator* (const Quaternion &q) const |
| Transform the vector part of a quaternion by this matrix. | |
| QTensor | operator* (const QTensor &T) const |
| Returns a q-tensor which is this matrix multiplied by the given other q-tensor. | |
| QTensor & | operator*= (const QTensor &T) |
| Multiplies this matrix in place by the given other matrix. | |
Transpose and related methods | |
| QTensor & | SetTransposeOf (const QTensor &T) |
| Sets the matrix to be the transpose of the given matrix. | |
| QTensor | Transpose () const |
| Returns a new matrix containing the transpose of this matrix. | |
Determinant, matrix Inverse and related methods | |
| double | Determinant () const |
| Returns the determinant of the matrix. | |
| QTensor & | SetInverseOf (const QTensor &T) |
| Sets the matrix to be the inverse of the given matrix. | |
| QTensor | Inverse () const |
| Returns a new matrix containing the inverse of this matrix. | |
Spatial transformations related methods | |
| Quaternion | operator() (const Quaternion &q) const |
| Transform the vector part of a quaternion by this matrix. | |
| Quaternion | TransformInverse (const Quaternion &q) const |
| Transform the given quaternion by the inverse of this matrix. | |
| QTensor | operator() (const QTensor &T) const |
| Transforms a tensor from one to another frame of reference. | |
| QTensor | TransformInverse (const QTensor &T) const |
| Transform the given matrix by the inverse of this matrix. | |
Data Fields | |
| Components | m |
| Holds the tensor components as a column-major matrix. | |
| double | data [Length] |
| Holds the contigous memory array of the components. | |
Q-Tensor components | |
| union { | |
| Components m | |
| Holds the tensor components as a column-major matrix. | |
| double data [Length] | |
| Holds the contigous memory array of the components. | |
| }; | |
Static Private Attributes | |
| static const int | Length = 16 |
| Number of components. | |
Constructors and assignment operators | |
| enum | Initializer { Uninitialized, Normalized, Zero, Identity } |
| Represents type of initial matrix data for QTensor constructor. More... | |
| QTensor (Initializer type=Normalized) | |
| Creates a tensor with initial contents according to the given type. | |
| QTensor (const Quaternion &q) | |
| Sets the main diagonal with quaternion components. | |
| QTensor (double xx, double yy, double zz, double ww=1.0) | |
| Sets the matrix with values along the main diagonal. | |
| QTensor & | operator= (double valueOnDiagonal) |
| Sets the main diagonal with the given value. | |
Encapsulates a quaternionic tensor (q-tensor) as a 4x4 row-major matrix.
Represents type of initial matrix data for QTensor constructor.
Definition at line 73 of file QTensor.h.
{
Uninitialized, //!< Matrix with uninitialized components
Normalized, //!< Matrix with m.ww = 1 and other components set to zero
Zero, //!< Matrix with all components set to zero
Identity //!< Identity matrix, i.e. 1 on the main diagonal
};
| WoRB::QTensor::QTensor | ( | Initializer | type = Normalized | ) | [inline] |
Creates a tensor with initial contents according to the given type.
Definition at line 83 of file QTensor.h.
References Identity, m, Normalized, SetComponents(), Uninitialized, WoRB::QTensor::Components::ww, WoRB::QTensor::Components::xx, WoRB::QTensor::Components::yy, Zero, and WoRB::QTensor::Components::zz.
Referenced by Inverse(), and Transpose().
{
switch( type )
{
case Uninitialized:
break;
case Normalized:
SetComponents( 0 );
m.ww = 1.0;
break;
case Zero:
SetComponents( 0 );
break;
case Identity:
SetComponents( 0 );
m.xx = m.yy = m.zz = m.ww = 1.0;
break;
}
}
| WoRB::QTensor::QTensor | ( | const Quaternion & | q | ) | [inline] |
Sets the main diagonal with quaternion components.
Definition at line 108 of file QTensor.h.
References m, SetComponents(), WoRB::Quaternion::w, WoRB::QTensor::Components::ww, WoRB::Quaternion::x, WoRB::QTensor::Components::xx, WoRB::Quaternion::y, WoRB::QTensor::Components::yy, WoRB::Quaternion::z, and WoRB::QTensor::Components::zz.
| WoRB::QTensor::QTensor | ( | double | xx, |
| double | yy, | ||
| double | zz, | ||
| double | ww = 1.0 |
||
| ) | [inline] |
Sets the matrix with values along the main diagonal.
Definition at line 119 of file QTensor.h.
References m, SetComponents(), WoRB::QTensor::Components::ww, WoRB::QTensor::Components::xx, WoRB::QTensor::Components::yy, and WoRB::QTensor::Components::zz.
| Quaternion WoRB::QTensor::Column | ( | unsigned | j | ) | const [inline] |
Gets a quaternion representing one unit base vector (axis).
Axis vectors are columns in the matrix. Axis with index 3 corresponds to the position of the transform matrix.
| j | Column index |
Definition at line 260 of file QTensor.h.
References data.
Referenced by WoRB::Geometry::Axis(), and WoRB::Geometry::Position().
{
const double* p = data + j * 4;
return Quaternion( p[3], p[0], p[1], p[2] );
}
| double WoRB::QTensor::Determinant | ( | ) | const [inline] |
Returns the determinant of the matrix.
Definition at line 445 of file QTensor.h.
References m, WoRB::QTensor::Components::xx, WoRB::QTensor::Components::xy, WoRB::QTensor::Components::xz, WoRB::QTensor::Components::yx, WoRB::QTensor::Components::yy, WoRB::QTensor::Components::yz, WoRB::QTensor::Components::zx, WoRB::QTensor::Components::zy, and WoRB::QTensor::Components::zz.
Referenced by SetInverseOf().
| void WoRB::QTensor::GetGLTransform | ( | double | d[Length] | ) | const [inline] |
Gets an OpenGL transform representing a combined translation and rotation.
Definition at line 268 of file QTensor.h.
Referenced by WoRB::GLTransform::GLTransform(), and WoRB_TestBed::Simulate().
{
// We can do simple memcpy since GL also use column-major matrix.
//
for ( int i = 0 ; i < Length; ++i ) {
d[i] = data[i];
}
// Otherwise, we should setup GL matrix explicitly:
// d[0] = m.xx ; d[4] = m.xy ; d[ 8] = m.xz ; d[12] = m.xw ;
// d[1] = m.yx ; d[5] = m.yy ; d[ 9] = m.yz ; d[13] = m.yw ;
// d[2] = m.zx ; d[6] = m.zy ; d[10] = m.zz ; d[14] = m.zw ;
// d[3] = m.wx ; d[7] = m.wy ; d[11] = m.wz ; d[15] = m.ww ;
}
| QTensor WoRB::QTensor::Inverse | ( | ) | const [inline] |
Returns a new matrix containing the inverse of this matrix.
Definition at line 509 of file QTensor.h.
References QTensor(), and Uninitialized.
Referenced by WoRB::RigidBody::CalculateDerivedQuantities(), and WoRB::Collision::GetImpulse_IncludeFriction().
{
return QTensor( Uninitialized ).SetInverseOf( *this );
}
| Quaternion WoRB::QTensor::operator() | ( | const Quaternion & | q | ) | const [inline] |
Transform the vector part of a quaternion by this matrix.
Definition at line 520 of file QTensor.h.
References m, WoRB::Quaternion::x, WoRB::QTensor::Components::xw, WoRB::QTensor::Components::xx, WoRB::QTensor::Components::xy, WoRB::QTensor::Components::xz, WoRB::Quaternion::y, WoRB::QTensor::Components::yw, WoRB::QTensor::Components::yx, WoRB::QTensor::Components::yy, WoRB::QTensor::Components::yz, WoRB::Quaternion::z, WoRB::QTensor::Components::zw, WoRB::QTensor::Components::zx, WoRB::QTensor::Components::zy, and WoRB::QTensor::Components::zz.
Transforms a tensor from one to another frame of reference.
Equivalent to: result = (*this) * T * Transpose()
Definition at line 546 of file QTensor.h.
References m, Uninitialized, WoRB::QTensor::Components::ww, WoRB::QTensor::Components::wx, WoRB::QTensor::Components::wy, WoRB::QTensor::Components::xw, WoRB::QTensor::Components::xx, WoRB::QTensor::Components::xy, WoRB::QTensor::Components::xz, WoRB::QTensor::Components::yw, WoRB::QTensor::Components::yx, WoRB::QTensor::Components::yy, WoRB::QTensor::Components::yz, WoRB::QTensor::Components::zw, WoRB::QTensor::Components::zx, WoRB::QTensor::Components::zy, and WoRB::QTensor::Components::zz.
{
QTensor result( Uninitialized );
double t_xx = m.xx * T.m.xx + m.xy * T.m.yx + m.xz * T.m.zx ;
double t_xy = m.xx * T.m.xy + m.xy * T.m.yy + m.xz * T.m.zy ;
double t_xz = m.xx * T.m.xz + m.xy * T.m.yz + m.xz * T.m.zz ;
double t_yx = m.yx * T.m.xx + m.yy * T.m.yx + m.yz * T.m.zx ;
double t_yy = m.yx * T.m.xy + m.yy * T.m.yy + m.yz * T.m.zy ;
double t_yz = m.yx * T.m.xz + m.yy * T.m.yz + m.yz * T.m.zz ;
double t_zx = m.zx * T.m.xx + m.zy * T.m.yx + m.zz * T.m.zx ;
double t_zy = m.zx * T.m.xy + m.zy * T.m.yy + m.zz * T.m.zy ;
double t_zz = m.zx * T.m.xz + m.zy * T.m.yz + m.zz * T.m.zz ;
result.m.xx = t_xx * m.xx + t_xy * m.xy + t_xz * m.xz ;
result.m.xy = t_xx * m.yx + t_xy * m.yy + t_xz * m.yz ;
result.m.xz = t_xx * m.zx + t_xy * m.zy + t_xz * m.zz ;
result.m.xw = 0 ;
result.m.yx = t_yx * m.xx + t_yy * m.xy + t_yz * m.xz ;
result.m.yy = t_yx * m.yx + t_yy * m.yy + t_yz * m.yz ;
result.m.yz = t_yx * m.zx + t_yy * m.zy + t_yz * m.zz ;
result.m.yw = 0 ;
result.m.zx = t_zx * m.xx + t_zy * m.xy + t_zz * m.xz ;
result.m.zy = t_zx * m.yx + t_zy * m.yy + t_zz * m.yz ;
result.m.zz = t_zx * m.zx + t_zy * m.zy + t_zz * m.zz ;
result.m.zw = 0 ;
result.m.wx = result.m.wy = result.m.ww = 0;
result.m.ww = 1;
return result;
}
| QTensor WoRB::QTensor::operator* | ( | double | scalar | ) | const [inline] |
Multiplies this matrix by the given scalar.
Definition at line 350 of file QTensor.h.
References data, Length, and Uninitialized.
{
QTensor result( Uninitialized );
for ( int i = 0; i < Length; ++i ) {
result.data[i] = data[i] * scalar;
}
return result;
}
| Quaternion WoRB::QTensor::operator* | ( | const Quaternion & | q | ) | const [inline] |
Transform the vector part of a quaternion by this matrix.
Definition at line 372 of file QTensor.h.
References m, WoRB::Quaternion::x, WoRB::QTensor::Components::xw, WoRB::QTensor::Components::xx, WoRB::QTensor::Components::xy, WoRB::QTensor::Components::xz, WoRB::Quaternion::y, WoRB::QTensor::Components::yw, WoRB::QTensor::Components::yx, WoRB::QTensor::Components::yy, WoRB::QTensor::Components::yz, WoRB::Quaternion::z, WoRB::QTensor::Components::zw, WoRB::QTensor::Components::zx, WoRB::QTensor::Components::zy, and WoRB::QTensor::Components::zz.
Returns a q-tensor which is this matrix multiplied by the given other q-tensor.
Definition at line 384 of file QTensor.h.
References m, Uninitialized, WoRB::QTensor::Components::ww, WoRB::QTensor::Components::wx, WoRB::QTensor::Components::wy, WoRB::QTensor::Components::wz, WoRB::QTensor::Components::xw, WoRB::QTensor::Components::xx, WoRB::QTensor::Components::xy, WoRB::QTensor::Components::xz, WoRB::QTensor::Components::yw, WoRB::QTensor::Components::yx, WoRB::QTensor::Components::yy, WoRB::QTensor::Components::yz, WoRB::QTensor::Components::zw, WoRB::QTensor::Components::zx, WoRB::QTensor::Components::zy, and WoRB::QTensor::Components::zz.
{
QTensor result( Uninitialized );
result.m.xx = m.xx * T.m.xx + m.xy * T.m.yx + m.xz * T.m.zx ;
result.m.xy = m.xx * T.m.xy + m.xy * T.m.yy + m.xz * T.m.zy ;
result.m.xz = m.xx * T.m.xz + m.xy * T.m.yz + m.xz * T.m.zz ;
result.m.xw = m.xx * T.m.xw + m.xy * T.m.yw + m.xz * T.m.zw + m.xw ;
result.m.yx = m.yx * T.m.xx + m.yy * T.m.yx + m.yz * T.m.zx ;
result.m.yy = m.yx * T.m.xy + m.yy * T.m.yy + m.yz * T.m.zy ;
result.m.yz = m.yx * T.m.xz + m.yy * T.m.yz + m.yz * T.m.zz ;
result.m.yw = m.yx * T.m.xw + m.yy * T.m.yw + m.yz * T.m.zw + m.yw ;
result.m.zx = m.zx * T.m.xx + m.zy * T.m.yx + m.zz * T.m.zx ;
result.m.zy = m.zx * T.m.xy + m.zy * T.m.yy + m.zz * T.m.zy ;
result.m.zz = m.zx * T.m.xz + m.zy * T.m.yz + m.zz * T.m.zz ;
result.m.zw = m.zx * T.m.xw + m.zy * T.m.yw + m.zz * T.m.zw + m.zw ;
result.m.wx = result.m.wy = result.m.wz = 0;
result.m.ww = 1;
return result;
}
| QTensor& WoRB::QTensor::operator*= | ( | double | scalar | ) | [inline] |
Does a component-wise addition of this matrix and other matrix.
Definition at line 306 of file QTensor.h.
References data, Length, and Uninitialized.
{
QTensor result( Uninitialized );
for ( int i = 0; i < Length; ++i ) {
result.data[i] = data[i] + T.data[i];
}
return result;
}
| QTensor WoRB::QTensor::operator- | ( | ) | const [inline] |
Flips signs of all the components of the matrix.
Definition at line 289 of file QTensor.h.
References data, Length, and Uninitialized.
{
QTensor result( Uninitialized );
for ( int i = 0; i < Length; ++i ) {
result.data[i] = - data[i];
}
return result;
}
Does a component-wise subtraction of this matrix and other matrix.
Definition at line 328 of file QTensor.h.
References data, Length, and Uninitialized.
{
QTensor result( Uninitialized );
for ( int i = 0; i < Length; ++i ) {
result.data[i] = data[i] - T.data[i];
}
return result;
}
| QTensor& WoRB::QTensor::operator= | ( | double | valueOnDiagonal | ) | [inline] |
Sets the main diagonal with the given value.
Definition at line 130 of file QTensor.h.
References m, SetComponents(), WoRB::QTensor::Components::ww, WoRB::QTensor::Components::xx, WoRB::QTensor::Components::yy, and WoRB::QTensor::Components::zz.
| double& WoRB::QTensor::operator[] | ( | unsigned | index | ) | [inline] |
| Quaternion WoRB::QTensor::Row | ( | unsigned | i | ) | const [inline] |
| QTensor& WoRB::QTensor::SetColumnVectors | ( | const Quaternion & | v1, |
| const Quaternion & | v2, | ||
| const Quaternion & | v3 | ||
| ) | [inline] |
Sets the q-tensor values from the given three vector components.
These are arranged as the three columns of the vector.
Definition at line 164 of file QTensor.h.
References m, WoRB::QTensor::Components::ww, WoRB::QTensor::Components::wx, WoRB::QTensor::Components::wy, WoRB::QTensor::Components::wz, WoRB::Quaternion::x, WoRB::QTensor::Components::xw, WoRB::QTensor::Components::xx, WoRB::QTensor::Components::xy, WoRB::QTensor::Components::xz, WoRB::Quaternion::y, WoRB::QTensor::Components::yw, WoRB::QTensor::Components::yx, WoRB::QTensor::Components::yy, WoRB::QTensor::Components::yz, WoRB::Quaternion::z, WoRB::QTensor::Components::zw, WoRB::QTensor::Components::zx, WoRB::QTensor::Components::zy, and WoRB::QTensor::Components::zz.
Referenced by WoRB::Collision::FindOrthonormalBasisAtContactPoint().
| QTensor& WoRB::QTensor::SetComponents | ( | double | valueForAllComponents | ) | [inline] |
Sets all components to the same value.
Definition at line 152 of file QTensor.h.
Referenced by operator=(), QTensor(), and SetInverseOf().
| QTensor& WoRB::QTensor::SetFromOrientationAndPosition | ( | const Quaternion & | q, |
| const Quaternion & | translate | ||
| ) | [inline] |
Creates a transform matrix from a position and orientation.
This is so called Shoemake's matrix, which is obtained as L(q) * R(q*). See "Rotation of Moment of Inertia Tensor" Mathematica notebook by MBK.
Definition at line 221 of file QTensor.h.
References m, WoRB::Quaternion::w, WoRB::QTensor::Components::ww, WoRB::QTensor::Components::wx, WoRB::QTensor::Components::wy, WoRB::QTensor::Components::wz, WoRB::Quaternion::x, WoRB::QTensor::Components::xw, WoRB::QTensor::Components::xx, WoRB::QTensor::Components::xy, WoRB::QTensor::Components::xz, WoRB::Quaternion::y, WoRB::QTensor::Components::yw, WoRB::QTensor::Components::yx, WoRB::QTensor::Components::yy, WoRB::QTensor::Components::yz, WoRB::Quaternion::z, WoRB::QTensor::Components::zw, WoRB::QTensor::Components::zx, WoRB::QTensor::Components::zy, and WoRB::QTensor::Components::zz.
Referenced by WoRB::RigidBody::CalculateDerivedQuantities().
{
m.xx = 1 - 2 * ( q.y * q.y + q.z * q.z ) ;
m.xy = 2 * ( q.x * q.y - q.w * q.z ) ;
m.xz = 2 * ( q.x * q.z + q.w * q.y ) ;
m.xw = translate.x;
m.yx = 2 * ( q.x * q.y + q.w * q.z ) ;
m.yy = 1 - 2 * ( q.x * q.x + q.z * q.z ) ;
m.yz = 2 * ( q.y * q.z - q.w * q.x ) ;
m.yw = translate.y;
m.zx = 2 * ( q.x * q.z - q.w * q.y ) ;
m.zy = 2 * ( q.y * q.z + q.w * q.x ) ;
m.zz = 1 - 2 * ( q.x * q.x + q.y * q.y ) ;
m.zw = translate.z;
m.wx = m.wy = m.wz = 0; m.ww = 1;
return *this;
}
| QTensor& WoRB::QTensor::SetInverseOf | ( | const QTensor & | T | ) | [inline] |
Sets the matrix to be the inverse of the given matrix.
Definition at line 457 of file QTensor.h.
References data, Determinant(), Length, m, SetComponents(), WoRB::QTensor::Components::xw, WoRB::QTensor::Components::xx, WoRB::QTensor::Components::xy, WoRB::QTensor::Components::xz, WoRB::QTensor::Components::yw, WoRB::QTensor::Components::yx, WoRB::QTensor::Components::yy, WoRB::QTensor::Components::yz, WoRB::QTensor::Components::zw, WoRB::QTensor::Components::zx, WoRB::QTensor::Components::zy, and WoRB::QTensor::Components::zz.
Referenced by WoRB::RigidBody::SetMomentOfInertia().
{
double det_T = T.Determinant();
// Make sure the determinant is non-zero.
//
if ( det_T == 0 ) {
SetComponents( 0 );
return *this;
}
m.xx = - T.m.zy * T.m.yz + T.m.yy * T.m.zz;
m.yx = T.m.zx * T.m.yz - T.m.yx * T.m.zz;
m.zx = - T.m.zx * T.m.yy + T.m.yx * T.m.zy;
m.xy = T.m.zy * T.m.xz - T.m.xy * T.m.zz;
m.yy = - T.m.zx * T.m.xz + T.m.xx * T.m.zz;
m.zy = T.m.zx * T.m.xy - T.m.xx * T.m.zy;
m.xz = - T.m.yy * T.m.xz + T.m.xy * T.m.yz;
m.yz = T.m.yx * T.m.xz - T.m.xx * T.m.yz;
m.zz = - T.m.yx * T.m.xy + T.m.xx * T.m.yy;
m.xw = T.m.zy * T.m.yz * T.m.xw
- T.m.yy * T.m.zz * T.m.xw
- T.m.zy * T.m.xz * T.m.yw
+ T.m.xy * T.m.zz * T.m.yw
+ T.m.yy * T.m.xz * T.m.zw
- T.m.xy * T.m.yz * T.m.zw;
m.yw = - T.m.zx * T.m.yz * T.m.xw
+ T.m.yx * T.m.zz * T.m.xw
+ T.m.zx * T.m.xz * T.m.yw
- T.m.xx * T.m.zz * T.m.yw
- T.m.yx * T.m.xz * T.m.zw
+ T.m.xx * T.m.yz * T.m.zw;
m.zw = T.m.zx * T.m.yy * T.m.xw
- T.m.yx * T.m.zy * T.m.xw
- T.m.zx * T.m.xy * T.m.yw
+ T.m.xx * T.m.zy * T.m.yw
+ T.m.yx * T.m.xy * T.m.zw
- T.m.xx * T.m.yy * T.m.zw;
for ( int i = 0; i < Length; ++ i ) {
data[i] /= det_T;
}
return *this;
}
| QTensor& WoRB::QTensor::SetLeftMultiplier | ( | const Quaternion & | q | ) | [inline] |
Sets the q-tensor to represent a "left-multiplier quaternion" matrix L(q).
See "Rotation of Moment of Inertia Tensor" Mathematica notebook by MBK.
Definition at line 192 of file QTensor.h.
References m, WoRB::Quaternion::w, WoRB::QTensor::Components::ww, WoRB::QTensor::Components::wx, WoRB::QTensor::Components::wy, WoRB::QTensor::Components::wz, WoRB::Quaternion::x, WoRB::QTensor::Components::xw, WoRB::QTensor::Components::xx, WoRB::QTensor::Components::xy, WoRB::QTensor::Components::xz, WoRB::Quaternion::y, WoRB::QTensor::Components::yw, WoRB::QTensor::Components::yx, WoRB::QTensor::Components::yy, WoRB::QTensor::Components::yz, WoRB::Quaternion::z, WoRB::QTensor::Components::zw, WoRB::QTensor::Components::zx, WoRB::QTensor::Components::zy, and WoRB::QTensor::Components::zz.
| QTensor& WoRB::QTensor::SetRightMultiplier | ( | const Quaternion & | q | ) | [inline] |
Sets the q-tensor to represent a "right-multiplier quaternion" matrix R(q).
See "Rotation of Moment of Inertia Tensor" Mathematica notebook by MBK.
Definition at line 206 of file QTensor.h.
References m, WoRB::Quaternion::w, WoRB::QTensor::Components::ww, WoRB::QTensor::Components::wx, WoRB::QTensor::Components::wy, WoRB::QTensor::Components::wz, WoRB::Quaternion::x, WoRB::QTensor::Components::xw, WoRB::QTensor::Components::xx, WoRB::QTensor::Components::xy, WoRB::QTensor::Components::xz, WoRB::Quaternion::y, WoRB::QTensor::Components::yw, WoRB::QTensor::Components::yx, WoRB::QTensor::Components::yy, WoRB::QTensor::Components::yz, WoRB::Quaternion::z, WoRB::QTensor::Components::zw, WoRB::QTensor::Components::zx, WoRB::QTensor::Components::zy, and WoRB::QTensor::Components::zz.
| QTensor& WoRB::QTensor::SetSkewSymmetric | ( | const Quaternion & | q | ) | [inline] |
Sets the matrix to be a skew symmetric matrix based on the given quaternion.
Definition at line 178 of file QTensor.h.
References m, WoRB::QTensor::Components::ww, WoRB::QTensor::Components::wx, WoRB::QTensor::Components::wy, WoRB::QTensor::Components::wz, WoRB::Quaternion::x, WoRB::QTensor::Components::xw, WoRB::QTensor::Components::xx, WoRB::QTensor::Components::xy, WoRB::QTensor::Components::xz, WoRB::Quaternion::y, WoRB::QTensor::Components::yw, WoRB::QTensor::Components::yx, WoRB::QTensor::Components::yy, WoRB::QTensor::Components::yz, WoRB::Quaternion::z, WoRB::QTensor::Components::zw, WoRB::QTensor::Components::zx, WoRB::QTensor::Components::zy, and WoRB::QTensor::Components::zz.
Referenced by WoRB::Collision::GetImpulse_IncludeFriction().
| QTensor& WoRB::QTensor::SetTransposeOf | ( | const QTensor & | T | ) | [inline] |
Sets the matrix to be the transpose of the given matrix.
Definition at line 422 of file QTensor.h.
References m, WoRB::QTensor::Components::ww, WoRB::QTensor::Components::wx, WoRB::QTensor::Components::wy, WoRB::QTensor::Components::wz, WoRB::QTensor::Components::xw, WoRB::QTensor::Components::xx, WoRB::QTensor::Components::xy, WoRB::QTensor::Components::xz, WoRB::QTensor::Components::yw, WoRB::QTensor::Components::yx, WoRB::QTensor::Components::yy, WoRB::QTensor::Components::yz, WoRB::QTensor::Components::zw, WoRB::QTensor::Components::zx, WoRB::QTensor::Components::zy, and WoRB::QTensor::Components::zz.
| Quaternion WoRB::QTensor::TransformInverse | ( | const Quaternion & | q | ) | const [inline] |
Transform the given quaternion by the inverse of this matrix.
Definition at line 531 of file QTensor.h.
References m, WoRB::Quaternion::x, WoRB::QTensor::Components::xw, WoRB::QTensor::Components::xx, WoRB::QTensor::Components::xy, WoRB::QTensor::Components::xz, WoRB::Quaternion::y, WoRB::QTensor::Components::yw, WoRB::QTensor::Components::yx, WoRB::QTensor::Components::yy, WoRB::QTensor::Components::yz, WoRB::Quaternion::z, WoRB::QTensor::Components::zw, WoRB::QTensor::Components::zx, WoRB::QTensor::Components::zy, and WoRB::QTensor::Components::zz.
Referenced by WoRB::Cuboid::Check(), WoRB::Collision::GetImpulse_IncludeFriction(), WoRB::Collision::GetRelativeVelocity(), and WoRB::CollisionResolver::ImpulseTransfers().
| QTensor WoRB::QTensor::TransformInverse | ( | const QTensor & | T | ) | const [inline] |
Transform the given matrix by the inverse of this matrix.
Equivalent to: result = Transpose() * T * (*this)
Definition at line 587 of file QTensor.h.
References m, Uninitialized, WoRB::QTensor::Components::ww, WoRB::QTensor::Components::wx, WoRB::QTensor::Components::wy, WoRB::QTensor::Components::xw, WoRB::QTensor::Components::xx, WoRB::QTensor::Components::xy, WoRB::QTensor::Components::xz, WoRB::QTensor::Components::yw, WoRB::QTensor::Components::yx, WoRB::QTensor::Components::yy, WoRB::QTensor::Components::yz, WoRB::QTensor::Components::zw, WoRB::QTensor::Components::zx, WoRB::QTensor::Components::zy, and WoRB::QTensor::Components::zz.
{
QTensor result( Uninitialized );
double t_xx = m.xx * T.m.xx + m.yx * T.m.yx + m.zx * T.m.zx ;
double t_xy = m.xx * T.m.xy + m.yx * T.m.yy + m.zx * T.m.zy ;
double t_xz = m.xx * T.m.xz + m.yx * T.m.yz + m.zx * T.m.zz ;
double t_yx = m.xy * T.m.xx + m.yy * T.m.yx + m.zy * T.m.zx ;
double t_yy = m.xy * T.m.xy + m.yy * T.m.yy + m.zy * T.m.zy ;
double t_yz = m.xy * T.m.xz + m.yy * T.m.yz + m.zy * T.m.zz ;
double t_zx = m.xz * T.m.xx + m.yz * T.m.yx + m.zz * T.m.zx ;
double t_zy = m.xz * T.m.xy + m.yz * T.m.yy + m.zz * T.m.zy ;
double t_zz = m.xz * T.m.xz + m.yz * T.m.yz + m.zz * T.m.zz ;
result.m.xx = t_xx * m.xx + t_xy * m.yx + t_xz * m.zx ;
result.m.xy = t_xx * m.xy + t_xy * m.yy + t_xz * m.zy ;
result.m.xz = t_xx * m.xz + t_xy * m.yz + t_xz * m.zz ;
result.m.xw = 0 ;
result.m.yx = t_yx * m.xx + t_yy * m.yx + t_yz * m.zx ;
result.m.yy = t_yx * m.xy + t_yy * m.yy + t_yz * m.zy ;
result.m.yz = t_yx * m.xz + t_yy * m.yz + t_yz * m.zz ;
result.m.yw = 0 ;
result.m.zx = t_zx * m.xx + t_zy * m.yx + t_zz * m.zx ;
result.m.zy = t_zx * m.xy + t_zy * m.yy + t_zz * m.zy ;
result.m.zz = t_zx * m.xz + t_zy * m.yz + t_zz * m.zz ;
result.m.zw = 0 ;
result.m.wx = result.m.wy = result.m.ww = 0;
result.m.ww = 1;
return result;
}
| QTensor WoRB::QTensor::Transpose | ( | ) | const [inline] |
Returns a new matrix containing the transpose of this matrix.
Definition at line 434 of file QTensor.h.
References QTensor(), and Uninitialized.
{
return QTensor( Uninitialized ).SetTransposeOf( *this );
}
| union { ... } |
| double WoRB::QTensor::data[Length] |
Holds the contigous memory array of the components.
Definition at line 64 of file QTensor.h.
Referenced by Column(), GetGLTransform(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), Row(), SetComponents(), and SetInverseOf().
const int WoRB::QTensor::Length = 16 [static, private] |
Number of components.
Definition at line 26 of file QTensor.h.
Referenced by GetGLTransform(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), SetComponents(), and SetInverseOf().
Holds the tensor components as a column-major matrix.
Definition at line 60 of file QTensor.h.
Referenced by Determinant(), WoRB::Collision::GetImpulse_IncludeFriction(), operator()(), operator*(), operator=(), operator[](), QTensor(), SetColumnVectors(), SetFromOrientationAndPosition(), SetInverseOf(), SetLeftMultiplier(), SetRightMultiplier(), SetSkewSymmetric(), SetTransposeOf(), and TransformInverse().