Package me.autobot.lib.math.objects
Class Geometry
java.lang.Object
me.autobot.lib.math.objects.Geometry
A class containing geometry utility functions.
-
Constructor Summary
ConstructorsConstructorDescriptionGeometry()
Geometry class is a utility class and should not be instantiated. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isSeparatingAxisTheorem
(Vector2d[] a, Vector2d[] b) Checks if two polygons are intersecting using the Separating Axis Theoremstatic Projection
projectPolygon
(Vector2d[] polygon, Vector2d axis) Projects a polygon onto an axis and returns the projection rangestatic boolean
twoPolygonsIntersecting
(Vector2d[] polygonA, Vector2d[] polygonB) Checks if two polygons are intersecting
-
Constructor Details
-
Geometry
public Geometry()Geometry class is a utility class and should not be instantiated.
-
-
Method Details
-
twoPolygonsIntersecting
Checks if two polygons are intersecting- Parameters:
polygonA
- The first polygon The polygon is represented as an array of Vector2d points The points are in counter-clockwise order The last point is connected to the first point The polygon is assumed to be convex The polygon is assumed to be simple (no self-intersections)polygonB
- The second polygon The polygon is represented as an array of Vector2d points Same assumptions as polygonA- Returns:
- true if the polygons are intersecting, false otherwise
-
isSeparatingAxisTheorem
Checks if two polygons are intersecting using the Separating Axis Theorem- Parameters:
a
- The first polygonb
- The second polygon- Returns:
- true if the polygons are intersecting, false otherwise
-
projectPolygon
Projects a polygon onto an axis and returns the projection range- Parameters:
polygon
- The polygon to project The polygon is represented as an array of Vector2d pointsaxis
- The axis to project the polygon onto The axis is represented as a Vector2d- Returns:
- The projection range
-