Skip to content

Transform3

3D affine transform with position, rotation, and scale.

Transform3 represents a 3D transform combining translation, non-uniform scaling, and Euler-based rotation. It lazily builds a Matrix4 suitable for use as a world transform in scene graphs and rendering code.

Properties

position Vector3

Translation in 3D space.

cpp
Vector3 position {0.0f};

rotation Euler

Rotation stored as Euler angles.

cpp
Euler rotation {};

scale Vector3

Non-uniform scale in 3D.

cpp
Vector3 scale {1.0f};

touched bool

Dirty flag indicating the cached matrix needs to be recomputed.

cpp
bool touched {true};

Functions

Get() Matrix4

Returns the 4×4 transform matrix.

Recomputes the underlying matrix if any component has changed since the last call, then returns the cached Matrix4.

cpp
Matrix4 Transform3::Get();

LookAt() void

Sets the rotation such that the object looks at a target point.

Computes an orientation that looks from position toward target, using world_up to resolve roll and construct a stable basis.

cpp
void Transform3::LookAt(const Vector3& position, const Vector3& target, const Vector3& world_up);
ParameterDescription
positionObject position.
targetTarget point to look at.
world_upWorld up direction.

Rotate() void

Applies an additional rotation around a principal axis.

Only the canonical axes Vector3::Right, Vector3::Up, and Vector3::Forward are supported.

cpp
void Transform3::Rotate(const Vector3& axis, float angle);
ParameterDescription
axisRotation axis.
angleRotation angle in radians.

Scale() void

Scales the transform.

cpp
void Transform3::Scale(const Vector3& value);
ParameterDescription
valueScale factors to apply.

SetPosition() void

Sets the translation component.

cpp
void Transform3::SetPosition(const Vector3& position);
ParameterDescription
positionNew position.

SetRotation() void

Sets the rotation component.

cpp
void Transform3::SetRotation(const Euler& rotation);
ParameterDescription
rotationNew Euler rotation.

SetScale() void

Sets the scale component.

cpp
void Transform3::SetScale(const Vector3& scale);
ParameterDescription
scaleNew scale factors.

Translate() void

Translates the transform in local space.

If the rotation is not empty, the input vector is rotated by the current orientation before being added to position.

cpp
void Transform3::Translate(const Vector3& value);
ParameterDescription
valueTranslation vector.

Released under the MIT License.