# traversing the area

i want to move point along spiral like hexagon for example i want to traverse the whole area and my player (point) is standing where i have placed it manually. now i want to start from this point and move outwards in concentric hexagonal path so that it moves along a bigger hexagon each time till it has covered the entire area. kindly suggest me how to develop such algorithm in c++ or simple c.

• Your question's wording is rather unclear, would you try to re-phrase it? Some image would be also nice. Aug 24, 2015 at 17:24
• i have added an image to help you understand the question :) Aug 24, 2015 at 18:05

Lets say player is at origin, and you have (any convex shape should work) your inner-most hexagon defined as array vec2 shape[6]. The simplest algorithm would be:

int windingsNo; //=some value
const int vertexCount = 6;
vec2 shape[vertexCount];
float scale = 1.f;
for(int w = 0; w < windingsNo; w++)
{
for(int v = 0; v < vertexCount; v++)
{
scale *= 1.1; // or += .1f
player.MoveTo(shape[v] * scale);
}
//if you wish non-spiral path like on image, move scaling here, requires one more move().
}


or in other words: 1) move onto inner-most shape 2) move on vertex with index +1 on +1 bigger shape. This has the upside you can make gradually bigger absolute size difference if you put relative scaling (e.g. scale *= 1.1) in the inner loop. Translating the path to the desired location is now trivial.