Class Polygon

java.lang.Object
buildengine.math.shape.Shape
buildengine.math.shape.Polygon
Direct Known Subclasses:
Line, Rectangle

public abstract class Polygon extends Shape
Polygon All not-round shapes. For example a triangle.
Author:
Kai v. Maurik
See Also:
  • Field Details

    • VERTICES_LENGTH

      public static final int VERTICES_LENGTH
      Default vertices length
      See Also:
    • vertices

      protected final Vector2f[] vertices
      Vertices of the Polygon. The vertices are to be CW(Counter-Clockwise) defined.
    • rotation

      protected double rotation
  • Constructor Details

    • Polygon

      public Polygon(Vector2f[] vertices, float diameter, Vector2f center)
      Parameters:
      vertices - Specifies how many cords the Polygon consists of.
      center - The default center for rotation calculations.
    • Polygon

      public Polygon(Vector2f[] vertices, Vector2f center, float diameter, double rotation)
      Parameters:
      vertices - Specifies how many cords the Polygon consists of.
      center - The default center for rotation calculations.
      rotation - The rotation of the object.
  • Method Details

    • project

      public SAT.Projection project(Vector2f axis)
      Project vertices on an axis
      Returns:
      A new Projection object.
      See Also:
    • getAxes

      public Vector2f[] getAxes()
      Gets the normalized axes of every edge of the Polygon. This is used in for collision detection.
      Returns:
      axes of all edges.
    • getVertices

      public Vector2f[] getVertices()
      Returns:
      vertices of Polygon
    • getRotation

      public double getRotation()
    • setRotation

      public void setRotation(double rotation)