public class Plane
extends java.lang.Object
implements java.io.Serializable
T n x - d = 0where n is the plane normal and d is the offset.
Modifier and Type | Field and Description |
---|---|
Vector3d |
normal
Plane normal
|
double |
offset
Plane offset (distance of the origin from the plane)
|
Constructor and Description |
---|
Plane()
Creates a plane initialized to the x-y plane.
|
Plane(double nx,
double ny,
double nz,
double off)
Creates a plane from normal components and the an offset value.
|
Plane(Plane p)
Creates a plane initialized to another plane.
|
Plane(Point3d p1,
Point3d p2,
Point3d p3)
Constructs a plane given three non-colinear points arranged
counter-clockwise around the normal.
|
Plane(RigidTransform3d TPW)
Creates a plane from the x-y plane of the coordinate frame indicated
by
TPW . |
Plane(Vector3d n,
double d)
Creates a plane with a specified normal and offset.
|
Plane(Vector3d n,
Vector3d p)
Creates a plane which passes through a particular point with a specified
normal direction.
|
Modifier and Type | Method and Description |
---|---|
double |
distance(Vector3d p)
Returns the signed distance between a point and this plane.
|
boolean |
epsilonEquals(Plane plane,
double eps) |
boolean |
equals(Plane plane) |
void |
fit(java.util.Collection<Point3d> pnts)
Fits this plane to a collection of points.
|
void |
fit(Point3d[] pnts,
int num)
Fits this plane to a set of points.
|
void |
flip() |
Vector3d |
getNormal()
Returns the normal for this plane.
|
double |
getOffset()
Returns the offset for this plane.
|
double |
intersectLine(Point3d isect,
Vector3d dir,
Vector3d pnt)
Intersects this plane with a line.
|
boolean |
intersectPlane(Point3d pnt,
Vector3d dir,
Plane plane)
Intersects this plane with another plane.
|
boolean |
intersectRay(Point3d isect,
Vector3d dir,
Vector3d origin)
Intersects this plane with a directed ray.
|
void |
inverseTransform(AffineTransform3dBase X)
Applies an inverse affine transformation to this plane, in place.
|
void |
inverseTransform(AffineTransform3dBase X,
Plane plane)
Applies an inverse affine transformation to a specified plane and places
the result in this plane.
|
void |
inverseTransform(RigidTransform3d X)
Applies an inverse rigid transformation to this plane, in place.
|
void |
inverseTransform(RigidTransform3d X,
Plane plane)
Applies an inverse rigid transformation to a specified plane and places
the result in this plane.
|
void |
inverseTransform(VectorTransformer3d T)
Applies an inverse vector transform to this place.
|
void |
inverseTransform(VectorTransformer3d T,
Plane plane)
Applies an inverse vector transform to a plane and places
the result in this plane.
|
double |
project(Point3d pr,
Point3d p1)
Projects a point onto this plane, and returns the signed distance of the
original point from the plane.
|
void |
projectVector(Vector3d vr,
Vector3d v1)
Projects a vector onto this plane, by removing any component
that is perpendicular to it.
|
void |
reflect(Point3d pr,
Point3d p1)
Reflects a point about this plane.
|
void |
scale(double s)
Scales the units of this plane by the specified scale factor.
|
void |
scan(ReaderTokenizer rtok)
Sets the contents of this plane to values read from a ReaderTokenizer.
|
void |
set(double nx,
double ny,
double nz,
double d)
Sets the plane to the indicated normal direction and offset.
|
void |
set(Plane p)
Sets this plane to the values of another plane.
|
void |
set(Point3d p1,
Point3d p2,
Point3d p3)
Sets this plane to pass through three non-colinear points arranged
counter-clockwise around the normal.
|
void |
set(RigidTransform3d X)
Sets this plane to the x-y plane defined by a RigidTransformation.
|
void |
set(Vector3d n,
double d)
Sets the plane to the indicated normal direction and offset.
|
void |
set(Vector3d n,
Vector3d p)
Sets this plane to pass through a particular point with a specified normal
direction.
|
void |
setNormal(Vector3d nrm) |
void |
setOffset(double o) |
void |
setRandom() |
java.lang.String |
toString()
Returns a String representation of this Plane, consisting of the x, y, and
z components of the normal, followed by the offset.
|
java.lang.String |
toString(NumberFormat fmt)
Returns a String representation of this Plane, consisting of the x, y, and
z components of the normal, followed by the offset.
|
java.lang.String |
toString(java.lang.String fmtStr)
Returns a String representation of this Plane, consisting of the x, y, and
z components of the normal, followed by the offset.
|
void |
transform(AffineTransform3dBase X)
Applies an affine transformation to this plane, in place.
|
void |
transform(AffineTransform3dBase X,
Plane plane)
Applies an affine transformation to a specified plane and places the
result in this plane.
|
void |
transform(RigidTransform3d X)
Applies a rigid transformation to this plane, in place.
|
void |
transform(RigidTransform3d X,
Plane plane)
Applies a rigid transformation to a specified plane and places the
result in this plane.
|
void |
transform(VectorTransformer3d T)
Applies a vector transform to this plane.
|
void |
transform(VectorTransformer3d T,
Plane plane)
Applies a vector transform to a plane and places the result in this plane.
|
public Vector3d normal
public double offset
public Plane()
public Plane(Plane p)
p
- plane to copypublic Plane(RigidTransform3d TPW)
TPW
. The plane passes through the frame origin and its
normal is aligned with the frames's z axis.TPW
- transform defining the planepublic Plane(Vector3d n, Vector3d p)
n
- normal directionp
- point to pass throughpublic Plane(double nx, double ny, double nz, double off)
nx
- normal x componentny
- normal y componentnz
- normal z componentoff
- offset valuepublic Plane(Vector3d n, double d)
n
- normal directiond
- offset (equal to the dot product of the normal and every point on the
plane).public Plane(Point3d p1, Point3d p2, Point3d p3) throws java.lang.IllegalArgumentException
p1
- first pointp2
- second pointp3
- third pointjava.lang.IllegalArgumentException
- if the points are colinearpublic void set(Plane p)
p
- plane to copypublic void set(Vector3d n, double d)
n
- normal directiond
- offsetpublic void set(double nx, double ny, double nz, double d)
nx
- x component of normal directionny
- y component of normal directionnz
- z component of normal directiond
- offsetpublic void set(Vector3d n, Vector3d p)
n
- normal directionp
- point to pass throughpublic void set(RigidTransform3d X)
X
- transformation defining the planepublic void set(Point3d p1, Point3d p2, Point3d p3) throws java.lang.IllegalArgumentException
p1
- first pointp2
- second pointp3
- third pointjava.lang.IllegalArgumentException
- if the points are colinearpublic void flip()
public double distance(Vector3d p)
p
- point to compute distance forpublic double project(Point3d pr, Point3d p1)
pr
- projected pointp1
- point to projectpublic void projectVector(Vector3d vr, Vector3d v1)
vr
- returns the projected vectorv1
- vector to projectpublic void reflect(Point3d pr, Point3d p1)
pr
- reflected pointp1
- point to reflectpublic boolean intersectRay(Point3d isect, Vector3d dir, Vector3d origin)
isect
- intersection pointdir
- direction of the rayorigin
- origin of the raypublic double intersectLine(Point3d isect, Vector3d dir, Vector3d pnt)
isect
- intersection point (optional)dir
- vector in the direction of the linepnt
- point lying on the linepublic boolean intersectPlane(Point3d pnt, Vector3d dir, Plane plane)
false
and the point and direction are undefined. In
that case the offsets should be compared to see if the planes are
coincident.pnt
- returns a point on the intersection line.dir
- returns a unit vector in the direction of the intersection line.plane
- plane to intersecttrue
if the planes intersect in a line
or false
if they are parallel.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(java.lang.String fmtStr)
printf
style format string. For a
description of the format string syntax, see
NumberFormat
.fmtStr
- numeric format specificationpublic java.lang.String toString(NumberFormat fmt)
printf
style as decribed by the
parameter NumberFormat
. When called numerous times, this
routine can be more efficient than
toString(String)
, because the NumberFormat
does not need to be recreated each
time from a specification string.fmt
- numeric formatpublic void transform(AffineTransform3dBase X)
X
- affine transformationpublic void inverseTransform(AffineTransform3dBase X)
X
- affine transformationpublic void transform(AffineTransform3dBase X, Plane plane)
X
- affine transformationplane
- plane to transformpublic void transform(VectorTransformer3d T)
T
- vector transformerpublic void transform(VectorTransformer3d T, Plane plane)
T
- vector transformerplane
- plane to be transformedpublic void inverseTransform(VectorTransformer3d T, Plane plane)
T
- vector transformerplane
- plane to be transformedpublic void inverseTransform(VectorTransformer3d T)
T
- vector transformerpublic void inverseTransform(AffineTransform3dBase X, Plane plane)
X
- affine transformationplane
- plane to transformpublic void transform(RigidTransform3d X)
X
- rigid transformationpublic void inverseTransform(RigidTransform3d X)
X
- rigid transformationpublic void transform(RigidTransform3d X, Plane plane)
X
- rigid transformationplane
- plane to transformpublic void inverseTransform(RigidTransform3d X, Plane plane)
X
- rigid transformationplane
- plane to transformpublic void scale(double s)
s
- scale factor by which to scale planepublic Vector3d getNormal()
public void setNormal(Vector3d nrm)
public double getOffset()
public void setOffset(double o)
public void scan(ReaderTokenizer rtok) throws java.io.IOException
[ ]
.rtok
- Tokenizer from which vector values are read. Number parsing should be
enabled.java.io.IOException
- if an I/O or formatting error is encounteredpublic void fit(java.util.Collection<Point3d> pnts)
pnts
- points to fitpublic void fit(Point3d[] pnts, int num)
pnts
- points to fitnum
- number of pointspublic void setRandom()
public boolean equals(Plane plane)
public boolean epsilonEquals(Plane plane, double eps)