Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica 2D itteration

  1. May 30, 2012 #1
    here is the pseudo java (processing) code I'm trying to run


    Code (Text):

    float x0,y0,x,y,t;

    x0 = 2; //arbitrary value
    y0 = 5; //arbitrary value

    x = x0;
    y = y0;

    for(int t = 1; t <= 100; t++){   //one hundred iterations
        t =atan2(y,x);
        x += cos(t);
        y += sin(t);

        print( x, y)

    }
     
    I'm trying to run something more complex than this, but the code above shows the main point where I can't convert standard "for loop" programming to mathemitica.


    please help me write an equivalent code in mathematica.
     
  2. jcsd
  3. May 31, 2012 #2
    Perhaps better posted in the Math and Science Software section.

    Note/Warning: read
    http://reference.wolfram.com/mathematica/ref/ArcTan.html
    for information on the order of arguments in ArcTan to tell
    whether you need ArcTan[x,y] or ArcTan[y,x].

    x0 = 2;
    y0 = 5;
    x = x0;
    y = y0;
    For[t = 1, t <= 100, t++,
    t = ArcTan[y,x];
    x += Cos[t];
    y += Sin[t];
    Print[ x," ",y];
    ];
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Mathematica 2D itteration
  1. 2D Geometry (Replies: 2)

  2. Plots in Mathematica (Replies: 1)

  3. Mathematica Trouble (Replies: 2)

Loading...