A convex polygon class in 2D. More...
Public Member Functions | |
ConvexPoly2 (Vector2[] points) | |
ConvexPoly2 constructor. | |
void | MakeBox (Bounds2 bounds) |
void | MakeRegular (uint num, float r) |
uint | Size () |
Return the number of vertices (or faces) | |
Vector2 | GetPoint (int index) |
Get a vertex position. | |
Vector2 | GetNormal (int index) |
Get the normal vector of a face of this poly. | |
Plane2 | GetPlane (int index) |
Get the plane formed by a face of this poly. | |
Bounds2 | CalcBounds () |
Calculate the bounds of this poly. | |
Vector2 | CalcCenter () |
Calculate the gravity center of this poly. | |
float | CalcArea () |
Calculate the area of this convex poly. | |
bool | IsInside (Vector2 point) |
Return true if 'point' is inside the primitive (in its negative space). | |
void | ClosestSurfacePoint (Vector2 point, out Vector2 ret, out float sign) |
Return the closest point to 'point' that lies on the surface of the primitive. | |
float | SignedDistance (Vector2 point) |
Return the signed distance (penetration distance) from 'point' to the surface of the primitive. | |
void | Translate (Vector2 dx, ConvexPoly2 poly) |
bool | NegativeClipSegment (ref Vector2 A, ref Vector2 B) |
Assuming the primitive is convex, clip the segment AB against the primitive. | |
Public Attributes | |
Plane2[] | Planes |
The convex poly is stored as a list of planes assumed to define a convex region. | |
Properties | |
Sphere2 | Sphere [get] |
Bounding sphere, centered at center of mass. |
A convex polygon class in 2D.
ConvexPoly2 | ( | Vector2[] | points | ) |
ConvexPoly2 constructor.
Assumes input points define a convex region.
Return the closest point to 'point' that lies on the surface of the primitive.
If that point is inside the primitive, sign is negative.
Implements ICollisionBasics.
Vector2 GetNormal | ( | int | index | ) |
Get the normal vector of a face of this poly.
index | The face index. |
Plane2 GetPlane | ( | int | index | ) |
Get the plane formed by a face of this poly.
index | The face index. |
Vector2 GetPoint | ( | int | index | ) |
Get a vertex position.
index | The vertex index. |
void MakeBox | ( | Bounds2 | bounds | ) |
void MakeRegular | ( | uint | num, |
float | r | ||
) |
Assuming the primitive is convex, clip the segment AB against the primitive.
Return false if AB is entirely in positive halfspace, else clip against negative space and return true.
Implements ICollisionBasics.
void Translate | ( | Vector2 | dx, |
ConvexPoly2 | poly | ||
) |