Skip to content
This repository was archived by the owner on Mar 1, 2025. It is now read-only.

Commit cb36fb6

Browse files
committed
Placement: Adds a helper to print the value of the placement.
1 parent d057fd7 commit cb36fb6

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/Base/Placement.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "PreCompiled.h"
2424

25+
#include "Console.h"
2526
#include "Placement.h"
2627
#include "Matrix.h"
2728
#include "Rotation.h"
@@ -209,3 +210,22 @@ Placement Placement::sclerp(const Placement& p0, const Placement& p1, double t,
209210
Placement trf = p0.inverse() * p1;
210211
return p0 * trf.pow(t, shorten);
211212
}
213+
214+
std::string Placement::toString()
215+
{
216+
Base::Vector3d pos = getPosition();
217+
Base::Rotation rot = getRotation();
218+
219+
Base::Vector3d axis;
220+
double angle;
221+
rot.getRawValue(axis, angle);
222+
223+
return fmt::format("position ({.1f}, {.1f}, {.1f}), axis ({.1f}, {.1f}, {.1f}), angle {.1f}\n",
224+
pos.x,
225+
pos.y,
226+
pos.z,
227+
axis.x,
228+
axis.y,
229+
axis.z,
230+
angle);
231+
}

src/Base/Placement.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ class BaseExport Placement
105105
static Placement
106106
sclerp(const Placement& p0, const Placement& p1, double t, bool shorten = true);
107107

108+
/// Returns string representation of the placement, useful for debugging
109+
std::string Placement::toString();
110+
108111
private:
109112
Vector3<double> _pos;
110113
Base::Rotation _rot;

0 commit comments

Comments
 (0)