Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
spat::Transformation< Valtype > Class Template Reference

Homogenous transformation matrix. More...

#include <C:/Trend/Development/Trax3/Code/spat/Matrix.h>

Inheritance diagram for spat::Transformation< Valtype >:

Public Types

using Basetype = typename SquareMatrix<Valtype,4>::Basetype
Public Types inherited from spat::SquareMatrix< Valtype, 4 >
using Basetype
 Utmost base type of this SquareMatrix.
Public Types inherited from spat::Matrix< Valtype, nColsAndRows, nColsAndRows >
typedef Valtype value_type

Public Member Functions

template<typename Valtype2>
Transformation< Valtype > & operator= (const Rotation< Valtype2 > &rot) noexcept
template<typename Valtype2, typename ValtypeT2>
Transformation< Valtype > & operator= (const Frame< Valtype2, ValtypeT2 > &frame) noexcept
Construction
Parameters
rotConstruct pure rotational transformation
matrixConstruct from matrix
frameConstruct from frame so that this transformation transforms coordinates, local to the frame into coordinates in the system the frame is defined.
 Transformation (const SquareMatrix< Valtype, 4 > &matrix)
 Transformation (SquareMatrix< Valtype, 4 > &&matrix) noexcept
 Transformation (const Basetype &matrix)
 Transformation (Basetype &&matrix) noexcept
template<typename Valtype2>
 Transformation (const Rotation< Valtype2 > &rot)
template<typename Valtype2, typename ValtypeT2>
 Transformation (const Frame< Valtype2, ValtypeT2 > &frame)
 Transformation (const std::initializer_list< Valtype > &elements)
Assignment
Parameters
rotAssign pure rotational transformation
frameAssign frame local to parent transformation
template<typename Valtype2>
Transformation & operator= (const Rotation< Valtype2 > &rot) noexcept
template<typename Valtype2, typename ValtypeT2>
Transformation & operator= (const Frame< Valtype2, ValtypeT2 > &frame) noexcept
Transformation
template<typename Valtype2>
PositionH< Valtype2 > operator* (const PositionH< Valtype2 > &p) const noexcept
template<typename Valtype2>
Position< Valtype2 > operator* (const Position< Valtype2 > &pos) const noexcept
template<typename Valtype2>
Vector< Valtype2 > operator* (const Vector< Valtype2 > &vec) const noexcept
CreateTranslation

Creates a matrix that has the effect of a translation.

Parameters
translationTranslation vector
txx - translation.
tyy - translation.
tzz - translation.
void CreateTranslation (const Vector< Valtype > &translation) noexcept
void CreateTranslation (Valtype tx, Valtype ty, Valtype tz) noexcept
CreateRotation

Creates a matrix that has the effect of a rotation.

Parameters
rotationRotation vector
rxx - component of rotation vector.
ryy - component of rotation vector.
rzz - component of rotation vector.
void CreateRotation (const Vector< Valtype > &rotation)
void CreateRotation (Valtype rx, Valtype ry, Valtype rz)
CreateScaling

Creates a matrix that has the effect of a scaling.

Parameters
scalingScaling vector
rxx - component of scaling vector.
ryy - component of scaling vector.
rzz - component of scaling vector.
void CreateScaling (const Vector< Valtype > &scaling) noexcept
void CreateScaling (Valtype sx, Valtype sy, Valtype sz) noexcept
CreateMirror

Creates a matrix that has the effect of mirroring on a plane, described by mirror.

template<typename Valtype2>
void CreateMirror (const VectorBundle< Valtype2, Valtype > &mirror)
 Create a view matrix that transforms to camera space.
void LookAt (const Position< Valtype > &at, const Position< Valtype > &eye, const Vector< Valtype > &up) noexcept
 Create a view matrix that transforms to camera space.
void CreateViewport (Valtype Width, Valtype Height, Valtype MinZ, Valtype MaxZ, Valtype LeftMargin=0.0f, Valtype TopMargin=0.0f) noexcept
 Creates a viewport projection.
bool CreateCameraProjection (Valtype fovy, Valtype Aspect, Valtype zn, Valtype zf) noexcept
 Creates camera projection transformation.
bool CreateOrthographicProjection (Valtype width, Valtype height, Valtype znear, Valtype zfar) noexcept
 Creates orthographic projection transformation.
Vector< Valtype > TransformVector (const Vector< Valtype > &vec) const noexcept
 Vector transformation. Use it for difference vectors between positions or dynamic vectors like velocities and accellerations.
void GetTranslation (Transformation &T) const noexcept
 Kovariant vector use this for face normals or vectors denoting a rotation orientation.
bool GeRotation (Transformation &R) const noexcept
 Calculates a rotational part of the transformation so that T * R * S == *this.
bool GetScaling (Transformation &S) const noexcept
 Calculates a scaling part of the transformation so that T * R * S == *this.
bool Dismantle (Transformation &T, Transformation &R, Transformation &S) const noexcept
 Calculates translational, rotational and scaling part of the transformation so that T * R * S == *this.
bool IsValid () const noexcept
 Tests wether the matrix is a valid homogenous transformation.
Public Member Functions inherited from spat::SquareMatrix< Valtype, 4 >
Matrix & operator= (const Matrix &matrix) noexcept
Matrix & operator= (Matrix &&matrix) noexcept
Matrix & operator= (const std::initializer_list< Valtype > &elements) noexcept
const Valtype & operator() (unsigned short col, unsigned short row) const noexcept
Valtype & operator() (unsigned short col, unsigned short row) noexcept
void SetIdentity () noexcept
 Sets the matrix to the identity matrix (i.e. all 1 in diagonal, 0 for everything else).
bool IsIdentity (Valtype epsilon=0) const noexcept
bool IsDiagonal () const noexcept
bool IsSymmetric (Valtype epsilon=0) const noexcept
SquareMatrix & Transpose () noexcept
 Change colums and rows.
SquareMatrix & Invert ()
 Invert matrix so that M*I == Identity.
Valtype Trace () const noexcept
 Trace of the matrix, wich is the sum of all element with same indices.
Public Member Functions inherited from spat::Matrix< Valtype, nColsAndRows, nColsAndRows >
void SetNull () noexcept
 Sets all elements to 0.
constexpr unsigned short Cols () const noexcept
 Number of columns.
constexpr unsigned short Rows () const noexcept
 Number of rows.
bool IsEqual (const Matrix &matrix, Valtype delta=0) const noexcept
 Test elements for equality up to delta distance.
bool operator== (const Matrix &matrix) const noexcept
 Comparison for equality.
bool operator!= (const Matrix &matrix) const noexcept
 Comparison for inequality.
void operator*= (Valtype skalar) noexcept
 Matrix * Skalar multiplication.
void operator*= (const Matrix< Valtype, nCols, nCols > &matrix)
 Matrix multiplication.
void operator/= (Valtype skalar) noexcept
 Matrix / Skalar division.
void operator+= (const Matrix &matrix) noexcept
 Matrix addition.
void operator-= (const Matrix &matrix) noexcept
 Matrix subtraction.
const Valtype * ptr () const noexcept
 Pointer accessor for direct copying. The memory layout is column-major order.
Matrix< Valtype, nCols-1, nRows-1 > SubMatrix (unsigned short c, unsigned short r) const
 Extracts the submatrix of mat wich results from omitting the row r and collumn c.
 Matrix (const Matrix &matrix)
 Matrix (Matrix &&matrix) noexcept
 Matrix (const std::initializer_list< Valtype > &elements)
Matrix & operator= (const Matrix &matrix) noexcept
Matrix & operator= (Matrix &&matrix) noexcept
Matrix & operator= (const std::initializer_list< Valtype > &elements) noexcept
const Valtype & operator() (unsigned short col, unsigned short row) const noexcept
Valtype & operator() (unsigned short col, unsigned short row) noexcept

Detailed Description

template<typename Valtype>
class spat::Transformation< Valtype >

Homogenous transformation matrix.

Member Function Documentation

◆ CreateCameraProjection()

template<typename Valtype>
bool spat::Transformation< Valtype >::CreateCameraProjection ( Valtype fovy,
Valtype Aspect,
Valtype zn,
Valtype zf )
noexcept

Creates camera projection transformation.

Parameters
fovyField of view angle.
AspectWidth to height aspect of opening angles.
znDistance to the near plane of the camera frustum.
zfDistance to the far plane of the camera frustum.

◆ GetTranslation()

template<typename Valtype>
void spat::Transformation< Valtype >::GetTranslation ( Transformation< Valtype > & T) const
noexcept

Kovariant vector use this for face normals or vectors denoting a rotation orientation.

Calculates a translational part of the transformation so that T * R * S == *this.

◆ TransformVector()

template<typename Valtype>
Vector< Valtype > spat::Transformation< Valtype >::TransformVector ( const Vector< Valtype > & vec) const
noexcept

Vector transformation. Use it for difference vectors between positions or dynamic vectors like velocities and accellerations.

If you want to transform normal vectors be aware that due to the nature of this kind of vector beeing orthogonal to a plane you have to use the inverse transposed matrix.

M: Transformation matrix for coordinates. Q: Transformation matrix for normals. D = P2 - P1: Vector between two arbitrary points in a plane. D' = P2' - P1' = M * P2 - M * P1 = M * D: Transformed vector D. N: Normal on that plane.

Now its N*D = 0 for all D since N is orthogonal to the plane. But with the transformed vectors the same condition must hold: N'*D' = 0. -> Q*N*M*D = 0 -> N*Qt*M*D = 0 (Qt is the transposed of Q) since this must hold for all D (or lets put it the other way: to be on the safe side) Qt*M = IdentityMatrix must hold. hence Q = Transposed(Inverse(M)) = Inverse(Transposed(M))


The documentation for this class was generated from the following file:
  • C:/Trend/Development/Trax3/Code/spat/Matrix.h