Vertices
Declaration
public class tainicom.Aether.Physics2D.Common.Vertices
Inherits: System.Collections.Generic.List
Constructors
Vertices
void Vertices()
Vertices
void Vertices(int capacity)
Parameters:
| Name | Type | Description |
|---|---|---|
capacity |
System.Int32 |
Vertices
void Vertices(IEnumerable<Vector2> vertices)
Parameters:
| Name | Type | Description |
|---|---|---|
vertices |
System.Collections.Generic.IEnumerable |
Properties
Holes
You can add holes to this collection. It will get respected by some of the triangulation algoithms, but otherwise not used.
List<Vertices> Holes { get set }
Methods
NextIndex
Gets the next index. Used for iterating all the edges with wrap-around.
int NextIndex(int index)
Parameters:
| Name | Type | Description |
|---|---|---|
index |
System.Int32 |
The current index |
NextVertex
Gets the next vertex. Used for iterating all the edges with wrap-around.
Vector2 NextVertex(int index)
Parameters:
| Name | Type | Description |
|---|---|---|
index |
System.Int32 |
The current index |
PreviousIndex
Gets the previous index. Used for iterating all the edges with wrap-around.
int PreviousIndex(int index)
Parameters:
| Name | Type | Description |
|---|---|---|
index |
System.Int32 |
The current index |
PreviousVertex
Gets the previous vertex. Used for iterating all the edges with wrap-around.
Vector2 PreviousVertex(int index)
Parameters:
| Name | Type | Description |
|---|---|---|
index |
System.Int32 |
The current index |
GetSignedArea
Gets the signed area. If the area is less than 0, it indicates that the polygon is clockwise winded.
float GetSignedArea()
Returns: The signed area
GetArea
Gets the area.
float GetArea()
GetCentroid
Gets the centroid.
Vector2 GetCentroid()
GetAABB
Returns an AABB that fully contains this polygon.
AABB GetAABB()
Translate
Translates the vertices with the specified vector.
void Translate(Vector2 value)
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Strawberry.Math.Vector2 |
The value. |
Translate
Translates the vertices with the specified vector.
void Translate(ref Vector2 value)
Parameters:
| Name | Type | Description |
|---|---|---|
value |
ref Strawberry.Math.Vector2 |
The vector. |
Scale
Scales the vertices with the specified vector.
void Scale(Vector2 value)
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Strawberry.Math.Vector2 |
The Value. |
Scale
Scales the vertices with the specified vector.
void Scale(ref Vector2 value)
Parameters:
| Name | Type | Description |
|---|---|---|
value |
ref Strawberry.Math.Vector2 |
The Value. |
Rotate
Rotate the vertices with the defined value in radians. Warning: Using this method on an active set of vertices of a Body, will cause problems with collisions. Use Body.Rotation instead.
void Rotate(float value)
Parameters:
| Name | Type | Description |
|---|---|---|
value |
System.Single |
The amount to rotate by in radians. |
IsConvex
Determines whether the polygon is convex. O(n^2) running time. Assumptions: - The polygon is in counter clockwise order - The polygon has no overlapping edges
bool IsConvex()
Returns: true if it is convex; otherwise, false.
IsCounterClockWise
Indicates if the vertices are in counter clockwise order. Warning: If the area of the polygon is 0, it is unable to determine the winding.
bool IsCounterClockWise()
ForceCounterClockWise
Forces the vertices to be counter clock wise order.
void ForceCounterClockWise()
IsSimple
Checks if the vertices forms an simple polygon by checking for edge crossings.
bool IsSimple()
CheckPolygon
Checks if the polygon is valid for use in the engine. Performs a full check, for simplicity, convexity, orientation, minimum angle, and volume. From Eric Jordan's convex decomposition library
PolygonError CheckPolygon()
Returns: PolygonError.NoError if there were no error.
ProjectToAxis
Projects to axis.
void ProjectToAxis(ref Vector2 axis, out float min, out float max)
Parameters:
| Name | Type | Description |
|---|---|---|
axis |
ref Strawberry.Math.Vector2 |
The axis. |
min |
out System.Single |
The min. |
max |
out System.Single |
The max. |
PointInPolygon
Winding number test for a point in a polygon.
int PointInPolygon(ref Vector2 point)
Parameters:
| Name | Type | Description |
|---|---|---|
point |
ref Strawberry.Math.Vector2 |
The point to be tested. |
Returns: -1 if the winding number is zero and the point is outside the polygon, 1 if the point is inside the polygon, and 0 if the point is on the polygons edge.
PointInPolygonAngle
Compute the sum of the angles made between the test point and each pair of points making up the polygon. If this sum is 2pi then the point is an interior point, if 0 then the point is an exterior point. ref: http://ozviz.wasp.uwa.edu.au/~pbourke/geometry/insidepoly/ - Solution 2
bool PointInPolygonAngle(ref Vector2 point)
Parameters:
| Name | Type | Description |
|---|---|---|
point |
ref Strawberry.Math.Vector2 |
Transform
Transforms the polygon using the defined matrix.
void Transform(ref Matrix4 transform)
Parameters:
| Name | Type | Description |
|---|---|---|
transform |
ref Strawberry.Math.Matrix4 |
The matrix to use as transformation. |
ToString override
string ToString()