public class CollisionUtils
extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
getCollides(Vector2f lineStart,
Vector2f lineEnd,
Vector2f circleCenter,
float circleRadius)
Checks if a line connects with a circle.
|
static Vector2f |
getCollisionPoint(Vector2f lineStart,
Vector2f lineEnd,
CombatEntityAPI target)
Finds the part of the ship that would be intersected by a given path.
|
static Vector2f |
getCollisionPoint(Vector2f start1,
Vector2f end1,
Vector2f start2,
Vector2f end2)
Finds the point of intersection between two lines.
|
static boolean |
isPointOnSegment(Vector2f point,
BoundsAPI.SegmentAPI segment)
Check if a point is along a
BoundsAPI.SegmentAPI . |
static boolean |
isPointWithinBounds(Vector2f point,
CombatEntityAPI entity)
Checks if a point is inside or on the bounds of a
CombatEntityAPI . |
static boolean |
isPointWithinCollisionCircle(Vector2f point,
CombatEntityAPI entity)
Checks if a point is inside the collision circle of a
CombatEntityAPI . |
public static Vector2f getCollisionPoint(Vector2f lineStart, Vector2f lineEnd, CombatEntityAPI target)
target
- The CombatEntityAPI to check collision with.lineStart
- The start of the line to test collision with.lineEnd
- The end of the line to test collision with.
Vector2f
of the point the line would hit at,
or null
if it doesn't hit.
public static Vector2f getCollisionPoint(Vector2f start1, Vector2f end1, Vector2f start2, Vector2f end2)
start1
- The start of the first line to test collision with.end1
- The end of the first line to test collision with.start2
- The start of the second line to test collision with.end2
- The end of the second line to test collision with.
Vector2f
that the two lines intersect at,
null
if they don't collide.
public static boolean getCollides(Vector2f lineStart, Vector2f lineEnd, Vector2f circleCenter, float circleRadius)
lineStart
- The start point of the line to test.lineEnd
- The end point of the line to test.circleCenter
- The center point of the circle.circleRadius
- The radius of the circle.
true
if the line collides with the circle,
false
otherwise.
public static boolean isPointWithinCollisionCircle(Vector2f point, CombatEntityAPI entity)
CombatEntityAPI
.point
- The Vector2f
to check.entity
- The CombatEntityAPI
whose BoundsAPI
we
are checking against.
true
if point
is within the collision circle
of entity
, false
otherwise.
public static boolean isPointOnSegment(Vector2f point, BoundsAPI.SegmentAPI segment)
BoundsAPI.SegmentAPI
. Accurate to within 1/3
su, use MathUtils.isPointOnLine(Vector2f, Vector2f, Vector2f)
if you need higher precision.point
- The point to check.segment
- The BoundsAPI.SegmentAPI
to check for collision with.
true
if the point is along the line, false
otherwise.
public static boolean isPointWithinBounds(Vector2f point, CombatEntityAPI entity)
CombatEntityAPI
.point
- The Vector2f
to check.entity
- The CombatEntityAPI
whose BoundsAPI
we
are checking against.
true
if point
is within or on the bounds of
entity
, false
otherwise.