diff --git a/src/SceneGraph/AbstractTranslationRotation3D.h b/src/SceneGraph/AbstractTranslationRotation3D.h index 67178b269..4bc174a59 100644 --- a/src/SceneGraph/AbstractTranslationRotation3D.h +++ b/src/SceneGraph/AbstractTranslationRotation3D.h @@ -20,6 +20,7 @@ */ #include "AbstractTransformation.h" +#include "Math/Vector3.h" namespace Magnum { namespace SceneGraph { @@ -50,6 +51,48 @@ template class AbstractTranslationRotation3D: public Abstract * @see deg(), rad(), Vector3::xAxis(), Vector3::yAxis(), Vector3::zAxis() */ virtual AbstractTranslationRotation3D* rotate(T angle, const Math::Vector3& normalizedAxis, TransformationType type = TransformationType::Global) = 0; + + /** + * @brief Rotate object around X axis + * @param angle Angle in radians, counterclockwise + * @param type Transformation type + * @return Pointer to self (for method chaining) + * + * In some implementations faster than calling + * `rotate(angle, Vector3::xAxis())`. + * @see deg(), rad() + */ + virtual AbstractTranslationRotation3D* rotateX(T angle, TransformationType type = TransformationType::Global) { + return rotate(angle, Math::Vector3::xAxis(), type); + } + + /** + * @brief Rotate object around Y axis + * @param angle Angle in radians, counterclockwise + * @param type Transformation type + * @return Pointer to self (for method chaining) + * + * In some implementations faster than calling + * `rotate(angle, Vector3::yAxis())`. + * @see deg(), rad() + */ + virtual AbstractTranslationRotation3D* rotateY(T angle, TransformationType type = TransformationType::Global) { + return rotate(angle, Math::Vector3::yAxis(), type); + } + + /** + * @brief Rotate object around Z axis + * @param angle Angle in radians, counterclockwise + * @param type Transformation type + * @return Pointer to self (for method chaining) + * + * In some implementations faster than calling + * `rotate(angle, Vector3::zAxis())`. + * @see deg(), rad() + */ + virtual AbstractTranslationRotation3D* rotateZ(T angle, TransformationType type = TransformationType::Global) { + return rotate(angle, Math::Vector3::zAxis(), type); + } }; }} diff --git a/src/SceneGraph/MatrixTransformation3D.h b/src/SceneGraph/MatrixTransformation3D.h index 493b275ef..973e0bd36 100644 --- a/src/SceneGraph/MatrixTransformation3D.h +++ b/src/SceneGraph/MatrixTransformation3D.h @@ -103,6 +103,48 @@ template class MatrixTransformation3D: public AbstractTransla return this; } + /** + * @brief Rotate object around X axis + * @param angle Angle in radians, counterclockwise + * @param type Transformation type + * @return Pointer to self (for method chaining) + * + * Same as calling multiplyTransformation() with Matrix4::rotationX(). + * @see deg(), rad() + */ + inline MatrixTransformation3D* rotateX(T angle, TransformationType type = TransformationType::Global) override { + multiplyTransformation(Math::Matrix4::rotationX(angle), type); + return this; + } + + /** + * @brief Rotate object around Y axis + * @param angle Angle in radians, counterclockwise + * @param type Transformation type + * @return Pointer to self (for method chaining) + * + * Same as calling multiplyTransformation() with Matrix4::rotationY(). + * @see deg(), rad() + */ + inline MatrixTransformation3D* rotateY(T angle, TransformationType type = TransformationType::Global) override { + multiplyTransformation(Math::Matrix4::rotationY(angle), type); + return this; + } + + /** + * @brief Rotate object around Z axis + * @param angle Angle in radians, counterclockwise + * @param type Transformation type + * @return Pointer to self (for method chaining) + * + * Same as calling multiplyTransformation() with Matrix4::rotationZ(). + * @see deg(), rad() + */ + inline MatrixTransformation3D* rotateZ(T angle, TransformationType type = TransformationType::Global) override { + multiplyTransformation(Math::Matrix4::rotationZ(angle), type); + return this; + } + /** * @copydoc AbstractTranslationRotationScaling3D::scale() * Same as calling multiplyTransformation() with Matrix4::scaling().