Class Polygon

  • All Implemented Interfaces:
    Shape

    public class Polygon
    extends java.lang.Object
    implements Shape
    Describes a two-dimensional convex polygon with float precision coordinates. The polygon is described by an array of points, e.g. [x0, y0, x1, y1, ...].
    • Field Summary

      • Fields inherited from interface nl.colorize.multimedialib.math.Shape

        EPSILON
    • Constructor Summary

      Constructors 
      Constructor Description
      Polygon​(float... points)  
    • Constructor Detail

      • Polygon

        public Polygon​(float... points)
    • Method Detail

      • setPoints

        public void setPoints​(float... points)
      • getPoints

        public float[] getPoints()
      • getNumPoints

        public int getNumPoints()
      • getPointX

        public float getPointX​(int n)
      • getPointY

        public float getPointY​(int n)
      • move

        public void move​(float dx,
                         float dy)
      • intersects

        public boolean intersects​(Polygon p)
        Returns true if this polygon intersects with the specified other polygon. Implementation based on http://slick.cokeandcode.com.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • createCircle

        public static Polygon createCircle​(Point2D origin,
                                           float radius,
                                           int numPoints)
        Convenience method to create a polygon in the shape of a circle with the specified properties.
      • createCone

        public static Polygon createCone​(Point2D origin,
                                         float startAngle,
                                         float arc,
                                         float length)
        Convenience method to create a polygon in the shape of a circle with the specified properties. The cone's start angle and arc are specified in degrees.