LazyLib

org.lazywizard.lazylib
Class CollisionUtils

java.lang.Object
  extended by org.lazywizard.lazylib.CollisionUtils

public class CollisionUtils
extends java.lang.Object

Contains methods for working with bounds and collision detection.

Since:
1.0
Author:
LazyWizard

Method Summary
static boolean getCollides(org.lwjgl.util.vector.Vector2f lineStart, org.lwjgl.util.vector.Vector2f lineEnd, org.lwjgl.util.vector.Vector2f center, float radius)
          Check if a line connects with a circle.
static org.lwjgl.util.vector.Vector2f getCollisionPoint(org.lwjgl.util.vector.Vector2f lineStart, org.lwjgl.util.vector.Vector2f lineEnd, com.fs.starfarer.api.combat.CombatEntityAPI target)
          Finds the part of the ship that would be intersected by a given path.
static org.lwjgl.util.vector.Vector2f getCollisionPoint(org.lwjgl.util.vector.Vector2f start1, org.lwjgl.util.vector.Vector2f end1, org.lwjgl.util.vector.Vector2f start2, org.lwjgl.util.vector.Vector2f end2)
          Finds the point of intersection between two lines.
static boolean isPointWithinBounds(org.lwjgl.util.vector.Vector2f point, com.fs.starfarer.api.combat.CombatEntityAPI entity)
          Checks if a point is inside of the bounds of a CombatEntityAPI.
static boolean isPointWithinCollisionCircle(org.lwjgl.util.vector.Vector2f point, com.fs.starfarer.api.combat.CombatEntityAPI entity)
          Checks if a point is inside the collision circle of a CombatEntityAPI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getCollisionPoint

public static org.lwjgl.util.vector.Vector2f getCollisionPoint(org.lwjgl.util.vector.Vector2f lineStart,
                                                               org.lwjgl.util.vector.Vector2f lineEnd,
                                                               com.fs.starfarer.api.combat.CombatEntityAPI target)
Finds the part of the ship that would be intersected by a given path.

Parameters:
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.
Returns:
The Vector2f of the point the line would hit at, or null if it doesn't hit.
Since:
1.0

getCollisionPoint

public static org.lwjgl.util.vector.Vector2f getCollisionPoint(org.lwjgl.util.vector.Vector2f start1,
                                                               org.lwjgl.util.vector.Vector2f end1,
                                                               org.lwjgl.util.vector.Vector2f start2,
                                                               org.lwjgl.util.vector.Vector2f end2)
Finds the point of intersection between two lines.

Parameters:
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.
Returns:
The Vector2f that the two lines intersect at, null if they don't collide.
Since:
1.0

getCollides

public static boolean getCollides(org.lwjgl.util.vector.Vector2f lineStart,
                                  org.lwjgl.util.vector.Vector2f lineEnd,
                                  org.lwjgl.util.vector.Vector2f center,
                                  float radius)
Check if a line connects with a circle.

Parameters:
lineStart - The start point of the line to test.
lineEnd - The end point of the line to test.
center - The center point of the circle.
radius - The radius of the circle.
Returns:
true if the line collides with the circle, false otherwise.
Since:
1.0

isPointWithinCollisionCircle

public static boolean isPointWithinCollisionCircle(org.lwjgl.util.vector.Vector2f point,
                                                   com.fs.starfarer.api.combat.CombatEntityAPI entity)
Checks if a point is inside the collision circle of a CombatEntityAPI.

Parameters:
point - The Vector2f to check.
entity - The CombatEntityAPI whose BoundsAPI we are checking against.
Returns:
true if point is within the collision circle of entity, false otherwise.
Since:
1.4

isPointWithinBounds

public static boolean isPointWithinBounds(org.lwjgl.util.vector.Vector2f point,
                                          com.fs.starfarer.api.combat.CombatEntityAPI entity)
Checks if a point is inside of the bounds of a CombatEntityAPI.

Parameters:
point - The Vector2f to check.
entity - The CombatEntityAPI whose BoundsAPI we are checking against.
Returns:
true if point is within the bounds of entity, false otherwise.
Since:
1.0

LazyLib