Back to class index
float3[Class Summary]
x
y
z
zero[static][const]
one[static][const]
unitX[static][const]
unitY[static][const]
unitZ[static][const]
nan[static][const]
inf[static][const]
ctor (+5 overloads)
ptr() (+1 overload)
operator[](index) (+1 overload)
At(index) (+1 overload)
operators +,-,*,/(v)[const]
operators +=,-=,*=,/=(v)
Add/Sub/Mul/Div(v)[const] (+1 overload)
xx/xy/xz/..()[const]
xyz/xzy/yzx/..()[const]
Swizzled(i,j)[const] (+2 overloads)
SetFromScalar(scalar)
Set(x,y,z)
ToPos4()[const]
ToDir4()[const]
Length()[const]
LengthSq()[const]
Normalize()
Normalized()[const]
ScaleToLength(newLength)
ScaledToLength(newLength)[const]
IsNormalized(epsilonSq)[const]
IsZero(epsilonSq)[const]
IsFinite()[const]
IsPerpendicular(other,epsilon)[const]
Equals(other,epsilon)[const] (+1 overload)
SumOfElements()[const]
ProductOfElements()[const]
AverageOfElements()[const]
MinElement()[const]
MinElementIndex()[const]
MaxElement()[const]
MaxElementIndex()[const]
Abs()[const]
Neg()[const]
Recip()[const]
Min(ceil)[const] (+1 overload)
Max(floor)[const] (+1 overload)
Clamp(floor,ceil)[const] (+1 overload)
Clamp01()[const]
Distance(point)[const] (+9 overloads)
DistanceSq(point)[const]
Dot(v)[const]
Cross(v)[const]
OuterProduct(rhs)[const]
Perpendicular(hint,hint2)[const]
AnotherPerpendicular(hint,hint2)[const]
Reflect(normal)[const]
Refract(...)[const]
ProjectTo(direction)[const]
ProjectToNorm(direction)[const]
AngleBetween(other)[const]
AngleBetweenNorm(normalizedVector)[const]
Decompose(...)[const]
Lerp(b,t)[const]
FromScalar(scalar)[static]
FromString(str)[static]
ScalarTripleProduct(u,v,w)[static]
Lerp(a,b,t)[static]
Orthogonalize(a,b)[static] (+1 overload)
AreOrthogonal(a,b,epsilon)[static] (+1 overload)
Orthonormalize(a,b)[static] (+1 overload)
AreOrthonormal(a,b,epsilon)[static] (+1 overload)
RandomDir(lcg,length)[static]
RandomSphere(lcg,center,radius)[static]
RandomBox(...)[static] (+1 overload)

float3::Distance

Syntax

float float3::Distance(const float3 &point) const; [4 lines of code]
float float3::Distance(const Line &line) const; [1 lines of code]
float float3::Distance(const Ray &ray) const; [1 lines of code]
float float3::Distance(const LineSegment &lineSegment) const; [1 lines of code]
float float3::Distance(const Plane &plane) const; [1 lines of code]
float float3::Distance(const Triangle &triangle) const; [1 lines of code]
float float3::Distance(const AABB &aabb) const; [1 lines of code]
float float3::Distance(const OBB &obb) const; [1 lines of code]
float float3::Distance(const Sphere &sphere) const; [1 lines of code]
float float3::Distance(const Capsule &capsule) const; [1 lines of code]

Computes the distance between this point and the given object.

This function finds the nearest point to this point on the given object, and computes its distance to this point. If this point lies inside the given object, a distance of 0 is returned.

Performance

float float3::Distance(const float3 &point) const

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

float float3::Distance(const Line &line) const

20.526nsecs/call ≈ 48.72M calls/second ≈ 811.97k calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

float float3::Distance(const Ray &ray) const

24.632nsecs/call ≈ 40.6M calls/second ≈ 676.64k calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

float float3::Distance(const LineSegment &lineSegment) const

28.737nsecs/call ≈ 34.8M calls/second ≈ 579.98k calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

float float3::Distance(const Plane &plane) const

4.105nsecs/call ≈ 243.59M calls/second ≈ 4.06M calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

float float3::Distance(const Triangle &triangle) const

32.842nsecs/call ≈ 30.45M calls/second ≈ 507.48k calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

float float3::Distance(const AABB &aabb) const

20.526nsecs/call ≈ 48.72M calls/second ≈ 811.97k calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

float float3::Distance(const OBB &obb) const

45.158nsecs/call ≈ 22.14M calls/second ≈ 369.08k calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

float float3::Distance(const Sphere &sphere) const

16.421nsecs/call ≈ 60.9M calls/second ≈ 1.01M calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

float float3::Distance(const Capsule &capsule) const

32.842nsecs/call ≈ 30.45M calls/second ≈ 507.48k calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

See Also

DistanceSq(), Length(), LengthSq().

Work in progress:

Todo: in float float3::Distance(const float3 &point) const:
Add float3::Distance(Polygon/Circle/Disc/Frustum/Polyhedron).

Leave a Comment

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