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

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

Similar to BasicMatrixTransformation2D, 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 AbstractBasicTranslationRotationScaling2D<T>
Base transformation for two-dimensional scenes supporting translation, rotation and scaling.

Public types

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

Public functions

auto transformation() const -> Math::Matrix3<T>
Object transformation.
auto setTransformation(const Math::Matrix3<T>& transformation) -> Object<BasicTranslationRotationScalingTransformation2D<T>>&
Set transformation.
auto translation() const -> Math::Vector2<T>
Object translation.
auto setTranslation(const Math::Vector2<T>& translation) -> Object<BasicTranslationRotationScalingTransformation2D<T>>&
Set translation.
auto rotation() const -> Math::Complex<T>
Object rotation.
auto setRotation(const Math::Complex<T>& rotation) -> Object<BasicTranslationRotationScalingTransformation2D<T>>&
Set rotation.
auto scaling() const -> Math::Vector2<T>
Object scaling.
auto setScaling(const Math::Vector2<T>& scaling) -> Object<BasicTranslationRotationScalingTransformation2D<T>>&
Set scaling.
auto resetTransformation() -> Object<BasicTranslationRotationScalingTransformation2D<T>>&
Reset object transformation.
auto translate(const Math::Vector2<T>& vector) -> Object<BasicTranslationRotationScalingTransformation2D<T>>&
Translate the object.
auto translateLocal(const Math::Vector2<T>& vector) -> Object<BasicTranslationRotationScalingTransformation2D<T>>&
Translate the object as a local transformation.
auto rotate(const Math::Complex<T>& complex) -> Object<BasicTranslationRotationScalingTransformation2D<T>>&
Rotate the object using a complex number.
auto rotateLocal(const Math::Complex<T>& complex) -> Object<BasicTranslationRotationScalingTransformation2D<T>>&
Rotate the object using a complex number as a local transformation.
auto rotate(Math::Rad<T> angle) -> Object<BasicTranslationRotationScalingTransformation2D<T>>&
Rotate the object.
auto rotateLocal(Math::Rad<T> angle) -> Object<BasicTranslationRotationScalingTransformation2D<T>>&
Rotate the object as a local transformation.
auto scale(const Math::Vector2<T>& vector) -> Object<BasicTranslationRotationScalingTransformation2D<T>>&
Scale the object.
auto scaleLocal(const Math::Vector2<T>& vector) -> Object<BasicTranslationRotationScalingTransformation2D<T>>&
Scale the object as a local transformation.

Function documentation

template<class T>
Object<BasicTranslationRotationScalingTransformation2D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation2D<T>::setTransformation(const Math::Matrix3<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<BasicTranslationRotationScalingTransformation2D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation2D<T>::setTranslation(const Math::Vector2<T>& translation)

Set translation.

Returns Reference to self (for method chaining)

Translation is always applied last, after rotation and scaling.

template<class T>
Object<BasicTranslationRotationScalingTransformation2D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation2D<T>::setRotation(const Math::Complex<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<BasicTranslationRotationScalingTransformation2D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation2D<T>::setScaling(const Math::Vector2<T>& scaling)

Set scaling.

Returns Reference to self (for method chaining)

Scaling is always applied first, before rotation and translation.

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

Reset object transformation.

Returns Reference to self (for method chaining)

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

Translate the object.

Returns Reference to self (for method chaining)

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

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

Translate the 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<BasicTranslationRotationScalingTransformation2D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation2D<T>::rotate(const Math::Complex<T>& complex)

Rotate the object using a complex number.

Parameters
complex Normalized complex number
Returns Reference to self (for method chaining)

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

template<class T>
Object<BasicTranslationRotationScalingTransformation2D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation2D<T>::rotateLocal(const Math::Complex<T>& complex)

Rotate the object using a complex number as a local transformation.

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

template<class T>
Object<BasicTranslationRotationScalingTransformation2D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation2D<T>::rotate(Math::Rad<T> angle)

Rotate the object.

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

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

template<class T>
Object<BasicTranslationRotationScalingTransformation2D<T>>& Magnum::SceneGraph::BasicTranslationRotationScalingTransformation2D<T>::rotateLocal(Math::Rad<T> angle)

Rotate the 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::Complex<T>&) with Math::Complex::rotation().

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

Scale the object.

Returns Reference to self (for method chaining)

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

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

Scale the object as a local transformation.

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