home *** CD-ROM | disk | FTP | other *** search
- ;/*
- lc -O -f8 -Lm881 Lyap.c
- copy Lyap Lyap.881
- lc -O -Lm Lyap.c
- copy Lyap Lyap.ffp
- delete Lyap
- lharc a Lyap.lzh Lyap.881 Lyap.ffp ReadMe.lyap Lyap.c Lyap.h Amiga.h
- quit
- */
-
- /* ==================================================================== */
- /* File - Lyap.c - Lyapunov Space to Vista DEM converter. */
- /* Created - 24 Aug 1991 - by : Clint H. Woeltjen */
- /* Copyright © 1991 by : Virtual Reality Laboratories, Inc. */
- /* All Rights Reserved. */
- /* Placed in the Public Domain by Virtual Reality Laboratories, Inc. */
- /* This program may be copied and distributed in any manner desired by */
- /* the user. The only restriction is that this header be left on the */
- /* source, and all of the files in this archive be distributed together.*/
- /* ==================================================================== */
-
- #include "amiga.h"
- #include "Lyap.h"
-
- main (argc, argv)
- int argc;
- char **argv;
- {
- register int i;
- int a,b,ix,ofile,iter;
- register double x,y,z,tot;
- double rx,ry,d,m;
- short int *dem;
- char *p;
- char *q;
-
- if (argc == 1) {
- printf("syntax: lyap scapefile xoffs yoffs divisor scale pattern iterations\n");
- printf(" scapefile == Name of destination Vista Scape file\n");
- printf(" xoffs == Starting r value in x := r*x*(1-x)\n");
- printf(" yoffs == Starting r value in x := r*x*(1-x)\n");
- printf(" divisor == d value needed for 258/d to cover desired width\n");
- printf(" scale == Multiplier value to give satisfactory elevations\n");
- printf(" pattern == lyapunov pattern of a and b\n");
- printf(" iterations == Number of iterations per point\n");
- exit(0);
- }
- rx = atof(argv[2]);
- ry = atof(argv[3]);
- d = atof(argv[4]);
- m = atof(argv[5]);
- iter = atoi(argv[7]);
- q = (char *)cmap;
- q += 32;
- sprintf(q,"%s\0",argv[1]);
- q += 32;
- sprintf(q,"%s %s %s %s %s %s\0",argv[2],argv[3],argv[4],argv[5],argv[6],argv[7]);
-
- dem = (short int *)AllocMem(133128,0);
-
- for (a = 1; a <= 258; a++) {
- for (b = 1; b <= 258; b++) {
- tot = 0.0;
- z = 1.1;
- x = (double)a;
- x = (x/d) + rx;
- y = (double)b;
- y = (y/d) + ry;
- for (i = 0; i < iter; i++) {
- p = argv[6];
- while (*p) {
- switch (p[0]) {
- case 'a':
- z = (x * z) * (1.0 - z);
- tot += (log(fabs(x * (1.0 - (2.0 * z)))));
- break;
- case 'b':
- z = (y * z) * (1.0 - z);
- tot += (log(fabs(y * (1.0 - (2.0 * z)))));
- break;
- }
- p++;
- }
- }
- if (tot > 0.0) tot = 0.0;
- tot = (-tot*m/(double)iter)/log(2.0);
- ix = (a-1)*258+b-1;
- dem[ix] = (short int)tot;
- }
- printf("Line == %4.4d\r",a);
- }
- printf("\n");
- ofile = creat(argv[1],O_CREAT);
- write(ofile,(char *)cmap,2048);
- write(ofile,(char *)dem,133128);
- close(ofile);
- FreeMem(dem,133128);
- }
-