Implement Polygon::ToPolyhedron
This commit is contained in:
@@ -80,6 +80,14 @@ namespace J3ML::Geometry {
|
|||||||
Vector3 ClosestPoint(const LineSegment &lineSegment, Vector3 *lineSegmentPt) const;
|
Vector3 ClosestPoint(const LineSegment &lineSegment, Vector3 *lineSegmentPt) const;
|
||||||
|
|
||||||
Vector3 ClosestPoint(const Vector3 &point) const;
|
Vector3 ClosestPoint(const Vector3 &point) const;
|
||||||
|
|
||||||
|
/// Converts this Polygon to a Polyhedron representation.
|
||||||
|
/** This function will create a Polyhedron with two faces, one for the front face of this Polygon,
|
||||||
|
and one for the back face.
|
||||||
|
@todo Add ToPolyhedron(float polygonThickness)
|
||||||
|
@see Triangulate(), MinimalEnclosingAABB(). */
|
||||||
|
Polyhedron ToPolyhedron() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
#include <J3ML/Geometry/Polygon.h>
|
#include <J3ML/Geometry/Polygon.h>
|
||||||
#include <J3ML/Geometry/AABB.h>
|
#include <J3ML/Geometry/AABB.hpp>
|
||||||
#include <J3ML/Geometry/Triangle.h>
|
#include <J3ML/Geometry/Triangle.h>
|
||||||
#include "J3ML/Geometry/Plane.h"
|
#include "J3ML/Geometry/Plane.h"
|
||||||
#include "J3ML/Geometry/Line.h"
|
#include "J3ML/Geometry/Line.h"
|
||||||
#include <J3ML/Algorithm/GJK.h>
|
#include <J3ML/Algorithm/GJK.hpp>
|
||||||
|
|
||||||
namespace J3ML::Geometry {
|
namespace J3ML::Geometry {
|
||||||
Vector3 Polygon::AnyPointFast() const { return !vertices.empty() ? vertices[0] : Vector3::NaN; }
|
Vector3 Polygon::AnyPointFast() const { return !vertices.empty() ? vertices[0] : Vector3::NaN; }
|
||||||
@@ -572,6 +572,19 @@ namespace J3ML::Geometry {
|
|||||||
return closestPt;
|
return closestPt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Polyhedron Polygon::ToPolyhedron() const {
|
||||||
|
Polyhedron poly;
|
||||||
|
poly.v = vertices;
|
||||||
|
poly.f.push_back(Polyhedron::Face());
|
||||||
|
poly.f.push_back(Polyhedron::Face());
|
||||||
|
for(int i = 0; i < NumVertices(); ++i)
|
||||||
|
{
|
||||||
|
poly.f[0].v.push_back(i);
|
||||||
|
poly.f[1].v.push_back(NumVertices()-1-i);
|
||||||
|
}
|
||||||
|
return poly;
|
||||||
|
}
|
||||||
|
|
||||||
Vector3 Polygon::ClosestPoint(const LineSegment &lineSegment) const
|
Vector3 Polygon::ClosestPoint(const LineSegment &lineSegment) const
|
||||||
{
|
{
|
||||||
return ClosestPoint(lineSegment, 0);
|
return ClosestPoint(lineSegment, 0);
|
||||||
|
Reference in New Issue
Block a user