Advertisement

3D Distance Forumla?

Started by October 11, 2002 01:13 PM
9 comments, last by DevLiquidKnight 22 years, 4 months ago
Im just wondering for the normal distance forumla its like distance = sqrt((x1 - x2)2 + (y1 - y2)2) with that being true does that mean that distance forumla for 3d is distance = sqrt((x1 - x2)2 + (y1 - y2)2 + (z1 - z2)2) Killer Eagle Software
yup.
Advertisement
yes it does. and you can even prove that easily. if you know how to calculate the distance in 2d, you can do it for a box in 3d simple: first calculate the 2d diagonal of one side. that builds up a quat in 2d, build up by this diagonal the length you know, and the 3rd dimension of your box. now you calculate its distance..

diagonal = sqrt(a^2 + b^2)
fulldiagonal = sqrt(diagonal^2 + c^2) = sqrt(sqrt(a^2 + b^2)^2 + c^2) = sqrt(a^2 + b^2 + c^2)

that is to get the diagonal of a box.

and that is the distance from one edge to the other. and calculating a,b,c is easy.. the distance vector from one point to the other..

"take a look around" - limp bizkit
www.google.com
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

shouldnt it be n2 - n1, not n1 - n2?
Is there any other formulas for calcuating distance or calclating like intersection of parts ect. If so what ones are there any basic ones u use in your programs?

Killer Eagle Software
quote:
Original post by MENTAL
shouldnt it be n2 - n1, not n1 - n2?


It doesn''t matter which way you do it, because you square the answer.

n2 - n1 = -1(n1 - n2)

so think off the 2 equations as

n1 - n2
and
-1(n1 - n2)

when you square both sides it''s

(n1 - n2)^2

and

(-1)^2 * (n1 - n2)^2

which is

1(n1 - n2)^2

and therefore

(n1 - n2)^2

The square of a positive number is the same as the square of its opposite.
Advertisement
it''s called the ''Pythagorean Theorem;'' it''s ancient. Remember, "A^2 + B^2 = C^2"? In 3 dimensions, you incorperate a third leg or dimension to the slope, or ¡î(X©÷+Y©÷+Z©÷)...sweet, i found the character map...
This post will self-destruct in 5 seconds...Actually, it's just Benjamin Bunny doing his thing.
oops, that''s for generating a vector, not distance
I don''t think it matters- isn''t a vector''s magnitude just it''s distance from the origin, or (x^2 + y^2 + z^2)? =)
Yeah, it''s exactly the same (it''s just like you''re measuring the distance between a point originally at the origin translated by the vector, and the origin).

This topic is closed to new replies.

Advertisement