Browse Source

python: adapt to deprecated Math::angle() for quaternions.

It's renamed to half_angle() here as well. No API deprecation, sorry.
next
Vladimír Vondruš 3 years ago
parent
commit
93f9eb814b
  1. 6
      src/python/magnum/math.cpp
  2. 4
      src/python/magnum/test/test_math.py

6
src/python/magnum/math.cpp

@ -269,8 +269,10 @@ template<class T> void quaternion(py::module_& m, py::class_<T>& c) {
m m
.def("dot", static_cast<typename T::Type(*)(const T&, const T&)>(&Math::dot), .def("dot", static_cast<typename T::Type(*)(const T&, const T&)>(&Math::dot),
"Dot product between two quaternions") "Dot product between two quaternions")
.def("angle", [](const T& a, const T& b) { .def("half_angle", [](const T& a, const T& b) {
return Radd(Math::angle(a, b)); /** @todo switch back to angle() once it's reintroduced with the
correct output again */
return Radd(Math::halfAngle(a, b));
}, "Angle between normalized quaternions", py::arg("normalized_a"), py::arg("normalized_b")) }, "Angle between normalized quaternions", py::arg("normalized_a"), py::arg("normalized_b"))
.def("lerp", static_cast<T(*)(const T&, const T&, typename T::Type)>(&Math::lerp), .def("lerp", static_cast<T(*)(const T&, const T&, typename T::Type)>(&Math::lerp),
"Linear interpolation of two quaternions", py::arg("normalized_a"), py::arg("normalized_b"), py::arg("t")) "Linear interpolation of two quaternions", py::arg("normalized_a"), py::arg("normalized_b"), py::arg("t"))

4
src/python/magnum/test/test_math.py

@ -1144,8 +1144,8 @@ class Quaternion_(unittest.TestCase):
self.assertAlmostEqual(float(Deg(a.angle())), float(Deg(45.0)), 4) self.assertAlmostEqual(float(Deg(a.angle())), float(Deg(45.0)), 4)
def test_functions(self): def test_functions(self):
a = math.angle(Quaterniond.rotation(Deg(45.0), Vector3d.x_axis()), a = math.half_angle(Quaterniond.rotation(Deg(45.0), Vector3d.x_axis()),
Quaterniond.rotation(Deg(75.0), Vector3d.x_axis())) Quaterniond.rotation(Deg(75.0), Vector3d.x_axis()))
self.assertEqual(Deg(a), Deg(15.0)) self.assertEqual(Deg(a), Deg(15.0))
def test_properties(self): def test_properties(self):

Loading…
Cancel
Save