Class Polygon

java.lang.Object
rekit.primitives.geometry.Polygon
All Implemented Interfaces:
Cloneable

public final class Polygon extends Object implements Cloneable
This class defines a polygon.
  • Constructor Details

    • Polygon

      public Polygon(Vec startPoint, Vec[] relPts)
      Create the polygon by start position and other points.
      Parameters:
      startPoint - the first point's position in units
      relPts - the relative positions of the next points relative to startPoint in units
  • Method Details

    • getStartPoint

      public Vec getStartPoint()
      Get the start point of the polygon.
      Returns:
      the start point in units
    • clone

      public Polygon clone()
      Overrides:
      clone in class Object
    • moveTo

      public void moveTo(Vec targetLocation)
      Move a polygon to target location.
      Parameters:
      targetLocation - the target location in units
    • addRelPt

      public void addRelPt(Vec relPt)
      Add a new relative point.
      Parameters:
      relPt - the point
    • rotate

      public Polygon rotate(float angle)
      Rotate the polygon by angle.
      Parameters:
      angle - the angle
      Returns:
      the rotated polygon
    • rotate

      public Polygon rotate(float angle, Vec rotationAnchor)
      Rotate the polygon by angle and anchor.
      Parameters:
      angle - the angle
      rotationAnchor - the rotation anchor in units
      Returns:
      the rotated polygon
    • getAbsoluteArray

      public float[] getAbsoluteArray()
      Get the absolute positions of all points.
      Returns:
      the points in units
    • scale

      public Polygon scale(float scale)
      Scale this polygon.
      Parameters:
      scale - the factor
      Returns:
      the result polygon