net.rim.device.api.math
Class BoundingSphere

java.lang.Object
  extended by net.rim.device.api.math.BoundingSphere
All Implemented Interfaces:
Bounds

public class BoundingSphere
extends Object
implements Bounds

Defines a 3-dimensional bounding sphere.

Since:
BlackBerry API 6.0.0

Constructor Summary
BoundingSphere()
          Constructs a new bounding sphere initialized to all zeros.
BoundingSphere(float[] array, int offset)
          Constructs a new bounding sphere from the specified values.
BoundingSphere(BoundingSphere sphere)
          Constructs a bounding sphere from the given bounding sphere.
BoundingSphere(Vector3f center, float radius)
          Constructs a new bounding sphere initialized to the specified values.
BoundingSphere(Vector3f[] points)
          Constructs a new bounding sphere that contains all of the specified points.
 
Method Summary
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one.
 boolean equals(BoundingSphere sphere)
          Returns true if all elements of the specified bounding sphere are equal to the elements of this bounding sphere.
 void getCenter(Vector3f center)
          Gets the bounding sphere's center in the given point.
 float getRadius()
          Gets the bounding sphere's radius.
 int hashCode()
          Returns a hash code value for the object.
 boolean intersects(Bounds bounds)
          Tests whether this bounding object intersects the specified bounding object.
 boolean intersects(Frustum frustum)
          Tests whether this bounding object intersects the specified frustum.
 float intersects(Plane plane)
          Tests whether this bounding object intersects the specified plane.
 float intersects(Ray ray)
          Tests whether this bounding object intersects the specified ray.
 boolean isEmpty()
          Determines if this bounding object is empty.
 void merge(Bounds bounds)
          Sets this bounding object to the smallest bounding object that contains both this bounding object and the specified bounds.
 void set(float[] array, int offset)
          Sets this bounding sphere to the specified values.
 void set(Bounds bounds)
          Sets this bounding object to the specified bounding object.
 void set(Vector3f center, float radius)
          Sets this bounding sphere to the specified values.
 void set(Vector3f[] points)
          Sets this bounding sphere to the smallest bounding sphere that contains all of the specified points.
 void setCenter(float cx, float cy, float cz)
          Sets the bounding sphere's center to the specified values.
 void setCenter(Vector3f center)
          Sets the bounding sphere's center.
 void setRadius(float radius)
          Sets the bounding sphere's radius.
 String toString()
          Returns a string representation of the object.
 void transform(Matrix4f matrix)
          Transforms the bounding object by the given transformation matrix.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 



Constructor Detail

BoundingSphere

public BoundingSphere()
Constructs a new bounding sphere initialized to all zeros.

Since:
BlackBerry API 6.0.0

BoundingSphere

public BoundingSphere(Vector3f center,
                      float radius)
Constructs a new bounding sphere initialized to the specified values.

Parameters:
center - The center of the sphere.
radius - The radius of the sphere.
Throws:
IllegalArgumentException - If the radius is negative.
NullPointerException - If center is null.
Since:
BlackBerry API 6.0.0

BoundingSphere

public BoundingSphere(float[] array,
                      int offset)
Constructs a new bounding sphere from the specified values.

Parameters:
array - An array containing a sequence of floating point values of the form [cx, cy, cz, radius].
offset - The offset into the array where the values are stored.
Throws:
NullPointerException - If array is null.
IllegalArgumentException - If the radius is negative.
IllegalArgumentException - If offset is less than zero or offset + 3 is greater than or equal to array.length.
Since:
BlackBerry API 6.0.0

BoundingSphere

public BoundingSphere(Vector3f[] points)
Constructs a new bounding sphere that contains all of the specified points.

Parameters:
points - The points to enclose inside the new bounding sphere.
Throws:
NullPointerException - If points or points[i] (for any integer 0 <= i < points.length) is null.
Since:
BlackBerry API 6.0.0

BoundingSphere

public BoundingSphere(BoundingSphere sphere)
Constructs a bounding sphere from the given bounding sphere.

Parameters:
sphere - The bounding sphere to copy.
Throws:
NullPointerException - If sphere is null.
Since:
BlackBerry API 6.0.0


Method Detail

getCenter

public void getCenter(Vector3f center)
Gets the bounding sphere's center in the given point.

Parameters:
center - The point to store the center in.
Throws:
NullPointerException - If center is null.
Since:
BlackBerry API 6.0.0

getRadius

public float getRadius()
Gets the bounding sphere's radius.

Returns:
The radius.
Since:
BlackBerry API 6.0.0

intersects

public boolean intersects(Bounds bounds)
Description copied from interface: Bounds
Tests whether this bounding object intersects the specified bounding object.

Specified by:
intersects in interface Bounds
Parameters:
bounds - The bounding object to test intersection with.
Returns:
true if the specified bounding object intersects this bounding object; false otherwise.
See Also:
Bounds.intersects(Bounds)
Since:
BlackBerry API 6.0.0

intersects

public boolean intersects(Frustum frustum)
Description copied from interface: Bounds
Tests whether this bounding object intersects the specified frustum.

Specified by:
intersects in interface Bounds
Parameters:
frustum - The frustum to test intersection with.
Returns:
true if this bounding object intersects the specified frustum; false otherwise.
See Also:
Bounds.intersects(Frustum)
Since:
BlackBerry API 6.0.0

intersects

public float intersects(Plane plane)
Description copied from interface: Bounds
Tests whether this bounding object intersects the specified plane.

Specified by:
intersects in interface Bounds
Parameters:
plane - The plane to test intersection with.
Returns:
INTERSECTS_BACK if this bounding object is in the negative half-space of the plane, INTERSECTS_FRONT if it is in the positive half-space of the plane; and INTERSECTS_INTERSECTING if it intersects the plane.
See Also:
Bounds.intersects(Plane)
Since:
BlackBerry API 6.0.0

intersects

public float intersects(Ray ray)
Description copied from interface: Bounds
Tests whether this bounding object intersects the specified ray.

Specified by:
intersects in interface Bounds
Parameters:
ray - The ray to test intersection with.
Returns:
The distance from the origin of the ray to this bounding object or INTERSECTS_NONE if the ray does not intersect this bounding object.
See Also:
Bounds.intersects(Ray)
Since:
BlackBerry API 6.0.0

isEmpty

public boolean isEmpty()
Description copied from interface: Bounds
Determines if this bounding object is empty.

Specified by:
isEmpty in interface Bounds
Returns:
true if this bounding object is empty;false otherwise.
See Also:
Bounds.isEmpty()
Since:
BlackBerry API 6.0.0

merge

public void merge(Bounds bounds)
Description copied from interface: Bounds
Sets this bounding object to the smallest bounding object that contains both this bounding object and the specified bounds.

Specified by:
merge in interface Bounds
Parameters:
bounds - The bounding object to merge with.
See Also:
Bounds.merge(Bounds)
Since:
BlackBerry API 6.0.0

set

public void set(Vector3f center,
                float radius)
Sets this bounding sphere to the specified values.

Parameters:
center - The center of the sphere.
radius - The radius of the sphere.
Throws:
IllegalArgumentException - If the radius is negative.
NullPointerException - If center is null.
Since:
BlackBerry API 6.0.0

set

public void set(float[] array,
                int offset)
Sets this bounding sphere to the specified values.

Parameters:
array - An array containing a sequence of floating point values of the form [cx, cy, cz, radius].
offset - The offset into the array where the values are stored.
Throws:
NullPointerException - If array is null.
IllegalArgumentException - If the radius is negative.
IllegalArgumentException - If offset is less than zero or offset + 3 is greater than or equal to array.length.
Since:
BlackBerry API 6.0.0

set

public void set(Vector3f[] points)
Sets this bounding sphere to the smallest bounding sphere that contains all of the specified points.

Parameters:
points - The points to enclose inside the bounding sphere.
Throws:
NullPointerException - If points or points[i] (for any integer 0 <= i < points.length) is null.
Since:
BlackBerry API 6.0.0

set

public void set(Bounds bounds)
Description copied from interface: Bounds
Sets this bounding object to the specified bounding object.

Specified by:
set in interface Bounds
Parameters:
bounds - The bounding object to set to.
See Also:
Bounds.set(Bounds)
Since:
BlackBerry API 6.0.0

setCenter

public void setCenter(Vector3f center)
Sets the bounding sphere's center.

Parameters:
center - The new center point.
Throws:
NullPointerException - If center is null.
Since:
BlackBerry API 6.0.0

setCenter

public void setCenter(float cx,
                      float cy,
                      float cz)
Sets the bounding sphere's center to the specified values.

Parameters:
cx - The new x coordinate of the center.
cy - The new y coordinate of the center.
cz - The new z coordinate of the center.
Since:
BlackBerry API 6.0.0

setRadius

public void setRadius(float radius)
Sets the bounding sphere's radius.

Parameters:
radius - The new radius.
Throws:
IllegalArgumentException - If the given radius is negative.
Since:
BlackBerry API 6.0.0

transform

public void transform(Matrix4f matrix)
Description copied from interface: Bounds
Transforms the bounding object by the given transformation matrix.

Specified by:
transform in interface Bounds
Parameters:
matrix - The transformation matrix to transform by.
See Also:
Bounds.transform(Matrix4f)
Since:
BlackBerry API 6.0.0

equals

public boolean equals(BoundingSphere sphere)
Returns true if all elements of the specified bounding sphere are equal to the elements of this bounding sphere.

Parameters:
sphere - The bounding sphere to compare.
Returns:
true if this bounding sphere is equal to boundingSphere; false otherwise.
Throws:
NullPointerException - If sphere is null.
Since:
BlackBerry API 6.0.0

equals

public boolean equals(Object obj)
Description copied from class: Object
Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation:

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any reference values x and y, this method returns true if and only if x and y refer to the same object (x==y has the value true).

Specified by:
equals in interface Bounds
Overrides:
equals in class Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
Bounds.equals(Object)
Since:
BlackBerry API 6.0.0

hashCode

public int hashCode()
Description copied from class: Object
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of hashCode is:

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

Specified by:
hashCode in interface Bounds
Overrides:
hashCode in class Object
Returns:
a hash code value for this object.
See Also:
Bounds.hashCode()
Since:
BlackBerry API 6.0.0

toString

public String toString()
Description copied from class: Object
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Specified by:
toString in interface Bounds
Overrides:
toString in class Object
Returns:
a string representation of the object.
See Also:
Bounds.toString()
Since:
BlackBerry API 6.0.0





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.