Message Board


Message Board > Malarkey > Simple math problem

January 30, 2012, 08:34
Zomg
None
641 posts
How do I calculate the distance between point A and point B if this distance lies diagonally?

Of course! How could we forget! :)
The answer is Pythagoras.

The sum of the squares of sides A and B is the square of side C, the hypothenusa.
a² + b² = c²

^^
____________
#
January 30, 2012, 11:42
Dennis
どこかにいる
2092 posts

* kadum * hish *

I used that in my Doom remake game to make Imp fireballs go diagonally towards the player. I had to know the distance to the player, but in DIV you only had distnace x and distance y.

real_distance = sqrt(get_distx(player_id)^2 + get_disty(player_id)^2)

:)

[Edited on January 30, 2012 by Dennis]
____________
Kwakkel
#

Message Board > Malarkey > Simple math problem

Quick reply


You must log in or register to post.
Copyright © 2005 Booleansoup.com
Questions? Comments? Bug reports? Contact us!