template<class T>
Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D class

Three-dimensional transformation implemented using translation, rotation and scaling.

Similar to BasicMatrixTransformation3D, but stores translation, rotation and scaling separately. This makes it more suitable for e.g. animation, where there are usually separate animation tracks for translation, rotation and scaling. This separation also imposes some constraints — for given object, scaling is always applied first, rotation second and translation last. In particular, unlike with matrix-based transformation implementation, it's not possible to rotate a translated object, for example — one has to apply the rotation first and then translate using a rotated vector.

Base classes

template<class T>
class AbstractBasicTranslationRotationScaling3D
Base transformation for three-dimensional scenes supporting translation, rotation and scaling.

Public types

using DataType = Math::Matrix4<T>
Underlying transformation type.

Public functions

auto transformation() const -> Math::Matrix4<T>
Object transformation.
auto setTransformation(const Math::Matrix4<T>& transformation) -> Object<BasicTranslationRotationScalingTransformation3D<T>>&
Set transformation.
auto translation() const -> Math::Vector3<T>
Object translation.
auto setTranslation(const Math::Vector3<T>& translation) -> Object<BasicTranslationRotationScalingTransformation3D<T>>&
Set translation.
auto rotation() const -> Math::Quaternion<T>
Object rotation.
auto setRotation(const Math::Quaternion<T>& rotation) -> Object<BasicTranslationRotationScalingTransformation3D<T>>&
Set rotation.
auto scaling() const -> Math::Vector3<T>
Object scaling.
auto setScaling(const Math::Vector3<T>& scaling) -> Object<BasicTranslationRotationScalingTransformation3D<T>>&
Set scaling.
auto resetTransformation() -> Object<BasicTranslationRotationScalingTransformation3D<T>>&
Reset object transformation.
auto translate(const Math::Vector3<T>& vector) -> Object<BasicTranslationRotationScalingTransformation3D<T>>&
Translate object.
auto translateLocal(const Math::Vector3<T>& vector) -> Object<BasicTranslationRotationScalingTransformation3D<T>>&
Translate object as a local transformation.
auto rotate(const Math::Quaternion<T>& quaternion) -> Object<BasicTranslationRotationScalingTransformation3D<T>>&
Rotate object using a quaternion.
auto rotateLocal(const Math::Quaternion<T>& quaternion) -> Object<BasicTranslationRotationScalingTransformation3D<T>>&
Rotate object using a quaternion as a local transformation.
auto rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) -> Object<BasicTranslationRotationScalingTransformation3D<T>>&
Rotate object.
auto rotateLocal(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) -> Object<BasicTranslationRotationScalingTransformation3D<T>>&
Rotate object as a local transformation.
auto rotateX(Math::Rad<T> angle) -> Object<BasicTranslationRotationScalingTransformation3D<T>>&
Rotate object around X axis.
auto rotateXLocal(Math::Rad<T> angle) -> Object<BasicTranslationRotationScalingTransformation3D<T>>&
Rotate object around X axis as a local transformation.
auto rotateY(Math::Rad<T> angle) -> Object<BasicTranslationRotationScalingTransformation3D<T>>&
Rotate object around Y axis.
auto rotateYLocal(Math::Rad<T> angle) -> Object<BasicTranslationRotationScalingTransformation3D<T>>&
Rotate object around Y axis as a local transformation.
auto rotateZ(Math::Rad<T> angle) -> Object<BasicTranslationRotationScalingTransformation3D<T>>&
Rotate object around Z axis.
auto rotateZLocal(Math::Rad<T> angle) -> Object<BasicTranslationRotationScalingTransformation3D<T>>&
Rotate object around Z axis as a local transformation.
auto scale(const Math::Vector3<T>& vector) -> Object<BasicTranslationRotationScalingTransformation3D<T>>&
Scale object.
auto scaleLocal(const Math::Vector3<T>& vector) -> Object<BasicTranslationRotationScalingTransformation3D<T>>&
Scale object as a local transformation.

Private functions

void doResetTransformation() override final virtual
Polymorphic implementation for resetTransformation()
void doRotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) override final virtual
Polymorphic implementation for rotate()
void doRotateLocal(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) override final virtual
Polymorphic implementation for rotateLocal()
void doRotateX(Math::Rad<T> angle) override final virtual
Polymorphic implementation for rotateX()
void doRotateXLocal(Math::Rad<T> angle) override final virtual
Polymorphic implementation for rotateXLocal()
void doRotateY(Math::Rad<T> angle) override final virtual
Polymorphic implementation for rotateY()
void doRotateYLocal(Math::Rad<T> angle) override final virtual
Polymorphic implementation for rotateYLocal()
void doRotateZ(Math::Rad<T> angle) override final virtual
Polymorphic implementation for rotateZ()
void doRotateZLocal(Math::Rad<T> angle) override final virtual
Polymorphic implementation for rotateZLocal()
void doScale(const Math::Vector3<T>& vector) override final virtual
Polymorphic implementation for scale()
void doScaleLocal(const Math::Vector3<T>& vector) override final virtual
Polymorphic implementation for scaleLocal()

Function documentation

template<class T>
Object<BasicTranslationRotationScalingTransformation3D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::setTransformation(const Math::Matrix4<T>& transformation)

Set transformation.

Returns Reference to self (for method chaining)

Expects that the transformation doesn't contain shear or reflection.

template<class T>
Object<BasicTranslationRotationScalingTransformation3D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::setTranslation(const Math::Vector3<T>& translation)

Set translation.

Returns Reference to self (for method chaining)

Translation is always applied last, after rotation and scaling.

template<class T>
Object<BasicTranslationRotationScalingTransformation3D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::setRotation(const Math::Quaternion<T>& rotation)

Set rotation.

Returns Reference to self (for method chaining)

Rotation is always applied after scaling and before translation. Expects that the quaternion is normalized.

template<class T>
Object<BasicTranslationRotationScalingTransformation3D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::setScaling(const Math::Vector3<T>& scaling)

Set scaling.

Returns Reference to self (for method chaining)

Scaling is always applied first, before rotation and translation.

template<class T>
Object<BasicTranslationRotationScalingTransformation3D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::resetTransformation()

Reset object transformation.

Returns Reference to self (for method chaining)

template<class T>
Object<BasicTranslationRotationScalingTransformation3D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::translate(const Math::Vector3<T>& vector)

Translate object.

Returns Reference to self (for method chaining)

Note that translation is always applied last, after rotation and scaling.

template<class T>
Object<BasicTranslationRotationScalingTransformation3D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::translateLocal(const Math::Vector3<T>& vector)

Translate object as a local transformation.

Equivalent to the above, as translation is commutative. Note that translation is always applied last, after rotation and scaling.

template<class T>
Object<BasicTranslationRotationScalingTransformation3D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::rotate(const Math::Quaternion<T>& quaternion)

Rotate object using a quaternion.

Parameters
quaternion Normalized quaternion
Returns Reference to self (for method chaining)

Note that rotation is always applied after scaling and before translation. Expects that the quaternion is normalized.

template<class T>
Object<BasicTranslationRotationScalingTransformation3D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::rotateLocal(const Math::Quaternion<T>& quaternion)

Rotate object using a quaternion as a local transformation.

Similar to the above, except that the rotation is applied before all other rotations. Note that rotation is always applied after scaling and before translation.

template<class T>
Object<BasicTranslationRotationScalingTransformation3D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis)

Rotate object.

Parameters
angle Angle (counterclockwise)
normalizedAxis Normalized rotation axis
Returns Reference to self (for method chaining)

Same as calling rotate(const Math::Quaternion<T>&) with Quaternion::rotation(). Note that rotation is always applied after scaling and before translation.

template<class T>
Object<BasicTranslationRotationScalingTransformation3D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::rotateLocal(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis)

Rotate object as a local transformation.

Similar to the above, except that the rotation is applied before all other rotations. Note that rotation is always applied after scaling and before translation. Same as calling rotateLocal(const Math::Quaternion<T>&) with Math::Quaternion::rotation().

template<class T>
Object<BasicTranslationRotationScalingTransformation3D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::rotateX(Math::Rad<T> angle)

Rotate object around X axis.

Parameters
angle Angle (counterclockwise)
Returns Reference to self (for method chaining)

Same as calling rotate() with Math::Vector3::xAxis() as an axis.

template<class T>
Object<BasicTranslationRotationScalingTransformation3D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::rotateXLocal(Math::Rad<T> angle)

Rotate object around X axis as a local transformation.

Similar to the above, except that the rotation is applied before all other rotations. Note that rotation is always applied after scaling and before translation. Same as calling rotateLocal() with Math::Vector3::xAxis() as an axis.

template<class T>
Object<BasicTranslationRotationScalingTransformation3D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::rotateY(Math::Rad<T> angle)

Rotate object around Y axis.

Parameters
angle Angle (counterclockwise)
Returns Reference to self (for method chaining)

Same as calling rotate() with Math::Vector3::yAxis() as an axis.

template<class T>
Object<BasicTranslationRotationScalingTransformation3D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::rotateYLocal(Math::Rad<T> angle)

Rotate object around Y axis as a local transformation.

Similar to the above, except that the rotation is applied before all other rotations. Note that rotation is always applied after scaling and before translation. Same as calling rotateLocal() with Math::Vector3::yAxis() as an axis.

template<class T>
Object<BasicTranslationRotationScalingTransformation3D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::rotateZ(Math::Rad<T> angle)

Rotate object around Z axis.

Parameters
angle Angle (counterclockwise)
Returns Reference to self (for method chaining)

Same as calling rotate() with Math::Vector3::yAxis() as an axis.

template<class T>
Object<BasicTranslationRotationScalingTransformation3D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::rotateZLocal(Math::Rad<T> angle)

Rotate object around Z axis as a local transformation.

Similar to the above, except that the rotation is applied before all other rotations. Note that rotation is always applied after scaling and before translation. Same as calling rotateLocal() with Math::Vector3::zAxis() as an axis.

template<class T>
Object<BasicTranslationRotationScalingTransformation3D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::scale(const Math::Vector3<T>& vector)

Scale object.

Returns Reference to self (for method chaining)

Note that scaling is always applied first, before rotation and translation.

template<class T>
Object<BasicTranslationRotationScalingTransformation3D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::scaleLocal(const Math::Vector3<T>& vector)

Scale object as a local transformation.

Equivalent to the above, as scaling is commutative. Note that scaling is always first, before rotation and translation.

template<class T>
void Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::doRotateX(Math::Rad<T> angle) override final virtual private

Polymorphic implementation for rotateX()

Default implementation calls rotate() with Math::Vector3::xAxis().

template<class T>
void Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::doRotateXLocal(Math::Rad<T> angle) override final virtual private

Polymorphic implementation for rotateXLocal()

Default implementation calls rotateLocal() with Math::Vector3::xAxis().

template<class T>
void Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::doRotateY(Math::Rad<T> angle) override final virtual private

Polymorphic implementation for rotateY()

Default implementation calls rotate() with Math::Vector3::yAxis().

template<class T>
void Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::doRotateYLocal(Math::Rad<T> angle) override final virtual private

Polymorphic implementation for rotateYLocal()

Default implementation calls rotateLocal() with Math::Vector3::yAxis().

template<class T>
void Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::doRotateZ(Math::Rad<T> angle) override final virtual private

Polymorphic implementation for rotateZ()

Default implementation calls rotate() with Math::Vector3::zAxis().

template<class T>
void Magnum::SceneGraph::BasicTranslationRotationScalingTransformation3D<T>::doRotateZLocal(Math::Rad<T> angle) override final virtual private

Polymorphic implementation for rotateZLocal()

Default implementation calls rotateLocal() with Math::Vector3::zAxis().