MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ point_ray_distance_sq()

float MayaFlux::Kinesis::point_ray_distance_sq ( const Ray ray,
const glm::vec3 &  point,
float *  out_t = nullptr 
)
inline

Squared perpendicular distance from a point to an infinite ray.

Parameters
rayWorld-space ray.
pointWorld-space position.
out_tIf non-null, receives the projection parameter along the ray. Negative values indicate the point is behind the origin.
Returns
Squared perpendicular distance.

Definition at line 84 of file HitTest.hpp.

88{
89 glm::vec3 op = point - ray.origin;
90 float t = glm::dot(op, ray.direction);
91 glm::vec3 closest = ray.origin + ray.direction * t;
92 glm::vec3 diff = point - closest;
93 if (out_t) {
94 *out_t = t;
95 }
96 return glm::dot(diff, diff);
97}

References MayaFlux::Kinesis::Ray::direction, and MayaFlux::Kinesis::Ray::origin.

Referenced by ray_cast(), and ray_cast_all().

+ Here is the caller graph for this function: