Class Polygon

java.lang.Object
org.alban098.physics2j.Polygon

public class Polygon extends Object
The Polygon class encapsulates a description of a closed, two-dimensional region within a coordinate space. This region is bounded by an arbitrary number of line segments, each of which is one side of the polygon. Internally, a polygon comprises of a list of (x,y) coordinate pairs, where each pair defines a vertex of the polygon, and two successive pairs are the endpoints of a line that is a side of the polygon. The first and final pairs of (x,y) points are joined by a line segment that closes the polygon. This Polygon is defined with an even-odd winding rule. See WIND_EVEN_ODD for a definition of the even-odd winding rule. This class's hit-testing methods, which include the contains, intersects and inside methods, use the insideness definition described in the Shape class comments.
Since:
1.0
Author:
Sami Shaio, Herb Jellinek
See Also:
  • Field Details

    • npoints

      public int npoints
    • xpoints

      public float[] xpoints
    • ypoints

      public float[] ypoints
    • bounds

      protected Rectangle2D bounds
    • MIN_LENGTH

      private static final int MIN_LENGTH
      See Also:
  • Constructor Details

    • Polygon

      public Polygon()
    • Polygon

      public Polygon(float[] xpoints, float[] ypoints, int npoints)
  • Method Details

    • reset

      public void reset()
    • invalidate

      public void invalidate()
    • translate

      public void translate(float deltaX, float deltaY)
    • calculateBounds

      void calculateBounds(float[] xpoints, float[] ypoints, int npoints)
    • updateBounds

      void updateBounds(float x, float y)
    • addPoint

      public void addPoint(float x, float y)
    • getBoundingBox

      public Rectangle2D getBoundingBox()
    • inside

      @Deprecated public boolean inside(float x, float y)
      Deprecated.
    • contains

      public boolean contains(float x, float y)
    • contains

      public boolean contains(Point2D p)
    • getPathIterator

      public PathIterator getPathIterator(AffineTransform at)
    • getPathIterator

      public PathIterator getPathIterator(AffineTransform at, double flatness)
    • getCenter

      public org.joml.Vector2f getCenter()
    • getMomentOfInertia

      public float getMomentOfInertia(float m)