Package physics.collision
Class Shapes
java.lang.Object
physics.collision.Shapes
Util methods to create
PrimitiveShape
on the fly.- Since:
- 20.06.2021
- Author:
- Juyas
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Quadrilateral
axisAlignedRectangle
(float ax, float ay, float bx, float by) Create an axis aligned rectangle.static Quadrilateral
axisAlignedRectangle
(org.joml.Vector2f a, org.joml.Vector2f b) Create an axis aligned rectangle.static Circle
circle
(float x, float y, float r) Create a circle.static Circle
circle
(org.joml.Vector2f center, float radius) Create a circle.static Circle
circle
(org.joml.Vector2f center, org.joml.Vector2f circlePosition, float radius) Create a circle.static ConvexPolygon
convexPolygon
(float... coordPairs) Create a convex polygon by a given set of coordinate pairs.static Quadrilateral
quadrilateral
(org.joml.Vector2f a, org.joml.Vector2f b, org.joml.Vector2f c, org.joml.Vector2f d) Create a quadrilateral.static Triangle
triangle
(float ax, float ay, float bx, float by, float cx, float cy) Create a triangle.static Triangle
triangle
(org.joml.Vector2f a, org.joml.Vector2f b, org.joml.Vector2f c) Create a triangle.
-
Constructor Details
-
Shapes
public Shapes()
-
-
Method Details
-
circle
public static Circle circle(org.joml.Vector2f center, org.joml.Vector2f circlePosition, float radius) Create a circle.- Parameters:
center
- the absolute center of the circlecirclePosition
- the current absolute position of the circle's centerradius
- the radius of the circle- Returns:
- a circle
-
circle
Create a circle.- Parameters:
center
- the relative center of the circleradius
- the radius of the circle- Returns:
- a circle
-
circle
Create a circle.- Parameters:
x
- the relative x coord of the circles centery
- the relative y coord of the circles centerr
- the radius of the circle- Returns:
- a circle
-
convexPolygon
Create a convex polygon by a given set of coordinate pairs.- Parameters:
coordPairs
- a dynamic array of coordinates, which must have an even size.- Returns:
- a
ConvexPolygon
over all given points or null if the coordinates have a odd size
-
triangle
Create a triangle.- Parameters:
ax
- relative coordinate Axay
- relative coordinate Aybx
- relative coordinate Bxby
- relative coordinate Bycx
- relative coordinate Cxcy
- relative coordinate Cy- Returns:
- a triangle
-
triangle
Create a triangle.- Parameters:
a
- relative point ab
- relative point bc
- relative point c- Returns:
- a triangle
-
axisAlignedRectangle
Create an axis aligned rectangle. This will find min corner and max corner and generate both missing points through basic geometry- Parameters:
ax
- relative coordinate Axay
- relative coordinate Aybx
- relative coordinate Bxby
- relative coordinate By- Returns:
- an axis aligned rectangle
-
quadrilateral
public static Quadrilateral quadrilateral(org.joml.Vector2f a, org.joml.Vector2f b, org.joml.Vector2f c, org.joml.Vector2f d) Create a quadrilateral.- Parameters:
a
- relative point ab
- relative point bc
- relative point cd
- relative point d- Returns:
- a quadrilateral
-
axisAlignedRectangle
Create an axis aligned rectangle. This will find min corner and max corner and generate both missing points through basic geometry- Parameters:
a
- relative point ab
- relative point b- Returns:
- an axis aligned rectangle
-