I assume this is in 3D (otherwise, yes, you'd use the pythagorean therum)
Okay, the way to do this is basically taking what you know about pythag thm and applying it. Say you are trying to find the distance between the two red dots:
what you need is the length of the blue line first. Find this by
a^2 + b^2 = c^2
Once you have the length of the blue line, you use the pythag thm, where the blue line is a, the green line is b, and the distance you've been looking for (the yellow line) is c.
Now, to apply this to DB. Say you have two cubes, one at location 90,110,500 and the other at 700,50,100.
To find a of the first triangle, you need the x distance, so you would take the absolute value of 90 - 700 = 610. Then to get b, you need the z distance, which is abs(500-100) = 400. 610^2 + 400^2 = 532,100. Take the square-root of that and you get 729.5. That is the c value And the a value of the second triangle. (blue line of 1st example)
Now, you have a of the 2nd triangle, but need b, or the y distance. find this by abs(110-50) = 60. Now take 729.5^2 + 60^2 = 535,700. sqrt(535,700) =
732. That number right there is the distance between your two objects.
I'll have DB Code example coming soon.
I am who I am