Class Rectangle


public class Rectangle extends Polygon
Author:
Kai v. Maurik
  • Field Details

    • VERTICES_LENGTH

      public static final int VERTICES_LENGTH
      See Also:
    • x

      public float x
    • y

      public float y
    • width

      public float width
    • height

      public float height
  • Constructor Details

    • Rectangle

      public Rectangle(float width, float height)
    • Rectangle

      public Rectangle(float x, float y, float width, float height)
    • Rectangle

      public Rectangle(float x, float y, float width, float height, double rotation)
  • Method Details

    • contains

      public boolean contains(Vector2f point)
    • intersects

      public boolean intersects(Rectangle with)
    • intersectsLazy

      public boolean intersectsLazy(Rectangle with)
    • getVertices

      public Vector2f[] getVertices()
      Translates bounds to vertices.
      Overrides:
      getVertices in class Polygon
      Returns:
      vertices of rectangle
    • getAxes

      public Vector2f[] getAxes()
      Gets the normalized axes of every edge of the Polygon. This is used in for collision detection. Because this is a Rectangle object, only 2 axes are required to check.
      Overrides:
      getAxes in class Polygon
      Returns:
      axes of all edges.
      See Also:
    • getCenter

      public Vector2f getCenter()
      Overrides:
      getCenter in class Shape
    • getWidth

      public float getWidth()
    • setWidth

      public void setWidth(float width)
    • getHeight

      public float getHeight()
    • setHeight

      public void setHeight(float height)
    • getX

      public float getX()
    • setX

      public void setX(float x)
    • getY

      public float getY()
    • setY

      public void setY(float y)