Skip to content

Modern Math Distance

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Math Library › Math Library › Distance

Distance

Returns the distance between two points.

Syntax

Distance( byref a as Vec3, byref b as Vec3 ) as float32

Notes

  • Length( b - a ), with the same one inexact square root.
  • DistanceSquared is the exact form, and is what a proximity test should use.

Examples

#import "std/numeric"
using numeric

dim as Vec3 a = type<Vec3>( 1, 2, 3 ), b = type<Vec3>( 4, 5, 6 )

print Distance( a, b )       '' 5.196152 -- sqr( 27 )

'' A proximity test needs no root: compare squares
dim as float32 radius = 6
print DistanceSquared( a, b ) < radius * radius        '' -1 (true)

Library: Math Library
Category: Math Library
Documented under: Members

Clone this wiki locally