Ocular Engine
Ocular::Math::Ray Class Reference

#include <Ray.hpp>

Public Member Functions

 Ray (Vector3f const &origin, Vector3f const &direction)
 
void setOrigin (Vector3f const &origin)
 
void setDirection (Vector3f const &direction)
 
Vector3f const & getOrigin () const
 
Vector3f const & getDirection () const
 
Vector3f getPointAlong (float distance) const
 
bool intersects (Point3f const &point) const
 
bool intersects (Ray const &other) const
 
bool intersects (Ray const &other, Point3f &point, float &distance) const
 
bool intersects (BoundsSphere const &bounds) const
 
bool intersects (BoundsSphere const &bounds, Point3f &point, float &distance) const
 
bool intersects (BoundsAABB const &bounds) const
 
bool intersects (BoundsAABB const &bounds, Point3f &point, float &distance) const
 
bool intersects (BoundsOBB const &bounds) const
 
bool intersects (BoundsOBB const &bounds, Point3f &point, float &distance) const
 
bool intersects (Plane const &plane) const
 
bool intersects (Plane const &plane, Vector3f &point, float &distance) const
 

Detailed Description

An infinite line that has an origin and direction.

Constructor & Destructor Documentation

Ocular::Math::Ray::Ray ( Vector3f const &  origin,
Vector3f const &  direction 
)

Creates a ray with the specified origin and direction.

Parameters
[in]origin
[in]directionNormalized vector direction.

Member Function Documentation

Vector3f const & Ocular::Math::Ray::getDirection ( ) const

Returns the normalized direction of the ray.

Vector3f const & Ocular::Math::Ray::getOrigin ( ) const

Returns the origin of the ray.

Vector3f Ocular::Math::Ray::getPointAlong ( float  distance) const

Returns the point that lies the given distance along the ray

bool Ocular::Math::Ray::intersects ( Point3f const &  point) const

Performs an intersection test on a ray and point.

Parameters
[in]point
Returns
TRUE if the two rays intersect.
bool Ocular::Math::Ray::intersects ( Ray const &  other) const

Performs an intersection test on two rays.

Parameters
[in]other
Returns
TRUE if the two rays intersect.
bool Ocular::Math::Ray::intersects ( Ray const &  other,
Point3f point,
float &  distance 
) const

Performs an intersection test on two rays.

Parameters
[in]other
[out]pointThe point that the rays intersect, if they intersect.
[out]distanceThe distance from the ray origin to the point of intersection
Returns
TRUE if the two rays intersect.
bool Ocular::Math::Ray::intersects ( BoundsSphere const &  bounds) const

Performs an intersection test on a ray and bounding sphere.

Parameters
[in]bounds
Returns
TRUE if the ray and bounding sphere intersect.
bool Ocular::Math::Ray::intersects ( BoundsSphere const &  bounds,
Point3f point,
float &  distance 
) const

Performs an intersection test on a ray and bounding sphere.

This version of the method also returns the point at which the two intersect. If speed is of the uptmost concern and/or the exact point of intersection is not required, then the other version may be used instead.

Parameters
[in]bounds
[out]pointThe point that the ray and bounding sphere intersects.
[out]distanceThe distance from the ray origin to the point of intersection
Returns
TRUE if the ray and bounding sphere intersect.
bool Ocular::Math::Ray::intersects ( BoundsAABB const &  bounds) const

Performs an intersection test on a ray and AABB.

Parameters
[in]bounds
Returns
TRUE if the ray and AABB intersect.
bool Ocular::Math::Ray::intersects ( BoundsAABB const &  bounds,
Point3f point,
float &  distance 
) const

Performs an intersection test on a ray and AABB.

This version of the method also returns the point at which the two intersect. If speed is of the uptmost concern and/or the exact point of intersection is not required, then the other version may be used instead.

Parameters
[in]bounds
[out]pointThe point that the ray and AABB intersect, if they intersect.
[out]distanceThe distance from the ray origin to the point of intersection
Returns
TRUE if the ray and AABB intersect.
bool Ocular::Math::Ray::intersects ( BoundsOBB const &  bounds) const

Performs an intersection test on a ray and OBB.

Parameters
[in]bounds
Returns
TRUE if the ray and OBB intersect.
bool Ocular::Math::Ray::intersects ( BoundsOBB const &  bounds,
Point3f point,
float &  distance 
) const

Performs an intersection test on a ray and OBB.

This version of the method also returns the point at which the two intersect. If speed is of the uptmost concern and/or the exact point of intersection is not required, then the other version may be used instead.

Parameters
[in]bounds
[out]pointThe point that the ray and OBB intersect, if they intersect.
[out]distanceThe distance from the ray origin to the point of intersection
Returns
TRUE if the ray and OBB intersect.
bool Ocular::Math::Ray::intersects ( Plane const &  plane) const

Performs an intersection test on a ray and plane.

Note that this operation is actually a line-plane intersection. The line begins at ray origin and extends RAY_LINE_LENGTH.

Parameters
[in]plane
Returns
TRUE if the ray and plane intersect.
bool Ocular::Math::Ray::intersects ( Plane const &  plane,
Vector3f point,
float &  distance 
) const

Performs an intersection test on a ray and plane.

Note that this operation is actually a line-plane intersection. The line begins at ray origin and extends RAY_LINE_LENGTH.

Parameters
[in]plane
[out]pointThe point that the ray and AABB intersect, if they intersect.
[out]distanceThe distance from the ray origin to the point of intersection
Returns
TRUE if the ray and plane intersect.
void Ocular::Math::Ray::setDirection ( Vector3f const &  direction)

Sets the normalized direction of the ray.

void Ocular::Math::Ray::setOrigin ( Vector3f const &  origin)

Sets the origin of the ray.


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