From fd352c14f13ecdef7b8d4005c987d2f449c69430 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 11 Oct 2019 01:14:35 +0200 Subject: [PATCH] expose Roation.slerp to Python --- src/Base/RotationPy.xml | 8 ++++++++ src/Base/RotationPyImp.cpp | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/Base/RotationPy.xml b/src/Base/RotationPy.xml index 4bac43b9ae..528f6bbc10 100644 --- a/src/Base/RotationPy.xml +++ b/src/Base/RotationPy.xml @@ -73,6 +73,14 @@ + + + + slerp(Rotation, Float) -> Rotation + Spherical linear interpolation of this and a given rotation. The float must be in the range of 0 and 1 + + + diff --git a/src/Base/RotationPyImp.cpp b/src/Base/RotationPyImp.cpp index e38985e50c..28d5c7e5be 100644 --- a/src/Base/RotationPyImp.cpp +++ b/src/Base/RotationPyImp.cpp @@ -256,6 +256,18 @@ PyObject* RotationPy::multVec(PyObject * args) return new VectorPy(new Vector3d(vec)); } +PyObject* RotationPy::slerp(PyObject * args) +{ + PyObject *rot; + double t; + if (!PyArg_ParseTuple(args, "O!d", &(RotationPy::Type), &rot, &t)) + return 0; + Rotation *rot0 = this->getRotationPtr(); + Rotation *rot1 = static_cast(rot)->getRotationPtr(); + Rotation sl = Rotation::slerp(*rot0, *rot1, t); + return new RotationPy(new Rotation(sl)); +} + PyObject* RotationPy::toEuler(PyObject * args) { if (!PyArg_ParseTuple(args, ""))