public class Plane extends AbstractHyperplane<Vector3D>
normal
and an origin offset
. If \(\vec{n}\) is the plane normal,
\(d\) is the origin offset, and \(p\) and \(q\) are any points in the plane, then the following are true:
origin offset
is equal to the
negation of the dot product of the normal and any point in the plane. The projection of the origin onto the
plane (given by getOrigin()
), is computed as \(-d \vec{n}\).
Instances of this class are guaranteed to be immutable.
Planes
Modifier and Type | Method and Description |
---|---|
boolean |
contains(Line3D line)
Check if the instance contains a line.
|
boolean |
contains(Plane plane)
Check if the instance contains another plane.
|
boolean |
contains(Vector3D p)
Check if the instance contains a point.
|
boolean |
eq(Plane other,
Precision.DoubleEquivalence precision)
Return true if this instance should be considered equivalent to the argument, using the
given precision context for comparison.
|
boolean |
equals(Object obj) |
EmbeddingPlane |
getEmbedding()
Return an
EmbeddingPlane instance suitable for embedding 2D geometric objects
into this plane. |
Vector3D.Unit |
getNormal()
Get the plane normal vector.
|
Vector3D |
getOrigin()
Get the orthogonal projection of the 3D-space origin in the plane.
|
double |
getOriginOffset()
Get the offset of the spatial origin (
0, 0, 0 ) with respect to the plane. |
int |
hashCode() |
Vector3D |
intersection(Line3D line)
Get the intersection of a line with this plane.
|
Line3D |
intersection(Plane other)
Get the line formed by the intersection of this instance with the given plane.
|
static Vector3D |
intersection(Plane plane1,
Plane plane2,
Plane plane3)
Get the intersection point of three planes.
|
boolean |
isParallel(Line3D line)
Check if the line is parallel to the instance.
|
boolean |
isParallel(Plane plane)
Check if the plane is parallel to the instance.
|
double |
offset(Line3D line)
Get the offset (oriented distance) of the given line with respect to the plane.
|
double |
offset(Plane plane)
Get the offset (oriented distance) of the given plane with respect to this instance.
|
double |
offset(Vector3D point) |
Line3D |
project(Line3D line)
Project a 3D line onto the plane.
|
Vector3D |
project(Vector3D point) |
Plane |
reverse()
Build a new reversed version of this plane, with opposite orientation.
|
Plane |
rotate(Vector3D center,
QuaternionRotation rotation)
Rotate the plane around the specified point.
|
boolean |
similarOrientation(Hyperplane<Vector3D> other) |
PlaneConvexSubset |
span() |
String |
toString() |
Plane |
transform(Transform<Vector3D> transform) |
Plane |
translate(Vector3D translation)
Translate the plane by the specified amount.
|
classify, getPrecision
public Vector3D getOrigin()
public double getOriginOffset()
0, 0, 0
) with respect to the plane.public Vector3D.Unit getNormal()
public EmbeddingPlane getEmbedding()
EmbeddingPlane
instance suitable for embedding 2D geometric objects
into this plane. Returned instances are guaranteed to be equal between invocations.public double offset(Line3D line)
line
- line to calculate the offset ofpublic double offset(Plane plane)
plane
- plane to calculate the offset ofpublic boolean contains(Vector3D p)
contains
in interface Hyperplane<Vector3D>
contains
in class AbstractHyperplane<Vector3D>
p
- point to checkpublic boolean contains(Line3D line)
line
- line to checkpublic boolean contains(Plane plane)
plane
- plane to which the instance is comparedpublic Line3D project(Line3D line)
line
- the line to projectpublic PlaneConvexSubset span()
public boolean isParallel(Line3D line)
line
- line to check.public boolean isParallel(Plane plane)
plane
- plane to check.public boolean similarOrientation(Hyperplane<Vector3D> other)
public Vector3D intersection(Line3D line)
line
- line intersecting the instancepublic Line3D intersection(Plane other)
n1 x n2
, where n1
is the normal of the current instance and n2
is the normal
of the argument.
Null is returned if the planes are parallel.
other
- other planepublic Plane reverse()
public Plane transform(Transform<Vector3D> transform)
Instances are transformed by selecting 3 representative points from the
plane, transforming them, and constructing a new plane from the transformed points.
Since the normal is not transformed directly, but rather is constructed new from the
transformed points, the relative orientations of points in the plane are preserved,
even for transforms that do not
preserve orientation
. The example below shows
a plane being transformed by a non-orientation-preserving transform. The normal of the
transformed plane retains its counterclockwise relationship to the points in the plane,
in contrast with the normal that is transformed directly by the transform.
// construct a plane from 3 points; the normal will be selected such that the // points are ordered counterclockwise when looking down the plane normal. Vector3D p1 = Vector3D.of(0, 0, 0); Vector3D p2 = Vector3D.of(+1, 0, 0); Vector3D p3 = Vector3D.of(0, +1, 0); Plane plane = Planes.fromPoints(p1, p2, p3, precision); // normal is (0, 0, +1) // create a transform that negates all x-values; this transform does not // preserve orientation, i.e. it will convert a right-handed system into a left-handed // system and vice versa AffineTransformMatrix3D transform = AffineTransformMatrix3D.createScale(-1, 1, 1); // transform the plane Plane transformedPlane = plane.transform(transform); // the plane normal is oriented such that transformed points are still ordered // counterclockwise when looking down the plane normal; since the point (1, 0, 0) has // now become (-1, 0, 0), the normal has flipped to (0, 0, -1) transformedPlane.getNormal(); // directly transform the original plane normal; the normal is unchanged by the transform // since the target space of the transform is left-handed AffineTransformMatrix3D normalTransform = transform.normalTransform(); Vector3D directlyTransformedNormal = normalTransform.apply(plane.getNormal()); // (0, 0, +1)
public Plane translate(Vector3D translation)
translation
- translation to applypublic Plane rotate(Vector3D center, QuaternionRotation rotation)
center
- rotation centerrotation
- 3-dimensional rotationpublic boolean eq(Plane other, Precision.DoubleEquivalence precision)
origins
and normals
.other
- the point to compare withprecision
- precision context to use for the comparisonVector3D.eq(Vector3D, Precision.DoubleEquivalence)
public static Vector3D intersection(Plane plane1, Plane plane2, Plane plane3)
plane1
- first plane1plane2
- second plane2plane3
- third plane2Copyright © 2016–2021 The Apache Software Foundation. All rights reserved.