Back to class index
Ray[Class Summary]
pos
dir
ctor (+3 overloads)
GetPoint(distance)[const]
Transform(transform) (+3 overloads)
Contains(...)[const] (+1 overload)
Equals(otherRay,epsilon)[const]
Distance(point,d)[const] (+9 overloads)
ClosestPoint(targetPoint,d)[const] (+3 overloads)
Intersects(...)[const] (+13 overloads)
IntersectsDisc(disc)[const]
ToLine()[const]
ToLineSegment(d)[const]

Ray::ClosestPoint

Syntax

float3 Ray::ClosestPoint(const float3 &targetPoint, float *d=0) const; [7 lines of code]
float3 Ray::ClosestPoint(const Ray &other, float *d=0, float *d2=0) const; [5 lines of code]
float3 Ray::ClosestPoint(const Line &other, float *d=0, float *d2=0) const; [4 lines of code]
float3 Ray::ClosestPoint(const LineSegment &other, float *d=0, float *d2=0) const; [5 lines of code]

Computes the closest point on this ray to the given object.

If the other object intersects this ray, this function will return an arbitrary point inside the region of intersection.

Parameters

float *d [out]If specified, receives the parametric distance along this ray that specifies the closest point on this ray to the given object. The value returned here can be negative. This pointer may be null.float *d2 [out]If specified, receives the parametric distance along the other line that specifies the closest point on that line to this ray. The value returned here can be negative. This pointer may be null.

Performance

float3 Ray::ClosestPoint(const float3 &targetPoint, float *d=0) const

12.316nsecs/call ≈ 81.2M calls/second ≈ 1.35M calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

float3 Ray::ClosestPoint(const Ray &other, float *d=0, float *d2=0) const

41.053nsecs/call ≈ 24.36M calls/second ≈ 405.98k calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

float3 Ray::ClosestPoint(const Line &other, float *d=0, float *d2=0) const

41.053nsecs/call ≈ 24.36M calls/second ≈ 405.98k calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

float3 Ray::ClosestPoint(const LineSegment &other, float *d=0, float *d2=0) const

36.947nsecs/call ≈ 27.07M calls/second ≈ 451.09k calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

See Also

Contains(), Distance(), Intersects(), GetPoint().

Work in progress:

Bug: in float3 Ray::ClosestPoint(const Ray &other, float *d=0, float *d2=0) const:
Properly cap d2.
Bug: in float3 Ray::ClosestPoint(const LineSegment &other, float *d=0, float *d2=0) const:
Properly cap d2.

Leave a Comment

Name:
Comments:
Captcha:captcha image Type in the black symbols:
Back to class index