jme.geometry.bounding
Class BoundingCylinder

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

public class BoundingCylinder
extends java.lang.Object
implements BoundingVolume

BoundingCylinder defines a cylinder as a set of all points a distance r from a line P + tD where D is unit length. We are defining the cylinder as a subset of this line and therefore finite. All points can be also defined by the equation Xi = P + RYi where R = [U V D], and U V causes R to be orthonormal.

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

Constructor Summary
BoundingCylinder()
          Constructor instantiates a new BoundingCylinder with default (zero) attributes.
BoundingCylinder(Vector center, Vector direction, Vector u, Vector v, float height, float radius)
          Constructor instantiates a new BoundingCylinder with set attributes.
 
Method Summary
 float distance(BoundingVolume volume)
           
 void generateCoordinateSystem()
          generateCoordinateSystem calculates the matrix R = [U V D].
 boolean hasCollision(BoundingVolume volume)
           
 boolean isVisible(Frustum frustum)
           
 void leastSquaresFit(Vector[] points)
          leastSquaresFit builds a cylinder from a collection of points where the radius is the distance from a line approximation to the furthest point and the height is the direction(max) - direction(min).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoundingCylinder

public BoundingCylinder()
Constructor instantiates a new BoundingCylinder with default (zero) attributes.


BoundingCylinder

public BoundingCylinder(Vector center,
                        Vector direction,
                        Vector u,
                        Vector v,
                        float height,
                        float radius)
Constructor instantiates a new BoundingCylinder with set attributes.

Parameters:
center - the center of the cylinder.
direction - the orientation of the cylinder.
u - the U unit vector to make [u v direction] orthonormal.
v - the V unit vector to make [u v direction] orthonormal.
height - the height of the cylinder.
radius - the radius of the cylinder.
Method Detail

generateCoordinateSystem

public void generateCoordinateSystem()
generateCoordinateSystem calculates the matrix R = [U V D].


leastSquaresFit

public void leastSquaresFit(Vector[] points)
leastSquaresFit builds a cylinder from a collection of points where the radius is the distance from a line approximation to the furthest point and the height is the direction(max) - direction(min). It is assumed that the matrix [U V D] has been predefined either through construction or calling generateCoordinateSystem.

Parameters:
points - the collection of points that the cylinder contains.

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