diff --git a/doc/python/pages/changelog.rst b/doc/python/pages/changelog.rst index 04ec371..8fb8829 100644 --- a/doc/python/pages/changelog.rst +++ b/doc/python/pages/changelog.rst @@ -69,8 +69,9 @@ Changelog - Exposed :ref:`Color3.from_xyz()`, :ref:`Color3.from_linear_rgb_int()`, :ref:`Color3.to_xyz()`, :ref:`Color3.to_linear_rgb_int()` and equivalent APIs on :ref:`Color4` -- Exposed new :ref:`Quaternion.rotation()`, :ref:`Quaternion.reflection()` - and :ref:`Quaternion.reflect_vector()` APIs +- Exposed new :ref:`Quaternion.rotation()`, :ref:`Quaternion.reflection()`, + :ref:`Quaternion.reflect_vector()`, :ref:`Quaternion.xyzw` and + :ref:`Quaternion.wxyz` APIs - Exposed :ref:`gl.Context` and its platform-specific subclasses for EGL, WGL and GLX - Exposed :ref:`gl.Framebuffer.attach_texture()` and missing sRGB, depth diff --git a/src/python/magnum/math.cpp b/src/python/magnum/math.cpp index c849951..a6a0d67 100644 --- a/src/python/magnum/math.cpp +++ b/src/python/magnum/math.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "magnum/bootstrap.h" #include "magnum/math.h" @@ -486,6 +487,8 @@ template void quaternion(py::module_& m, py::class_& c) { static_cast(&T::scalar), [](T& self, typename T::Type value) { self.scalar() = value; }, "Scalar part") + .def_property_readonly("xyzw", &T::xyzw, "Quaternion components in a XYZW order") + .def_property_readonly("wxyz", &T::wxyz, "Quaternion components in a WXYZ order") .def("__repr__", repr, "Object representation"); } diff --git a/src/python/magnum/test/test_math.py b/src/python/magnum/test/test_math.py index b49d7e9..af01dcf 100644 --- a/src/python/magnum/test/test_math.py +++ b/src/python/magnum/test/test_math.py @@ -1558,6 +1558,8 @@ Matrix\\(2, 0, 0, a.scalar = 4.0 self.assertEqual(a.vector, Vector3(1.0, 2.0, 3.0)) self.assertEqual(a.scalar, 4.0) + self.assertEqual(a.xyzw, Vector4(1.0, 2.0, 3.0, 4.0)) + self.assertEqual(a.wxyz, Vector4(4.0, 1.0, 2.0, 3.0)) self.assertEqual(a, Quaternion((1.0, 2.0, 3.0), 4.0)) def test_repr(self):