-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlorenzC.h
127 lines (109 loc) · 3.02 KB
/
lorenzC.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/* -*- Mode:C; Coding:us-ascii-unix; fill-column:132 -*- */
/**********************************************************************************************************************************/
/**
@file lorenzC.h
@author Mitch Richling <https://www.mitchr.me>
@Copyright Copyright 1997 by Mitch Richling. All rights reserved.
@Revision $Revision$
@SCMdate $Date$
@brief Function that will generate a lorenz curve, bounding box, and x/y/z-axes.@EOL
@Keywords none
@Std C89
***********************************************************************************************************************************/
/**********************************************************************************************************************************/
#define RADIUS 40
#define DRAW_MODE 2
/**********************************************************************************************************************************/
void computeGeometry() {
int maxBalls = 5000;
double tDelta = 0.01;
double x = 0.11;
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;
glNewList(1, GL_COMPILE);
glColor3f(1,1,1);
glPointSize(2.0);
#if DRAW_MODE == 3
glBegin(GL_POINTS);
#endif
#if DRAW_MODE == 2
glBegin(GL_LINE_STRIP);
#endif
#if DRAW_MODE == 3
glBegin(GL_TRIANGLE_FAN);
glVertex3f(50,0,0);
#endif
#if DRAW_MODE == 4
glBegin(GL_TRIANGLE_STRIP);
glVertex3f(0,0,0);
#endif
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;
glColor3f(1.0*numBalls/maxBalls, 0.2, 1.0-numBalls/maxBalls);
#if (DRAW_MODE == 5)
glMatrixMode(GL_MODELVIEW);
glTranslatef(xNew, yNew, zNew);
glutSolidSphere(0.5, 5, 5);
glMatrixMode(GL_MODELVIEW);
glTranslatef(-xNew, -yNew, -zNew);
#endif
#if (DRAW_MODE < 5)
glVertex3f(xNew, yNew, zNew);
#endif
#if (DRAW_MODE == 4)
glVertex3f(xNew, yNew, zNew+1);
#endif
x=xNew;
y=yNew;
z=zNew;
} /* end for */
#if (DRAW_MODE < 5)
glEnd();
#endif
// Draw the x/y/z axis
#if 1
glBegin(GL_LINE_STRIP);
glColor3f(1, 0, 0);
glVertex3f( 0, 0, 0);
glVertex3f(40, 0, 0);
glVertex3f( 0, 0, 0);
glColor3f(0, 1, 0);
glVertex3f( 0, 0, 0);
glVertex3f(0, 40, 0);
glVertex3f( 0, 0, 0);
glColor3f(0, 0, 1);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 40);
glEnd();
#endif
// Draw the box
#if 1
glBegin(GL_LINE_STRIP);
glColor3f(1, 1, 1);
glVertex3f( 40, -40, -40);
glVertex3f( 40, 40, -40);
glVertex3f(-40, 40, -40);
glVertex3f(-40, -40, -40);
glVertex3f( 40, -40, -40);
glVertex3f( 40, -40, 40);
glVertex3f( 40, 40, 40);
glVertex3f(-40, 40, 40);
glVertex3f(-40, -40, 40);
glVertex3f( 40, -40, 40);
glVertex3f( 40, 40, 40);
glVertex3f( 40, 40, -40);
glVertex3f(-40, 40, -40);
glVertex3f(-40, 40, 40);
glVertex3f(-40, -40, 40);
glVertex3f(-40, -40, -40);
glEnd();
#endif
glEndList();
} /* end func computeGeometry */