From 82081a6634813a55ff9d963fbb8457aa413ac415 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 17 Jun 2013 13:21:25 +0200 Subject: [PATCH] 0001152: The output of __repr__() of Vector and Rotatio would create Objects with different Values do to inapropriate rounding --- src/Base/RotationPyImp.cpp | 11 +++++++++-- src/Base/VectorPyImp.cpp | 5 ++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Base/RotationPyImp.cpp b/src/Base/RotationPyImp.cpp index 159952c7e0..2cf30426cd 100644 --- a/src/Base/RotationPyImp.cpp +++ b/src/Base/RotationPyImp.cpp @@ -38,9 +38,16 @@ using namespace Base; std::string RotationPy::representation(void) const { RotationPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + Py::Float q0(ptr->getValue()[0]); + Py::Float q1(ptr->getValue()[1]); + Py::Float q2(ptr->getValue()[2]); + Py::Float q3(ptr->getValue()[3]); std::stringstream str; - str << "Quaternion ("; - str << ptr->getValue()[0] << ","<< ptr->getValue()[1] << "," << ptr->getValue()[2] << "," << ptr->getValue()[3]; + str << "Rotation ("; + str << (std::string)q0.repr() << ", " + << (std::string)q1.repr() << ", " + << (std::string)q2.repr() << ", " + << (std::string)q3.repr(); str << ")"; return str.str(); diff --git a/src/Base/VectorPyImp.cpp b/src/Base/VectorPyImp.cpp index da2bb58311..4a1bae8498 100644 --- a/src/Base/VectorPyImp.cpp +++ b/src/Base/VectorPyImp.cpp @@ -40,9 +40,12 @@ using namespace Base; std::string VectorPy::representation(void) const { VectorPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + Py::Float x(ptr->x); + Py::Float y(ptr->y); + Py::Float z(ptr->z); std::stringstream str; str << "Vector ("; - str << ptr->x << ", "<< ptr->y << ", "<< ptr->z; + str << (std::string)x.repr() << ", "<< (std::string)y.repr() << ", "<< (std::string)z.repr(); str << ")"; return str.str();