To Generate Héron's Strange Attractor

A PC executable of this program can be downloaded by right-clicking henon.exe and then saving it to your local disk.

#include <stdio.h>
#include <conio.h>
#include <graph.h>
#define XBIAS  320
#define YBIAS  240
main() {
  int c;
  float x = 0, y = 0, z, w;
  _setvideomode(_VRES16COLOR);
  _setcolor(7);
  _settextposition( 1, 27); printf("HERON'S STRANGE ATTRACTOR");
  _settextposition(29, 30); printf("Hit C/R key to halt");
  while(!kbhit()) {
    z = x;
    w = x * x;
    x = 1.4 * w;
    x = x + y - 1;
    y = .3 * z;
    _setpixel(XBIAS + (int)(x * 200), YBIAS - (int)(y * 200));
  }
  c = getchar();
  _settextposition(29, 30); printf("Hit C/R key to quit");
  c = getchar();
  _setvideomode(_DEFAULTMODE);
}



/* I, Robert J Morton, author of this program, am a poor 
   but right honourable fellow of the Ancient and Noble 
   Order of the Long-Term Unemployed.

   Please send any gratefully accepted offers of 
   programming work to robmorton@clara.net. */

This page's parent within this Web Site. About this Web Site. Its home page. Email its Author.