Asked in
Algebra
Geometry

What is the distance formula in 3D?

Answer

User Avatar
Wiki User
September 09, 2009 1:31AM

The formula:

distance=sqrt(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2))+((z1-z2)*(z1-z2)))

In DarkBASIC it's:

function distance3D(x1,y1,z1,x2,y2,z2)

x=x1-x2

y=y1-y2

z=z1-z2 result=sqrt((x*x)+(y*y)+(z*z)) endfunction result

In classic BASIC I think it's:

FUNCTION distance3D(x1,y1,z1,x2,y2,z2)

x=x1-x2

y=y1-y2

z=z1-z2 result=SQRT((x*x)+(y*y)+(z*z))

RETURN result

END FUNCTION