struct TRay

template<typename T>

A ray in 3D space represented with an origin and direction.

Public

Constructors

TRay<T>

TRay<T>()

TRay<T>

TRay<T>(const TVector3<T> &origin, const TVector3<T> &direction)

TRay

TRay()

TRay

TRay(const TVector3<float> &origin, const TVector3<float> &direction)

TRay

TRay()

TRay

TRay(const TVector3<double> &origin, const TVector3<double> &direction)

Methods

GetPoint

TVector3<T> GetPoint(T t) const

Gets the position of a point t units along the ray.

Transform

void Transform(const TMatrix4<T> &matrix)

Transforms the ray by the given matrix.

TransformAffine

void TransformAffine(const TMatrix4<T> &matrix)

Transforms the ray by the given matrix.

Intersects

std::pair<bool, T> Intersects(const TPlane<T> &p) const

Ray/plane intersection, returns boolean result and distance to intersection point.

Intersects

std::pair<bool, T> Intersects(const TSphere<T> &s) const

Ray/sphere intersection, returns boolean result and distance to nearest intersection point.

Intersects

std::pair<bool, T> Intersects(const TAABox<T> &box) const

Ray/axis aligned box intersection, returns boolean result and distance to nearest intersection point.

Intersects

std::pair<bool, T> Intersects(const TVector3<T> &a, const TVector3<T> &b, const TVector3<T> &c, const TVector3<T> &normal, bool positiveSide = true, bool negativeSide = true) const

Ray/triangle intersection, returns boolean result and distance to intersection point.

a
Triangle first vertex.
b
Triangle second vertex.
c
Triangle third vertex.
normal
The normal of the triangle. Doesn't need to be normalized.
positiveSide
(optional) Should intersections with the positive side (normal facing) count.
negativeSide
(optional) Should intersections with the negative side (opposite of normal facing) count.

Returns: Boolean result if intersection happened and distance to intersection point.

GetPoint

TVector3<float> GetPoint(float t) const

Gets the position of a point t units along the ray.

Transform

void Transform(const TMatrix4<float> &matrix)

Transforms the ray by the given matrix.

TransformAffine

void TransformAffine(const TMatrix4<float> &matrix)

Transforms the ray by the given matrix.

Intersects

std::pair<bool, float> Intersects(const TPlane<float> &p) const

Ray/plane intersection, returns boolean result and distance to intersection point.

Intersects

std::pair<bool, float> Intersects(const TSphere<float> &s) const

Ray/sphere intersection, returns boolean result and distance to nearest intersection point.

Intersects

std::pair<bool, float> Intersects(const TAABox<float> &box) const

Ray/axis aligned box intersection, returns boolean result and distance to nearest intersection point.

Intersects

std::pair<bool, float> Intersects(const TVector3<float> &a, const TVector3<float> &b, const TVector3<float> &c, const TVector3<float> &normal, bool positiveSide, bool negativeSide) const

Ray/triangle intersection, returns boolean result and distance to intersection point.

a
Triangle first vertex.
b
Triangle second vertex.
c
Triangle third vertex.
normal
The normal of the triangle. Doesn't need to be normalized.
positiveSide
(optional) Should intersections with the positive side (normal facing) count.
negativeSide
(optional) Should intersections with the negative side (opposite of normal facing) count.

Returns: Boolean result if intersection happened and distance to intersection point.

GetPoint

TVector3<double> GetPoint(double t) const

Gets the position of a point t units along the ray.

Transform

void Transform(const TMatrix4<double> &matrix)

Transforms the ray by the given matrix.

TransformAffine

void TransformAffine(const TMatrix4<double> &matrix)

Transforms the ray by the given matrix.

Intersects

std::pair<bool, double> Intersects(const TPlane<double> &p) const

Ray/plane intersection, returns boolean result and distance to intersection point.

Intersects

std::pair<bool, double> Intersects(const TSphere<double> &s) const

Ray/sphere intersection, returns boolean result and distance to nearest intersection point.

Intersects

std::pair<bool, double> Intersects(const TAABox<double> &box) const

Ray/axis aligned box intersection, returns boolean result and distance to nearest intersection point.

Intersects

std::pair<bool, double> Intersects(const TVector3<double> &a, const TVector3<double> &b, const TVector3<double> &c, const TVector3<double> &normal, bool positiveSide, bool negativeSide) const

Ray/triangle intersection, returns boolean result and distance to intersection point.

a
Triangle first vertex.
b
Triangle second vertex.
c
Triangle third vertex.
normal
The normal of the triangle. Doesn't need to be normalized.
positiveSide
(optional) Should intersections with the positive side (normal facing) count.
negativeSide
(optional) Should intersections with the negative side (opposite of normal facing) count.

Returns: Boolean result if intersection happened and distance to intersection point.

Fields

Origin

TVector3<T> Origin

Direction

TVector3<T> Direction

Origin

TVector3<float> Origin

Direction

TVector3<float> Direction

Origin

TVector3<double> Origin

Direction

TVector3<double> Direction

Operators

operator*

TVector3<T> operator*(T t) const

Gets the position of a point t units along the ray.

operator*

TVector3<float> operator*(float t) const

Gets the position of a point t units along the ray.

operator*

TVector3<double> operator*(double t) const

Gets the position of a point t units along the ray.