public class PlanarPolygon3D
extends java.lang.Object
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
.Modifier and Type | Field and Description |
---|---|
private int |
facingPlane |
private Plane3D |
plane |
private Polygon |
poly |
Constructor and Description |
---|
PlanarPolygon3D(Polygon poly) |
Modifier and Type | Method and 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) |
private Plane3D plane
private Polygon poly
private int facingPlane
public PlanarPolygon3D(Polygon poly)
private Plane3D findBestFitPlane(Polygon poly)
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
poly
- the polygon to determine the plane forprivate Vector3D averageNormal(CoordinateSequence seq)
seq
- the sequence of coordinates for the polygonprivate Coordinate averagePoint(CoordinateSequence seq)
seq
- a coordinate sequencepublic Plane3D getPlane()
public Polygon getPolygon()
public boolean intersects(Coordinate intPt)
private int locate(Coordinate pt, LineString ring)
public boolean intersects(Coordinate pt, LineString ring)
private static CoordinateSequence project(CoordinateSequence seq, int facingPlane)
private static Coordinate project(Coordinate p, int facingPlane)