Maximize MenuMinimize Menu

 

 

Back | Home

Spherical Spiral Plot

This is an advanced Game-Editor Drawing Demo - meaning only the C-scripts are provided and you should already know the mechanics of starting a canvas actor, adding scripts, etc. If you are not at this level, please see the Let's DRAW! Basic Drawing Tutorial.

This was a rewarding exercise in converting TURBO BASIC code into Game-Editor C-script.

// Spherical Spiral
// Adapted from TURBO BASIC program in book
// Fractals Endlessly Repeated Geometrical Figures
// By Hans Lauwerier - Princeton Science Library

float a = .2; //Spiral Parameter
float c = .9; //Slope Projection Plane
float p = 1/sqrt(2);
float q = p*sqrt(1-c*c);
float s;
float t;
float x1;
float y1;
float z;
float u; //Plot X
float v; //Plot Y
float pi = 3.141593;
float va = 100; //Vertical aspect ratio
float ha = 100; //Horizontal aspect ratio

int n;

setpen(255,255,255,0,1);

for(n = -500; n < 500; n++)

{
s = (n*pi)/50;
t = atan(a*s);
x1 = cos(s)*cos(t);
y1 = sin(s)*cos(t);
z = -1*(sin(t));
u = 120+(va*(p*(y1-x1)));
v = 160+(ha*(c*z-q*(x1+y1)));

moveto(u,v);

if(n == -500) putpixel(u,v);
else lineto(u,v);
}

 

 

Enjoy!
How many other great old books are out there just waiting to be re-coded and re-discovered?

 

Radiosity Games
See our new game site

 

 

 

©Copyright TrajectoryLabs.com. All Rights Reserved.