Placement: Adds a helper to print the value of the placement.

This commit is contained in:
PaddleStroke
2024-12-13 17:44:54 +01:00
committed by Chris Hennes
parent 1e529bcc7d
commit 27be2ff16f
2 changed files with 26 additions and 0 deletions

View File

@@ -22,6 +22,8 @@
#include "PreCompiled.h"
#include <fmt/format.h>
#include "Placement.h"
#include "Matrix.h"
#include "Rotation.h"
@@ -209,3 +211,22 @@ Placement Placement::sclerp(const Placement& p0, const Placement& p1, double t,
Placement trf = p0.inverse() * p1;
return p0 * trf.pow(t, shorten);
}
std::string Placement::toString()
{
Base::Vector3d pos = getPosition();
Base::Rotation rot = getRotation();
Base::Vector3d axis;
double angle;
rot.getRawValue(axis, angle);
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);
}

View File

@@ -23,6 +23,8 @@
#ifndef BASE_PLACEMENT_H
#define BASE_PLACEMENT_H
#include <string>
#include "Rotation.h"
#include "Vector3D.h"
@@ -105,6 +107,9 @@ public:
static 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();
private:
Vector3<double> _pos;
Base::Rotation _rot;