⚠ Preview docs — built from the develop branch and may be unstable. Go to the stable docs.

Vec3.Distance

static float Distance(Vec3 a, Vec3 b)

Calculates the distance between two points in space! Make sure they’re in the same coordinate space! Uses a Sqrt, so it’s not blazing fast, prefer DistanceSq when possible.

   
Vec3 a The first point.
Vec3 b And the second point!
RETURNS: float Distance between the two points.

Examples

Distance between two points

Distance does use a Sqrt call, so only use it if you definitely need the actual distance. Otherwise, consider DistanceSq.

Vec3  pointA   = new Vec3(3,2,5);
Vec3  pointB   = new Vec3(3,2,8);
float distance = Vec3.Distance(pointA, pointB);




Found an issue with these docs, or have some additional questions? Create an Issue on Github!