-
Pixel distance
Hello
I have seen a formula that counts the distance between two pixels, (x,y) and another (x,y). I know that you can use the angle calculator to do that, but I don't whant to use it in this game. In other words, I'd be very glad if someone knew this magical mathematical formula. (-:
P.S. It was long
-
Re: Pixel distance
Here is a distance formula divised by Stuckboy:[:"blue"]
\/¯((X1-X2)²+(Y1-Y2)²)[/]
-
Re: Pixel distance
Do you know Pythagore ?
You learn that at school...
The formula is : sqrt( (x2-x1)^2 + (y2-y1)^2 )
-
Re: Pixel distance
it's pythagoras, not hard.
squareroot of: X difference squared plus Y difference squared
Edit: I'm too slow by a minute
-
Re: Pixel distance
[]Do you know Pythagore ?
You learn that at school...[/]
haven't got that far <img src="/center/images/graemlins/wink.gif" alt="" />
-
Re: Pixel distance
you must be about... 13 then, or younger
-
Re: Pixel distance
Basically you need to think about the two points being part of a right angled triangle.
Pythagoras' formula is basically:
(X-Difference)x(X-Difference) + (Y-Difference)x(Y-Difference) = (Distance)x(Distance)
Or basically X squared + Y squared = distance squared
Then just get a square root of the result, and you should have your distance. I've never really used it though - there are extensions out there which just do it for you :P
Take a look at: http://upload.wikimedia.org/wikipedi...agoras_abc.png
-
Re: Pixel distance
(only joking lol)
pythag is very useful <img src="/center/images/graemlins/smile.gif" alt="" />
-
Re: Pixel distance
One council ( <img src="/center/images/graemlins/wink.gif" alt="" />) : Do not use extensions when they are not necessary. <img src="/center/images/graemlins/tongue.gif" alt="" />
-
Re: Pixel distance
In MMF2 what you would need to have typed out is:
Sqr(((X( "Object 1" ) - X( "Object 2" )) Pow 2 )+ ((Y( "Object 1" ) - Y( "Object 2" ) Pow 2)))
Why hasn't anybody figured out the 'pow' operator yet???