decDCollisionCapsule Class Reference

Capsule collision volume. More...

#include <decDCollisionCapsule.h>

Inheritance diagram for decDCollisionCapsule:
decDCollisionVolume

List of all members.

Public Member Functions

Constructors and Destructors
 decDCollisionCapsule ()
 Creates a new unoriented capsule.
 decDCollisionCapsule (const decDVector &position, double halfHeight, double topRadius, double bottomRadius)
 Creates a new unoriented capsule.
 decDCollisionCapsule (const decDVector &position, double halfHeight, double topRadius, double bottomRadius, const decQuaternion &orientation)
 Creates a new oriented capsule.
virtual ~decDCollisionCapsule ()
 Cleans up the collision Capsule.
First Stage Dispatch
virtual bool VolumeHitsVolume (decDCollisionVolume *volume)
 Determines if this volume collides with the given one.
virtual double VolumeMoveHitsVolume (decDCollisionVolume *volume, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits another one.
Second Stage Dispatch
virtual bool SphereHitsVolume (decDCollisionSphere *sphere)
 Determines if the given sphere collides with this volume.
virtual bool CylinderHitsVolume (decDCollisionCylinder *cylinder)
 Determines if the given cylinder collides with this volume.
virtual bool CapsuleHitsVolume (decDCollisionCapsule *capsule)
 Determines if the given capsule collides with this volume.
virtual bool BoxHitsVolume (decDCollisionBox *box)
 Determines if the given box collides with this volume.
virtual bool TriangleHitsVolume (decDCollisionTriangle *triangle)
 Determines if the given triangle collides with this volume.
virtual bool FrustumHitsVolume (decDCollisionFrustum *frustum)
 Determines if the given frustum collides with this volume.
virtual double SphereMoveHitsVolume (decDCollisionSphere *sphere, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits a sphere.
virtual double CylinderMoveHitsVolume (decDCollisionCylinder *cylinder, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits a cylinder.
virtual double CapsuleMoveHitsVolume (decDCollisionCapsule *capsule, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits a capsule.
virtual double BoxMoveHitsVolume (decDCollisionBox *box, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits a box.
virtual double TriangleMoveHitsVolume (decDCollisionTriangle *triangle, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits a triangle.
virtual double FrustumMoveHitsVolume (decDCollisionFrustum *frustum, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits a frustum.
virtual double PointMoveHitsVolume (const decDVector &point, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until the given point hits this volume.
Enclosing Volumes
virtual void GetEnclosingSphere (decDCollisionSphere *sphere)
 Retrieves the sphere volume best enclosing this volume.
virtual void GetEnclosingBox (decDCollisionBox *box)
 Retrieves the box volume best enclosing this volume.
Miscelanous Functions
virtual decDVector ClosestPointTo (const decDVector &point)
 Retrieves the closest point on the volume.
virtual decDVector NormalAtPoint (const decDVector &point)
 Retrieves the surface normal through the given point.
virtual bool RayHitsVolume (const decDVector &rayOrigin, const decDVector &rayDirection, double &hitDistance)
 Determines if a ray hits the volume.
Visiting
virtual void Visit (decDCollisionVolumeVisitor *visitor)
 Visits the collision volume.
Collision Routines
bool SphereHitsCapsule (decDCollisionSphere *sphere)
 Determines if the given sphere hits this capsule.
bool CylinderHitsCapsule (decDCollisionCylinder *cylinder)
 Determines if the given cylinder hits this capsule.
bool CapsuleHitsCapsule (decDCollisionCapsule *capsule)
 Determines if the given capsule hits this capsule.
double SphereMoveHitsCapsule (decDCollisionSphere *sphere, const decDVector &displacement, decDVector *normal)
 Determines the distance of the given sphere to move until colliding with this capsule.
double CylinderMoveHitsCapsule (decDCollisionCylinder *cylinder, const decDVector &displacement, decDVector *normal)
 Determines the distance of the given cylinder to move until colliding with this capsule.
double CapsuleMoveHitsCapsule (decDCollisionCapsule *capsule, const decDVector &displacement, decDVector *normal)
 Determines the distance of the given capsule to move until colliding with this capsule.
Management
const decDVectorGetPosition () const
 Retrieves the capsule center.
void SetPosition (const decDVector &position)
 Sets the position.
const decQuaternionGetOrientation () const
 Retrieves the orientation.
void SetOrientation (const decQuaternion &orientation)
 Sets the orientation.
void ClearOrientation ()
 Clears the orientation of the capsule setting it to the identity quaternion.
double GetHalfHeight () const
 Retrieves the half height.
void SetHalfHeight (double halfHeight)
 Sets the half height.
double GetTopRadius () const
 Retrieves the top radius.
void SetTopRadius (double radius)
 Sets the top radius.
double GetBottomRadius () const
 Retrieves the bottom radius.
void SetBottomRadius (double radius)
 Sets the bottom radius.
void SetRadius (double radius)
 Sets both radi to the same value.
bool GetOriented () const
 Determines if this capsule is oriented.
bool GetAxisAligned () const
 Determines if this capsule is axis aligned.
bool GetTapered () const
 Determines if this capsule is tapered.
const decDVectorGetAxisX () const
 Retrieves the X-Axis.
const decDVectorGetAxisY () const
 Retrieves the Y-Axis.
const decDVectorGetAxisZ () const
 Retrieves the Z-Axis.
decDVector WorldToLocal (const decDVector &point) const
 Transforms a point from world coordinates into local coordinates.
decDVector LocalToWorld (const decDVector &point) const
 Transforms a point from local coordinates into world coordinates.
decDVector NormalWorldToLocal (const decDVector &normal) const
 Transforms a normal from world coordinates into local coordinates.
decDVector NormalLocalToWorld (const decDVector &normal) const
 Transforms a normal from local coordinates into world coordinates.

Detailed Description

Capsule collision volume.

Defines a collision volume in the shape of a capsule. The capsule is defined by a half height and two radi one for the top sphere and one for the bottom sphere. The capsule is oriented along the Y-Axis. A capsule with different radi is a tapered capsule while a capsule with two identical radi is a common capsule. Common capsules are usually faster.

Author:
Plüss Roland
Version:
1.0
Date:
2008
Warning:
This class is partially implemented. See the collision routine notices for functions not implemented yet.
Todo:
  • Implementing CylinderHitsCapsule

Constructor & Destructor Documentation

decDCollisionCapsule::decDCollisionCapsule (  )

Creates a new unoriented capsule.

The half height is set to 0.5, the top and bottom radius are set both to 0.5 too.

decDCollisionCapsule::decDCollisionCapsule ( const decDVector position,
double  halfHeight,
double  topRadius,
double  bottomRadius 
)

Creates a new unoriented capsule.

Parameters:
positionCenter of the capsule.
halfHeightHalf the height of the capsule. Has to be greater than 0.
topRadiusRadius of the top cap. Has to be greater than 0.
bottomRadiusRadius of the bottom cap. Has to be greater than 0.
decDCollisionCapsule::decDCollisionCapsule ( const decDVector position,
double  halfHeight,
double  topRadius,
double  bottomRadius,
const decQuaternion orientation 
)

Creates a new oriented capsule.

Parameters:
positionCenter of the capsule.
halfHeightHalf the height of the capsule. Has to be greater than 0.
topRadiusRadius of the top cap. Has to be greater than 0.
bottomRadiusRadius of the bottom cap. Has to be greater than 0.
orientationOrientation of the capsule as normalized quaternion.
virtual decDCollisionCapsule::~decDCollisionCapsule (  ) [virtual]

Cleans up the collision Capsule.


Member Function Documentation

virtual bool decDCollisionCapsule::BoxHitsVolume ( decDCollisionBox box ) [virtual]

Determines if the given box collides with this volume.

The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

virtual double decDCollisionCapsule::BoxMoveHitsVolume ( decDCollisionBox box,
const decDVector displacement,
decDVector normal 
) [virtual]

Retrieves the distance travelled along a given displacement vector until this volume hits a box.

The returned value is in the range of 0 to 1. If no collision happens 1 is returned. In case of collision 'normal' has to be filled in with a normalized vector designating the plane along which this volume can be moved without colliding the given volume. Set 'normal' to NULL if you are not interested in this information. The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

bool decDCollisionCapsule::CapsuleHitsCapsule ( decDCollisionCapsule capsule )

Determines if the given capsule hits this capsule.

virtual bool decDCollisionCapsule::CapsuleHitsVolume ( decDCollisionCapsule capsule ) [virtual]

Determines if the given capsule collides with this volume.

The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

double decDCollisionCapsule::CapsuleMoveHitsCapsule ( decDCollisionCapsule capsule,
const decDVector displacement,
decDVector normal 
)

Determines the distance of the given capsule to move until colliding with this capsule.

Warning:
Function is not implemented yet and always returns 1.
virtual double decDCollisionCapsule::CapsuleMoveHitsVolume ( decDCollisionCapsule capsule,
const decDVector displacement,
decDVector normal 
) [virtual]

Retrieves the distance travelled along a given displacement vector until this volume hits a capsule.

The returned value is in the range of 0 to 1. If no collision happens 1 is returned. In case of collision 'normal' has to be filled in with a normalized vector designating the plane along which this volume can be moved without colliding the given volume. Set 'normal' to NULL if you are not interested in this information. The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

void decDCollisionCapsule::ClearOrientation (  )

Clears the orientation of the capsule setting it to the identity quaternion.

virtual decDVector decDCollisionCapsule::ClosestPointTo ( const decDVector point ) [virtual]

Retrieves the closest point on the volume.

Implements decDCollisionVolume.

bool decDCollisionCapsule::CylinderHitsCapsule ( decDCollisionCylinder cylinder )

Determines if the given cylinder hits this capsule.

Warning:
Not implemented yet and always returns false.
virtual bool decDCollisionCapsule::CylinderHitsVolume ( decDCollisionCylinder cylinder ) [virtual]

Determines if the given cylinder collides with this volume.

The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

double decDCollisionCapsule::CylinderMoveHitsCapsule ( decDCollisionCylinder cylinder,
const decDVector displacement,
decDVector normal 
)

Determines the distance of the given cylinder to move until colliding with this capsule.

Warning:
Function is not implemented yet and always returns 1.
virtual double decDCollisionCapsule::CylinderMoveHitsVolume ( decDCollisionCylinder cylinder,
const decDVector displacement,
decDVector normal 
) [virtual]

Retrieves the distance travelled along a given displacement vector until this volume hits a cylinder.

The returned value is in the range of 0 to 1. If no collision happens 1 is returned. In case of collision 'normal' has to be filled in with a normalized vector designating the plane along which this volume can be moved without colliding the given volume. Set 'normal' to NULL if you are not interested in this information. The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

virtual bool decDCollisionCapsule::FrustumHitsVolume ( decDCollisionFrustum frustum ) [virtual]

Determines if the given frustum collides with this volume.

The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

virtual double decDCollisionCapsule::FrustumMoveHitsVolume ( decDCollisionFrustum frustum,
const decDVector displacement,
decDVector normal 
) [virtual]

Retrieves the distance travelled along a given displacement vector until this volume hits a frustum.

The returned value is in the range of 0 to 1. If no collision happens 1 is returned. In case of collision 'normal' has to be filled in with a normalized vector designating the plane along which this volume can be moved without colliding the given volume. Set 'normal' to NULL if you are not interested in this information. The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

bool decDCollisionCapsule::GetAxisAligned (  ) const [inline]

Determines if this capsule is axis aligned.

Returns:
True if the capsule has an orientation equal to the identity quaternion.
const decDVector& decDCollisionCapsule::GetAxisX (  ) const [inline]

Retrieves the X-Axis.

Returns:
Normalized vector along the X-Axis.
const decDVector& decDCollisionCapsule::GetAxisY (  ) const [inline]

Retrieves the Y-Axis.

Returns:
Normalized vector along the Y-Axis.
const decDVector& decDCollisionCapsule::GetAxisZ (  ) const [inline]

Retrieves the Z-Axis.

Returns:
Normalized vector along the Z-Axis.
double decDCollisionCapsule::GetBottomRadius (  ) const [inline]

Retrieves the bottom radius.

virtual void decDCollisionCapsule::GetEnclosingBox ( decDCollisionBox box ) [virtual]

Retrieves the box volume best enclosing this volume.

Implements decDCollisionVolume.

virtual void decDCollisionCapsule::GetEnclosingSphere ( decDCollisionSphere sphere ) [virtual]

Retrieves the sphere volume best enclosing this volume.

Implements decDCollisionVolume.

double decDCollisionCapsule::GetHalfHeight (  ) const [inline]

Retrieves the half height.

const decQuaternion& decDCollisionCapsule::GetOrientation (  ) const [inline]

Retrieves the orientation.

bool decDCollisionCapsule::GetOriented (  ) const [inline]

Determines if this capsule is oriented.

Returns:
True if the capsule has an orientation other than the identity quaternion.
const decDVector& decDCollisionCapsule::GetPosition (  ) const [inline]

Retrieves the capsule center.

bool decDCollisionCapsule::GetTapered (  ) const [inline]

Determines if this capsule is tapered.

Returns:
True if the top and bottom radius are not identical.
double decDCollisionCapsule::GetTopRadius (  ) const [inline]

Retrieves the top radius.

decDVector decDCollisionCapsule::LocalToWorld ( const decDVector point ) const

Transforms a point from local coordinates into world coordinates.

virtual decDVector decDCollisionCapsule::NormalAtPoint ( const decDVector point ) [virtual]

Retrieves the surface normal through the given point.

The point is either right on the surface or near to it. This function is relaxing in this case and tries to calculate the best normal pointing from the volume at the point. For certain points a normal is impossible to determine. The normal in this case is undefined.

Parameters:
pointPoint to determine the normal for.
Returns:
Surface normal at given point.

Reimplemented from decDCollisionVolume.

decDVector decDCollisionCapsule::NormalLocalToWorld ( const decDVector normal ) const

Transforms a normal from local coordinates into world coordinates.

decDVector decDCollisionCapsule::NormalWorldToLocal ( const decDVector normal ) const

Transforms a normal from world coordinates into local coordinates.

virtual double decDCollisionCapsule::PointMoveHitsVolume ( const decDVector point,
const decDVector displacement,
decDVector normal 
) [virtual]

Retrieves the distance travelled along a given displacement vector until the given point hits this volume.

The returned value is in the range of 0 to 1. If no collision happens 1 is returned. In case of collision 'normal' has to be filled in with a normalized vector designating the plane along which this volume can be moved without colliding the given volume. Set 'normal' to NULL if you are not interested in this information. The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

virtual bool decDCollisionCapsule::RayHitsVolume ( const decDVector rayOrigin,
const decDVector rayDirection,
double &  hitDistance 
) [virtual]

Determines if a ray hits the volume.

Parameters:
rayOriginOrigin of the ray.
rayDirectionNormalized direction of the ray.
hitDistanceIf the ray hits this will be set to the distance from the ray origin to the collision point.
Returns:
True if the ray hits the volume.

Reimplemented from decDCollisionVolume.

void decDCollisionCapsule::SetBottomRadius ( double  radius )

Sets the bottom radius.

Parameters:
radiusRadius of the bottom capsule cap. Has to be greater than 0.
void decDCollisionCapsule::SetHalfHeight ( double  halfHeight )

Sets the half height.

Parameters:
halfHeightHalf the height of the capsule. Has to be greater than 0.
void decDCollisionCapsule::SetOrientation ( const decQuaternion orientation )

Sets the orientation.

Parameters:
orientationNormalized rotation quaternion.
void decDCollisionCapsule::SetPosition ( const decDVector position )

Sets the position.

Parameters:
positionCenter of capsule.
void decDCollisionCapsule::SetRadius ( double  radius )

Sets both radi to the same value.

Parameters:
radiusRadius of both the top and bottom cap. Has to be greater than 0.
void decDCollisionCapsule::SetTopRadius ( double  radius )

Sets the top radius.

Parameters:
radiusRadius of the top capsule cap. Has to be greater than 0.
bool decDCollisionCapsule::SphereHitsCapsule ( decDCollisionSphere sphere )

Determines if the given sphere hits this capsule.

virtual bool decDCollisionCapsule::SphereHitsVolume ( decDCollisionSphere sphere ) [virtual]

Determines if the given sphere collides with this volume.

The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

double decDCollisionCapsule::SphereMoveHitsCapsule ( decDCollisionSphere sphere,
const decDVector displacement,
decDVector normal 
)

Determines the distance of the given sphere to move until colliding with this capsule.

Warning:
Function is not implemented yet and always returns 1.
virtual double decDCollisionCapsule::SphereMoveHitsVolume ( decDCollisionSphere sphere,
const decDVector displacement,
decDVector normal 
) [virtual]

Retrieves the distance travelled along a given displacement vector until this volume hits a sphere.

The returned value is in the range of 0 to 1. If no collision happens 1 is returned. In case of collision 'normal' has to be filled in with a normalized vector designating the plane along which this volume can be moved without colliding the given volume. Set 'normal' to NULL if you are not interested in this information. The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

virtual bool decDCollisionCapsule::TriangleHitsVolume ( decDCollisionTriangle triangle ) [virtual]

Determines if the given triangle collides with this volume.

The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

virtual double decDCollisionCapsule::TriangleMoveHitsVolume ( decDCollisionTriangle triangle,
const decDVector displacement,
decDVector normal 
) [virtual]

Retrieves the distance travelled along a given displacement vector until this volume hits a triangle.

The returned value is in the range of 0 to 1. If no collision happens 1 is returned. In case of collision 'normal' has to be filled in with a normalized vector designating the plane along which this volume can be moved without colliding the given volume. Set 'normal' to NULL if you are not interested in this information. The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

virtual void decDCollisionCapsule::Visit ( decDCollisionVolumeVisitor visitor ) [virtual]

Visits the collision volume.

Implements decDCollisionVolume.

virtual bool decDCollisionCapsule::VolumeHitsVolume ( decDCollisionVolume volume ) [virtual]

Determines if this volume collides with the given one.

The subclass has to dispatch to a second stage function here.

Implements decDCollisionVolume.

virtual double decDCollisionCapsule::VolumeMoveHitsVolume ( decDCollisionVolume volume,
const decDVector displacement,
decDVector normal 
) [virtual]

Retrieves the distance travelled along a given displacement vector until this volume hits another one.

The returned value is in the range of 0 to 1. If no collision happens 1 is returned. In case of collision 'normal' has to be filled in with a normalized vector designating the plane along which this volume can be moved without colliding the given volume. Set 'normal' to NULL if you are not interested in this information. The subclass has to dispatch to a second stage function here.

Implements decDCollisionVolume.

decDVector decDCollisionCapsule::WorldToLocal ( const decDVector point ) const

Transforms a point from world coordinates into local coordinates.


The documentation for this class was generated from the following file: