jme.geometry.bounding
Class BoundingCapsule

java.lang.Object
  extended byjme.geometry.bounding.BoundingCapsule
All Implemented Interfaces:
BoundingVolume

public class BoundingCapsule
extends java.lang.Object
implements BoundingVolume

BoundingCapsule defines a bounding volume in the shape of a capsule, where a capsule is an extension of sphere. A capsule can be thought of as a cylinder with domed caps.

Version:
$Id: BoundingCapsule.java,v 1.5 2003/09/08 20:29:28 mojomonkey Exp $
Author:
Mark Powell

Constructor Summary
BoundingCapsule()
          Default constructor instantiates an empty bounding capsule.
BoundingCapsule(Line lineSegment, float radius)
          Constructor instantiates a new BoundingCapsule with supplied attributes of line segment and radius.
 
Method Summary
 float distance(BoundingVolume volume)
           
 Vector getDirection()
          getDirection gets the direction vector of the line segment that makes up the capsule.
 Vector getOrigin()
          getOrigin gets the origin of the line segment that makes up the capsule.
 float getRadius()
          getRadius gets the radius of the capsule.
 boolean hasCollision(BoundingVolume volume)
           
 boolean isVisible(Frustum frustum)
           
 void leastSquaresFit(Vector[] points)
          leastSquaresFit selects a parameterized equation that represents a discrete set of points in a continuous manner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoundingCapsule

public BoundingCapsule()
Default constructor instantiates an empty bounding capsule. Both the radius and the line segment are initial values. It is recommended to use the leastSquaresFit method with an array of points.


BoundingCapsule

public BoundingCapsule(Line lineSegment,
                       float radius)
Constructor instantiates a new BoundingCapsule with supplied attributes of line segment and radius.

Parameters:
lineSegment - the line defining the length of center of the capsule.
radius - the radius of the capsule.
Method Detail

getOrigin

public Vector getOrigin()
getOrigin gets the origin of the line segment that makes up the capsule.

Returns:
the origin of the line segment.

getDirection

public Vector getDirection()
getDirection gets the direction vector of the line segment that makes up the capsule.

Returns:
the direction of the line segment.

getRadius

public float getRadius()
getRadius gets the radius of the capsule.

Returns:
the radius of the capsule.

leastSquaresFit

public void leastSquaresFit(Vector[] points)
leastSquaresFit selects a parameterized equation that represents a discrete set of points in a continuous manner. The radius is then found to be the maximum distance from the data points to the line.

Parameters:
points - the points to contain.

hasCollision

public boolean hasCollision(BoundingVolume volume)
Specified by:
hasCollision in interface BoundingVolume

distance

public float distance(BoundingVolume volume)
Specified by:
distance in interface BoundingVolume

isVisible

public boolean isVisible(Frustum frustum)
Specified by:
isVisible in interface BoundingVolume