Class PlanarPolygon3D
- java.lang.Object
-
- org.locationtech.jts.operation.distance3d.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 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 int
facingPlane
private Plane3D
plane
private Polygon
poly
-
Constructor Summary
Constructors Constructor Description PlanarPolygon3D(Polygon poly)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private Vector3D
averageNormal(CoordinateSequence seq)
Computes an average normal vector from a list of polygon coordinates.private Coordinate
averagePoint(CoordinateSequence seq)
Computes a point which is the average of all coordinates in a sequence.private Plane3D
findBestFitPlane(Polygon poly)
Finds a best-fit plane for the polygon, by sampling a few points from the exterior ring.Plane3D
getPlane()
Polygon
getPolygon()
boolean
intersects(Coordinate intPt)
boolean
intersects(Coordinate pt, LineString ring)
private int
locate(Coordinate pt, LineString ring)
private static Coordinate
project(Coordinate p, int facingPlane)
private static CoordinateSequence
project(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)
-
-