HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Points - XY for point A to B

12-21-2006, 02:51 AM#1
Zandose
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
Ammorth
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
Pyrogasm
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.
Misinformation

I suppose you could by making 2 more points: C and D. Make C so that its X coordinate is equal to the X of A and its Y corrdinate equal to that of B. Make D's X equal to B's X, and D's Y equal to A's Y.

Then, the distance between A and C, or D and B, is your Delta Y (or "rise" as it's called in high-school math), and the distance between A and D, or C and B, is your Delta X (or "run").

Examples:
Table:
PointXY
AXaYa
BXbYb
CXaYb
DXbYa
Table:
PointXY
A10
B32
C12
D30

Make sense?

There's probably an easier way to do this, but I can't think of it off the top of my head.

12-21-2006, 03:21 AM#4
xombie
I'm using JASS tags so that spaces will apply properly...
Collapse 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
Zandose
I don't think this will work for me. The games map has minus numbers.
12-21-2006, 04:49 AM#6
Ammorth
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
PipeDream
After careful deliberation, the most convoluted explanation I could manage.
12-22-2006, 09:27 PM#8
Szythe
I chuckled (mainly because I understood some of it)