Package cz.fidentis.analyst.data.shapes
Class Plane
java.lang.Object
cz.fidentis.analyst.data.shapes.Plane
- All Implemented Interfaces:
Serializable
Immutable symmetry plane.
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Plane
(double distance) Copy constructor without normalization.Copy constructor with possible normalization.Creates average plane from existing planes.Plane
(javax.vecmath.Point3d p1, javax.vecmath.Point3d p2, javax.vecmath.Point3d p3) Construction from three points.Plane
(javax.vecmath.Tuple3d point) Construction from a 3D point.Plane
(javax.vecmath.Tuple3d normal, double dist) Constructor.Plane
(javax.vecmath.Tuple3d point1, javax.vecmath.Tuple3d point2) Symmetry plane constructed from two points. -
Method Summary
Modifier and TypeMethodDescriptionboolean
flip()
Returns a plane with flipped directionjavax.vecmath.Matrix4d
getAlignmentMatrix
(Plane other, boolean forbidRotation) Computes and returns transformation matrix that transforms given plane into this plane.double
protected javax.vecmath.Vector3d
Returns a normalized vector laying on the plane and directing ahead (toward the plus Z axis).javax.vecmath.Point3d
getIntersectionWithLine
(javax.vecmath.Point3d p1, javax.vecmath.Point3d p2) Calculates an intersection of a plane and a line given by two pointsReturns rectangular mesh facet of this symmetry plane.getMesh
(javax.vecmath.Point3d point, double width, double height) Returns rectangular mesh facet of this symmetry plane.javax.vecmath.Vector3d
Returns reference to the normal vectorjavax.vecmath.Point3d
Returns a point laying at the planedouble
getPointDistance
(javax.vecmath.Point3d point) Returns distance of the point from the plane.protected javax.vecmath.Vector3d
Returns a normalized vector laying on the plane and directing right (toward the plus X axis).protected static javax.vecmath.Matrix4d
getRotationAroundAxis
(javax.vecmath.Vector3d targetV, javax.vecmath.Vector3d trV, javax.vecmath.Vector3d axis) Computes transformation matrix that rotates the given normal vector so that it fits our normal vector.protected javax.vecmath.Vector3d
Returns a normalized vector laying on the plane and directing up (toward the plus Y axis).int
hashCode()
javax.vecmath.Point3d
projectToPlane
(javax.vecmath.Point3d point) Returns a point laying on the plane.javax.vecmath.Point3d
reflectPointOverPlane
(javax.vecmath.Point3d point) Returns a point laying on the opposite side of the plane ("mirrors" the point).javax.vecmath.Vector3d
reflectUnitVectorOverPlane
(javax.vecmath.Vector3d vector) Reflects the give unit vector over this plane.void
Rotates plane over Y axis by 90 degrees.void
Rotates plane over Z axis by 90 degrees.protected final void
setNormal
(javax.vecmath.Tuple3d normal) Changes the normal vector.shift
(double value) Translate the plane along its normaltoString()
Returns string description of the plane
-
Constructor Details
-
Plane
public Plane(javax.vecmath.Tuple3d normal, double dist) Constructor.- Parameters:
normal
- Normalized (!) normal vector of the planedist
- distance- Throws:
IllegalArgumentException
- if the @code{plane} argument is null
-
Plane
Copy constructor with possible normalization.- Parameters:
plane
- original planenormalize
- normalize the normal vector and distance- Throws:
IllegalArgumentException
- if the @code{plane} argument is null
-
Plane
Copy constructor without normalization.- Parameters:
plane
- original plane- Throws:
IllegalArgumentException
- if the @code{plane} argument is null
-
Plane
public Plane(javax.vecmath.Tuple3d point) Construction from a 3D point.- Parameters:
point
- point in space- Throws:
IllegalArgumentException
- if the @code{plane} argument is null
-
Plane
public Plane(javax.vecmath.Tuple3d point1, javax.vecmath.Tuple3d point2) Symmetry plane constructed from two points.- Parameters:
point1
- point in spacepoint2
- point in space- Throws:
IllegalArgumentException
- if the @code{plane} argument is null
-
Plane
public Plane(javax.vecmath.Point3d p1, javax.vecmath.Point3d p2, javax.vecmath.Point3d p3) Construction from three points.- Parameters:
p1
- A first point from the planep2
- A second point from the planep3
- A third point from the plane- Throws:
NullPointerException
- if some point is missing
-
Plane
Creates average plane from existing planes.- Parameters:
planes
- Source planes, at leas two- Throws:
IllegalArgumentException
- if theplanes
list isnull
or empty
-
Plane
protected Plane(double distance)
-
-
Method Details
-
hashCode
public int hashCode() -
equals
-
toString
Returns string description of the plane -
getDistance
public double getDistance() -
getPlanePoint
public javax.vecmath.Point3d getPlanePoint()Returns a point laying at the plane- Returns:
- a point laying at the plane
-
getUpPlanarVector
protected javax.vecmath.Vector3d getUpPlanarVector()Returns a normalized vector laying on the plane and directing up (toward the plus Y axis).- Returns:
- a normalized vector laying on the plane and directing up
(toward the plus Y axis) or
null
-
getRightPlanarVector
protected javax.vecmath.Vector3d getRightPlanarVector()Returns a normalized vector laying on the plane and directing right (toward the plus X axis).- Returns:
- a normalized vector laying on the plane and directing up
(toward the plus X axis) or
null
-
getFrontPlanarVector
protected javax.vecmath.Vector3d getFrontPlanarVector()Returns a normalized vector laying on the plane and directing ahead (toward the plus Z axis).- Returns:
- a normalized vector laying on the plane and directing ahead
(toward the plus Z axis) or
null
-
shift
Translate the plane along its normal- Parameters:
value
- a value to be added to the current plane's distance value- Returns:
- shifted plane
-
flip
Returns a plane with flipped direction- Returns:
- a plane with flipped direction
-
getAlignmentMatrix
Computes and returns transformation matrix that transforms given plane into this plane.- Parameters:
other
- plane to be transformedforbidRotation
- Iffalse
, then the rotation around the normal is ignored.- Returns:
- transformation matrix or
null
-
projectToPlane
public javax.vecmath.Point3d projectToPlane(javax.vecmath.Point3d point) Returns a point laying on the plane.- Parameters:
point
- A 3D point, which is projected to the plane- Returns:
- a point laying on the plane.
- Throws:
NullPointerException
- if thepoint
isnull
-
reflectPointOverPlane
public javax.vecmath.Point3d reflectPointOverPlane(javax.vecmath.Point3d point) Returns a point laying on the opposite side of the plane ("mirrors" the point).- Parameters:
point
- A 3D point to be reflected- Returns:
- a point on the opposite side of the plane.
- Throws:
NullPointerException
- if thepoint
isnull
-
reflectUnitVectorOverPlane
public javax.vecmath.Vector3d reflectUnitVectorOverPlane(javax.vecmath.Vector3d vector) Reflects the give unit vector over this plane.- Parameters:
vector
- A normalized 3D vector- Returns:
- reflected vector
- Throws:
NullPointerException
- if thepoint
isnull
-
getMesh
Returns rectangular mesh facet of this symmetry plane.- Parameters:
point
- A 3D point, which is projected to the plane and used as a center of the rectangular facetwidth
- Widthheight
- Height- Returns:
- a rectangular mesh facet of this symmetry plane
- Throws:
NullPointerException
- if thepoint
isnull
IllegalArgumentException
- ifwidth
orheight
are <= 0
-
getMesh
Returns rectangular mesh facet of this symmetry plane. The centroid and size are estimated from bounding box.- Parameters:
bbox
- Bounding box- Returns:
- a rectangular mesh facet of this symmetry plane
- Throws:
NullPointerException
- if themidPoint
orbbox
arenull
-
getNormal
public javax.vecmath.Vector3d getNormal()Returns reference to the normal vector- Returns:
- reference to the normal vector
-
setNormal
protected final void setNormal(javax.vecmath.Tuple3d normal) Changes the normal vector.- Parameters:
normal
- new normalized normal vector- Throws:
IllegalArgumentException
- if the normal isnull
or if length is not one.
-
getPointDistance
public double getPointDistance(javax.vecmath.Point3d point) Returns distance of the point from the plane.- Parameters:
point
- Point whose distance is to be computed- Returns:
- Point's distance. If the point is on the opposite side with the respect to the plane's normal, the negative distance is returned
-
getIntersectionWithLine
public javax.vecmath.Point3d getIntersectionWithLine(javax.vecmath.Point3d p1, javax.vecmath.Point3d p2) Calculates an intersection of a plane and a line given by two points- Parameters:
p1
- first point of the linep2
- second point of the line- Returns:
- The point of intersection of null if no point found
-
getRotationAroundAxis
protected static javax.vecmath.Matrix4d getRotationAroundAxis(javax.vecmath.Vector3d targetV, javax.vecmath.Vector3d trV, javax.vecmath.Vector3d axis) Computes transformation matrix that rotates the given normal vector so that it fits our normal vector. Based on https://math.stackexchange.com/questions/180418/calculate-rotation-matrix-to-align-vector-a-to-vector-b-in-3d- Parameters:
targetV
- Vector towards which we want to rotate the second vectortrV
- Vector to be rotatedaxis
- Rotation axis. Ifnull
, then it's automatically computed- Returns:
- transformation matrix
-
rotateOverZ
public void rotateOverZ()Rotates plane over Z axis by 90 degrees. -
rotateOverY
public void rotateOverY()Rotates plane over Y axis by 90 degrees.
-