Package me.autobot.lib.math.coordinates
Class Box2d
java.lang.Object
me.autobot.lib.math.coordinates.Box2d
A class representing a 2D box.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the position of the box.getSize()Returns the size of the box.Vector2d[]Gets the vertices of the box.booleanintersectsRay(Vector2d start, Vector2d end) Checks if the box intersects with a ray.booleanChecks if the given point is inside the box.booleanlineIntersects(Vector2d start, Vector2d end) Checks if the box intersects with a linedoubleraycastDistance(Vector2d pos, Vector2d to) Figures out the distance between the box and a point looking in a certain direction.doubleReturns the signed distance between the box and the given point.
-
Field Details
-
flags
All flags on the robot.
-
-
Constructor Details
-
Box2d
public Box2d(int x, int y, int width, int height) Creates a new 2D box object.- Parameters:
x- The x position of the box.y- The y position of the box.width- The width of the box.height- The height of the box.
-
Box2d
Creates a new 2D box object.- Parameters:
position- The position of the box.size- The size of the box.
-
-
Method Details
-
isInside
Checks if the given point is inside the box.- Parameters:
point- The point to check.- Returns:
- Whether the point is inside the box.
-
getPosition
Returns the position of the box.- Returns:
- The position of the box.
-
getSize
Returns the size of the box.- Returns:
- The size of the box.
-
signedDistance
Returns the signed distance between the box and the given point.- Parameters:
uv- The point to calculate the distance to.- Returns:
- The signed distance between the box and the given point.
-
raycastDistance
Figures out the distance between the box and a point looking in a certain direction.- Parameters:
pos- The position to start from.to- The position to look at.- Returns:
- The distance between the box and the point.
-
intersectsRay
Checks if the box intersects with a ray.- Parameters:
start- The start of the ray.end- The end of the ray.- Returns:
- Whether the box intersects with the ray.
-
lineIntersects
Checks if the box intersects with a line- Parameters:
start- The start of the line.end- The end of the line.- Returns:
- Whether the box intersects with the line.
-
getVertices
Gets the vertices of the box.- Returns:
- The vertices of the box.
-