Class BoundingPolytope

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class BoundingPolytope
    extends Bounds
    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
    where A, B, C, D are the parameters that specify the plane. The parameters are passed in the x, y, z, and w fields, respectively, of a Vector4d object. The intersection of the set of half-spaces corresponding to the planes in this BoundingPolytope defines the bounding region.
    • Constructor Summary

      Constructors 
      Constructor Description
      BoundingPolytope()
      Constructs 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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object clone()
      Creates a copy of a polytope.
      Bounds closestIntersection​(Bounds[] boundsObjects)
      Finds closest bounding object that intersects this bounding polytope.
      void combine​(Bounds boundsObject)
      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 combine​(Bounds[] boundsObjects)
      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 equals​(java.lang.Object bounds)
      Indicates whether the specified bounds object is equal to this BoundingPolytope object.
      int getNumPlanes()  
      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 intersect​(Bounds boundsObject)
      Test for intersection with another bounds object.
      boolean intersect​(Bounds[] boundsObjects)
      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 set​(Bounds boundsObject)
      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.
      java.lang.String toString()
      Returns a string representation of this class
      void 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.
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • BoundingPolytope

        public BoundingPolytope​(javax.vecmath.Vector4d[] planes)
        Constructs a BoundingPolytope using the specified planes.
        Parameters:
        planes - a set of planes defining the polytope.
        Throws:
        java.lang.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

        public BoundingPolytope​(Bounds boundsObject)
        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

        public BoundingPolytope​(Bounds[] boundsObjects)
        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 Detail

      • 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:
        java.lang.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

        public void set​(Bounds boundsObject)
        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.
        Specified by:
        set in class Bounds
        Parameters:
        boundsObject - another bounds object
      • clone

        public java.lang.Object clone()
        Creates a copy of a polytope.
        Specified by:
        clone in class Bounds
        Returns:
        a new BoundingPolytope
      • equals

        public boolean equals​(java.lang.Object bounds)
        Indicates whether the specified bounds object is equal to this BoundingPolytope object. They are equal if the specified bounds object is an instance of BoundingPolytope and all of the data members of bounds are equal to the corresponding data members in this BoundingPolytope.
        Specified by:
        equals in class Bounds
        Parameters:
        bounds - the object with which the comparison is made.
        Returns:
        true if this BoundingPolytope is equal to bounds; otherwise false
        Since:
        Java 3D 1.2
      • 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.
        Specified by:
        hashCode in class Bounds
        Returns:
        a hash code value for this BoundingPolytope object.
        Since:
        Java 3D 1.2
      • combine

        public void combine​(Bounds boundsObject)
        Combines this bounding polytope with a bounding object so that the resulting bounding polytope encloses the original bounding polytope and the given bounds object.
        Specified by:
        combine in class Bounds
        Parameters:
        boundsObject - another bounds object
      • combine

        public void combine​(Bounds[] boundsObjects)
        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.
        Specified by:
        combine in class Bounds
        Parameters:
        boundsObjects - an array of bounds objects
      • combine

        public void combine​(javax.vecmath.Point3d point)
        Combines this bounding polytope with a point.
        Specified by:
        combine in class Bounds
        Parameters:
        point - a 3d point in space
      • combine

        public void combine​(javax.vecmath.Point3d[] points)
        Combines this bounding polytope with an array of points.
        Specified by:
        combine in class Bounds
        Parameters:
        points - an array of 3d points in space
      • transform

        public void transform​(Bounds boundsObject,
                              Transform3D matrix)
        Modifies the bounding polytope so that it bounds the volume generated by transforming the given bounding object.
        Specified by:
        transform in class Bounds
        Parameters:
        boundsObject - the bounding object to be transformed
        matrix - a transformation matrix
      • transform

        public void transform​(Transform3D matrix)
        Transforms this bounding polytope by the given transformation matrix.
        Specified by:
        transform in class Bounds
        Parameters:
        matrix - a transformation matrix
      • intersect

        public boolean intersect​(javax.vecmath.Point3d origin,
                                 javax.vecmath.Vector3d direction)
        Test for intersection with a ray.
        Specified by:
        intersect in class Bounds
        Parameters:
        origin - the starting point of the ray
        direction - the direction of the ray
        Returns:
        true or false indicating if an intersection occured
      • 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.
        Specified by:
        isEmpty in class Bounds
        Returns:
        true if the bounding polytope is empty; otherwise, it returns false
      • intersect

        public boolean intersect​(javax.vecmath.Point3d point)
        Test for intersection with a point.
        Specified by:
        intersect in class Bounds
        Parameters:
        point - a Point defining a position in 3-space
        Returns:
        true or false indicating if an intersection occured
      • intersect

        public boolean intersect​(Bounds boundsObject)
        Test for intersection with another bounds object.
        Specified by:
        intersect in class Bounds
        Parameters:
        boundsObject - another bounds object
        Returns:
        true or false indicating if an intersection occured
      • intersect

        public boolean intersect​(Bounds[] boundsObjects)
        Test for intersection with another bounds object.
        Specified by:
        intersect in class Bounds
        Parameters:
        boundsObjects - an array of bounding objects
        Returns:
        true or false indicating if an intersection occured
      • intersect

        public boolean intersect​(Bounds boundsObject,
                                 BoundingPolytope newBoundPolytope)
        Test for intersection with another bounds object.
        Parameters:
        boundsObject - another bounds object
        newBoundPolytope - the new bounding polytope, which is the intersection of the boundsObject and this BoundingPolytope
        Returns:
        true or false indicating if an intersection occured
      • intersect

        public boolean intersect​(Bounds[] boundsObjects,
                                 BoundingPolytope newBoundingPolytope)
        Test for intersection with an array of bounds objects.
        Parameters:
        boundsObjects - an array of bounds objects
        newBoundingPolytope - the new bounding polytope, which is the intersection of the boundsObject and this BoundingPolytope
        Returns:
        true or false indicating if an intersection occured
      • closestIntersection

        public Bounds closestIntersection​(Bounds[] boundsObjects)
        Finds closest bounding object that intersects this bounding polytope.
        Specified by:
        closestIntersection in class Bounds
        Parameters:
        boundsObjects - is an array of bounds objects
        Returns:
        closest bounding object
      • toString

        public java.lang.String toString()
        Returns a string representation of this class
        Overrides:
        toString in class java.lang.Object