Core: Format Placement::toString() and fix const correctness

This commit is contained in:
wmayer
2024-12-19 11:13:28 +01:00
committed by wwmayer
parent 8e0bf192df
commit 44065bfff4
2 changed files with 6 additions and 10 deletions

View File

@@ -212,21 +212,17 @@ Placement Placement::sclerp(const Placement& p0, const Placement& p1, double t,
return p0 * trf.pow(t, shorten);
}
std::string Placement::toString()
std::string Placement::toString() const
{
Base::Vector3d pos = getPosition();
Base::Rotation rot = getRotation();
Base::Vector3d axis;
double angle;
double angle {};
rot.getRawValue(axis, angle);
// clang-format off
return fmt::format("position ({:.1f}, {:.1f}, {:.1f}), axis ({:.1f}, {:.1f}, {:.1f}), angle {:.1f}\n",
pos.x,
pos.y,
pos.z,
axis.x,
axis.y,
axis.z,
angle);
pos.x, pos.y, pos.z, axis.x, axis.y, axis.z, angle);
// clang-format on
}

View File

@@ -108,7 +108,7 @@ public:
sclerp(const Placement& p0, const Placement& p1, double t, bool shorten = true);
/// Returns string representation of the placement, useful for debugging
std::string toString();
std::string toString() const;
private:
Vector3<double> _pos;