Support Forum       G3D Web Page     
Public Member Functions | Friends | List of all members
G3D::ConvexPolygon Class Reference

Public Member Functions

 ConvexPolygon ()
 
 ConvexPolygon (const Vector3 &v0, const Vector3 &v1, const Vector3 &v2)
 
 ConvexPolygon (const Array< Vector3 > &__vertex)
 
virtual ~ConvexPolygon ()
 
void cut (const Plane &plane, ConvexPolygon &above, ConvexPolygon &below, DirectedEdge &newEdge)
 Cuts the polygon at the plane. More...
 
void cut (const Plane &plane, ConvexPolygon &above, ConvexPolygon &below)
 
float getArea () const
 
O(n) in the number of edges More...
 
ConvexPolygon inverse () const
 
Returns the same polygon with inverse winding. More...
 
bool isEmpty () const
 O(n) in the number of edges. More...
 
Vector3 normal () const
 
int numVertices () const
 Zero vertices indicates an empty polygon (zero area). More...
 
void removeDuplicateVertices ()
 When a cut plane grazes a vertex in the polygon, two near-identical vertices may be created. More...
 
void setNumVertices (int n)
 
void setVertex (int i, const Vector3 &v)
 
const Vector3vertex (int i) const
 
Counter clockwise winding order. More...
 

Friends

class ConvexPolyhedron
 

Constructor & Destructor Documentation

◆ ConvexPolygon() [1/3]

G3D::ConvexPolygon::ConvexPolygon ( )
inline

◆ ConvexPolygon() [2/3]

G3D::ConvexPolygon::ConvexPolygon ( const Vector3 v0,
const Vector3 v1,
const Vector3 v2 
)

◆ ConvexPolygon() [3/3]

G3D::ConvexPolygon::ConvexPolygon ( const Array< Vector3 > &  __vertex)

◆ ~ConvexPolygon()

virtual G3D::ConvexPolygon::~ConvexPolygon ( )
inlinevirtual

Member Function Documentation

◆ cut() [1/2]

void G3D::ConvexPolygon::cut ( const Plane plane,
ConvexPolygon above,
ConvexPolygon below,
DirectedEdge newEdge 
)

Cuts the polygon at the plane.

If the polygon is entirely above or below the plane, one of the returned polygons will be empty.

Parameters
aboveThe part of the polygon above (on the side the normal points to or in the plane) the plane
belowThe part of the polygon below the plane.
newEdgeIf a new edge was introduced, this is that edge (on the above portion; the below portion is the opposite winding.

◆ cut() [2/2]

void G3D::ConvexPolygon::cut ( const Plane plane,
ConvexPolygon above,
ConvexPolygon below 
)

◆ getArea()

float G3D::ConvexPolygon::getArea ( ) const


O(n) in the number of edges

◆ inverse()

ConvexPolygon G3D::ConvexPolygon::inverse ( ) const


Returns the same polygon with inverse winding.

◆ isEmpty()

bool G3D::ConvexPolygon::isEmpty ( ) const

O(n) in the number of edges.

◆ normal()

Vector3 G3D::ConvexPolygon::normal ( ) const
inline

◆ numVertices()

int G3D::ConvexPolygon::numVertices ( ) const
inline

Zero vertices indicates an empty polygon (zero area).

◆ removeDuplicateVertices()

void G3D::ConvexPolygon::removeDuplicateVertices ( )

When a cut plane grazes a vertex in the polygon, two near-identical vertices may be created.

The closeness of these two points can cause a number of problems, such as ConvexPolygon::normal() returning an infinite vector. It should be noted, however, that not all applications are sensitive to near-identical vertices.

removeDuplicateVertices() detects and eliminates redundant vertices.

◆ setNumVertices()

void G3D::ConvexPolygon::setNumVertices ( int  n)
inline

◆ setVertex()

void G3D::ConvexPolygon::setVertex ( int  i,
const Vector3 v 
)
inline

◆ vertex()

const Vector3& G3D::ConvexPolygon::vertex ( int  i) const
inline


Counter clockwise winding order.

Friends And Related Function Documentation

◆ ConvexPolyhedron

friend class ConvexPolyhedron
friend

documentation generated on Wed Nov 24 2021 08:01:54 using doxygen 1.8.15