Skip to main content

Transform Class

Represents a 3D transformation consisting of translation, rotation and scale. More...

Declaration

class helios::core::spatial::Transform { ... }

Public Constructors Index

Transform ()=default

Constructs a new Transform object with the default identity transformation, i.e. scale (1, 1, 1), rotation 4x4_id, translate (0, 0, 0). More...

Transform (const helios::math::mat4f &rotation, helios::math::vec3f scale, helios::math::vec3f translation) noexcept

Constructs a new Transformation matrix from the specified rotation, scale and translation. More...

Public Destructor Index

~Transform ()=default

Public Member Functions Index

voidsetRotation (const math::mat4f &rotation) noexcept

Sets the rotation component of this Transform. Marks this Transform object as dirty. More...

voidsetTranslation (const math::vec3f &translation) noexcept

Sets the translation component of this Transform. Marks this Transform object as dirty. More...

voidsetScale (const math::vec3f &scale) noexcept

Sets the scale component of this Transform. Marks this Transform object as dirty. More...

helios::math::mat4frotation () const noexcept

Returns the current rotation component of this Transform object. More...

helios::math::vec3ftranslation () const noexcept

Returns the current translation component of this Transform object. More...

helios::math::vec3fscaling () const noexcept

Returns the current scale component of this Transform object. More...

helios::math::mat4ftransform () const noexcept

Returns the 4x4 transformation matrix combined from scale, rotation, and translation. More...

boolneedsUpdate () const noexcept

Checks whether this Transform needs to be updated, e.g. because the various components changed. More...

Private Member Functions Index

helios::math::mat4fupdateCache () const

Internal helper function to compute the full 4x4 affine transformation matrix. More...

Private Member Attributes Index

boolneedsUpdate_ = true

Flag indicating whether this Transform needs to recompute its transformation matrix. More...

helios::math::mat4frotation_ = helios::math::mat4f::identity()

The rotation component of the transformation, stored as a 4x4 matrix. More...

helios::math::vec3fscale_ = helios::math::vec3f(1)

The scaling component of the transformation, stored as a 3D vector. More...

helios::math::vec3ftranslation_ = helios::math::vec3f(0)

The translation component of the transformation, stored as a 3D vector. More...

helios::math::mat4fcached_ = helios::math::mat4f::identity()

The cached 4x4 matrix, computed from scale, rotation and translation (in this order: T * (R * S)). More...

Description

Represents a 3D transformation consisting of translation, rotation and scale.

This class encapsulates the components of a local transform for SceneNodes. It uses lazy evaluation to compute the final transform. The current scale, translation and rotation is queryable. Changing the transformation is always considered against an "origin" of an object, that is, a 4x4 identity matrix

Todo

use quaternions for rotation

Definition at line 29 of file Transform.ixx.

Public Constructors

Transform()

helios::core::spatial::Transform::Transform ()
default

Constructs a new Transform object with the default identity transformation, i.e. scale (1, 1, 1), rotation 4x4_id, translate (0, 0, 0).

Definition at line 81 of file Transform.ixx.

Transform()

helios::core::spatial::Transform::Transform (const helios::math::mat4f & rotation, helios::math::vec3f scale, helios::math::vec3f translation)
inline noexcept

Constructs a new Transformation matrix from the specified rotation, scale and translation.

Parameters
rotation

The initial rotation matrix.

scale

The initial scaling vector.

translation

The initial translation vector.

Definition at line 90 of file Transform.ixx.

93 ) noexcept :
94 rotation_(rotation),
95 scale_(scale),
96 translation_(translation),
97 needsUpdate_(true)
98 {}

References rotation and translation.

Public Destructor

~Transform()

helios::core::spatial::Transform::~Transform ()
default

Definition at line 75 of file Transform.ixx.

Public Member Functions

needsUpdate()

bool helios::core::spatial::Transform::needsUpdate ()
inline nodiscard noexcept

Checks whether this Transform needs to be updated, e.g. because the various components changed.

Returns

true if this Transform is considered to be dirty, otherwise false.

Definition at line 179 of file Transform.ixx.

179 [[nodiscard]] bool needsUpdate() const noexcept {
180 return needsUpdate_;
181 }

rotation()

helios::math::mat4f helios::core::spatial::Transform::rotation ()
inline nodiscard noexcept

Returns the current rotation component of this Transform object.

Returns

The current 4x4 rotation matrix.

Definition at line 138 of file Transform.ixx.

138 [[nodiscard]] helios::math::mat4f rotation() const noexcept {
139 return rotation_;
140 }

Referenced by setRotation and Transform.

scaling()

helios::math::vec3f helios::core::spatial::Transform::scaling ()
inline nodiscard noexcept

Returns the current scale component of this Transform object.

Returns

The current 3D scale vector.

Definition at line 156 of file Transform.ixx.

156 [[nodiscard]] helios::math::vec3f scaling() const noexcept {
157 return scale_;
158 }

setRotation()

void helios::core::spatial::Transform::setRotation (const math::mat4f & rotation)
inline noexcept

Sets the rotation component of this Transform. Marks this Transform object as dirty.

Parameters
rotation

A const ref to the new rotation matrix.

Definition at line 106 of file Transform.ixx.

106 void setRotation(const math::mat4f& rotation) noexcept {
107 rotation_ = rotation;
108 needsUpdate_ = true;
109 }

Reference rotation.

setScale()

void helios::core::spatial::Transform::setScale (const math::vec3f & scale)
inline noexcept

Sets the scale component of this Transform. Marks this Transform object as dirty.

Parameters
scale

A const ref to the new scale vector.

Definition at line 128 of file Transform.ixx.

128 void setScale(const math::vec3f& scale) noexcept {
129 scale_ = scale;
130 needsUpdate_ = true;
131 }

setTranslation()

void helios::core::spatial::Transform::setTranslation (const math::vec3f & translation)
inline noexcept

Sets the translation component of this Transform. Marks this Transform object as dirty.

Parameters
translation

A const ref to the new translation vector.

Definition at line 117 of file Transform.ixx.

117 void setTranslation(const math::vec3f& translation) noexcept {
118 translation_ = translation;
119 needsUpdate_ = true;
120 }

Reference translation.

transform()

helios::math::mat4f helios::core::spatial::Transform::transform ()
inline nodiscard noexcept

Returns the 4x4 transformation matrix combined from scale, rotation, and translation.

Returns

The current 4x4 affine transformation matrix.

Definition at line 165 of file Transform.ixx.

165 [[nodiscard]] helios::math::mat4f transform() const noexcept {
166 if (needsUpdate_) {
167 cached_ = updateCache();
168 }
169 return cached_;
170 }

translation()

helios::math::vec3f helios::core::spatial::Transform::translation ()
inline nodiscard noexcept

Returns the current translation component of this Transform object.

Returns

The current 3D translation vector.

Definition at line 147 of file Transform.ixx.

147 [[nodiscard]] helios::math::vec3f translation() const noexcept {
148 return translation_;
149 }

Referenced by setTranslation and Transform.

Private Member Functions

updateCache()

helios::math::mat4f helios::core::spatial::Transform::updateCache ()
inline

Internal helper function to compute the full 4x4 affine transformation matrix.

Returns

The newly computed transformation matrix.

Definition at line 65 of file Transform.ixx.

65 helios::math::mat4f updateCache() const {
66 needsUpdate_ = false;
67 return math::translate(
69 translation_) *
70 (rotation_ * helios::math::mat4f(scale_)
71 );
72 }

Private Member Attributes

cached_

helios::math::mat4f helios::core::spatial::Transform::cached_ = helios::math::mat4f::identity()
mutable

The cached 4x4 matrix, computed from scale, rotation and translation (in this order: T * (R * S)).

Definition at line 57 of file Transform.ixx.

needsUpdate_

bool helios::core::spatial::Transform::needsUpdate_ = true
mutable

Flag indicating whether this Transform needs to recompute its transformation matrix.

Definition at line 36 of file Transform.ixx.

36 mutable bool needsUpdate_ = true;

rotation_

helios::math::mat4f helios::core::spatial::Transform::rotation_ = helios::math::mat4f::identity()

The rotation component of the transformation, stored as a 4x4 matrix.

Definition at line 41 of file Transform.ixx.

scale_

helios::math::vec3f helios::core::spatial::Transform::scale_ = helios::math::vec3f(1)

The scaling component of the transformation, stored as a 3D vector.

Definition at line 46 of file Transform.ixx.

translation_

helios::math::vec3f helios::core::spatial::Transform::translation_ = helios::math::vec3f(0)

The translation component of the transformation, stored as a 3D vector.

Definition at line 51 of file Transform.ixx.


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.