From 45f50aff631fb4d79ceb507367dd1d9f8e411e17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 17 Dec 2012 21:49:04 +0100 Subject: [PATCH] SceneGraph: convenience function for reflecting objects. --- src/SceneGraph/MatrixTransformation2D.h | 14 ++++++++++++++ src/SceneGraph/MatrixTransformation3D.h | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/SceneGraph/MatrixTransformation2D.h b/src/SceneGraph/MatrixTransformation2D.h index e797fba84..9ecb37a70 100644 --- a/src/SceneGraph/MatrixTransformation2D.h +++ b/src/SceneGraph/MatrixTransformation2D.h @@ -118,6 +118,20 @@ class MatrixTransformation2D: public AbstractTranslationRotationScaling2D { return this; } + /** + * @brief Reflect object + * @param normal Normal of the line through which to reflect + * (normalized) + * @param type Transformation type + * @return Pointer to self (for method chaining) + * + * Same as calling transform() with Matrix3::reflection(). + */ + inline MatrixTransformation2D* reflect(const Math::Vector2& normal, TransformationType type = TransformationType::Global) { + transform(Math::Matrix3::reflection(normal), type); + return this; + } + /** * @brief Move object in stacking order * @param under Sibling object under which to move or `nullptr`, diff --git a/src/SceneGraph/MatrixTransformation3D.h b/src/SceneGraph/MatrixTransformation3D.h index 4afc360c0..c133aca7b 100644 --- a/src/SceneGraph/MatrixTransformation3D.h +++ b/src/SceneGraph/MatrixTransformation3D.h @@ -160,6 +160,20 @@ class MatrixTransformation3D: public AbstractTranslationRotationScaling3D { return this; } + /** + * @brief Reflect object + * @param normal Normal of the plane through which to reflect + * (normalized) + * @param type Transformation type + * @return Pointer to self (for method chaining) + * + * Same as calling transform() with Matrix4::reflection(). + */ + inline MatrixTransformation3D* reflect(const Math::Vector3& normal, TransformationType type = TransformationType::Global) { + transform(Math::Matrix4::reflection(normal), type); + return this; + } + protected: /* Allow construction only from Object */ inline explicit MatrixTransformation3D() = default;