View Single Post
  #1  
Old November 5th, 2009, 10:05 AM
Zamadatix Zamadatix is offline
Newbie
 
Join Date: Nov 2009
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Zamadatix is on a distinguished road
Default How to find X,Y coordinates on this?

Given this square-spiral pattern of numbers:

7 6 5
8 1 4
9 2 3
10 11 12...

Is it possible to create a equation that will give me an X,Y coordinate, with 1 being 0,0, if I have a number (N)?

I figured out an algorithm (of sorts) using the knowledge that evens^2(from 2 up)+1 give a diagonal line upright and odds^2 (from 1 up)+0 give a diagonal line down and that the side length is sqrt(next corner>N [as defined above])-1. This is quite slow and inefficient, hence the hope for some sort of equation or simpler logic to find the coordinates.

Thanks in advanced , and I hope this is the appropriate area to post this question.

Last edited by Zamadatix; November 5th, 2009 at 11:12 AM.
Reply With Quote