Transform class

A class that represents a 3D transformation; it can store the same information as a 4x4 matrix, but it's easier to use.

This class stores the location, scale and rotation (as a 3x3 matrix) separately, making it a lot easier to use than a matrix. It has a method to convert it to a 4x4 matrix, so that it can be used in matematical operations. Transforms can be multiplied in order to concatenate multiple transformations using Multiply(other)

Public types

enum TransformFlags { kTransformFlagScale = 1, kTransformFlagRotation = 2, kTransformFlagOffset = 4 }

Constructors, destructors, conversion operators

Transform()

Public functions

auto GetOffset() const -> const Math::Vector3&
auto SetOffset(const Math::Vector3& value) -> Transform&
auto SetOffset(float x, float y, float z) -> Transform&
auto GetScale() const -> float
auto SetScale(float value) -> Transform&
auto GetRotation() const -> const Math::Matrix3&
auto SetRotation(const Math::Matrix3& value) -> Transform&
auto SetRotation(const Math::Vector3& euler) -> Transform&
auto SetRotation(const Math::Quaternion& value) -> Transform&
auto ToMatrix4() const -> Math::Matrix4
Returns the 4x4 matrix that represents this transform.
auto Invert() -> void
Inverts this transform, so that now it will do exactly the opposite transformation.
auto PreTransformBy(const Transform& other) -> Transform&
Applies another transform into this transform.

Protected variables

int16_t mnFlags
int16_t mnTransformCount
Math::Vector3 mOffset
float mfScale
Math::Matrix3 mRotation

Function documentation

Math::Matrix4 Transform::ToMatrix4() const

Returns the 4x4 matrix that represents this transform.

This matrix can be used to apply the transform to vectors, by just multiplying.

void Transform::Invert()

Inverts this transform, so that now it will do exactly the opposite transformation.

A transform multiplied by its inverse results in the identity transform, which doesn't change anything.

Transform& Transform::PreTransformBy(const Transform& other)

Applies another transform into this transform.

Parameters
other