D# = Sqr((X1#-X2#)*(X1#-X2#) + (Y1#-Y2#)*(Y1#-Y2#) + (Z1#-Z2#)*(Z1#-Z2#))
That's the fast way. Use if you're gonna call it a thousand times a frame.
D# = Sqr((X1#-X2#)^2 + (Y1#-Y2#)^2 + (Z1#-Z2#)^2)
This is the math way. X^2 is slower than X*X. Takes less typing and looks cleaner so use this if you're not calling it often.
D2# = (X1#-X2#)*(X1#-X2#) + (Y1#-Y2#)*(Y1#-Y2#) + (Z1#-Z2#)*(Z1#-Z2#)
Use this when you need to simply COMPARE two distances to dtermine if one object is farther away than another, and you intend to make that comparison a thousand times a frame for various objects. Ie, If (D2a# > D2b#) then object 1 is in front of object 2.
Note that you can also use this trick of using squared distances to determine if an obejct is farther away than a certain distance.
If D2# > (Distance*Distance) Then object is greater than distance away from whatever.
That's the fast way. Use if you're gonna call it a thousand times a frame.
D# = Sqr((X1#-X2#)^2 + (Y1#-Y2#)^2 + (Z1#-Z2#)^2)
This is the math way. X^2 is slower than X*X. Takes less typing and looks cleaner so use this if you're not calling it often.
D2# = (X1#-X2#)*(X1#-X2#) + (Y1#-Y2#)*(Y1#-Y2#) + (Z1#-Z2#)*(Z1#-Z2#)
Use this when you need to simply COMPARE two distances to dtermine if one object is farther away than another, and you intend to make that comparison a thousand times a frame for various objects. Ie, If (D2a# > D2b#) then object 1 is in front of object 2.
Note that you can also use this trick of using squared distances to determine if an obejct is farther away than a certain distance.
If D2# > (Distance*Distance) Then object is greater than distance away from whatever.