net.rim.device.api.math
Class BoundingBox

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

public class BoundingBox
extends Object
implements Bounds

Defines a 3-dimensional axis-aligned bounding box.

Since:
BlackBerry API 6.0.0

Constructor Summary
BoundingBox()
          Constructs an empty bounding box at the origin.
BoundingBox(float[] array, int offset)
          Constructs a new bounding box from the specified values.
BoundingBox(BoundingBox box)
          Constructs a new bounding box from the given bounding box.
BoundingBox(Vector3f min, Vector3f max)
          Constructs a new bounding box from the specified values.
BoundingBox(Vector3f[] points)
          Constructs a new bounding box 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(BoundingBox box)
          Returns true if all elements of the specified bounding box are equal to the elements of this bounding box.
 void getCorners(Vector3f[] corners, int offset)
          Gets the corners of the bounding box in the specified array.
 void getMax(Vector3f max)
          Gets the maximum point of the bounding box in the given point.
 void getMin(Vector3f min)
          Gets the minimum point of the bounding box in the given point.
 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 box to the specified values.
 void set(Bounds bounds)
          Sets this bounding object to the specified bounding object.
 void set(Vector3f min, Vector3f max)
          Sets this bounding box to the specified values.
 void set(Vector3f[] points)
          Sets this bounding box to the smallest bounding box that contains all of the specified points.
 void setMax(float maxX, float maxY, float maxZ)
          Sets the maximum point of the bounding box to the specified values.
 void setMax(Vector3f max)
          Sets the maximum point of the bounding box.
 void setMin(float minX, float minY, float minZ)
          Sets the minimum point of the bounding box to the specified values.
 void setMin(Vector3f min)
          Sets the minimum point of the bounding box.
 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

BoundingBox

public BoundingBox()
Constructs an empty bounding box at the origin.

Since:
BlackBerry API 6.0.0

BoundingBox

public BoundingBox(Vector3f min,
                   Vector3f max)
Constructs a new bounding box from the specified values.

Parameters:
min - The minimum point of the bounding box.
max - The maximum point of the bounding box.
Throws:
IllegalArgumentException - If the minimum and maximum values are invalid (i.e. a max value is less than a min value).
NullPointerException - If min or max is null.
Since:
BlackBerry API 6.0.0

BoundingBox

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

Parameters:
array - An array containing a sequence of floating point values of the form [minX, minY, minZ, maxX, maxY, maxZ].
offset - The offset into the array where the values are stored.
Throws:
IllegalArgumentException - If the minimum and maximum values are invalid (i.e. a max value is less than a min value).
IllegalArgumentException - If offset is less than zero or offset + 5 is greater than or equal to array.length.
NullPointerException - If array is null.
Since:
BlackBerry API 6.0.0

BoundingBox

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

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

BoundingBox

public BoundingBox(BoundingBox box)
Constructs a new bounding box from the given bounding box.

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


Method Detail

getCorners

public void getCorners(Vector3f[] corners,
                       int offset)
Gets the corners of the bounding box in the specified array.

The corners are returned as follows: 0 to 3 specify the near face starting at the upper left point when looking towards the origin from the positive z-axis in a counter-clockwise fashion; 4 to 7 specify the far face starting at the upper left point when looking towards the origin from the negative z-axis in a counter-clockwise fashion.

Parameters:
corners - The array to store the corners in.
offset - The offset to start storing the corners at.
Throws:
IllegalArgumentException - If offset is negative or if offset + 7 is greater than or equal to corners.length.
NullPointerException - If corners or corners[i] (for any integer 0 <= i < 8) is null.
Since:
BlackBerry API 6.0.0

getMax

public void getMax(Vector3f max)
Gets the maximum point of the bounding box in the given point.

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

getMin

public void getMin(Vector3f min)
Gets the minimum point of the bounding box in the given point.

Parameters:
min - The point to store the minimum point in.
Throws:
NullPointerException - If min is null.
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 min,
                Vector3f max)
Sets this bounding box to the specified values.

Parameters:
min - The minimum point of the bounding box.
max - The maximum point of the bounding box.
Throws:
IllegalArgumentException - If the minimum and maximum values are invalid (i.e. a max value is less than a min value).
NullPointerException - If min or max is null.
Since:
BlackBerry API 6.0.0

set

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

Parameters:
array - An array containing a sequence of floating point values of the form [minX, minY, minZ, maxX, maxY, maxZ].
offset - The offset into the array where the values are stored.
Throws:
NullPointerException - If array is null.
IllegalArgumentException - If the minimum and maximum values are invalid (i.e. a max value is less than a min value).
IllegalArgumentException - If offset is less than zero or offset + 5 is greater than or equal to array.length.
Since:
BlackBerry API 6.0.0

set

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

Parameters:
points - The points to enclose inside the bounding box.
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

setMax

public void setMax(Vector3f max)
Sets the maximum point of the bounding box.

Parameters:
max - The new maximum point.
Throws:
IllegalArgumentException - If (at least) one of the new maximum values is less than its corresponding current minimum value.
NullPointerException - If max is null.
Since:
BlackBerry API 6.0.0

setMax

public void setMax(float maxX,
                   float maxY,
                   float maxZ)
Sets the maximum point of the bounding box to the specified values.

Parameters:
maxX - The new x coordinate of the maximum point.
maxY - The new y coordinate of the maximum point.
maxZ - The new z coordinate of the maximum point.
Throws:
IllegalArgumentException - If (at least) one of the new maximum values is less than its corresponding current minimum value.
Since:
BlackBerry API 6.0.0

setMin

public void setMin(Vector3f min)
Sets the minimum point of the bounding box.

Parameters:
min - The new minimum point.
Throws:
IllegalArgumentException - If (at least) one of the new minimum values is greater than its corresponding current maximum value.
NullPointerException - If min is null.
Since:
BlackBerry API 6.0.0

setMin

public void setMin(float minX,
                   float minY,
                   float minZ)
Sets the minimum point of the bounding box to the specified values.

Parameters:
minX - The new x coordinate of the minimum point.
minY - The new y coordinate of the minimum point.
minZ - The new z coordinate of the minimum point.
Throws:
IllegalArgumentException - If (at least) one of the new minimum values is greater than its corresponding current maximum value.
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(BoundingBox box)
Returns true if all elements of the specified bounding box are equal to the elements of this bounding box.

Parameters:
box - The bounding box to compare.
Returns:
true if this bounding box is equal to boundingBox; false otherwise.
Throws:
NullPointerException - If boundingBox 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.