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

Commit 1289997

Browse files
PaddleStrokechennes
authored andcommitted
Placement: Adds a helper to print the value of the placement.
1 parent 2afdd58 commit 1289997

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/Base/Placement.cpp

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

2323
#include "PreCompiled.h"
2424

25+
#include <fmt/format.h>
26+
2527
#include "Placement.h"
2628
#include "Matrix.h"
2729
#include "Rotation.h"
@@ -209,3 +211,22 @@ Placement Placement::sclerp(const Placement& p0, const Placement& p1, double t,
209211
Placement trf = p0.inverse() * p1;
210212
return p0 * trf.pow(t, shorten);
211213
}
214+
215+
std::string Placement::toString()
216+
{
217+
Base::Vector3d pos = getPosition();
218+
Base::Rotation rot = getRotation();
219+
220+
Base::Vector3d axis;
221+
double angle;
222+
rot.getRawValue(axis, angle);
223+
224+
return fmt::format("position ({.1f}, {.1f}, {.1f}), axis ({.1f}, {.1f}, {.1f}), angle {.1f}\n",
225+
pos.x,
226+
pos.y,
227+
pos.z,
228+
axis.x,
229+
axis.y,
230+
axis.z,
231+
angle);
232+
}

src/Base/Placement.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#ifndef BASE_PLACEMENT_H
2424
#define BASE_PLACEMENT_H
2525

26+
#include <string>
27+
2628
#include "Rotation.h"
2729
#include "Vector3D.h"
2830

@@ -105,6 +107,9 @@ class BaseExport Placement
105107
static Placement
106108
sclerp(const Placement& p0, const Placement& p1, double t, bool shorten = true);
107109

110+
/// Returns string representation of the placement, useful for debugging
111+
std::string toString();
112+
108113
private:
109114
Vector3<double> _pos;
110115
Base::Rotation _rot;

0 commit comments

Comments
 (0)