Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Is that possible to put objects in a 2D map using only a matrix of their relative distance ?

An example would be putting cities on a map using the distances between them. There would be a minimum of 4 cities.

Thanks a lot.

share|improve this question
1  
Can you be more specific? The simple answer is yes, if you have 4 cities (A,B,C,D) and know distances between them so A->B is 3 units, A->C is 4 units and B->C is 5 units then you can. You would have to have a reference point to start it all from (probably just stick the first city at 0,0 or a random position. Then it would be possible to supply distances that made it impossible, so you may have to handle that –  Adrian Brown Feb 10 '13 at 16:43
add comment

1 Answer 1

up vote 0 down vote accepted

Distance could be enough information to plot 4 cities - but only if you're ok with them ending up in a different configuration every time.

For example, if you have city B a distance of 10 cells away from city A, then you can use bresenham's to determine a circle describing all possible locations for city B. If you add city C into the equation (and City C has to be 12 cells away from city B and 8 away from city A), then it gets tricky - you'll have to again use bresenham's to get circles of radius 8 and 12 around cities A and B, and see where those two intersect. There's dozens of possible layouts just for this - the larger the radii, the more there will be.

If your cities all have required distances from each other, this gets more complicated as you add more cities. As soon as you add a city D, your layout for cities A B and C isn't guaranteed to accomodate it. If all you have is a single distance requirement (i.e. city D only has to be 15 cells from city C), then it becomes a lot simpler.

I hope I didn't overcomplicate this - let me know if I can clarify or elaborate!

share|improve this answer
    
Thanks a lot =) I got the answer here : math.stackexchange.com/questions/299386/… It's all about maths =) –  Charaf Feb 14 '13 at 17:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.