Class Box2d

java.lang.Object
me.autobot.lib.math.coordinates.Box2d

public class Box2d extends Object
A class representing a 2D box.
  • Field Details

  • 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

      public Box2d(Int2 position, Int2 size)
      Creates a new 2D box object.
      Parameters:
      position - The position of the box.
      size - The size of the box.
  • Method Details

    • isInside

      public boolean isInside(Int2 point)
      Checks if the given point is inside the box.
      Parameters:
      point - The point to check.
      Returns:
      Whether the point is inside the box.
    • getPosition

      public Int2 getPosition()
      Returns the position of the box.
      Returns:
      The position of the box.
    • getSize

      public Int2 getSize()
      Returns the size of the box.
      Returns:
      The size of the box.
    • signedDistance

      public double signedDistance(Vector2d uv)
      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

      public double raycastDistance(Vector2d pos, Vector2d to)
      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

      public boolean intersectsRay(Vector2d start, Vector2d end)
      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

      public boolean lineIntersects(Vector2d start, Vector2d end)
      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

      public Vector2d[] getVertices()
      Gets the vertices of the box.
      Returns:
      The vertices of the box.