Math Help Forum

Math Help Forum Feed Site Feed

Go Back   Math Help Forum > Pre-University Math Help > Geometry
Reply
 
Thread Tools Display Modes
  #1  
Old November 5th, 2009, 11:05 AM
Newbie
 
Join Date: Nov 2009
Posts: 3
Thanks: 0
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 12:12 PM.
Reply With Quote
Advertisement
 
  #2  
Old November 14th, 2009, 04:29 PM
Newbie
 
Join Date: Nov 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Zamadatix is on a distinguished road
Default

Did I do a horrible job explaining my question or should I just assume it impossible and move on?
Reply With Quote
  #3  
Old November 15th, 2009, 08:37 PM
Super Member
 
Join Date: Jan 2009
Posts: 524
Country:
Thanks: 56
Thanked 108 Times in 100 Posts
aidan will become famous soon enoughaidan will become famous soon enough
Default

Quote:
Originally Posted by Zamadatix View Post
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.
Do an internet search for ULAM SPIRAL.
There is a lot of code (in many languages) available that will generate the spiral.
You have the basic understanding of the algorithm and the key, by knowing what numbers will occur at the corners of the squares.

The algorithm you've outlined is not slow nor inefficient.
You know n. The square root (or half the square root shifted) will give the starting coordinates (x,y). Then a subtraction of that will provide the adjustment required for the final coordinate pair.

Write back if you have a problem finding/creating the code.
Reply With Quote
  #4  
Old November 16th, 2009, 01:39 PM
Newbie
 
Join Date: Nov 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Zamadatix is on a distinguished road
Default

Oh, the code is already created, and it is "speedy" (it only takes a few seconds to generate a multi megapixel image) but I am always chasing more elegant ways to explain and do things :P.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -7. The time now is 10:48 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
©2005 - 2009 Math Help Forum


Math Help Forum is a community of maths forums with an emphasis on maths help in all levels of mathematics.
Register to post your math questions or just hang out and try some of our math games or visit the arcade.