home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / lyap / lyap.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-09  |  5.3 KB  |  179 lines

  1. /*
  2.  *    @(#) lyap.h 12.1 95/05/09 SCOINC
  3.  */
  4. /*************************************************************************
  5.  *                                                                       *
  6.  *  Copyright (c) 1992, 1993 Ronald Joe Record                           *
  7.  *                                                                       *
  8.  *  All rights reserved. No part of this program or publication may be   *
  9.  *  reproduced, transmitted, transcribed, stored in a retrieval system,  *
  10.  *  or translated into any language or computer language, in any form or *
  11.  *  by any means, electronic, mechanical, magnetic, optical, chemical,   *
  12.  *  biological, or otherwise, without the prior written permission of:   *
  13.  *                                                                       *
  14.  *      Ronald Joe Record (408) 458-3718                                 *
  15.  *      212 Owen St., Santa Cruz, California 95062 USA                   *
  16.  *                                                                       *
  17.  *************************************************************************/
  18.  
  19. /*
  20.  *    Written by Ron Record (rr@sco.com) 03 Sep 1991.
  21.  */
  22.  
  23. static char *lyap_h_id = "@(#) lyap.h 12.1 95/05/09 SCOINC";
  24.  
  25. #include "patchlevel.h"
  26. #include "libXrr.h"
  27. #include <assert.h>
  28. #include <math.h>
  29. #include <memory.h>
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32. #include <string.h>
  33. #include <values.h>
  34. #include <X11/Xlib.h> 
  35. #include <X11/StringDefs.h> 
  36. #include <X11/keysym.h> 
  37. #include <X11/cursorfont.h> 
  38. #include <X11/Xutil.h>
  39. #include <X11/Xatom.h>
  40.  
  41. #define ABS(a)    (((a)<0) ? (0-(a)) : (a) )
  42. #define Min(x,y) ((x < y)?x:y)
  43. #define Max(x,y) ((x > y)?x:y)
  44.  
  45. /* Useful mathematical constants that should have been defined in math.h 
  46.  * M_LOG2E    - log2(e)
  47.  * M_LN2        - ln(2)
  48.  * M_PI        - pi
  49.  */
  50. #ifndef M_LOG2E
  51. #define M_LOG2E    1.4426950408889634074
  52. #endif
  53. #ifndef M_PI
  54. #define M_PI    3.14159265358979323846
  55. #endif
  56. #ifndef M_LN2
  57. #define M_LN2      6.9314718055994530942E-1 /*Hex  2^-1 * 1.62E42FEFA39EF */
  58. #endif
  59.  
  60. /* Useful machine-dependent values that should have been defined in values.h
  61.  * LN_MAXDOUBLE - the natural log of the largest double  -- log(MAXDOUBLE)
  62.  * LN_MINDOUBLE - the natural log of the smallest double -- log(MINDOUBLE)
  63.  */
  64. #ifndef LN_MINDOUBLE
  65. #define LN_MINDOUBLE (M_LN2 * (DMINEXP - 1))
  66. #endif
  67. #ifndef LN_MAXDOUBLE
  68. #define LN_MAXDOUBLE (M_LN2 * DMAXEXP)
  69. #endif
  70.  
  71. #ifndef TRUE
  72. #define TRUE 1
  73. #define FALSE 0
  74. #endif
  75.  
  76. #define MAXFRAMES 2
  77.  
  78. int maxcolor=256, startcolor=17, color_offset=96, mincolindex=33;
  79. int dwell=100, settle=50;
  80. int width=256, height=256, xposition=-1, yposition=-1;
  81. short delay=0;
  82. int bottom, screen;
  83. Display*    dpy;
  84. char*        displayname = 0;
  85. FILE *infile;
  86.  
  87. extern double log();
  88. extern double fabs();
  89. extern long time();
  90. extern int optind;
  91. extern char *optarg;
  92.  
  93. unsigned long foreground, background;
  94.  
  95. Window canvas, help, info;
  96.  
  97. void     resize();
  98. void     redisplay();
  99. void     quit();
  100. void     Spin();
  101. void     start_iterate();
  102. void     stop_iterate();
  103. void     show_defaults();
  104. void     StartRubberBand();
  105. void     TrackRubberBand();
  106. void     EndRubberBand();
  107. void     CreateXorGC();
  108. void     InitBuffer();
  109. void     BufferPoint();
  110. void     FlushBuffer();
  111.  
  112. typedef struct {
  113.     int x, y;
  114. } xy_t;
  115.  
  116. typedef struct {
  117.     int start_x, start_y;
  118.     int last_x, last_y;
  119.     } rubber_band_data_t;
  120.  
  121. typedef struct {
  122.     Cursor band_cursor;
  123.     double p_min, p_max, q_min, q_max;
  124.     rubber_band_data_t rubber_band;
  125.     } image_data_t;
  126.  
  127. points_t Points; /* typedef in ../lib/libXrr.h */
  128. image_data_t rubber_data;
  129.  
  130. GC Data_GC[MAXCOLOR], RubberGC;
  131.  
  132. #define MAXINDEX 64
  133. #define FUNCMAXINDEX 16
  134. #define NUMMAPS 5
  135.  
  136. typedef double (*PFD)();
  137.  
  138. double logistic(), circle(), leftlog(), rightlog(), doublelog();
  139. double dlogistic(), dcircle(), dleftlog(), drightlog(), ddoublelog();
  140. PFD map, deriv;
  141. PFD Maps[NUMMAPS] = { logistic, circle, leftlog, rightlog, doublelog };
  142. PFD Derivs[NUMMAPS] = { dlogistic, dcircle, dleftlog, drightlog, ddoublelog };
  143.  
  144. int aflag=0, bflag=0, wflag=0, hflag=0, Rflag=0;
  145. double pmins[NUMMAPS] = { 2.0, 0.0, 0.0, 0.0, 0.0 };
  146. double pmaxs[NUMMAPS] = { 4.0, 1.0, 6.75, 6.75, 16.0 };
  147. double amins[NUMMAPS] = { 2.0, 0.0, 0.0, 0.0, 0.0 };
  148. double aranges[NUMMAPS] = { 2.0, 1.0, 6.75, 6.75, 16.0 };
  149. double bmins[NUMMAPS] = { 2.0, 0.0, 0.0, 0.0, 0.0 };
  150. double branges[NUMMAPS] = { 2.0, 1.0, 6.75, 6.75, 16.0 };
  151.  
  152. int   forcing[MAXINDEX] = { 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,
  153.             0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,
  154.             0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1 };
  155. int   Forcing[FUNCMAXINDEX] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
  156.  
  157. int   maxindex = MAXINDEX;
  158. int   funcmaxindex = FUNCMAXINDEX;
  159. double    min_a=2.0, min_b=2.0, a_range=2.0, b_range=2.0, minlyap=1.0;
  160. double  max_a=4.0, max_b=4.0;
  161. double  start_x=0.5, lyapunov, a_inc, b_inc, a, b;
  162. int    numcolors=16, numfreecols, displayplanes, lowrange;
  163. xy_t    point, velocity;
  164. Pixmap  pixmap;
  165. Colormap cmap;
  166. XColor    Colors[MAXCOLOR];
  167. double  *exponents[MAXFRAMES];
  168. double  a_minimums[MAXFRAMES], b_minimums[MAXFRAMES];
  169. double  a_maximums[MAXFRAMES], b_maximums[MAXFRAMES];
  170. double  minexp, maxexp, prob=0.5;
  171. int     expind[MAXFRAMES]={0}, resized[MAXFRAMES]={0};
  172. int    numwheels=MAXWHEELS, force=0, Force=0, negative=1;
  173. int     nostart=1, stripe_interval=7;
  174. int    save=1, show=0, useprod=1, savefile=0, restfile=0, storefile=0;
  175. int    maxframe=0, frame=0, dorecalc=0, mapindex=0, run=1, demo=0;
  176. char    *outname="lyap.ppm";
  177. char    *inname="lyap.sav";
  178. char    *savname="lyap.sav";
  179.