/*
Author: Mitch Richling<http://www.mitchr.me>
IP: Copyright 1994 by Mitch Richling. All rights reserved.
Key word: lorenz strange attractor povray Euler
Notes: This is a very simple program to generate a curve based
on Lorenz's attractor. It uses Euler's method to solve the
equations. The "curve" consists of a series of spheres
placed at each point found on the curve. The spheres
are connected with cylinders. Note that this program
is simple enough to be coded with Povray itself.
*/
#include <stdio.h>
int main() {
int maxBalls = 10000;
double tDelta = 0.01;
double x = 0.1;
double y = 0.0;
double z = 0;
double a = 10;
double b = 28;
double c = 8.0 / 3.0;
int numBalls;
double xNew, yNew, zNew;
fprintf(stderr, "Computation starting...\n");
printf("sphere {<%f,%f,%f>, %f texture { crvTex } }\n", x, y, z, 0.2);
for(numBalls=0;numBalls<maxBalls;numBalls++) {
xNew = x + a*(y-x)*tDelta;
yNew = y + (x*(b-z)-y)*tDelta;
zNew = z + (x*y-c*z)*tDelta;
/* Display 20 "status" messages. */
if((numBalls % (int)(maxBalls/20)) == 0)
fprintf(stderr, "Step: %6d tDelta: %15.3f x: %15.2f y: %15.2f z: %15.2f\n", numBalls, tDelta, x, y, z);
printf("sphere {<%f,%f,%f>, %f texture { crvTex } }\n", xNew, yNew, zNew, 0.1);
printf("cylinder {<%f,%f,%f>, <%f,%f,%f>, %f texture { crvTex } }\n", x, y, z, xNew, yNew, zNew, 0.2);
x=xNew;
y=yNew;
z=zNew;
}
}
Generated by GNU Enscript 1.6.5.2.