This is kind of funny because i actually made the correct function a while back. I can't understand the maths behind these and i made them.
Correct function:
function threedistance(x1#,y1#,z1#,x2#,y2#,z2#)
d#=sqrt(((x2#-x1#)*(x2#-x1#))+((y2#-y1#)*(y2#-y1#))+((z2#-z1#)*(z2#-z1#)))
endfunction d#
Incorrect function:
function threedistance(x1#,y1#,z1#,x2#,y2#,z2#)
d#=sqrt(sqrt(((x2-x1)*(x2-x1))+((z2-z1)*(z2-z1)))+((y2#-y1#)*(y2#-y1#)))
endfunction d#
Pythagorean theorem=a^2+b^2=c^2 translated to c=sqrt(a^2+b^2)
Now in my head. the second function makes more sense. what i'm doing is taking the x and z points and using the pythagorean theorem to get the hypotenuse of the space between the x and z points, (x2-x1)^2=a while (z2-z1)^2=b c=sqrt(a+b), then i'm take the hypotenuse and the space between y points and getting the hypotenuse between them, a=old c while b=(y2-y1)^2 c=sqrt(a+b). That makes sense to me in my head but its incorrect. I know i have the right formula for the first one, but i just want to understand what i did again
and using the hypotenuse as my a and
edit:
nevermind. i resolved it. i wasn't squaring the old hypotenuse when i brought it into the function again
here's the incorrect function corrected
function mthreedistance(x1#,y1#,z1#,x2#,y2#,z2#)
d#=sqrt((sqrt(((x2#-x1#)*(x2#-x1#))+((z2#-z1#)*(z2#-z1#)))*sqrt(((x2#-x1#)*(x2#-x1#))+((z2#-z1#)*(z2#-z1#))))+((y2#-y1#)*(y2#-y1#)))
endfunction d#