Library of Assembled Shared Sources
|
convex or concave polygon in 3D (not selfintersecting, no holes) More...
#include <simple_polygon_3d.h>
Public Member Functions | |
const TPoint & | operator[] (size_t iIndexOfVertex) const |
return vertex of polygon by its index, not wrapped, no bounds check. | |
TPoint & | operator[] (size_t iIndexOfVertex) |
return vertex of polygon by its index, not wrapped, no bounds check. | |
const TPoint & | at (int iIndexOfVertex) const |
return vertex of polygon by its index, but wrap around the bounds. | |
TPoint & | at (int iIndexOfVertex) |
return vertex of polygon by its index, but wrap around the bounds. | |
const TLineSegment | edge (int iIndexOfTailVertex) const |
return the edge of the polygon between vertices at(iIndex) and at(iIndex + 1). | |
const TVector | vector (int iIndexOfTailVertex) const |
return the vector between vertices at(iIndex) and at(iIndex + 1)\ | |
const TPlane & | plane () const |
return support plane of polygon. | |
TPlane & | plane () |
access support plane of polygon. | |
const TVector | normal () const |
return normal of plane | |
const XYZ | majorAxis () const |
determines the major axis of the normal vector. | |
void | add (const TPoint &iVertex) |
add a point at the "end" of the vertex list | |
void | insert (int iIndexOfVertex, const TPoint &iVertex) |
insert a vertex at iIndex (so it will sit before the current at(iIndex)). | |
void | remove (int iIndexOfVertex) |
remove the vertex at(iIndex) | |
bool | isEmpty () const |
return true if polygon has no vertices | |
size_t | size () const |
return number of vertices | |
const TValue | signedArea () const |
return signed polygon area. | |
const TValue | area () const |
return area of the polygons surface. | |
const TValue | perimeter () const |
return sum of the lengths of all edges | |
const TPointH | vertexCentroid () const |
return the barycenter of all vertices. | |
const TPointH | surfaceCentroid () const |
return the centroid of the filled polygon. | |
bool | isSimple () const |
return true if polygon is simple, false if not. | |
bool | isConvex () const |
return true if polygon is convex, false if not. | |
Orientation | orientation () const |
return orientation of polygon | |
bool | isReflex (int iIndexOfVertex) const |
return true if inner angle of vertex is reflex (is > 180 degrees). | |
const SimplePolygon2D< T > | mapping (XYZ iAxis) const |
maps a 3D polygon as a 2D polygon by ignoring the component along an axis. | |
bool | contains (const TPoint &iP) const |
return true if a point iP is inside the polygon, on condition iP is on the plane | |
void | flip () |
flip normal and reverse sequence of vertices | |
Related Symbols | |
(Note that these are not member symbols.) | |
template<typename T, class EP1, class NP1, class NP2, class PP2> | |
Result | intersect (const SimplePolygon3D< T, EP1, NP1 > &polygon, const Ray3D< T, NP2, PP2 > &triangle, T &t, const T &tMin) |
Find the intersection of a ray and a simple polygon by their parameter t on the ray. | |
template<typename T, class EP, class NP, class PP> | |
Result | intersect (const SimplePolygon3D< T, EP, NP > &iPolygon, const LineSegment3D< T, PP > &iSegment, T &oT, const T &iMinT) |
Find the intersection of a line segment and a simple polygon by their parameter t on the line segment. | |
convex or concave polygon in 3D (not selfintersecting, no holes)
Definition at line 79 of file simple_polygon_3d.h.
const SimplePolygon3D< T, EP, NP >::TPoint & lass::prim::SimplePolygon3D< T, EP, NP >::at | ( | int | iIndexOfVertex | ) | const |
return vertex of polygon by its index, but wrap around the bounds.
this->at(-1) will return the same vertex as this->at(this->size() - 1);
Definition at line 100 of file simple_polygon_3d.inl.
References at().
Referenced by at(), at(), and perimeter().
SimplePolygon3D< T, EP, NP >::TPoint & lass::prim::SimplePolygon3D< T, EP, NP >::at | ( | int | iIndexOfVertex | ) |
return vertex of polygon by its index, but wrap around the bounds.
this->at(-1) will return the same vertex as this->at(this->size() - 1);
Definition at line 114 of file simple_polygon_3d.inl.
References at().
const XYZ lass::prim::SimplePolygon3D< T, EP, NP >::majorAxis | ( | ) | const |
determines the major axis of the normal vector.
The major axis is the one with the largest (absolute) component value. e.g. if the normal vector is (-1, 4, -8), this will be the z axis because abs(-8) > abs(4) > abs(-1). In case there's more than one major axis possible, the "highest" index is choosen. e.g. if the normal vector is (1, 1, 0), then y axis will be choosen, because y has a higher index than x .
Definition at line 186 of file simple_polygon_3d.inl.
References majorAxis().
Referenced by contains(), isSimple(), and majorAxis().
const SimplePolygon3D< T, EP, NP >::TValue lass::prim::SimplePolygon3D< T, EP, NP >::signedArea | ( | ) | const |
return signed polygon area.
The area of a convex polygon is defined to be positive if the points are arranged in a counterclockwise order, and negative if they are in clockwise order., Eric W. Weisstein. "Polygon Area." From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/PolygonArea.html
Definition at line 260 of file simple_polygon_3d.inl.
References normal(), lass::prim::Vector3D< T >::normal(), signedArea(), and size().
Referenced by area(), orientation(), and signedArea().
const SimplePolygon3D< T, EP, NP >::TValue lass::prim::SimplePolygon3D< T, EP, NP >::area | ( | ) | const |
return area of the polygons surface.
The area of a surface is the amount of material needed to "cover" it completely, Eric W. Weisstein. "Area." From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/Area.html
Definition at line 290 of file simple_polygon_3d.inl.
References lass::num::abs(), area(), and signedArea().
Referenced by area(), and orientation().
const SimplePolygon3D< T, EP, NP >::TPointH lass::prim::SimplePolygon3D< T, EP, NP >::vertexCentroid | ( | ) | const |
return the barycenter of all vertices.
The barycenter is the homogenous sum of all vertices.
Definition at line 319 of file simple_polygon_3d.inl.
References size(), and vertexCentroid().
Referenced by surfaceCentroid(), and vertexCentroid().
const SimplePolygon3D< T, EP, NP >::TPointH lass::prim::SimplePolygon3D< T, EP, NP >::surfaceCentroid | ( | ) | const |
return the centroid of the filled polygon.
Eric W. Weisstein. "Geometric Centroid." From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/GeometricCentroid.html
Definition at line 345 of file simple_polygon_3d.inl.
References normal(), lass::prim::Vector3D< T >::normal(), size(), surfaceCentroid(), and vertexCentroid().
Referenced by surfaceCentroid().
bool lass::prim::SimplePolygon3D< T, EP, NP >::isSimple | ( | ) | const |
return true if polygon is simple, false if not.
A polygon P is said to be simple (or Jordan) if the only points of the plane belonging to two polygon edges of P are the polygon vertices of P. Such a polygon has a well defined interior and exterior. Simple polygons are topologically equivalent to a disk., Eric W. Weisstein. "Simple Polygon." From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/SimplePolygon.html
In 3D, we test if the 2D mapping on the major axis is simple.
Definition at line 382 of file simple_polygon_3d.inl.
References isSimple(), majorAxis(), and mapping().
Referenced by isSimple().
bool lass::prim::SimplePolygon3D< T, EP, NP >::isConvex | ( | ) | const |
return true if polygon is convex, false if not.
A planar polygon is convex if it contains all the line segments connecting any pair of its points. Thus, for example, a regular pentagon is convex, while an indented pentagon is not. A planar polygon that is not convex is said to be a concave polygon, Eric W. Weisstein. "Convex Polygon." From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/ConvexPolygon.html
A simple polygon is convex if all the cross products of adjacent edges will be the same sign (we ignore zero signs, only + or - are taken in account), a concave polygon will have a mixture of cross product signs.
A polygon with less than three vertices is always convex. A polygon with all colinear vertices is considered convex (not very usefull maybe, but convex).
Definition at line 406 of file simple_polygon_3d.inl.
References isConvex(), lass::num::sign(), sign(), size(), and vector().
Referenced by isConvex().
Orientation lass::prim::SimplePolygon3D< T, EP, NP >::orientation | ( | ) | const |
return orientation of polygon
Definition at line 439 of file simple_polygon_3d.inl.
References area(), lass::prim::oClockWise, lass::prim::oCounterClockWise, lass::prim::oInvalid, orientation(), and signedArea().
Referenced by orientation().
bool lass::prim::SimplePolygon3D< T, EP, NP >::isReflex | ( | int | iIndexOfVertex | ) | const |
return true if inner angle of vertex is reflex (is > 180 degrees).
Definition at line 462 of file simple_polygon_3d.inl.
References isReflex(), normal(), and vector().
Referenced by isReflex().
const SimplePolygon2D< T > lass::prim::SimplePolygon3D< T, EP, NP >::mapping | ( | XYZ | iAxis | ) | const |
maps a 3D polygon as a 2D polygon by ignoring the component along an axis.
if iAxis is z, then it's easy. We ignore the z component and we get a polygon with only the x and y components.
if iAxis is x, then we have to keep the z axis while there's no z axis in 2D. We solve this by mapping the 3D y axis on the 2D x axis, and the 3D z axis on the 2D y axis.
if iAxis is y, then we have a similar problem. This time the 3D z axis is mapped on the 2D x axis, and the 3D x axis is mapped on the 2D y axis.
You can write this in short by saying the 2D x axis will correspond with 3D axis (iAxis
Definition at line 487 of file simple_polygon_3d.inl.
References lass::prim::SimplePolygon2D< T, DegeneratePolicy >::add(), mapping(), and size().
Referenced by isSimple(), and mapping().
bool lass::prim::SimplePolygon3D< T, EP, NP >::contains | ( | const TPoint & | iP | ) | const |
return true if a point iP is inside the polygon, on condition iP is on the plane
Definition at line 520 of file simple_polygon_3d.inl.
References contains(), majorAxis(), and size().
Referenced by contains(), lass::prim::SimplePolygon3D< U, PlaneEquationPolicy, PlaneNormalizingPolicy >::intersect(), and lass::prim::SimplePolygon3D< U, PlaneEquationPolicy, PlaneNormalizingPolicy >::intersect().
|
Find the intersection of a ray and a simple polygon by their parameter t on the ray.
polygon | [in] the simple polygon |
triangle | [in] the ray |
t | [out] the parameter of the intersection point > tMin. |
tMin | [in] the minimum t that may be returned as valid intersection. |
Definition at line 69 of file ray_3d_simple_polygon_3d.h.
|
Find the intersection of a line segment and a simple polygon by their parameter t on the line segment.
iPolygon | [in] the simple polygon |
iSegment | [in] the line segment |
oT | [out] the parameter of the intersection point > iMinT. |
iMinT | [in] the minimum t that may be returned as valid intersection. |
Definition at line 583 of file simple_polygon_3d.inl.