Results 1 to 4 of 4

Math Help - help - goniometric problem - formula for drawing a circular path inside a square

  1. #1
    Newbie
    Joined
    May 2011
    Posts
    3

    help - goniometric problem - formula for drawing a circular path inside a square

    Hi,
    After some coding in Visual Studio I came across a goniomethrical problem:

    I want to draw a line.
    this line is made by defining two positions. (position = X & Y value)

    The first position is constant/stationary over time.

    The second position changes over time.
    I want to define the second position so that the second position of the line would move in a circular path,
    following the traditional formula of drawing a circle

    pos2.x = pos1.x + (cos(angle) * length);
    pos2.y = pos1.y + (sin(angle) * length);

    ('angle' changes it's value as time passes)

    However, that's not really what I want to achieve.

    I want to achieve that the angle of the line would change in the exact same way as the example given above,
    however the length of the line has to vary, so that the rotation of the line would fit in a square shape instead of a circular shape.

    so that adds another variable: 'size' of the border of the square.

    so the variables to use are:
    pos1.x
    pos1.y
    pos2.x
    pos2.y
    angle
    length
    'size' of the border of the square


    I have been struggling alot with this problem, and I've found some ways to approach the exact visualisation of this problem, but it is far from perfect.

    Does anyone have an idea of a formula I could use or a solution to this problem?

    Thanks in advance.

    see sketch below for help to the visualisation of the problem

    http://i54.tinypic.com/315gxsh.png
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Super Member

    Joined
    May 2006
    From
    Lexington, MA (USA)
    Posts
    11,865
    Thanks
    744
    Hello, xcrypt!

    I hope I understand the problem.


    \text{We want a square with side }2r.

    \text{We have its center }O(x_o,y_o)

    \text{We want a function so that }P(x,y)\text{ traces out the square.}

    Code:
                          |
              * - - - - - + - - - - - *
              | *         |         * |
              |   *       |       *   |
              |     *    [2]    *     | r
              |       *   |   *       |
              |         * | *         |
          - - + - - [3] - * - [1] - - + - -
              |         * | *         |
              |       *   |   *       |
              |     *    [4]    *     | r
              |   *       |       *   |
              | *         |         * |
              * - - - - - + - - - - - *
                    r     |     r

    We divide the coordinate plane into four oblique quadrants.


    Each quadrant has its set of parametric equations.


    . . . . . . . . . . . . . . .

    . . . . . . . . . . . . . . . .

    . . . . . . . . . . . . . . .

    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    May 2011
    Posts
    3
    ah, I see now, makes sense
    I'll try to program it tomorrow and see if it works, while I'm sure it will trace out the square, I'm not sure if say I programmed this new line
    , if it would draw exactly on top of the first one
    (
    pos2.x = pos1.x + (cos(angle) * length);
    pos2.y = pos1.y + (sin(angle) * length);
    )
    only with a bigger radius as it reaches the corners of the square
    , though I think it will

    I will update tomorrow

    Thanks a bunch
    Last edited by xcrypt; May 4th 2011 at 02:45 PM.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    May 2011
    Posts
    3
    --> programmed it. Works perfectly.

    Thank you kind sir
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 3
    Last Post: August 16th 2011, 06:23 AM
  2. Drawing a triangle within a square/rectangle
    Posted in the Geometry Forum
    Replies: 3
    Last Post: July 19th 2011, 01:01 PM
  3. Replies: 4
    Last Post: February 18th 2011, 01:48 PM
  4. Replies: 4
    Last Post: February 23rd 2009, 10:36 AM
  5. Leaving a circular path
    Posted in the Calculus Forum
    Replies: 3
    Last Post: February 23rd 2008, 03:38 AM

Search Tags


/mathhelpforum @mathhelpforum