Base: [skip ci] in Rotation class allow to set angle in radian

App.Rotation(axis, angle) still defines the angle in degree
App.Rotation(axis, Degree=angle) does the same as above
App.Rotation(axis, Radian=angle) defines the angle in radian
This commit is contained in:
wmayer
2021-10-27 10:59:34 +02:00
parent e424faa131
commit 16c08ec96f

View File

@@ -60,7 +60,7 @@ PyObject *RotationPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // P
}
// constructor method
int RotationPy::PyInit(PyObject* args, PyObject* /*kwd*/)
int RotationPy::PyInit(PyObject* args, PyObject* kwds)
{
PyObject* o;
if (PyArg_ParseTuple(args, "")) {
@@ -76,10 +76,18 @@ int RotationPy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyErr_Clear();
double angle;
if (PyArg_ParseTuple(args, "O!d", &(Base::VectorPy::Type), &o, &angle)) {
// NOTE: The last parameter defines the rotation angle in degree.
getRotationPtr()->setValue(static_cast<Base::VectorPy*>(o)->value(), Base::toRadians<double>(angle));
return 0;
static char *kw_deg[] = {"Axis", "Degree", nullptr};
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!d", kw_deg, &(Base::VectorPy::Type), &o, &angle)) {
// NOTE: The last parameter defines the rotation angle in degree.
getRotationPtr()->setValue(static_cast<Base::VectorPy*>(o)->value(), Base::toRadians<double>(angle));
return 0;
}
PyErr_Clear();
static char *kw_rad[] = {"Axis", "Radian", nullptr};
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!d", kw_rad, &(Base::VectorPy::Type), &o, &angle)) {
getRotationPtr()->setValue(static_cast<Base::VectorPy*>(o)->value(), angle);
return 0;
}
PyErr_Clear();