Documentation of 'math.geom2d.polygon.Polygons2D' Java class
Polygons2D
math.geom2d.polygon

Class Polygons2D



  • public final class Polygons2D
    extends java.lang.Object
    Several utility functions for working on polygons, including polygon creation, and basic computations such as polygon area or centroid.
    • Constructor Detail

      • Polygons2D

        public Polygons2D()
    • Method Detail

      • createRectangle

        public static final SimplePolygon2D createRectangle(Point2D p1,
                                                            Point2D p2)
        Creates a new polygon representing a rectangle with edges parallel to the main directions, and having the two specified opposite corners.
        Since:
        0.10.3
      • createRectangle

        public static final SimplePolygon2D createRectangle(double x1,
                                                            double y1,
                                                            double x2,
                                                            double y2)
        Creates a new polygon representing a rectangle with edges parallel to the main directions, and having the two specified opposite corners.
        Since:
        0.10.3
      • createCenteredRectangle

        public static final SimplePolygon2D createCenteredRectangle(Point2D center,
                                                                    double length,
                                                                    double width)
        Creates a new polygon representing a rectangle centered around a point. Rectangle sides are parallel to the main axes. The function returns an instance of SimplePolygon2D.
        Since:
        0.9.1
      • createOrientedRectangle

        public static final SimplePolygon2D createOrientedRectangle(Point2D center,
                                                                    double length,
                                                                    double width,
                                                                    double theta)
        Creates a new polygon representing an oriented rectangle centered around a point. The function returns an instance of SimplePolygon2D.
        Since:
        0.9.1
      • computeCentroid

        public static final Point2D computeCentroid(Polygon2D polygon)
        Computes the centroid of the given polygon.
        Since:
        0.9.1
      • computeCentroid

        public static final Point2D computeCentroid(LinearRing2D ring)
        Computes the centroid of the given linear ring.
        Since:
        0.9.1
      • computeArea

        public static final double computeArea(Polygon2D polygon)
        Computes the signed area of the polygon. Algorithm is taken from page: http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/. Signed area is positive if polygon is oriented counter-clockwise, and negative otherwise. Result is wrong if polygon is self-intersecting.
        Returns:
        the signed area of the polygon.
        Since:
        0.9.1
      • computeArea

        public static final double computeArea(LinearRing2D ring)
        Computes the signed area of the linear ring. Algorithm is taken from page: http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/. Signed area is positive if linear ring is oriented counter-clockwise, and negative otherwise. Result is wrong if linear ring is self-intersecting.
        Returns:
        the signed area of the polygon.
        Since:
        0.9.1
      • windingNumber

        public static final int windingNumber(java.util.Collection<Point2D> vertices,
                                              Point2D point)
        Computes the winding number of the polygon. Algorithm adapted from http://www.geometryalgorithms.com/Archive/algorithm_0103/algorithm_0103.htm http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm
        Parameters:
        vertices - the vertices of a polygon
        point - the reference point
        Returns:
        the number of windings of the curve around the point
      • convexHull

        public static final Polygon2D convexHull(java.util.Collection<? extends Point2D> points)
        Returns the convex hull of the given set of points. Uses the Jarvis March algorithm.
        Parameters:
        points - a collection of points
        Returns:
        the convex hull of the set of points

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.