Class BoundingSphere

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class BoundingSphere
    extends Bounds
    This class defines a spherical bounding region which is defined by a center point and a radius.
    • Constructor Summary

      Constructors 
      Constructor Description
      BoundingSphere()
      Constructs and initializes a BoundingSphere with radius = 1 at 0 0 0.
      BoundingSphere​(Bounds boundsObject)
      Constructs and initializes a BoundingSphere from a bounding object.
      BoundingSphere​(Bounds[] boundsObjects)
      Constructs and initializes a BoundingSphere from an array of bounding objects.
      BoundingSphere​(javax.vecmath.Point3d center, double radius)
      Constructs and initializes a BoundingSphere from a center and radius.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object clone()
      Creates a copy of the bounding sphere.
      Bounds closestIntersection​(Bounds[] boundsObjects)
      Finds closest bounding object that intersects this bounding sphere.
      void combine​(Bounds boundsObject)
      Combines this bounding sphere with a bounding object so that the resulting bounding sphere encloses the original bounding sphere and the given bounds object.
      void combine​(Bounds[] boundsObjects)
      Combines this bounding sphere with an array of bounding objects so that the resulting bounding sphere encloses the original bounding sphere and the given array of bounds object.
      void combine​(javax.vecmath.Point3d point)
      Combines this bounding sphere with a point.
      void combine​(javax.vecmath.Point3d[] points)
      Combines this bounding sphere with an array of points.
      boolean equals​(java.lang.Object bounds)
      Indicates whether the specified bounds object is equal to this BoundingSphere object.
      void getCenter​(javax.vecmath.Point3d center)
      Returns the position of this bounding sphere as a point.
      double getRadius()
      Returns the radius of this bounding sphere as a double.
      int hashCode()
      Returns a hash code value for this BoundingSphere 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, BoundingSphere newBoundSphere)
      Test for intersection with an array of bounds objects.
      boolean intersect​(Bounds boundsObject, BoundingSphere newBoundSphere)
      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 sphere is empty.
      void set​(Bounds boundsObject)
      Sets the value of this BoundingSphere.
      void setCenter​(javax.vecmath.Point3d center)
      Sets the position of this bounding sphere from a point.
      void setRadius​(double r)
      Sets the radius of this bounding sphere from a double.
      java.lang.String toString()
      Returns a string representation of this class.
      void transform​(Bounds boundsObject, Transform3D matrix)
      Modifies the bounding sphere so that it bounds the volume generated by transforming the given bounding object.
      void transform​(Transform3D trans)
      Transforms this bounding sphere by the given matrix.
      • Methods inherited from class java.lang.Object

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

      • BoundingSphere

        public BoundingSphere​(javax.vecmath.Point3d center,
                              double radius)
        Constructs and initializes a BoundingSphere from a center and radius.
        Parameters:
        center - the center of the bounding sphere
        radius - the radius of the bounding sphere
      • BoundingSphere

        public BoundingSphere()
        Constructs and initializes a BoundingSphere with radius = 1 at 0 0 0.
      • BoundingSphere

        public BoundingSphere​(Bounds boundsObject)
        Constructs and initializes a BoundingSphere from a bounding object.
        Parameters:
        boundsObject - a bounds object
      • BoundingSphere

        public BoundingSphere​(Bounds[] boundsObjects)
        Constructs and initializes a BoundingSphere from an array of bounding objects.
        Parameters:
        boundsObjects - an array of bounds objects
    • Method Detail

      • getRadius

        public double getRadius()
        Returns the radius of this bounding sphere as a double.
        Returns:
        the radius of the bounding sphere
      • setRadius

        public void setRadius​(double r)
        Sets the radius of this bounding sphere from a double.
        Parameters:
        r - the new radius for the bounding sphere
      • getCenter

        public void getCenter​(javax.vecmath.Point3d center)
        Returns the position of this bounding sphere as a point.
        Parameters:
        center - a Point to receive the center of the bounding sphere
      • setCenter

        public void setCenter​(javax.vecmath.Point3d center)
        Sets the position of this bounding sphere from a point.
        Parameters:
        center - a Point defining the new center of the bounding sphere
      • set

        public void set​(Bounds boundsObject)
        Sets the value of this BoundingSphere.
        Specified by:
        set in class Bounds
        Parameters:
        boundsObject - another bounds object
      • clone

        public java.lang.Object clone()
        Creates a copy of the bounding sphere.
        Specified by:
        clone in class Bounds
        Returns:
        a BoundingSphere
      • equals

        public boolean equals​(java.lang.Object bounds)
        Indicates whether the specified bounds object is equal to this BoundingSphere object. They are equal if the specified bounds object is an instance of BoundingSphere and all of the data members of bounds are equal to the corresponding data members in this BoundingSphere.
        Specified by:
        equals in class Bounds
        Parameters:
        bounds - the object with which the comparison is made.
        Returns:
        true if this BoundingSphere is equal to bounds; otherwise false
        Since:
        Java 3D 1.2
      • hashCode

        public int hashCode()
        Returns a hash code value for this BoundingSphere object based on the data values in this object. Two different BoundingSphere objects with identical data values (i.e., BoundingSphere.equals returns true) will return the same hash code value. Two BoundingSphere 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 BoundingSphere object.
        Since:
        Java 3D 1.2
      • combine

        public void combine​(Bounds boundsObject)
        Combines this bounding sphere with a bounding object so that the resulting bounding sphere encloses the original bounding sphere 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 sphere with an array of bounding objects so that the resulting bounding sphere encloses the original bounding sphere 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 sphere 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 sphere 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 sphere 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 trans)
        Transforms this bounding sphere by the given matrix.
        Specified by:
        transform in class Bounds
        Parameters:
        trans - the 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
      • 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
      • isEmpty

        public boolean isEmpty()
        Tests whether the bounding sphere is empty. A bounding sphere 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 sphere with a volume of zero is not empty.
        Specified by:
        isEmpty in class Bounds
        Returns:
        true if the bounding sphere is empty; otherwise, it returns false
      • 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,
                                 BoundingSphere newBoundSphere)
        Test for intersection with another bounds object.
        Parameters:
        boundsObject - another bounds object
        newBoundSphere - the new bounding sphere which is the intersection of the boundsObject and this BoundingSphere
        Returns:
        true or false indicating if an intersection occured
      • intersect

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

        public Bounds closestIntersection​(Bounds[] boundsObjects)
        Finds closest bounding object that intersects this bounding sphere.
        Specified by:
        closestIntersection in class Bounds
        Parameters:
        boundsObjects - 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