diff --git a/include/coal/math/transform.h b/include/coal/math/transform.h index d2cf8ed41..7d712fadc 100644 --- a/include/coal/math/transform.h +++ b/include/coal/math/transform.h @@ -202,10 +202,14 @@ class COAL_DLLAPI Transform3s { } /// @brief return a random transform - static Transform3s Random() { return Transform3s().setRandom(); } + static Transform3s Random() { + Transform3s tf = Transform3s(); + tf.setRandom(); + return tf; + } /// @brief set the transform to a random transform - Transform3s& setRandom(); + inline void setRandom(); bool operator==(const Transform3s& other) const { return (R == other.getRotation()) && (T == other.getTranslation()); @@ -247,12 +251,10 @@ inline Quatf uniformRandomQuaternion() { return q; } -inline Transform3s& Transform3s::setRandom() { +inline void Transform3s::setRandom() { const Quatf q = uniformRandomQuaternion(); this->rotation() = q.matrix(); this->translation().setRandom(); - - return *this; } /// @brief Construct othonormal basis from vector. diff --git a/python/math.cc b/python/math.cc index be6d13dc4..0261ae5f1 100644 --- a/python/math.cc +++ b/python/math.cc @@ -111,6 +111,10 @@ void exposeMaths() { .def(dv::member_func("Identity", &Transform3s::Identity)) .staticmethod("Identity") + .def(dv::member_func("setRandom", &Transform3s::setRandom)) + .def(dv::member_func("Random", &Transform3s::Random)) + .staticmethod("Random") + .def(dv::member_func("transform", &Transform3s::transform)) .def("inverseInPlace", &Transform3s::inverseInPlace, return_internal_reference<>(),