Map map coordinates into grid reference id

Started by
2 comments, last by vinterberg 8 years, 6 months ago

I want to squeeze down the range of ids that identify individual cells of the map.

Like this as follows:


-10,30 (0,0)  0,30 (1,0)   10,30(2,0)
-10,20 (0,1)  0,20 (1,1)   10,20(2,1)
-10,10 (0,2)  0,10 (1,2)   10,10(2,2)
-10,  0 (0,3)  0, 0 (1,3)    10,0 (2,3)

My purpose of this move is to simplify the astar distance between nodes

Say if the true distance is 10.0 units (-10,30) to (0,30), I just want 1

Hope you get what I mean...

How do I go about doing that in C++?

Thanks

Jack

Advertisement

In the given example...

newX = (oldX + 10) / 10

newY = (30 - oldY) / 10

Hello to all my stalkers.

I find my map is not perfectly squared at 1:1

newX = (oldX + 10) / 10

newY = (30 - oldY) / 9

okay?

Thanks

Jack

Set a reference point ((-10, 30) in your example), and calculate the delta values, then divide them by 10 :)


int refX = -10;
int refY = -30;

int simpleX = (mapX - refX) / 10;
int simpleY = (mapY - refY) / 10;

.:vinterberg:.

This topic is closed to new replies.

Advertisement