public final class Planes extends Object
Plane
and PlaneSubset
instances.Modifier and Type | Method and Description |
---|---|
static ConvexPolygon3D |
convexPolygonFromVertices(Collection<Vector3D> pts,
Precision.DoubleEquivalence precision)
Create a new convex polygon from the given sequence of vertices.
|
static List<PlaneConvexSubset> |
extrude(LinePath path,
EmbeddingPlane plane,
Vector3D extrusionVector,
Precision.DoubleEquivalence precision)
Get the boundaries of the 3D region created by extruding a 2D line path.
|
static List<PlaneConvexSubset> |
extrude(RegionBSPTree2D region,
EmbeddingPlane plane,
Vector3D extrusionVector,
Precision.DoubleEquivalence precision)
Get the boundaries of the 3D region created by extruding a 2D region.
|
static List<PlaneConvexSubset> |
extrudeVertexLoop(List<Vector2D> vertices,
EmbeddingPlane plane,
Vector3D extrusionVector,
Precision.DoubleEquivalence precision)
Get the boundaries of a 3D region created by extruding a polygon defined by a list of vertices.
|
static Plane |
fromNormal(Vector3D normal,
Precision.DoubleEquivalence precision)
Build a plane from a normal.
|
static Plane |
fromPointAndNormal(Vector3D p,
Vector3D normal,
Precision.DoubleEquivalence precision)
Build a plane from a point and a normal.
|
static EmbeddingPlane |
fromPointAndPlaneVectors(Vector3D p,
Vector3D u,
Vector3D v,
Precision.DoubleEquivalence precision)
Build a plane from a point and two (on plane) vectors.
|
static Plane |
fromPoints(Collection<Vector3D> pts,
Precision.DoubleEquivalence precision)
Construct a plane from a collection of points lying on the plane.
|
static Plane |
fromPoints(Vector3D p1,
Vector3D p2,
Vector3D p3,
Precision.DoubleEquivalence precision)
Build a plane from three points.
|
static List<ConvexPolygon3D> |
indexedConvexPolygons(List<? extends Vector3D> vertices,
int[][] faceIndices,
Precision.DoubleEquivalence precision)
Construct a list of
ConvexPolygon3D instances from a set of vertices and arrays of face indices. |
static List<ConvexPolygon3D> |
indexedConvexPolygons(Vector3D[] vertices,
int[][] faceIndices,
Precision.DoubleEquivalence precision)
Construct a list of
ConvexPolygon3D instances from a set of vertices and arrays of face indices. |
static List<Triangle3D> |
indexedTriangles(List<? extends Vector3D> vertices,
int[][] faceIndices,
Precision.DoubleEquivalence precision)
Construct a list of
Triangle3D instances from a set of vertices and arrays of face indices. |
static List<Triangle3D> |
indexedTriangles(Vector3D[] vertices,
int[][] faceIndices,
Precision.DoubleEquivalence precision)
Construct a list of
Triangle3D instances from a set of vertices and arrays of face indices. |
static PlaneConvexSubset |
subsetFromConvexArea(EmbeddingPlane plane,
ConvexArea area)
Create a new plane subset from a plane and an embedded convex subspace area.
|
static Triangle3D |
triangleFromVertices(Vector3D p1,
Vector3D p2,
Vector3D p3,
Precision.DoubleEquivalence precision)
Construct a triangle from three vertices.
|
public static EmbeddingPlane fromPointAndPlaneVectors(Vector3D p, Vector3D u, Vector3D v, Precision.DoubleEquivalence precision)
p
- the provided point (on plane)u
- u vector (on plane)v
- v vector (on plane)precision
- precision context used to compare floating point valuesIllegalArgumentException
- if the norm of the given values is zero, NaN, or infinite.public static Plane fromNormal(Vector3D normal, Precision.DoubleEquivalence precision)
normal
- normal direction to the planeprecision
- precision context used to compare floating point valuesIllegalArgumentException
- if the norm of the given values is zero, NaN, or infinite.public static Plane fromPointAndNormal(Vector3D p, Vector3D normal, Precision.DoubleEquivalence precision)
p
- point belonging to the planenormal
- normal direction to the planeprecision
- precision context used to compare floating point valuesIllegalArgumentException
- if the norm of the given values is zero, NaN, or infinite.public static Plane fromPoints(Vector3D p1, Vector3D p2, Vector3D p3, Precision.DoubleEquivalence precision)
The plane is oriented in the direction of (p2-p1) ^ (p3-p1)
p1
- first point belonging to the planep2
- second point belonging to the planep3
- third point belonging to the planeprecision
- precision context used to compare floating point valuesIllegalArgumentException
- if the points do not define a unique planepublic static Plane fromPoints(Collection<Vector3D> pts, Precision.DoubleEquivalence precision)
u
vector for the plane is set to the first non-zero vector between
points in the sequence (ie, the first direction in the path).pts
- collection of sequenced points lying on the planeprecision
- precision context used to compare floating point valuesIllegalArgumentException
- if the given collection does not contain at least 3 points or the
points do not define a unique planepublic static PlaneConvexSubset subsetFromConvexArea(EmbeddingPlane plane, ConvexArea area)
plane
- embedding plane for the areaarea
- area embedded in the planepublic static ConvexPolygon3D convexPolygonFromVertices(Collection<Vector3D> pts, Precision.DoubleEquivalence precision)
pts
- collection of points defining the convex polygonprecision
- precision context used to compare floating point valuesIllegalArgumentException
- if fewer than 3 vertices are given or the vertices do not define a
unique planefromPoints(Collection, Precision.DoubleEquivalence)
public static Triangle3D triangleFromVertices(Vector3D p1, Vector3D p2, Vector3D p3, Precision.DoubleEquivalence precision)
p1
- first vertexp2
- second vertexp3
- third vertexprecision
- precision context used for floating point comparisonsIllegalArgumentException
- if the points do not define a unique planepublic static List<Triangle3D> indexedTriangles(Vector3D[] vertices, int[][] faceIndices, Precision.DoubleEquivalence precision)
Triangle3D
instances from a set of vertices and arrays of face indices.
For example, the following code constructs a list of triangles forming a square pyramid.
Precision.DoubleEquivalence precision = Precision.doubleEquivalenceOfEpsilon(1e-10); Vector3D[] vertices = { Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(1, 1, 0), Vector3D.of(0, 1, 0), Vector3D.of(0.5, 0.5, 4) }; int[][] faceIndices = { {0, 2, 1}, {0, 3, 2}, {0, 1, 4}, {1, 2, 4}, {2, 3, 4}, {3, 0, 4} }; List<Triangle3D> triangles = Planes.indexedTriangles(vertices, faceIndices, TEST_PRECISION);
vertices
- vertices available for use in triangle constructionfaceIndices
- array of indices for each triangular face; each entry in the array is an array of
3 index values into vertices
, defining the 3 vertices that will be used to construct the
triangleprecision
- precision context used for floating point comparisonsIllegalArgumentException
- if any face index array does not contain exactly 3 elements or a set
of 3 vertices do not define a planeIndexOutOfBoundsException
- if any index into vertices
is out of boundspublic static List<Triangle3D> indexedTriangles(List<? extends Vector3D> vertices, int[][] faceIndices, Precision.DoubleEquivalence precision)
Triangle3D
instances from a set of vertices and arrays of face indices.vertices
- vertices available for use in triangle constructionfaceIndices
- array of indices for each triangular face; each entry in the array is an array of
3 index values into vertices
, defining the 3 vertices that will be used to construct the
triangleprecision
- precision context used for floating point comparisonsIllegalArgumentException
- if any face index array does not contain exactly 3 elements or a set
of 3 vertices do not define a planeIndexOutOfBoundsException
- if any index into vertices
is out of boundsindexedTriangles(Vector3D[], int[][], Precision.DoubleEquivalence)
public static List<ConvexPolygon3D> indexedConvexPolygons(Vector3D[] vertices, int[][] faceIndices, Precision.DoubleEquivalence precision)
ConvexPolygon3D
instances from a set of vertices and arrays of face indices. Each
face must contain at least 3 vertices but the number of vertices per face does not need to be constant.
For example, the following code constructs a list of convex polygons forming a square pyramid.
Note that the first face (the pyramid base) uses a different number of vertices than the other faces.
Precision.DoubleEquivalence precision = Precision.doubleEquivalenceOfEpsilon(1e-10); Vector3D[] vertices = { Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(1, 1, 0), Vector3D.of(0, 1, 0), Vector3D.of(0.5, 0.5, 4) }; int[][] faceIndices = { {0, 3, 2, 1}, // square base {0, 1, 4}, {1, 2, 4}, {2, 3, 4}, {3, 0, 4} }; List<ConvexPolygon3D> polygons = Planes.indexedConvexPolygons(vertices, faceIndices, precision);
vertices
- vertices available for use in convex polygon constructionfaceIndices
- array of indices for each triangular face; each entry in the array is an array of
at least 3 index values into vertices
, defining the vertices that will be used to construct the
convex polygonprecision
- precision context used for floating point comparisonsIllegalArgumentException
- if any face index array does not contain at least 3 elements or a set
of vertices do not define a planar convex polygonIndexOutOfBoundsException
- if any index into vertices
is out of boundspublic static List<ConvexPolygon3D> indexedConvexPolygons(List<? extends Vector3D> vertices, int[][] faceIndices, Precision.DoubleEquivalence precision)
ConvexPolygon3D
instances from a set of vertices and arrays of face indices. Each
face must contain at least 3 vertices but the number of vertices per face does not need to be constant.vertices
- vertices available for use in convex polygon constructionfaceIndices
- array of indices for each triangular face; each entry in the array is an array of
at least 3 index values into vertices
, defining the vertices that will be used to construct the
convex polygonprecision
- precision context used for floating point comparisonsIllegalArgumentException
- if any face index array does not contain at least 3 elements or a set
of vertices do not define a planar convex polygonIndexOutOfBoundsException
- if any index into vertices
is out of boundsindexedConvexPolygons(Vector3D[], int[][], Precision.DoubleEquivalence)
public static List<PlaneConvexSubset> extrudeVertexLoop(List<Vector2D> vertices, EmbeddingPlane plane, Vector3D extrusionVector, Precision.DoubleEquivalence precision)
vertices
- vertices forming the 2D polygon to extrudeplane
- plane to extrude the 2D polygon fromextrusionVector
- vector to extrude the polygon vertices throughprecision
- precision context used to construct the 3D region boundariesIllegalStateException
- if vertices
contains only a single unique vertexIllegalArgumentException
- if regions of non-zero size cannot be produced with the
given plane and extrusion vector. This occurs when the extrusion vector has zero length
or is orthogonal to the plane normalLinePath.fromVertexLoop(Collection, Precision.DoubleEquivalence)
,
extrude(LinePath, EmbeddingPlane, Vector3D, Precision.DoubleEquivalence)
public static List<PlaneConvexSubset> extrude(LinePath path, EmbeddingPlane plane, Vector3D extrusionVector, Precision.DoubleEquivalence precision)
path
- path to extrudeplane
- plane to extrude the path fromextrusionVector
- vector to extrude the polygon points throughprecision
- precision precision context used to construct the 3D region boundariesIllegalArgumentException
- if regions of non-zero size cannot be produced with the
given plane and extrusion vector. This occurs when the extrusion vector has zero length
or is orthogonal to the plane normalextrude(RegionBSPTree2D, EmbeddingPlane, Vector3D, Precision.DoubleEquivalence)
public static List<PlaneConvexSubset> extrude(RegionBSPTree2D region, EmbeddingPlane plane, Vector3D extrusionVector, Precision.DoubleEquivalence precision)
region
- region to extrudeplane
- plane to extrude the region fromextrusionVector
- vector to extrude the region points throughprecision
- precision precision context used to construct the 3D region boundariesIllegalArgumentException
- if regions of non-zero size cannot be produced with the
given plane and extrusion vector. This occurs when the extrusion vector has zero length
or is orthogonal to the plane normalCopyright © 2016–2021 The Apache Software Foundation. All rights reserved.