Support Forum       G3D Web Page     
Public Member Functions | Static Public Member Functions | Friends | List of all members
G3D::PrecomputedRay Class Reference

A 3D Ray optimized for AABox and Tri intersection, optionally limited to a positive subsegment of the ray. More...

Public Member Functions

 PrecomputedRay (const Ray &ray)
 
 PrecomputedRay ()
 
 PrecomputedRay (const Point3 &origin, const Vector3 &direction, float minDistance=0.0f, float maxDistance=finf())
 
 PrecomputedRay (class BinaryInput &b)
 
PrecomputedRay bumpedRay (float distance) const
 Returns a new ray which has the same direction but an origin advanced along direction by distance. More...
 
PrecomputedRay bumpedRay (float distance, const Vector3 &bumpDirection) const
 Returns a new ray which has the same direction but an origin advanced by distance * bumpDirection. More...
 
Point3 closestPoint (const Point3 &point) const
 Returns the closest point on the PrecomputedRay to point. More...
 
void deserialize (class BinaryInput &b)
 
const Vector3direction () const
 Unit direction vector. More...
 
float distance (const Point3 &point) const
 
Returns the closest distance between point and the PrecomputedRay More...
 
Point3 intersection (const class Plane &plane) const
 
Returns the point where the PrecomputedRay and plane intersect. More...
 
float intersectionTime (const class Sphere &sphere, bool solid=false) const
 
Returns the distance until intersection with the sphere or the (solid) ball bounded by the sphere. More...
 
float intersectionTime (const class Plane &plane) const
 
float intersectionTime (const class Box &box) const
 
float intersectionTime (const class AABox &box) const
 
float intersectionTime (const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, const Vector3 &edge01, const Vector3 &edge02, float &w0, float &w1, float &w2) const
 
The three extra arguments are the weights of vertices 0, 1, and 2 at the intersection point; they are useful for texture mapping and interpolated normals. More...
 
float intersectionTime (const Point3 &vert0, const Point3 &vert1, const Point3 &vert2, const Vector3 &edge01, const Vector3 &edge02) const
 
PrecomputedRay-triangle intersection for a 1-sided triangle. More...
 
float intersectionTime (const Point3 &vert0, const Point3 &vert1, const Point3 &vert2) const
 
float intersectionTime (const Point3 &vert0, const Point3 &vert1, const Point3 &vert2, float &w0, float &w1, float &w2) const
 
float intersectionTime (const Triangle &triangle) const
 
float intersectionTime (const Triangle &triangle, float &w0, float &w1, float &w2) const
 
const Vector3invDirection () const
 Component-wise inverse of direction vector. More...
 
float maxDistance () const
 
float minDistance () const
 
 operator Ray () const
 
PrecomputedRayoperator= (const Ray &ray)
 
const Point3origin () const
 
PrecomputedRay reflect (const Vector3 &newOrigin, const Vector3 &normal) const
 Reflects about the normal using G3D::Vector3::reflectionDirection and bumps the ray slightly from the newOrigin. More...
 
PrecomputedRay refract (const Vector3 &newOrigin, const Vector3 &normal, float iInside, float iOutside) const
 Refracts about the normal using G3D::Vector3::refractionDirection and bumps the ray slightly from the newOrigin. More...
 
void serialize (class BinaryOutput &b) const
 
void set (const Point3 &origin, const Vector3 &direction, float minDistance=0.0f, float maxDistance=finf())
 

Static Public Member Functions

static PrecomputedRay fromOriginAndDirection (const Point3 &point, const Vector3 &direction, float minDistance=0.0f, float maxDistance=finf())
 Creates a PrecomputedRay from a origin and a (nonzero) unit direction. More...
 

Friends

class Intersect
 

Detailed Description

A 3D Ray optimized for AABox and Tri intersection, optionally limited to a positive subsegment of the ray.

See also
G3D::Ray, G3D::LineSegment, G3D::Line

Constructor & Destructor Documentation

◆ PrecomputedRay() [1/4]

G3D::PrecomputedRay::PrecomputedRay ( const Ray ray)
explicit

◆ PrecomputedRay() [2/4]

G3D::PrecomputedRay::PrecomputedRay ( )
inline

◆ PrecomputedRay() [3/4]

G3D::PrecomputedRay::PrecomputedRay ( const Point3 origin,
const Vector3 direction,
float  minDistance = 0.0f,
float  maxDistance = finf() 
)
inline
Parameters
directionAssumed to have unit length

◆ PrecomputedRay() [4/4]

G3D::PrecomputedRay::PrecomputedRay ( class BinaryInput b)

Member Function Documentation

◆ bumpedRay() [1/2]

PrecomputedRay G3D::PrecomputedRay::bumpedRay ( float  distance) const
inline

Returns a new ray which has the same direction but an origin advanced along direction by distance.

The min and max distance of the ray are unmodified.

◆ bumpedRay() [2/2]

PrecomputedRay G3D::PrecomputedRay::bumpedRay ( float  distance,
const Vector3 bumpDirection 
) const
inline

Returns a new ray which has the same direction but an origin advanced by distance * bumpDirection.

The min and max distance of the ray are unmodified.

◆ closestPoint()

Point3 G3D::PrecomputedRay::closestPoint ( const Point3 point) const
inline

Returns the closest point on the PrecomputedRay to point.

Referenced by distance().

◆ deserialize()

void G3D::PrecomputedRay::deserialize ( class BinaryInput b)

◆ direction()

const Vector3& G3D::PrecomputedRay::direction ( ) const
inline

Unit direction vector.

Referenced by fromOriginAndDirection(), and PrecomputedRay().

◆ distance()

float G3D::PrecomputedRay::distance ( const Point3 point) const
inline


Returns the closest distance between point and the PrecomputedRay

Referenced by bumpedRay().

◆ fromOriginAndDirection()

static PrecomputedRay G3D::PrecomputedRay::fromOriginAndDirection ( const Point3 point,
const Vector3 direction,
float  minDistance = 0.0f,
float  maxDistance = finf() 
)
inlinestatic

Creates a PrecomputedRay from a origin and a (nonzero) unit direction.

◆ intersection()

Point3 G3D::PrecomputedRay::intersection ( const class Plane plane) const


Returns the point where the PrecomputedRay and plane intersect.

If there is no intersection, returns a point at infinity.

Planes are considered one-sided, so the ray will not intersect a plane where the normal faces in the traveling direction.

◆ intersectionTime() [1/10]

float G3D::PrecomputedRay::intersectionTime ( const class Sphere sphere,
bool  solid = false 
) const


Returns the distance until intersection with the sphere or the (solid) ball bounded by the sphere.

Will be 0 if inside the sphere, inf if there is no intersection.

The ray direction is not normalized. If the ray direction has unit length, the distance from the origin to intersection is equal to the time. If the direction does not have unit length, the distance = time * direction.length().

See also the G3D::CollisionDetection "movingPoint" methods, which give more information about the intersection.

Parameters
solidIf true, rays inside the sphere immediately intersect (good for collision detection). If false, they hit the opposite side of the sphere (good for ray tracing).

Referenced by intersectionTime().

◆ intersectionTime() [2/10]

float G3D::PrecomputedRay::intersectionTime ( const class Plane plane) const

◆ intersectionTime() [3/10]

float G3D::PrecomputedRay::intersectionTime ( const class Box box) const

◆ intersectionTime() [4/10]

float G3D::PrecomputedRay::intersectionTime ( const class AABox box) const

◆ intersectionTime() [5/10]

float G3D::PrecomputedRay::intersectionTime ( const Vector3 v0,
const Vector3 v1,
const Vector3 v2,
const Vector3 edge01,
const Vector3 edge02,
float &  w0,
float &  w1,
float &  w2 
) const
inline


The three extra arguments are the weights of vertices 0, 1, and 2 at the intersection point; they are useful for texture mapping and interpolated normals.

◆ intersectionTime() [6/10]

float G3D::PrecomputedRay::intersectionTime ( const Point3 vert0,
const Point3 vert1,
const Point3 vert2,
const Vector3 edge01,
const Vector3 edge02 
) const
inline


PrecomputedRay-triangle intersection for a 1-sided triangle.

Fastest version.

Referenced Code: http://www.acm.org/jgt/papers/MollerTrumbore97/
http://www.graphics.cornell.edu/pubs/1997/MT97.html

◆ intersectionTime() [7/10]

float G3D::PrecomputedRay::intersectionTime ( const Point3 vert0,
const Point3 vert1,
const Point3 vert2 
) const
inline

◆ intersectionTime() [8/10]

float G3D::PrecomputedRay::intersectionTime ( const Point3 vert0,
const Point3 vert1,
const Point3 vert2,
float &  w0,
float &  w1,
float &  w2 
) const
inline

◆ intersectionTime() [9/10]

float G3D::PrecomputedRay::intersectionTime ( const Triangle triangle) const
inline

◆ intersectionTime() [10/10]

float G3D::PrecomputedRay::intersectionTime ( const Triangle triangle,
float &  w0,
float &  w1,
float &  w2 
) const
inline

◆ invDirection()

const Vector3& G3D::PrecomputedRay::invDirection ( ) const
inline

Component-wise inverse of direction vector.

May have inf() components

◆ maxDistance()

float G3D::PrecomputedRay::maxDistance ( ) const
inline

◆ minDistance()

float G3D::PrecomputedRay::minDistance ( ) const
inline

◆ operator Ray()

G3D::PrecomputedRay::operator Ray ( ) const

◆ operator=()

PrecomputedRay& G3D::PrecomputedRay::operator= ( const Ray ray)

◆ origin()

const Point3& G3D::PrecomputedRay::origin ( ) const
inline

Referenced by PrecomputedRay().

◆ reflect()

PrecomputedRay G3D::PrecomputedRay::reflect ( const Vector3 newOrigin,
const Vector3 normal 
) const

Reflects about the normal using G3D::Vector3::reflectionDirection and bumps the ray slightly from the newOrigin.

Sets the min distance to zero and the max distance to infinity.

◆ refract()

PrecomputedRay G3D::PrecomputedRay::refract ( const Vector3 newOrigin,
const Vector3 normal,
float  iInside,
float  iOutside 
) const

Refracts about the normal using G3D::Vector3::refractionDirection and bumps the ray slightly from the newOrigin.

Sets the min distance to zero and the max distance to infinity.

◆ serialize()

void G3D::PrecomputedRay::serialize ( class BinaryOutput b) const

◆ set()

void G3D::PrecomputedRay::set ( const Point3 origin,
const Vector3 direction,
float  minDistance = 0.0f,
float  maxDistance = finf() 
)
Parameters
directionAssumed to have unit length

Friends And Related Function Documentation

◆ Intersect

friend class Intersect
friend

documentation generated on Wed Nov 24 2021 08:01:59 using doxygen 1.8.15