Class PlanarPolygon3D
- java.lang.Object
-
- org.locationtech.jts.operation.distance3d.PlanarPolygon3D
-
public class PlanarPolygon3D extends java.lang.ObjectModels a polygon lying in a plane in 3-dimensional Cartesian space. The polygon representation is supplied by aPolygon, 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 aPlane3D.
-
-
Field Summary
Fields Modifier and Type Field Description private intfacingPlaneprivate Plane3Dplaneprivate Polygonpoly
-
Constructor Summary
Constructors Constructor Description PlanarPolygon3D(Polygon poly)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private Vector3DaverageNormal(CoordinateSequence seq)Computes an average normal vector from a list of polygon coordinates.private CoordinateaveragePoint(CoordinateSequence seq)Computes a point which is the average of all coordinates in a sequence.private Plane3DfindBestFitPlane(Polygon poly)Finds a best-fit plane for the polygon, by sampling a few points from the exterior ring.Plane3DgetPlane()PolygongetPolygon()booleanintersects(Coordinate intPt)booleanintersects(Coordinate pt, LineString ring)private intlocate(Coordinate pt, LineString ring)private static Coordinateproject(Coordinate p, int facingPlane)private static CoordinateSequenceproject(CoordinateSequence seq, 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)
-
locate
private int locate(Coordinate pt, LineString ring)
-
intersects
public boolean intersects(Coordinate pt, LineString ring)
-
project
private static CoordinateSequence project(CoordinateSequence seq, int facingPlane)
-
project
private static Coordinate project(Coordinate p, int facingPlane)
-
-