#jupiter alive
25-Jul-94 22:26:29
Sb: #114480-#jupiter alive
Fm: Ed Kellerman 71532,3255
To: dave aguilar 76260,453
Smoking cigarettes! Hmph.
Judging from the speed of your response you must also be one of us guys not at
Siggraph.
——-
Since you are into astronomy, you could have some fun with a program I played
with last night. I started out by trying to compute the path of an object
under the influence of two point masses. I got the effects I wanted after
playing with the equations for a while, so I don't know if as it stands now, it
has any connection to real motion under gravity. For one thing, the paths are
chaotic. The object can orbit one of the masses many times, then suddenly move
over to the other mass, and eventually catapult out of the screen, gaining
speed all the time!
Run it w/o changes (at 640×480). Then look at the path in Optics. You'll see
what I was aiming for, a figure-8 path (like the one I used in "Sloshing Water
" (ROLL69.ZIP) and "Flying Carpet" (ROLL56). In this case the object
alternately orbits each of the masses.
Now the starts, start changing the values! (I almost didn't get any sleep last
night!).
I am thinking of making the program into a more complete package ("Chaos with
AniPro"). I was wondering about the user interface. When I use it, I prefer to
just edit the program and change a value or two. But, for other users, is there
a way to put up several sliders at once, or some way to modify several values
with just one menu?
Ed K
———————————
main()
//two concentrated masses. figure 8 orbit 94 -7-24
//Copyright 1994. Ed Kellerman
{
#define n 202
int mass1_x = 200, mass1_y = 200;
int mass2_x = 400, mass2_y = 200;
double init_x = 300, init_y = 200, init_x_vel = 8, init_y_vel
= 5, accel = 23.105;
int t = 0, x[n], y[n];
Box(mass1_x,mass1_y,2,2); Box(mass2_x,mass2_y,2,2);
double ii,last_y,last_x,
a_x1,v_x1,a_y1,v_y1,dist1,
a_x2,v_x2,a_y2,v_y2,dist2;
last_x = init_x; last_y = init_y;
v_x1 = init_x_vel; v_y1 = init_y_vel;
v_x2 = init_x_vel; v_y2 = init_y_vel;
for ( t = 0; t < n; t++)
{
dist1 = sqrt((last_x-mass1_x)*(last_x-mass1_x) +
(last_y-mass1_y)*(last_y-mass1_y)); dist1 = pow(dist1,2);
dist2 = sqrt((last_x-mass2_x)*(last_x-mass2_x) +
(last_y-mass2_y)*(last_y-mass2_y)); dist2 = pow(dist2,2);
a_x1 = accel * (mass1_x-last_x) / dist1; a_y1 = accel *
(mass1_y-last_y) / dist1;
a_x2 = accel * (mass2_x-last_x) / dist2; a_y2 = accel *
(mass2_y-last_y) / dist2;
// v_x1 = v_x1 + a_x1; v_y1 = v_y1 + a_y1;
v_x1 = v_x1 + a_x1 + a_x2; v_y1 = v_y1 + a_y1 + a_y2;
// for ( ii = 0; ii<400; ii++) {printf("%f %f",a_x1,a_x2);}
last_x = last_x + v_x1; last_y = last_y + v_y1;
x[t] = last_x; y[t] = last_y;
}
OptSetPath(n,x,y);
}