You should provide links with the video for anyone interested in learning more.
On Sat, May 24, 2014 at 12:25 PM, Brian Schott <[email protected]>wrote: > Yet another version of the pendula simulator script, which is now dyadic, > taking a left argument of the amount of time to simulate, (approx 30 works) > and a right argument fixed the number of turtles/pendula (approx 9 works). > A video clip link follows. > > http://youtu.be/xW8U9mJOHgU > > My pendulum simulation is coming along a little bit. The newer version of > the script is included below. I have different experiences with different > browsers, but I don't know how to generalize on that statement. In general, > various scaling factors alter the simulation, but I cannot elaborate on > their settings. > > The main problem relates to my version of turtle graphics relative to the > original Python/Logo, which contains a turtle control called setheading > which is intelligent enough to reverse the turtle when the pitch angle of > the heading goes past pi. Lacking such a control my turtle graphics system > needed to separately distinguish such a change in direction. My crude > attempt at making this fix produces a small anomaly in the pendulum path > resulting in the swings of the pendulum not exactly repeating each other > necessarily. > > Another problem is that the simulation cannot long run for very long at > least on my computer. Perhaps a JSON version would get around this problem. > > As always, any ideas would be appreciated. > > > NB. > http://code.activestate.com/recipes/577553-pendulum-simulation-with-turtle/ > > NB. to execute load this after loading tgsjhs.ijs; enter something like: > main 4 > > coclass'tgsj' > coinsert'jhs' > > GA =: 9.80665 NB. Gravitational Acceleration (meters per second squared) > > scale =: 2 > fdscale =: 0.05 > NB. 21 main 5 works but 21 main 9 may not, for example > main =: 4 : 0 > duration =: x > PENDING=: '' > NUMBER=: 0 > NB. Step_scale =: %100 > init '' > cs'' > initTurtles y > pu '' > > scalediff =. scale * 0.05 > setlength =. <.@-: + 4 +i. > length =. setlength y > xdist =. * i:@-:@<: > ngol =: - GA % length NB. Negative G over L > total_time =: 0.0 NB. Seconds > angle =: 1.0 NB. Initial angle of pendulum (radians) > sinAngle =. sin angle > goto scale * (xdist,.-@setlength,.sinAngle * -@setlength) y > speed =: 0.0 NB. Initial angular velocity (radians/second) > time_step =: 0.05 NB. Seconds > NB. pt dfr -pi-1 > while. total_time < duration do. > total_time =: total_time + time_step > oldspeed =: speed > speed =: speed + ngol * (sin angle) * time_step > angle =: angle + speed * time_step > pt dfr pi * speed ~:&*&(+&scalediff) oldspeed > pt dfr speed * time_step > fd fdscale * length > end. > ) > > Thanks, again for all the help, > > -- > (B=) > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Devon McCormick, CFA ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
