Task 73 Hexagonal Grid

Back to General discussions forum

Stefan Dell     2015-08-14 09:37:19

I've solved the problem for accurate movements. (like 7.00000000 3.00000000 0.00000000 Can you explain to me how you get numbers that gives you movements, that are not accurate decimals? Should i multiply them with something? thanks

Rodion (admin)     2015-08-15 13:52:40
User avatar

Stefan, Hi!

>Should i multiply them with something?

I think the main idea was that for any of six directions you can write what is shift by X and by Y like this:

        dX       dY
A:      1.0      0.0
B:      ...      ...
...     ...      ...

etc. And then simply sum up these dXs and dYs for all steps. Then the total distance is calculated by Pythagor's theoreme as hypotenuse of triangle with sum(dX) and sum(dY) sides.

As about calculating dX/dY-s for other steps, you can see, for example, that path BFD is a triangle with all sides equal to 1.0 and all angles of 60 degrees. Plot it and you will see that our wanted shifts are either sines or cosines of 60 degrees (multiplied by the length of the side which is 1.0 anyway).

Please login and solve 5 problems to be able to post at forum