Table of Contents

Class Vertices

Namespace
Alis.Core.Physic.Common
Assembly
Alis.dll

The vertices class

public class Vertices : List<Vector2>, IList<Vector2>, ICollection<Vector2>, IReadOnlyList<Vector2>, IReadOnlyCollection<Vector2>, IEnumerable<Vector2>, IList, ICollection, IEnumerable

Inheritance

Derived

Implements

Inherited Members

Constructors

Vertices()

Initializes a new instance of the Alis.Core.Physic.Common.Vertices class

public Vertices()

Vertices(int)

Initializes a new instance of the Alis.Core.Physic.Common.Vertices class

public Vertices(int capacity)

Parameters

capacity int

The capacity

Vertices(IEnumerable<Vector2>)

Initializes a new instance of the Alis.Core.Physic.Common.Vertices class

public Vertices(IEnumerable<Vector2> vertices)

Parameters

vertices IEnumerable<Vector2>

The vertices

Properties

AttachedToBody

Gets or sets the value of the attached to body

internal bool AttachedToBody { get; set; }

Property Value

bool

Holes

You can add holes to this collection. It will get respected by some of the triangulation algoithms, but otherwise not used.

public List<Vertices> Holes { get; set; }

Property Value

List<Vertices>

Methods

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

public PolygonError CheckPolygon()

Returns

PolygonError

PolygonError.NoError if there were no error.

ForceCounterClockWise()

Forces the vertices to be counter clock wise order.

public void ForceCounterClockWise()

GetAABB()

Returns an AABB that fully contains this polygon.

public AABB GetAABB()

Returns

AABB

GetArea()

Gets the area.

public float GetArea()

Returns

float

GetCentroid()

Gets the centroid.

public Vector2 GetCentroid()

Returns

Vector2

GetSignedArea()

Gets the signed area. If the area is less than 0, it indicates that the polygon is clockwise winded.

public float GetSignedArea()

Returns

float

The signed area

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
public bool IsConvex()

Returns

bool

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.

public bool IsCounterClockWise()

Returns

bool

IsSimple()

Checks if the vertices forms an simple polygon by checking for edge crossings.

public bool IsSimple()

Returns

bool

NextIndex(int)

Gets the next index. Used for iterating all the edges with wrap-around.

public int NextIndex(int index)

Parameters

index int

The current index

Returns

int

NextVertex(int)

Gets the next vertex. Used for iterating all the edges with wrap-around.

public Vector2 NextVertex(int index)

Parameters

index int

The current index

Returns

Vector2

PointInPolygon(ref Vector2)

Winding number test for a point in a polygon.

public int PointInPolygon(ref Vector2 point)

Parameters

point Vector2

The point to be tested.

Returns

int

-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(ref Vector2)

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

public bool PointInPolygonAngle(ref Vector2 point)

Parameters

point Vector2

Returns

bool

PreviousIndex(int)

Gets the previous index. Used for iterating all the edges with wrap-around.

public int PreviousIndex(int index)

Parameters

index int

The current index

Returns

int

PreviousVertex(int)

Gets the previous vertex. Used for iterating all the edges with wrap-around.

public Vector2 PreviousVertex(int index)

Parameters

index int

The current index

Returns

Vector2

ProjectToAxis(ref Vector2, out float, out float)

Projects to axis.

public void ProjectToAxis(ref Vector2 axis, out float min, out float max)

Parameters

axis Vector2

The axis.

min float

The min.

max float

The max.

Rotate(float)

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.

public void Rotate(float value)

Parameters

value float

The amount to rotate by in radians.

Scale(Vector2)

Scales the vertices with the specified vector.

public void Scale(Vector2 value)

Parameters

value Vector2

The Value.

Scale(ref Vector2)

Scales the vertices with the specified vector.

public void Scale(ref Vector2 value)

Parameters

value Vector2

The Value.

ToString()

Returns the string

public override string ToString()

Returns

string

The string

Translate(Vector2)

Translates the vertices with the specified vector.

public void Translate(Vector2 value)

Parameters

value Vector2

The value.

Translate(ref Vector2)

Translates the vertices with the specified vector.

public void Translate(ref Vector2 value)

Parameters

value Vector2

The vector.

See Also

List<T>