| 12-21-2006, 02:51 AM | #1 |
How do you find the distance for X and Y from one point to another? I'm trying to find out how many points it takes to get from point A to point B but I don't just want the distance. I want to know how many points up/down and left/right to get to point B. |
| 12-21-2006, 02:58 AM | #2 |
x2 - x1, y2 - y1 x2, y2 being point B, x1, y1 being point one. Edit: Removed Abs(); didn't read question =D |
| 12-21-2006, 03:12 AM | #3 | |||||||||||||||||||||||||||||||
Damn, Ammorth beat me to it. I also just realized that what I wrote is incomplete as is. There's some more you'd have to do to get it to work.
|
| 12-21-2006, 03:21 AM | #4 |
I'm using JASS tags so that spaces will apply properly... JASS:
o (Point: 5, 5)
|
|
|
o--------------------|
(Point: 0, 0)Now, the difference in X values will be the second X-value, in this case '5', to the first X-value, in this case '0'. (5 - 0 = 5); Therefore, the X-value distance is 5. In this case, the Y-values are the same thing. In total you have a difference of 5 'x' values, and 5 'y' values. The actual distance would be (x² + y²)^½, or the square root of 50. |
| 12-21-2006, 04:13 AM | #5 |
I don't think this will work for me. The games map has minus numbers. |
| 12-21-2006, 04:49 AM | #6 |
Negative numbers work in the formula provided. Example: A(-3,5), B(4,-8) 4 - (-3), -8 - 5 (7, -13) The negative specifies direction. If you don't believe me, draw yourself a grid and test it. =) |
| 12-21-2006, 06:04 AM | #7 |
After careful deliberation, the most convoluted explanation I could manage. |
| 12-22-2006, 09:27 PM | #8 |
I chuckled (mainly because I understood some of it) |
