Skip to content

Commit

Permalink
Core: Format Placement::toString() and fix const correctness
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Dec 19, 2024
1 parent 8e0bf19 commit 44065bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
14 changes: 5 additions & 9 deletions src/Base/Placement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion src/Base/Placement.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class BaseExport Placement
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;
Expand Down

0 comments on commit 44065bf

Please sign in to comment.