Attachment 'cap14.c'
Download 1 // cap14.c M288, capture rail 6 hours of simulation
2 // ------------------------------------------------------------------------
3 // cc -o cap14 cap14.c -lgd -lpng -lm
4 // ------------------------------------------------------------------------
5 // Uses the libgd library, documentation: /usr/share/doc/gd-*/index.html
6 //
7 // The image is drawn large, then resampled down with ImageMagick "convert"
8 // Slow, but resulting in better looking output.
9 //
10 // png2swf segmentation faults if given too many large frames
11
12 #define NAME "cap14"
13 #define TITLETEXT "M288 Capture rail"
14
15 #define DEBUG 1
16
17 // earth and orbits -----------------------------------------------
18 // we will use a 24 hour, not a 23.9346 hour, sidereal day.
19 //
20 #define CAPTURE 11924.05647 // climbing capture
21
22 #define SCALE 1200 // bigger for less magnification
23
24 #define OTIME 4.0 // orbit time 4 hours
25 #define RAILHIGH 13500.0
26 #define RAILLOW 11000.0
27
28 #define NSTAR 100
29
30 #define RE 6378.0
31 #define ETIME 24.0 // hours per turn
32 #define MU 398600.0 // grav parameter km3/s2
33 #define ALTITUDE 80.0 // perigee altitude
34 #define GMAX 0.006 // 6.0m/s^2, 0.006km/s^2
35
36 // plot rate ------------------------------------------------------
37 #define RATE 5
38 #define NPLOT 120
39 #define MAXHOUR 6.0
40 #define STEPS 1000 // orbit simulation steps per plot
41
42 // plot sizing -----------------------------------------------------
43 #define PSCALE 32 // global scaling factor for drawing
44 #define LINSCALE 1
45 #define XSIZE (96*PSCALE)
46 #define YSIZE (32*PSCALE)
47
48 #define XOUT 960 // size of output image after convert
49 #define YOUT 320
50
51 #define XCENT1 (16*PSCALE) // #1 fixed frame orbit
52 #define YCENT1 (18*PSCALE)
53 #define MAG1 1.0
54 #define DWIDE 1.5
55
56 #define XCENT2 (48*PSCALE) // #2 rotating frame orbit
57 #define YCENT2 (18*PSCALE)
58 #define MAG2 1.0
59
60 #define XCENT3 (80*PSCALE) // #3 magnified rotating frame orbit
61 #define YCENT3 (58*PSCALE)
62 #define MAG3 4.0
63
64 #define VSIZE (PSCALE/2) // Vehicle circle size
65
66 #define FNT "DejaVuMonoSans"
67 #define FSZ (1.25*PSCALE)
68
69 #include <gd.h>
70 #include <time.h>
71 #include <math.h>
72 #include <stdio.h>
73 #include <stdlib.h>
74
75 //-----------------------------------------------------------------------
76
77 int white, lgray, gray, dgray ; // color indexes
78 int black, blue, cyan, dcyan ;
79 int red, dred, green, dgreen ;
80 int yellow, dyellow ;
81
82 // elapsed time
83 long start_time = 0L ; // epoch start time
84 int end_time = 0 ; // estimated end time
85 int elapsed_time = 0 ; // elapsed time
86 int remaining_time = 0 ; // remaining time
87
88 double speedup ; // simulation to display time
89 double pi2 = 6.28318530717958646 ;
90 double third = 0.33333333333333 ;
91
92 // files and graphics arrays
93 gdImagePtr im ; // Declare the image
94 FILE *pngout ; // Declare output file
95 char command[200] ; //
96 char filename[80] ; //
97
98 // simulation time parameters
99
100 int iplot ; // number of plot
101 double ip1 ; // fraction of complete plot
102 double hour ; // time of plot in hours from start
103 double eangle ; // earth turn angle
104 double oangle ; // destination orbit turn angle
105
106 //-----------------------------------------------------------------------
107 // orbit parameters
108 // distances in km
109 // speeds in km/sec
110
111 // target orbit parameters
112 double omega ; // rad/sec angular velocity
113 double orbsize ; // km orbit radius
114
115 // transfer orbit parameters
116 double rp ; // km perigee radius
117 double ra ; // km apogee radius
118 double rc ; // km capture radius, apogee
119 double vc ; // km/s capture velocity
120 double sem ; // km semimajor axis
121 double e ; // eccentricity
122 double h ; // km^2/s angular momentum
123 double vp ; // km/s perigee velocity
124 double vct ; // km/s transverse capture velocity
125 double v0 ; // km/s orbit velocity
126 double r0 ; // km/s orbit radius
127 double costh ; // cos of orbit angle at capture
128 double sinth ; // sin of orbit angle at capture
129 double theta ; // orbit angle radians
130 double dtheta ; // orbit angle degrees
131 double period ; // orbit period, seconds
132 double tr_time ; // orbit transfer time, seconds
133 double arg_p ; // argument of perigee
134 double energy ; // orbit energy, MJ
135 double enc ; // energy at capture, MJ
136 double av ; //
137 double rv ; //
138 double vv ; //
139 double tstep ; // simulation timestep
140
141 // background stars ;
142 double starx[NSTAR], stary[NSTAR] ; // star field position
143
144 // transfer orbit simulation radius (km) and angle (radians), fixed frame
145 double cr[NPLOT], ca[NPLOT] ; // transfer orbit, with capture
146 double mr[NPLOT], ma[NPLOT] ; // transfer orbit, missed capture
147 double rr[NPLOT] ; // transfer orbit, rotation
148 int nc = NPLOT ; // capture step
149 int nv = 0 ; // number of transfer orbit points
150
151 int scale = SCALE/PSCALE ; // pixels per kilometer
152
153 // ========================================================================
154 void initialize() {
155
156 int i ;
157 double tmp ;
158 double E ;
159 double M ;
160
161 sprintf( command, "rm -rf %sdir ; mkdir %sdir", NAME, NAME );
162 system( command ) ; // make directory
163 start_time = (long) time( NULL );
164
165 speedup = 3600.0 * MAXHOUR * RATE / NPLOT ; // sim/display time ratio
166 tstep = 3600.0*MAXHOUR/(NPLOT*STEPS) ; // simulation timestep
167
168 // orbit initialize
169 // fake: sidereal 24 hour day
170
171 omega = pi2 / ( 3600.0 * OTIME ) ; // angular velocity
172 orbsize = pow( ( MU /(omega*omega)), third ) ; // orbit radius
173 rp = RE + ALTITUDE ; // perigee radius
174
175
176 // three different possibilities -
177 #ifdef CAPTURE // ---------------- new capture rail
178 rc = CAPTURE ;
179
180 // see http://www.nature1st.net/bogan/orbits/kepler/orbteqtn.html
181 // though be careful of the redefinition of q, both perigee and
182 // true anomaly
183
184 vct = rc*omega ; // transverse capture velocity
185 h = rc*vct ; // orbit angular momentum
186 vp = h/rp ; // perigee velocity km/sec
187 v0 = MU/h ; // orbit velocity
188 r0 = h/v0 ; // orbit radius
189 e = (r0/rp)-1.0 ; // eccentricity
190 ra = r0/(1.0-e) ; // apogee radius
191 sem = r0/(1.0-e*e) ; // semimajor axis
192 energy = 0.5*vp*vp-MU/rp ; // orbit energy MJ
193 enc = 0.5*vct*vct-MU/rc ; //
194 vc = sqrt(2.0*(energy-enc)); //
195 tmp = fabs(sem*sem*sem)/MU ; //
196 period = pi2*sqrt( tmp ) ; // orbit period
197 costh = ((r0/rc)-1.0)/e ;
198 sinth = sqrt(1.0-costh*costh) ;
199 theta = atan2(sinth,costh) ; // true anomaly
200 dtheta = (360.0/pi2)*theta ;
201 av = vct*vct/rc-MU/(rc*rc) ; // acceleration at capture
202
203 if( sem > 0.0 ) { // ----- elliptical
204
205 double cosE = (e+costh)/(1.0+e*costh);
206
207 // possibly two solutions for E, M, and tr_time !
208 E = acos( cosE ) ; // eccentric anomaly
209 M = E - e*sin( E ) ; // mean anomaly
210 }
211 else { // ----- hyperbolic
212 double coshE = (e+costh)/(1.0+e*costh);
213
214 // possibly two solutions for E, M, and tr_time !
215 E = acosh( coshE ) ; // eccentric anomaly
216 M = e*sinh( E ) - E ; // mean anomaly
217 }
218
219 #else // --------------------- classical capture
220
221 rc = 0.7*orbsize ;
222
223 tmp = 2.0 * MU / (omega*omega);
224
225 for( i = 0 ; i < 77 ; i++ ) {
226 rc = pow( tmp*rp/(rc+rp), third);//
227 }
228
229 sem = 0.5*(rp+rc) ; // semimajor axis
230 e = 1.0 - rp/sem ; // eccentricity
231 vct = rc*omega ; // apogee (capture) velocity
232 h = rc*vct ; // orbit angular momentum
233 v0 = MU/h ; // orbit velocity
234 r0 = h/v0 ; // orbit radius
235 ra = rc ; // apogee
236 vp = h/rp ; // perigee velocity km/sec
237 energy = 0.5*vp*vp-MU/rp ; // orbit energy MJ
238 enc = 0.5*vct*vct-MU/rc ; //
239 vc = sqrt(2.0*(energy-enc)); // radial capture velocity
240 tmp = fabs(sem*sem*sem)/MU ; //
241 period = pi2*sqrt( tmp ) ; // orbit period
242 costh = -1.0 ; //
243 sinth = 0.0 ; //
244 theta = 0.5*pi2 ; //
245 dtheta = 180.0 ; //
246 E = 0.5*pi2 ; //
247 M = E ; //
248 av = vct*vct/rc-MU/(rc*rc) ; // acceleration at capture
249
250 #endif
251
252 tr_time = M*period / pi2 ; // time from perigee, seconds
253 arg_p = omega*tr_time-theta ; // argument of perigee
254
255 #ifdef DEBUG
256 printf( "|omega %11.3e rd/s ", omega );
257 printf( "|orbsize%11.2f km ", orbsize );
258 printf( "|tstep %11.5f sec ", tstep );
259 printf( "|\n" );
260 printf( "|rp %11.2f km ", rp );
261 printf( "|ra %11.2f km ", ra );
262 printf( "|sem %11.2f km ", sem );
263 printf( "|\n" );
264 printf( "|e %11.6f ", e );
265 printf( "|vp %11.4f km/s ", vp );
266 printf( "|vct %11.4f km/s ", vct );
267 printf( "|\n" );
268 printf( "|h %11.2fkm2/s ", h );
269 printf( "|r0 %11.2f km ", r0 );
270 printf( "|v0 %11.4f km/s ", v0 );
271 printf( "|\n" );
272 printf( "|mu %11.2fm3/s2 ", MU );
273 printf( "|energy %11.4fMJ/kg ", energy );
274 printf( "|vc %11.4f km/s ", vc );
275 printf( "|\n" );
276 printf( "|rc %11.2f km ", rc );
277 printf( "|E %11.4f rad ", E );
278 printf( "|M %11.4f rad ", M );
279 printf( "|\n" );
280 printf( "|tr_time%11.2f sec ", tr_time );
281 printf( "|period %11.4f sec ", period );
282 printf( "|p.hours%11.4f hr ", period/3600.0 );
283 printf( "|\n" );
284 printf( "|theta %11.4f rad ", theta );
285 printf( "|arg_p %11.6f rad ", arg_p );
286 printf( "|av_c %11.4f m/s2 ", 1000.0*av );
287 printf( "|\n" );
288 #endif // DEBUG
289
290 // start simulations at perigee
291 cr[0] = rp ; // captured radius
292 mr[0] = rp ; // missed capture radius
293 ca[0] = 0.0 ; // captured angle
294 ma[0] = 0.0 ; // missed capture angle
295 rr[0] = 0.0 ; // rotation at capture
296
297 // --------------------------------------------- initialize stars
298 // generate a disk of stars with
299 // radius < 1.414*orbsize
300
301 double stmult = orbsize*sqrt(8.0);
302 for( i=0 ; i < NSTAR ; ) {
303 double x = drand48()-0.5;
304 double y = drand48()-0.5;
305 if( x*x+y*y < 0.25 ) {
306 starx[i]=stmult*x ;
307 stary[i]=stmult*y ;
308 i++ ;
309 }
310 }
311 }
312
313 //-----------------------------------------------------------------------
314 void openplot() {
315 im = gdImageCreateTrueColor( (int)XSIZE, (int)YSIZE );
316
317 black = gdImageColorAllocate(im, 0, 0, 0);
318 dgray = gdImageColorAllocate(im, 96, 96, 96);
319 gray = gdImageColorAllocate(im, 128, 128, 128);
320 lgray = gdImageColorAllocate(im, 160, 160, 160);
321 white = gdImageColorAllocate(im, 255, 255, 255);
322
323 red = gdImageColorAllocate(im, 255, 0, 0);
324 dred = gdImageColorAllocate(im, 160, 0, 0);
325 green = gdImageColorAllocate(im, 0, 255, 0);
326 dgreen = gdImageColorAllocate(im, 0, 160, 0);
327 cyan = gdImageColorAllocate(im, 0, 160, 160);
328 dcyan = gdImageColorAllocate(im, 0, 80, 80);
329 yellow = gdImageColorAllocate(im, 255, 255, 0);
330 dyellow = gdImageColorAllocate(im, 160, 160, 0);
331 blue = gdImageColorAllocate(im, 0, 0, 255);
332
333 gdImageSetThickness( im, LINSCALE );
334
335 #if DEBUG > 1
336 printf("\n---------------------------------------------------\n");
337 #endif // DEBUG
338 }
339
340 //-----------------------------------------------------------------------
341 // draw orbiting GEO tether
342 // ex, ey are center of drawing in pixels
343 // ang and rot in radians
344
345 void tether( double ang, double rot, double mag, int ex, int ey ) {
346 int x0, y0 ;
347 int x1, y1 ;
348 double rang = ang+rot;
349
350 double rlow = mag*RAILLOW /scale ;
351 double rhigh = mag*RAILHIGH/scale ;
352 double rcs = mag*rc/scale ;
353
354 int orb = 2*(int)(mag*orbsize/scale) ;
355 int wide = (int)(DWIDE*mag*orbsize/scale);
356
357 // Draw a black box over background. This covers up overlap
358 // from other views.
359
360 gdImageFilledRectangle( im, ex-wide, 0, ex+wide, YSIZE, black );
361
362 // draw orbit circle
363 gdImageSetThickness( im, (int)5.0*mag*LINSCALE );
364 gdImageArc( im, ex, ey, orb, orb, 0, 360, dgray );
365
366 // draw target
367 int tar = 2*(int)( 4.0*mag*LINSCALE );
368 gdImageSetThickness( im, 2 );
369 x0 = ex + (int)( rcs * sin(rang));
370 y0 = ey - (int)( rcs * cos(rang));
371 gdImageFilledArc( im, x0, y0, tar, tar, 0, 360, white, gdArc );
372
373 // draw tether
374 gdImageSetThickness( im, (int)3.0*mag*LINSCALE );
375
376 x0 = ex + (int)( rlow * sin(rang));
377 y0 = ey - (int)( rlow * cos(rang));
378 x1 = ex + (int)( rhigh * sin(rang));
379 y1 = ey - (int)( rhigh * cos(rang));
380 gdImageLine( im, x0, y0, x1, y1, white );
381 }
382
383 //-----------------------------------------------------------------------
384 // draw stars
385 void stars( double rot, double mag, int ex, int ey ) {
386 int x, y, i ;
387 double s = sin( rot );
388 double c = cos( rot );
389 double ms = mag/scale ;
390 int size = 4*(int)sqrt(mag) ;
391 int wide = (int)(1.3*ms*orbsize) ;
392
393
394 gdImageSetThickness( im, 1);
395
396 for( i=0 ; i < NSTAR ; i++ ) {
397 int x = (int)(-ms*(c*starx[i] + s*stary[i]));
398 if( abs( x ) < wide ) {
399 x += ex ;
400 int y = ey + (int)(ms*(c*stary[i] - s*starx[i]));
401 gdImageFilledArc(im, x, y, size, size, 0, 360, white, gdArc);
402 }
403 }
404 }
405
406 //-----------------------------------------------------------------------
407 // draw rotating earth
408 // ex, ey are center of drawing in pixels
409 // ang and rot in radians
410
411 void earth( double ang, double rot, double mag, int ex, int ey ) {
412 int x0, y0 ;
413 int x1, y1 ;
414 double an0 ;
415 int i ;
416 double r2d = 360.0/pi2 ;
417 double drot = r2d*rot + 360000.0 ; // make sure it is positive
418 double rang = ang+rot;
419
420 double re = mag*RE/scale ;
421 int esize = 2*((int)re) ;
422
423 double ea1 = fmod( drot + 180.0, 360.0 ) ;
424 double ea2 = fmod( drot , 360.0 ) ;
425
426 gdImageSetThickness( im, 1);
427 gdImageFilledArc(im, ex, ey, esize, esize, 0, 360, cyan, gdArc);
428 gdImageFilledArc(im, ex, ey, esize, esize, ea2, ea1, dcyan, gdArc);
429
430 // draw longitude lines ( 6 = 180/30 degrees )
431 gdImageSetThickness( im, LINSCALE );
432 for( i=5 ; i >= 0 ; i-- ) {
433 an0 = rang + pi2*( (double) i ) / 12.0 ;
434 x0 = ex + (int)( re * sin(an0 ));
435 y0 = ey - (int)( re * cos(an0 ));
436 x1 = ex - (int)( re * sin(an0 ));
437 y1 = ey + (int)( re * cos(an0 ));
438 gdImageLine( im, x0, y0, x1, y1, black );
439 }
440 gdImageSetThickness( im, 3*LINSCALE );
441 gdImageLine( im, x0, y0, ex, ey, black );
442
443 // draw launch site pointer
444 x0 = ex + (int)( re * sin( rang + arg_p ));
445 y0 = ey - (int)( re * cos( rang + arg_p ));
446 x1 = ex + (int)( 0.5*re * sin( rang + arg_p ));
447 y1 = ey - (int)( 0.5*re * cos( rang + arg_p ));
448 gdImageSetThickness( im, 6*LINSCALE );
449 gdImageLine( im, x0, y0, x1, y1, yellow );
450
451 // draw latitude lines
452 gdImageSetThickness( im, LINSCALE );
453 for( i=1 ; i < 3 ; i++ ) {
454 an0 = pi2*( (double) i ) / 12.0 ;
455 x0 = (int)( 2.0 * ((double)re) * cos(an0) );
456 gdImageArc( im, ex, ey, x0, x0, 0, 360, black );
457 }
458 }
459
460 //-----------------------------------------------------------------------
461 // draw vehicle transfer orbit
462
463 void trans( int rotflag, double rot, double mag, int ex, int ey ) {
464 int i ;
465 int x, y ;
466
467 if( nv < iplot ) { // ------------ compute new transfer orbit point
468 double th0 = ma[nv] ;
469
470 #if DEBUG > 1
471 printf( "%5dnv%6dnc%6diplot%16.8fth0\n", nv, nc, iplot, th0 );
472 printf( "theta%9.4f rot%9.4f\n", theta, rot );
473 #endif // DEBUG
474
475 double rt = r0/(1.0+e*cos(th0)) ;
476 for( i = 0; i < STEPS ; i++ ) {
477 th0 += h*tstep/(rt*rt);
478 // rt = r0/(1.0+e*cos(th0)) + 0.5*v0*e*tstep*sin(th0);
479 rt = r0/(1.0+e*cos(th0)) ;
480
481 #if DEBUG > 1
482 printf( "rt%12.4e th0%10.6f\n", rt, th0 );
483 #endif // DEBUG
484
485 if( nc != NPLOT ) {
486 #ifdef CAPTURE
487 double atest = 0.5*vv*vv/fabs(orbsize-rv) ;
488 if( atest < GMAX ) { av = omega*omega*rv-MU/(rv*rv) ; }
489 else { av = -GMAX ; }
490 vv += tstep*av ;
491 if( ( vv < 0.0 ) || ( rv > orbsize ) ) { vv=0.0 ; }
492 rv += tstep*vv ;
493 #endif // CAPTURE
494 }
495 else if( th0 > theta ) {
496 nc = iplot ;
497 rv = r0/(1.0+e*cos(th0)) ;
498 vv = v0*e*sin(th0) ;
499 #if DEBUG > 0
500 printf("\nCapture nc=%04d rv=%9.2f vv=%7.4f\n", nc, rv, vv );
501 #endif
502 }
503 }
504 nv++ ;
505
506 rr[nv] = rot ;
507 mr[nv] = r0/(1.0+e*cos(th0));
508 ma[nv] = th0 ;
509
510 if( nc == NPLOT ) {
511 cr[nv] = mr[nv];
512 ca[nv] = ma[nv];
513 }
514 else {
515 cr[nv] = rv ;
516 ca[nv] = oangle-arg_p;
517 #if DEBUG > 0
518 printf("%8.4f%7.3f%9.1f", 1000.0*av, vv, rv );
519 #endif
520 }
521 }
522
523 // plot transfer orbit points
524
525 double man0 ;
526 int mx ;
527 int my ;
528 double can0 ;
529 int cx ;
530 int cy ;
531 double ms = mag/scale ;
532 int vsize = 2*((int)(0.5*mag*VSIZE)) ;
533 double ar ;
534
535 for( i = 0 ; i <= nv ; i++ ) {
536
537 if( rotflag == 1 ) { ar = arg_p + rr[i]; }
538 else { ar = arg_p + rot; }
539
540 man0 = ma[i] + ar ;
541 mx = ex + (int)(ms*mr[i]*sin(man0));
542 my = ey - (int)(ms*mr[i]*cos(man0));
543
544 #if DEBUG > 1
545 printf( "%4dnv%4dnc%4diplot%4di%5dmx%5dmy%8.1f_r%9.4f_an0\n",
546 nv, nc, iplot, i, mx, my , mr[i], man0 );
547 #endif // DEBUG
548
549 if( i < nc ) {
550 gdImageFilledArc( im, mx, my, vsize, vsize, 0, 360, dyellow, gdArc );
551 } else {
552 gdImageFilledArc( im, mx, my, vsize, vsize, 0, 360, dred , gdArc );
553 can0 = ca[i] + ar ;
554 cx = ex + (int)(ms*cr[i]*sin(can0));
555 cy = ey - (int)(ms*cr[i]*cos(can0));
556 gdImageFilledArc( im, cx, cy, vsize, vsize, 0, 360, dgreen , gdArc );
557 }
558 }
559
560 // current points
561 if( iplot < nc ) {
562 gdImageFilledArc( im, mx, my, vsize, vsize, 0, 360, yellow, gdArc );
563 } else {
564 gdImageFilledArc( im, mx, my, vsize, vsize, 0, 360, red , gdArc );
565 gdImageFilledArc( im, cx, cy, vsize, vsize, 0, 360, green , gdArc );
566 }
567 }
568
569 //-----------------------------------------------------------------------
570 void closeplot() {
571 sprintf( command, "%s.png", NAME );
572 pngout = fopen( command, "wb");
573 gdImagePngEx(im, pngout, 1);
574 fclose(pngout); // write out image
575 gdImageDestroy(im);
576
577 sprintf( command, "convert %s.png -resize %dx%d\\> %sdir/b%04d.png",
578 NAME, XOUT, YOUT, NAME, iplot );
579 system( command );
580 }
581
582 // ========================================================================
583 int main() {
584
585 initialize() ;
586
587 for( iplot = 0 ; iplot < NPLOT ; iplot++ ) {
588
589 openplot() ;
590
591 ip1 = ((double)iplot)/((double) NPLOT) ;
592 hour = ip1*MAXHOUR ;
593 eangle= pi2 * hour/ETIME ; // radians
594 oangle= pi2 * hour/OTIME ; // radians
595
596 tether( oangle, -oangle, MAG3, XCENT3, YCENT3 ) ;
597 stars( -oangle, MAG3, XCENT3, YCENT3 ) ;
598 earth( eangle, -oangle, MAG3, XCENT3, YCENT3 ) ;
599 trans( 1, -oangle, MAG3, XCENT3, YCENT3 ) ;
600
601 // note - the "tether" portion of the next two drawings
602 // overlap and obscure the first magnified plot
603
604 tether( oangle, -oangle, MAG2, XCENT2, YCENT2 ) ;
605 stars( -oangle, MAG2, XCENT2, YCENT2 ) ;
606 earth( eangle, -oangle, MAG2, XCENT2, YCENT2 ) ;
607
608 tether( oangle, 0.0, MAG1, XCENT1, YCENT1 ) ;
609 stars( 0.0, MAG1, XCENT1, YCENT1 ) ;
610 earth( eangle, 0.0, MAG1, XCENT1, YCENT1 ) ;
611
612 trans( 1, -oangle, MAG2, XCENT2, YCENT2 ) ;
613 trans( 0, 0.0, MAG1, XCENT1, YCENT1 ) ;
614
615 // labels -----------------------------------------------------------
616
617 gdImageStringFT( im, NULL, // imagespace, bounding
618 white, FNT, 1.6*FSZ, // color, font, fontsize
619 0.0, 1*PSCALE, 3*PSCALE, // angle, x, y
620 TITLETEXT ); // text
621
622 sprintf( command,
623 "View from South %04.1f/%04.1f hours, %4.0fx speedup",
624 hour, MAXHOUR, speedup );
625
626 gdImageStringFT( im, NULL, // imagespace, bounding
627 white, FNT, FSZ, // color, font, fontsize
628 0.0, 44*PSCALE, 3*PSCALE, // angle, x, y
629 command ); // text
630
631 gdImageStringFT( im, NULL, // imagespace, bounding
632 white, FNT, 0.75*FSZ, // color, font, fontsize
633 0.0, 1*PSCALE, 31*PSCALE, // angle, x, y
634 "Fixed Frame" ); // text
635
636 gdImageStringFT( im, NULL, // imagespace, bounding
637 white, FNT, 0.75*FSZ, // color, font, fontsize
638 0.0, 32*PSCALE, 31*PSCALE, // angle, x, y
639 "Rotating Frame" ); // text
640
641 gdImageStringFT( im, NULL, // imagespace, bounding
642 white, FNT, 0.75*FSZ, // color, font, fontsize
643 0.0, 64*PSCALE, 31*PSCALE, // angle, x, y
644 "Rotating Frame, 4x larger" );// text
645
646 closeplot();
647
648 elapsed_time = (int)(((long) time( NULL )) - start_time ) ;
649
650 if( elapsed_time > 1 ) {
651 end_time = (long)(((double) elapsed_time ) / ip1 );
652 remaining_time = end_time - elapsed_time ;
653 }
654
655 #if DEBUG < 2
656 printf( "%4d/%d-plot%4d-nc%5.1f/%04.1f-hour%4ld/%4ld/%4ldsec\r",
657 iplot+1, NPLOT, nc, hour, ((double)MAXHOUR),
658 elapsed_time, remaining_time, end_time );
659 fflush(stdout);
660 #endif // DEBUG
661 }
662
663 printf( "\n" ); fflush(stdout);
664
665 sprintf( command, "png2swf -o %s.swf -r%3d %sdir/*.png", NAME, RATE, NAME );
666 system( command );
667 return(0);
668 }
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.