Aviatrix3D
2.1.0

org.j3d.aviatrix3d
Class BoundingSphere

java.lang.Object
  extended by org.j3d.aviatrix3d.rendering.BoundingVolume
      extended by org.j3d.aviatrix3d.BoundingSphere

public class BoundingSphere
extends BoundingVolume

Bounds described as a spherical volume.

Version:
$Revision: 1.17 $
Author:
Justin Couch

Field Summary
 
Fields inherited from class org.j3d.aviatrix3d.rendering.BoundingVolume
BOX_BOUNDS, FRUSTUM_ALLIN, FRUSTUM_ALLOUT, FRUSTUM_PARTIAL, GEOMETRY_BOUNDS, NULL_BOUNDS, SPHERE_BOUNDS
 
Constructor Summary
BoundingSphere()
          The default constructor with the sphere radius as one and center at the origin.
BoundingSphere(float radius)
          Construct a bounding sphere at the origin with a set radius.
BoundingSphere(float[] pos, float radius)
          Construct a bounding sphere with a set radius and position.
 
Method Summary
 boolean checkIntersectionBox(float[] minExtents, float[] maxExtents)
          Check for the given AA box intersecting this bounds.
 boolean checkIntersectionCone(float[] vertex, float[] direction, float angle)
          Check for the given cone intersecting this bounds.
 boolean checkIntersectionCylinder(float[] center, float[] direction, float radius, float height)
          Check for the given cylinder segment intersecting this bounds.
 int checkIntersectionFrustum(javax.vecmath.Vector4f[] planes, javax.vecmath.Matrix4d mat)
          Check whether this volume intersects with the view frustum.
 int checkIntersectionFrustum(javax.vecmath.Vector4f[] planes, javax.vecmath.Matrix4f mat)
          Check whether this volume intersects with the view frustum.
 boolean checkIntersectionLine(float[] coeff)
          Check for the given line intersecting this bounds.
 boolean checkIntersectionPoint(float[] pos)
          Check for the given point lieing inside this bounds.
 boolean checkIntersectionRay(float[] pos, float[] dir)
          Check for the given ray intersecting this bounds.
 boolean checkIntersectionSegment(float[] start, float[] end)
          Check for the given line segment intersecting this bounds.
 boolean checkIntersectionSegment(float[] start, float[] dir, float length)
          Check for the given line segment intersecting this bounds.
 boolean checkIntersectionSphere(float[] c, float r)
          Check for the given sphere intersecting this bounds.
 boolean checkIntersectionTriangle(float[] v0, float[] v1, float[] v2)
          Check for the given triangle intersecting this bounds.
 void getCenter(float[] center)
          Get the center of the bounding volume.
 void getExtents(float[] min, float[] max)
          Get the maximum extents of the bounding volume.
 float getRadius()
          Get the current radius of the sphere
 int getType()
          The type of bounds this object represents.
 void setCenter(float[] pos)
          Center the local center of the sphere to be used.
 void setRadius(float radius)
          Set the radius of the sphere to the new value.
 java.lang.String toString()
          Generate a string representation of this box.
 void transform(javax.vecmath.Matrix4d mat)
          Transform the current postion by the given transformation matrix.
 void transform(javax.vecmath.Matrix4f mat)
          Transform the current postion by the given transformation matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BoundingSphere

public BoundingSphere()
The default constructor with the sphere radius as one and center at the origin.


BoundingSphere

public BoundingSphere(float radius)
Construct a bounding sphere at the origin with a set radius.

Parameters:
radius - The new radius value to use
Throws:
java.lang.IllegalArgumentException - Radius was negative

BoundingSphere

public BoundingSphere(float[] pos,
                      float radius)
Construct a bounding sphere with a set radius and position.

Parameters:
pos - The new position of the center of the sphere to be used
radius - The new radius value to use
Throws:
java.lang.IllegalArgumentException - Radius was negative
Method Detail

getType

public int getType()
The type of bounds this object represents.

Specified by:
getType in class BoundingVolume
Returns:
One of the constant types defined

getExtents

public void getExtents(float[] min,
                       float[] max)
Get the maximum extents of the bounding volume.

Specified by:
getExtents in class BoundingVolume
Parameters:
min - The minimum position of the bounds
max - The maximum position of the bounds

getCenter

public void getCenter(float[] center)
Get the center of the bounding volume.

Specified by:
getCenter in class BoundingVolume
Parameters:
center - The center of the bounds will be copied here

checkIntersectionPoint

public boolean checkIntersectionPoint(float[] pos)
Check for the given point lieing inside this bounds.

Specified by:
checkIntersectionPoint in class BoundingVolume
Parameters:
pos - The location of the point to test against
Returns:
true if the point lies inside this bounds

checkIntersectionLine

public boolean checkIntersectionLine(float[] coeff)
Check for the given line intersecting this bounds. The line is described in normal vector form of ax + by + cz + d = 0.

Parameters:
coeff - The 4 constants for the line equation
Returns:
true if the line intersects this bounds

checkIntersectionRay

public boolean checkIntersectionRay(float[] pos,
                                    float[] dir)
Check for the given ray intersecting this bounds. The line is described as a starting point and a vector direction.

Specified by:
checkIntersectionRay in class BoundingVolume
Parameters:
pos - The start location of the ray
dir - The direction vector of the ray
Returns:
true if the ray intersects this bounds

checkIntersectionSegment

public boolean checkIntersectionSegment(float[] start,
                                        float[] end)
Check for the given line segment intersecting this bounds. The line is described as the line connecting the start and end points.

Specified by:
checkIntersectionSegment in class BoundingVolume
Parameters:
start - The start location of the segment
end - The start location of the segment
Returns:
true if the segment intersects this bounds

checkIntersectionSegment

public boolean checkIntersectionSegment(float[] start,
                                        float[] dir,
                                        float length)
Check for the given line segment intersecting this bounds. The line is described as the line going from the start point in a given direction with a length in that direction.

Parameters:
start - The start location of the segment
dir - The direction vector of the segment
length - The length to the segment
Returns:
true if the segment intersects this bounds

checkIntersectionSphere

public boolean checkIntersectionSphere(float[] c,
                                       float r)
Check for the given sphere intersecting this bounds. The sphere is described by a centre location and the radius.

Specified by:
checkIntersectionSphere in class BoundingVolume
Parameters:
c - The location of the sphere's center
r - The radius of the sphere
Returns:
true if the sphere intersects this bounds

checkIntersectionTriangle

public boolean checkIntersectionTriangle(float[] v0,
                                         float[] v1,
                                         float[] v2)
Check for the given triangle intersecting this bounds. Assumes the three coordinates of the triangle are declared in RH coordinate system.

Specified by:
checkIntersectionTriangle in class BoundingVolume
Parameters:
v0 - The first vertex of the triangle
v1 - The second vertex of the triangle
v2 - The third vertex of the triangle
Returns:
true if the sphere intersects this bounds

checkIntersectionCylinder

public boolean checkIntersectionCylinder(float[] center,
                                         float[] direction,
                                         float radius,
                                         float height)
Check for the given cylinder segment intersecting this bounds. The cylinder is described by a centre location, axial direction and the radius.

Specified by:
checkIntersectionCylinder in class BoundingVolume
Parameters:
center - The location of the cylinder's center
direction - A unit vector indicating the axial direction
radius - The radius of the cylinder
height - The half-height of the cylinder from the center point
Returns:
true if the sphere intersects this bounds

checkIntersectionCone

public boolean checkIntersectionCone(float[] vertex,
                                     float[] direction,
                                     float angle)
Check for the given cone intersecting this bounds. The cone is described by the location of the vertex, a direction vector and the spread angle of the cone.

Specified by:
checkIntersectionCone in class BoundingVolume
Parameters:
vertex - The location of the cone's vertex
direction - A unit vector indicating the axial direction
angle - The spread angle of the cone
Returns:
true if the sphere intersects this bounds

checkIntersectionBox

public boolean checkIntersectionBox(float[] minExtents,
                                    float[] maxExtents)
Check for the given AA box intersecting this bounds. The box is described by the minimum and maximum extents on each axis.

Specified by:
checkIntersectionBox in class BoundingVolume
Parameters:
minExtents - The minimum extent value on each axis
maxExtents - The maximum extent value on each axis
Returns:
true if the box intersects this bounds

checkIntersectionFrustum

public int checkIntersectionFrustum(javax.vecmath.Vector4f[] planes,
                                    javax.vecmath.Matrix4d mat)
Check whether this volume intersects with the view frustum.

Specified by:
checkIntersectionFrustum in class BoundingVolume
Parameters:
planes - The 6 planes of the frustum
mat - The vworld to local transformation matrix
Returns:
int FRUSTUM_ALLOUT, FRUSTUM_ALLIN, FRUSTUM_PARTIAL.

checkIntersectionFrustum

public int checkIntersectionFrustum(javax.vecmath.Vector4f[] planes,
                                    javax.vecmath.Matrix4f mat)
Check whether this volume intersects with the view frustum.

Specified by:
checkIntersectionFrustum in class BoundingVolume
Parameters:
planes - The 6 planes of the frustum
mat - The vworld to local transformation matrix
Returns:
int FRUSTUM_ALLOUT, FRUSTUM_ALLIN, FRUSTUM_PARTIAL.

transform

public void transform(javax.vecmath.Matrix4d mat)
Transform the current postion by the given transformation matrix.

Specified by:
transform in class BoundingVolume
Parameters:
mat - The matrix to transform this bounds by

transform

public void transform(javax.vecmath.Matrix4f mat)
Transform the current postion by the given transformation matrix.

Specified by:
transform in class BoundingVolume
Parameters:
mat - The matrix to transform this bounds by

toString

public java.lang.String toString()
Generate a string representation of this box.

Overrides:
toString in class java.lang.Object
Returns:
A string representing the bounds information

setCenter

public void setCenter(float[] pos)
Center the local center of the sphere to be used.

Parameters:
pos - The new position of the center of the sphere to be used

setRadius

public void setRadius(float radius)
Set the radius of the sphere to the new value. When the radius is zero, it is considered to be a point space.

Parameters:
radius - The new radius value to use
Throws:
java.lang.IllegalArgumentException - Radius was negative

getRadius

public float getRadius()
Get the current radius of the sphere

Returns:
A non-negative value

Aviatrix3D
2.1.0

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - 2009 j3d.org