Skip to content
Snippets Groups Projects
Commit d1e19b59 authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Add plane() to viz::Polygon

parent 319ed1af
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,12 @@
#include "elements/PointCloud.h"
namespace Eigen
{
using Hyperplane3f = Hyperplane<float, 3>;
}
namespace armarx::viz
{
using data::ColoredPoint;
......@@ -172,6 +178,11 @@ namespace armarx::viz
public:
using ElementOps::ElementOps;
Polygon& clear()
{
data_->points.clear();
}
Polygon& lineColor(Color color)
{
data_->lineColor = color;
......@@ -205,6 +216,29 @@ namespace armarx::viz
return *this;
}
/**
* @brief Add points representing a plane as rectangle.
* @param plane The plane.
* @param at Center of rectangle, is projected onto plane.
* @param size Extents of rectangle.
*/
Polygon& plane(Eigen::Hyperplane3f plane, Eigen::Vector3f at, Eigen::Vector2f size)
{
const Eigen::Quaternionf ori = Eigen::Quaternionf::FromTwoVectors(
Eigen::Vector3f::UnitZ(), plane.normal());
const Eigen::Vector3f x = 0.5f * size.x() * (ori * Eigen::Vector3f::UnitX());
const Eigen::Vector3f y = 0.5f * size.y() * (ori * Eigen::Vector3f::UnitY());
const Eigen::Vector3f& origin = plane.projection(at);
addPoint(origin + x + y);
addPoint(origin - x + y);
addPoint(origin - x - y);
addPoint(origin + x - y);
return *this;
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment