Results 1 to 4 of 4

Math Help - How to find X,Y coordinates on this?

  1. #1
    Newbie
    Joined
    Nov 2009
    Posts
    11

    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 10:12 AM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Newbie
    Joined
    Nov 2009
    Posts
    11
    Did I do a horrible job explaining my question or should I just assume it impossible and move on?
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Super Member
    Joined
    Jan 2009
    Posts
    591
    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.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Nov 2009
    Posts
    11
    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.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. find the coordinates
    Posted in the Algebra Forum
    Replies: 1
    Last Post: January 30th 2011, 02:15 AM
  2. Find the coordinates...
    Posted in the Pre-Calculus Forum
    Replies: 5
    Last Post: June 16th 2009, 03:06 AM
  3. Find Coordinates of Q
    Posted in the Geometry Forum
    Replies: 3
    Last Post: June 15th 2009, 04:32 PM
  4. Find x-coordinates
    Posted in the Calculus Forum
    Replies: 5
    Last Post: November 29th 2007, 05:25 PM
  5. find all polar coordinates
    Posted in the Pre-Calculus Forum
    Replies: 4
    Last Post: February 13th 2007, 10:08 PM

Search Tags


/mathhelpforum @mathhelpforum