cz.cuni.jagrlib
Class BoundingSphere

java.lang.Object
  extended by cz.cuni.jagrlib.BoundingSphere
All Implemented Interfaces:
BoundingVolume

public class BoundingSphere
extends java.lang.Object
implements BoundingVolume

Sphere as simple bounding-volume.

Since:
0.25
See Also:
BoundingSphere.java

Field Summary
protected  double[] center
          Center of the sphere in cartesian coordinates.
protected  double r
          Radius of the sphere.
protected  double rr
          Square of the radius.
 
Constructor Summary
BoundingSphere(double[] center, double radius)
           
 
Method Summary
 double intersection(double[] P0, double[] P1)
          Ray vs. bounding-volume intersection test with quantitative result.
 boolean intersectsCell(double[] o, double[] size)
          Rectangular box (AABB) vs. bounding-volume intersection test.
 boolean intersectsRay(double[] P0, double[] P1)
          Ray vs. bounding-volume intersection test.
 boolean isInside(double[] point)
          Point vs. bounding-volume test ("inside-test").
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

center

protected double[] center
Center of the sphere in cartesian coordinates.


r

protected double r
Radius of the sphere.


rr

protected double rr
Square of the radius.

Constructor Detail

BoundingSphere

public BoundingSphere(double[] center,
                      double radius)
Method Detail

intersectsRay

public boolean intersectsRay(double[] P0,
                             double[] P1)
Ray vs. bounding-volume intersection test.

Specified by:
intersectsRay in interface BoundingVolume
Parameters:
P0 - Ray origin (double[3] or double[4]).
P1 - Direction vector of the ray (double[3] or double[4]).
Returns:
true if the ray intersects the bounding-volume.
See Also:
intersection(double[], double[])

intersection

public double intersection(double[] P0,
                           double[] P1)
Ray vs. bounding-volume intersection test with quantitative result.

Specified by:
intersection in interface BoundingVolume
Parameters:
P0 - Ray origin (double[3] or double[4]).
P1 - Direction vector of the ray (double[3] or double[4]).
Returns:
t-parameter >= 0.0 if the ray intersects the bounding-volume, number < 0.0 if no intersection exists.
See Also:
intersectsRay(double[], double[])

intersectsCell

public boolean intersectsCell(double[] o,
                              double[] size)
Rectangular box (AABB) vs. bounding-volume intersection test.

Specified by:
intersectsCell in interface BoundingVolume
Parameters:
o - Coordinate of minimal cell-vertex (double[3]).
size - Box size (double[3]).
Returns:
true if intersection of the cell and the bounding-volume is non-empty.
See Also:
isInside(double[])

isInside

public boolean isInside(double[] point)
Point vs. bounding-volume test ("inside-test").

Specified by:
isInside in interface BoundingVolume
Parameters:
point - Coordinates of the 3D point (double[3] or double[4]).
Returns:
true if the given point lies inside the bounding-volume.
See Also:
intersectsCell(double[], double[])