simple geometry

Started by
0 comments, last by jjd 18 years, 1 month ago
hi, im feeling embarassed asking such a simple question but it has been a long time since I did maths in college. I'm developing a program, for which I have to calculate the length between 2 objects. I have tried: x1 - x2; y1 - y2; but this results in another set of co-ordinates and I need a single value that gives the distance between these 2 objects. If anybody understands what I'm saying and has the solution it would be a great help. thanx
Advertisement
The distance will be

sqrt((x1 - x2)^2 + (y1 - y2)^2)

And in 3D it is just

sqrt((x1 - x2)^2 + (y1 - y2)^2 + (z1 - z2)^2)

--www.physicaluncertainty.com
--linkedin
--irc.freenode.net#gdnet

This topic is closed to new replies.

Advertisement