Class PlanarPolygon3D


  • public class PlanarPolygon3D
    extends java.lang.Object
    Models a polygon lying in a plane in 3-dimensional Cartesian space. The polygon representation is supplied by a Polygon, containing coordinates with XYZ ordinates. 3D polygons are assumed to lie in a single plane. The plane best fitting the polygon coordinates is computed and is represented by a Plane3D.
    • Field Detail

      • facingPlane

        private int facingPlane
    • Constructor Detail

      • PlanarPolygon3D

        public PlanarPolygon3D​(Polygon poly)
    • Method Detail

      • findBestFitPlane

        private Plane3D findBestFitPlane​(Polygon poly)
        Finds a best-fit plane for the polygon, by sampling a few points from the exterior ring.

        The algorithm used is Newell's algorithm: - a base point for the plane is determined from the average of all vertices - the normal vector is determined by computing the area of the projections on each of the axis planes

        Parameters:
        poly - the polygon to determine the plane for
        Returns:
        the best-fit plane
      • averageNormal

        private Vector3D averageNormal​(CoordinateSequence seq)
        Computes an average normal vector from a list of polygon coordinates. Uses Newell's method, which is based on the fact that the vector with components equal to the areas of the projection of the polygon onto the Cartesian axis planes is normal.
        Parameters:
        seq - the sequence of coordinates for the polygon
        Returns:
        a normal vector
      • averagePoint

        private Coordinate averagePoint​(CoordinateSequence seq)
        Computes a point which is the average of all coordinates in a sequence. If the sequence lies in a single plane, the computed point also lies in the plane.
        Parameters:
        seq - a coordinate sequence
        Returns:
        a Coordinate with averaged ordinates
      • getPlane

        public Plane3D getPlane()
      • getPolygon

        public Polygon getPolygon()
      • intersects

        public boolean intersects​(Coordinate intPt)