Functional spiral grid algorithm