Emergency 2017 Dokumentation  v3.0.1
qsf::Transform Class Reference

3D transform class More...

#include <Transform.h>

Public Member Functions

 Transform ()
 Default constructor (set's an identity transform matrix) More...
 
 Transform (const Transform &source)
 Copy constructor. More...
 
 Transform (const glm::vec3 &position, const glm::quat &rotation=glm::quat(), const glm::vec3 &scale=glm::vec3(1.0f, 1.0f, 1.0f))
 Constructor from position, rotation and scale. More...
 
 Transform (const glm::mat4x4 &transformMatrix)
 Constructor from transformation matrix. More...
 
Transformoperator= (const Transform &source)
 Copy operator. More...
 
bool operator== (const Transform &other) const
 Equal compare operator. More...
 
bool operator!= (const Transform &other) const
 Not equal compare operator. More...
 
Transformoperator+= (const Transform &other)
 Add operator. More...
 
Transformoperator-= (const Transform &other)
 Subtract operator. More...
 
const glm::vec3 & getPosition () const
 Return the position. More...
 
void setPosition (const glm::vec3 &position)
 Set the position. More...
 
const glm::quat & getRotation () const
 Return the rotation quaternion. More...
 
void setRotation (const glm::quat &rotation)
 Set the rotation quaternion. More...
 
const glm::vec3 & getScale () const
 Return the scale. More...
 
void setScale (const glm::vec3 &scale)
 Set the scale. More...
 
void setPositionAndRotation (const glm::vec3 &position, const glm::quat &rotation)
 Set the position and rotation. More...
 
void setMatrix (const glm::mat4x4 &transform)
 Set the current final transform matrix. More...
 
void calculateMatrix (glm::mat4x4 &matrix) const
 Calculate the current final transform matrix. More...
 
void calculateInverseMatrix (glm::mat4x4 &inverseMatrix) const
 Calculate the current final inverse transform matrix. More...
 
void createLocalTransform (const Transform &worldTransform, const Transform &referenceTransform)
 Create a transform that describes a local transformation. More...
 
void fromLocalTransform (const Transform &localTransform, const Transform &referenceTransform)
 Create a transform object from a given local transformation. More...
 
glm::vec3 vec3PositionWorldToLocal (const glm::vec3 &position) const
 Transform a given world space position into a local space position relative to a given world space transform. More...
 
glm::vec3 vec3PositionLocalToWorld (const glm::vec3 &position) const
 Transform a given local space position relative to a given world space transform into a world space position. More...
 
glm::vec3 vec3DirectionWorldToLocal (const glm::vec3 &direction) const
 Transform a given world space direction vector into a local space vector relative to a given world space transform. More...
 
glm::vec3 vec3DirectionLocalToWorld (const glm::vec3 &direction) const
 Transform a given local space direction vector relative to a given world space transform into a world space vector. More...
 
glm::quat quatRotationWorldToLocal (const glm::quat &rotation) const
 Transform a given world space rotation into a local space rotation relative to a given world space transform. More...
 
glm::quat quatRotationLocalToWorld (const glm::quat &rotation) const
 Transform a given local space rotation relative to a given world space transform into a world space rotation. More...
 
Line lineWorldToLocal (const Line &line) const
 Transform a given world space line into a local space line relative to a given world space transform. More...
 
Line lineLocalToWorld (const Line &line) const
 Transform a given local space line relative to a given world space transform into a world space line. More...
 
void serialize (BinarySerializer &serializer)
 Serialize this transform instance. More...
 

Detailed Description

3D transform class

Remarks
The design goal of this class was to be as memory compact as possible and to provide a class which is able to convert between different representations of a 3D transform in an efficient way.

Definition at line 45 of file Transform.h.

Constructor & Destructor Documentation

qsf::Transform::Transform ( )
inline

Default constructor (set's an identity transform matrix)

Definition at line 14 of file Transform-inl.h.

qsf::Transform::Transform ( const Transform source)
inline

Copy constructor.

Parameters
[in]sourceSource to copy from

Definition at line 20 of file Transform-inl.h.

qsf::Transform::Transform ( const glm::vec3 &  position,
const glm::quat &  rotation = glm::quat(),
const glm::vec3 &  scale = glm::vec3(1.0f, 1.0f, 1.0f) 
)
inlineexplicit

Constructor from position, rotation and scale.

Parameters
[in]positionPosition to set
[in]rotationOptional rotation to set
[in]scaleOptional scale to set

Definition at line 28 of file Transform-inl.h.

qsf::Transform::Transform ( const glm::mat4x4 &  transformMatrix)
inlineexplicit

Constructor from transformation matrix.

Parameters
[in]transformMatrixMatrix to incorporate as transformation

Definition at line 36 of file Transform-inl.h.

Member Function Documentation

void qsf::Transform::calculateInverseMatrix ( glm::mat4x4 &  inverseMatrix) const

Calculate the current final inverse transform matrix.

Parameters
[out]inverseMatrixReceives the calculated final inverse transform matrix
Note
  • No internal caching due to memory constrains
void qsf::Transform::calculateMatrix ( glm::mat4x4 &  matrix) const

Calculate the current final transform matrix.

Parameters
[out]matrixReceives the calculated final transform matrix
Note
  • No internal caching due to memory constrains
void qsf::Transform::createLocalTransform ( const Transform worldTransform,
const Transform referenceTransform 
)

Create a transform that describes a local transformation.

Parameters
[in]worldTransformWorld space transformation to convert to local space
[in]referenceTransformReference transformation that defines local space coordinates and is expressed in world space coordinates
void qsf::Transform::fromLocalTransform ( const Transform localTransform,
const Transform referenceTransform 
)
inline

Create a transform object from a given local transformation.

Parameters
[in]localTransformLocal space transformation to convert to world space
[in]referenceTransformReference transformation that defines local space coordinates and is expressed in world space coordinates

Definition at line 102 of file Transform-inl.h.

const glm::vec3 & qsf::Transform::getPosition ( ) const
inline

Return the position.

Returns
Position

Definition at line 62 of file Transform-inl.h.

const glm::quat & qsf::Transform::getRotation ( ) const
inline

Return the rotation quaternion.

Returns
Rotation quaternion

Definition at line 73 of file Transform-inl.h.

const glm::vec3 & qsf::Transform::getScale ( ) const
inline

Return the scale.

Returns
Scale

Definition at line 84 of file Transform-inl.h.

Line qsf::Transform::lineLocalToWorld ( const Line line) const

Transform a given local space line relative to a given world space transform into a world space line.

Parameters
[in]lineLocal space line to convert to world space
Returns
The resulting world space line
Note
  • This transform instance is used as reference transformation that defines local space coordinates and is expressed in world space coordinates
Line qsf::Transform::lineWorldToLocal ( const Line line) const

Transform a given world space line into a local space line relative to a given world space transform.

Parameters
[in]lineWorld space line to convert to local space
Returns
The resulting local space line
Note
  • This transform instance is used as reference transformation that defines local space coordinates and is expressed in world space coordinates
bool qsf::Transform::operator!= ( const Transform other) const
inline

Not equal compare operator.

Parameters
[in]otherOther transform instance to compare with
Returns
"true" if both transform instances are not equal (no epsilon used), else "false"

Definition at line 57 of file Transform-inl.h.

Transform& qsf::Transform::operator+= ( const Transform other)

Add operator.

Parameters
[in]otherOther transform instance to add to this transform
Returns
Reference to this instance
Transform& qsf::Transform::operator-= ( const Transform other)

Subtract operator.

Parameters
[in]otherOther transform instance to subtract from this transform
Returns
Reference to this instance
Transform & qsf::Transform::operator= ( const Transform source)
inline

Copy operator.

Parameters
[in]sourceSource to copy from
Returns
Reference to this instance

Definition at line 41 of file Transform-inl.h.

bool qsf::Transform::operator== ( const Transform other) const
inline

Equal compare operator.

Parameters
[in]otherOther transform instance to compare with
Returns
"true" if both transform instances are equal (no epsilon used), else "false"

Definition at line 52 of file Transform-inl.h.

glm::quat qsf::Transform::quatRotationLocalToWorld ( const glm::quat &  rotation) const

Transform a given local space rotation relative to a given world space transform into a world space rotation.

Parameters
[in]rotationLocal space rotation to convert to world space
Returns
The resulting world space rotation
Note
  • This transform instance is used as reference transformation that defines local space coordinates and is expressed in world space coordinates
  • The scaling is not used, in case of negative scaling we change the coordinate system, this is not supported, we get wrong results
glm::quat qsf::Transform::quatRotationWorldToLocal ( const glm::quat &  rotation) const

Transform a given world space rotation into a local space rotation relative to a given world space transform.

Parameters
[in]rotationWorld space rotation to convert to local space
Returns
The resulting local space position
Note
  • This transform instance is used as reference transformation that defines local space coordinates and is expressed in world space coordinates
  • The scaling is not used, in case of negative scaling we change the coordinate system, this is not supported, we get wrong results
void qsf::Transform::serialize ( BinarySerializer serializer)

Serialize this transform instance.

Parameters
[in]serializerThe serializer, which can be either in read or write mode
void qsf::Transform::setMatrix ( const glm::mat4x4 &  transform)

Set the current final transform matrix.

Parameters
[in]transformThe current final transform matrix
Note
  • The scale can't be extracted correctly from the given transform matrix if one or two scale components are negative while another is/are not (we can't figure out which axis are negative!)
void qsf::Transform::setPosition ( const glm::vec3 &  position)
inline

Set the position.

Parameters
[in]positionNew position

Definition at line 67 of file Transform-inl.h.

void qsf::Transform::setPositionAndRotation ( const glm::vec3 &  position,
const glm::quat &  rotation 
)
inline

Set the position and rotation.

Parameters
[in]positionNew position
[in]rotationNew rotation quaternion

Definition at line 95 of file Transform-inl.h.

void qsf::Transform::setRotation ( const glm::quat &  rotation)
inline

Set the rotation quaternion.

Parameters
[in]rotationNew rotation quaternion

Definition at line 78 of file Transform-inl.h.

void qsf::Transform::setScale ( const glm::vec3 &  scale)
inline

Set the scale.

Parameters
[in]scaleNew scale

Definition at line 89 of file Transform-inl.h.

glm::vec3 qsf::Transform::vec3DirectionLocalToWorld ( const glm::vec3 &  direction) const

Transform a given local space direction vector relative to a given world space transform into a world space vector.

Parameters
[in]directionLocal space direction to convert to world space; does not need to be normalized
Returns
The resulting world space vector
Note
  • This transform instance is used as reference transformation that defines local space coordinates and is expressed in world space coordinates
glm::vec3 qsf::Transform::vec3DirectionWorldToLocal ( const glm::vec3 &  direction) const

Transform a given world space direction vector into a local space vector relative to a given world space transform.

Parameters
[in]directionWorld space direction vector to convert to local space; does not need to be normalized
Returns
The resulting local space vector
Note
  • This transform instance is used as reference transformation that defines local space coordinates and is expressed in world space coordinates
glm::vec3 qsf::Transform::vec3PositionLocalToWorld ( const glm::vec3 &  position) const

Transform a given local space position relative to a given world space transform into a world space position.

Parameters
[in]positionLocal space position to convert to world space
Returns
The resulting world space position
Note
  • This transform instance is used as reference transformation that defines local space coordinates and is expressed in world space coordinates
glm::vec3 qsf::Transform::vec3PositionWorldToLocal ( const glm::vec3 &  position) const

Transform a given world space position into a local space position relative to a given world space transform.

Parameters
[in]positionWorld space position to convert to local space
Returns
The resulting local space position
Note
  • This transform instance is used as reference transformation that defines local space coordinates and is expressed in world space coordinates

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