Package javax.media.j3d
Class BoundingPolytope
java.lang.Object
javax.media.j3d.Bounds
javax.media.j3d.BoundingPolytope
- All Implemented Interfaces:
Cloneable
A BoundingPolytope defines a polyhedral bounding region using the
intersection of four or more half spaces. The region defined by a
BoundingPolytope is always convex and must be closed.
Each plane in the BoundingPolytope specifies a half-space defined by the equation:
-
Ax + By + Cz + D <= 0
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a BoundingPolytope and initializes it to a set of 6 planes that defines a cube such that -1 <= x,y,z <= 1.BoundingPolytope
(Bounds boundsObject) Constructs a BoundingPolytope from the specified bounds object.BoundingPolytope
(Bounds[] boundsObjects) Constructs a BoundingPolytope from the specified array of bounds objects.BoundingPolytope
(javax.vecmath.Vector4d[] planes) Constructs a BoundingPolytope using the specified planes. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Creates a copy of a polytope.closestIntersection
(Bounds[] boundsObjects) Finds closest bounding object that intersects this bounding polytope.void
Combines this bounding polytope with a bounding object so that the resulting bounding polytope encloses the original bounding polytope and the given bounds object.void
Combines this bounding polytope with an array of bounding objects so that the resulting bounding polytope encloses the original bounding polytope and the given array of bounds object.void
combine
(javax.vecmath.Point3d point) Combines this bounding polytope with a point.void
combine
(javax.vecmath.Point3d[] points) Combines this bounding polytope with an array of points.boolean
Indicates whether the specifiedbounds
object is equal to this BoundingPolytope object.int
void
getPlanes
(javax.vecmath.Vector4d[] planes) Returns the equations of the bounding planes for this bounding polytope.int
hashCode()
Returns a hash code value for this BoundingPolytope object based on the data values in this object.boolean
Test for intersection with another bounds object.boolean
Test for intersection with another bounds object.boolean
intersect
(Bounds[] boundsObjects, BoundingPolytope newBoundingPolytope) Test for intersection with an array of bounds objects.boolean
intersect
(Bounds boundsObject, BoundingPolytope newBoundPolytope) Test for intersection with another bounds object.boolean
intersect
(javax.vecmath.Point3d point) Test for intersection with a point.boolean
intersect
(javax.vecmath.Point3d origin, javax.vecmath.Vector3d direction) Test for intersection with a ray.boolean
isEmpty()
Tests whether the bounding polytope is empty.void
Sets the planes for this BoundingPolytope by keeping its current number and position of planes and computing new planes positions to enclose the given bounds object.void
setPlanes
(javax.vecmath.Vector4d[] planes) Sets the bounding planes for this polytope.toString()
Returns a string representation of this classvoid
transform
(Bounds boundsObject, Transform3D matrix) Modifies the bounding polytope so that it bounds the volume generated by transforming the given bounding object.void
transform
(Transform3D matrix) Transforms this bounding polytope by the given transformation matrix.
-
Constructor Details
-
BoundingPolytope
public BoundingPolytope(javax.vecmath.Vector4d[] planes) Constructs a BoundingPolytope using the specified planes.- Parameters:
planes
- a set of planes defining the polytope.- Throws:
IllegalArgumentException
- if the length of the specified array of planes is less than 4.
-
BoundingPolytope
public BoundingPolytope()Constructs a BoundingPolytope and initializes it to a set of 6 planes that defines a cube such that -1 <= x,y,z <= 1. The values of the planes are as follows:-
planes[0] : x <= 1 (1,0,0,-1)
planes[1] : -x <= 1 (-1,0,0,-1)
planes[2] : y <= 1 (0,1,0,-1)
planes[3] : -y <= 1 (0,-1,0,-1)
planes[4] : z <= 1 (0,0,1,-1)
planes[5] : -z <= 1 (0,0,-1,-1)
-
BoundingPolytope
Constructs a BoundingPolytope from the specified bounds object. The new polytope will circumscribe the region specified by the input bounds.- Parameters:
boundsObject
- the bounds object from which this polytope is constructed.
-
BoundingPolytope
Constructs a BoundingPolytope from the specified array of bounds objects. The new polytope will circumscribe the union of the regions specified by the input bounds objects.- Parameters:
boundsObjects
- the array bounds objects from which this polytope is constructed.
-
-
Method Details
-
setPlanes
public void setPlanes(javax.vecmath.Vector4d[] planes) Sets the bounding planes for this polytope.- Parameters:
planes
- the new set of planes for this polytope- Throws:
IllegalArgumentException
- if the length of the specified array of planes is less than 4.
-
getPlanes
public void getPlanes(javax.vecmath.Vector4d[] planes) Returns the equations of the bounding planes for this bounding polytope. The equations are copied into the specified array. The array must be large enough to hold all of the vectors. The individual array elements must be allocated by the caller.- Parameters:
planes
- an array Vector4d to receive the bounding planes
-
getNumPlanes
public int getNumPlanes() -
set
Sets the planes for this BoundingPolytope by keeping its current number and position of planes and computing new planes positions to enclose the given bounds object. -
clone
Creates a copy of a polytope. -
equals
Indicates whether the specifiedbounds
object is equal to this BoundingPolytope object. They are equal if the specifiedbounds
object is an instance of BoundingPolytope and all of the data members ofbounds
are equal to the corresponding data members in this BoundingPolytope. -
hashCode
public int hashCode()Returns a hash code value for this BoundingPolytope object based on the data values in this object. Two different BoundingPolytope objects with identical data values (i.e., BoundingPolytope.equals returns true) will return the same hash code value. Two BoundingPolytope objects with different data members may return the same hash code value, although this is not likely. -
combine
Combines this bounding polytope with a bounding object so that the resulting bounding polytope encloses the original bounding polytope and the given bounds object. -
combine
Combines this bounding polytope with an array of bounding objects so that the resulting bounding polytope encloses the original bounding polytope and the given array of bounds object. -
combine
public void combine(javax.vecmath.Point3d point) Combines this bounding polytope with a point. -
combine
public void combine(javax.vecmath.Point3d[] points) Combines this bounding polytope with an array of points. -
transform
Modifies the bounding polytope so that it bounds the volume generated by transforming the given bounding object. -
transform
Transforms this bounding polytope by the given transformation matrix. -
intersect
public boolean intersect(javax.vecmath.Point3d origin, javax.vecmath.Vector3d direction) Test for intersection with a ray. -
isEmpty
public boolean isEmpty()Tests whether the bounding polytope is empty. A bounding polytope is empty if it is null (either by construction or as the result of a null intersection) or if its volume is negative. A bounding polytope with a volume of zero is not empty. -
intersect
public boolean intersect(javax.vecmath.Point3d point) Test for intersection with a point. -
intersect
Test for intersection with another bounds object. -
intersect
Test for intersection with another bounds object. -
intersect
Test for intersection with another bounds object.- Parameters:
boundsObject
- another bounds objectnewBoundPolytope
- the new bounding polytope, which is the intersection of the boundsObject and this BoundingPolytope- Returns:
- true or false indicating if an intersection occured
-
intersect
Test for intersection with an array of bounds objects.- Parameters:
boundsObjects
- an array of bounds objectsnewBoundingPolytope
- the new bounding polytope, which is the intersection of the boundsObject and this BoundingPolytope- Returns:
- true or false indicating if an intersection occured
-
closestIntersection
Finds closest bounding object that intersects this bounding polytope.- Specified by:
closestIntersection
in classBounds
- Parameters:
boundsObjects
- is an array of bounds objects- Returns:
- closest bounding object
-
toString
Returns a string representation of this class
-