calculate distance between 2 points?

i suppose this is more of a general maths than a c question, but this place seems very active and friendly, so... how do i calulate distance between x1,y1 and x2,y2? all the guides seem to be really complicated, taking into account the earths curve etc... this is for a game, i just need a simple way to do it. thanks!
You have to use the Pythagorean theorem:

__________________
╲│ (x1-x2)2+(y1-y2)2

Last edited on
Thank you very much!!
oh, i dont suppose you could explain how to work out the angle as well? thanks very much!
You have to use trigonometry for that ( http://en.wikipedia.org/wiki/Inverse_trigonometric_functions http://en.wikipedia.org/wiki/Trigonometric_functions )

α = arctan ( Δy/Δx ) = arctan ( (y2-y1) / (x2-x1) )
Last edited on
Aw man thanks! you guys are so helpful!
Topic archived. No new replies allowed.