Skip to content

Commit

Permalink
Placement: Adds a helper to print the value of the placement.
Browse files Browse the repository at this point in the history
  • Loading branch information
PaddleStroke authored and chennes committed Dec 16, 2024
1 parent 2afdd58 commit 1289997
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Base/Placement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#include "PreCompiled.h"

#include <fmt/format.h>

#include "Placement.h"
#include "Matrix.h"
#include "Rotation.h"
Expand Down Expand Up @@ -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);
}
5 changes: 5 additions & 0 deletions src/Base/Placement.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#ifndef BASE_PLACEMENT_H
#define BASE_PLACEMENT_H

#include <string>

#include "Rotation.h"
#include "Vector3D.h"

Expand Down Expand Up @@ -105,6 +107,9 @@ class BaseExport Placement
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;
Expand Down

0 comments on commit 1289997

Please sign in to comment.