How to walk a volume?

A cube, side size N, I want to walk from the center going out, walking on each shell, each step can only add 1 to one direction. How to get the position index?
Example: N=4, first "shell" is the nut of N=2, 8 element; then the outer shell. with N=6 another shell. It's easy to "see" how it walk on continuously.
Is there an algorithm out there to have the walking position vectors generated automatically?
Thanks.

1 commentaire

Walter Roberson
Walter Roberson le 12 Jan 2016
Is it permitted to visit any vertex twice? Is it permitted to visit the start vertex of the layer twice?

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Centre d'aide et File Exchange

Question posée :

le 12 Jan 2016

Commenté :

le 12 Jan 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by