Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - # http://www.youtube.com/watch?v=Im2JdZ_bvFI
 - v0 = 0
 - #constants
 - time = 0;
 - end_time = 1;
 - steps = 1*25000; # cover the time period in that many intervals. Te more, the higher is precision
 - dt = end_time/steps;
 - t = 0:dt:end_time;
 - steps = length(t);
 - w = 2*pi; # angular speed
 - #initial values
 - b = 0; # arm angle
 - a = 0; # speed angle with respect to arm push direction (arm normal vector) before push
 - v = 0; # speed vector length
 - g = 0; # speed angle with respect to arm push direction (arm normal vector) after push. Normal component is increased, horizontal - intecat.
 - r = 1; # initial radius
 - v = 500; a = 1*99.9 /180 * pi;
 - v_records = zeros(1, steps);
 - a_records = zeros(1, steps);
 - r_records = zeros(1, steps);
 - b_records = w*t;
 - db = w * dt;
 - #b = b + db;
 - ctb = cot(db);
 - for i = 2:steps
 - vsina = v * sin(a);
 - wr = w * r ;
 - v = sqrt(vsina^2 + wr ^2); # absolute speed
 - tg = vsina / wr; # tg(g), g = arctg(tg);
 - #printf("%d: r=%f, a=%f, b=%f, v=%f, g=%f, tg=%f\n", i, r, a, b, v, g, tg);
 - g = atan(tg);
 - r = r * sqrt(1+ctb^2) / (ctb-tg); # mult raises r due to tangent move vertically up, div by (ctg-tg) due to moving away from center (horizontal)
 - a = db + g;
 - r_records(i) = r * 10;
 - v_records(i) = v;
 - a_records(i) = a*180/pi*100;
 - end
 - plot (t, r_records, ";radius;", t, v_records, ";absolute velocity;", t, a_records, ";decline from tangent;");
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment