Помогите разобраться в коде фрактального дерева opengl
#include
#include
#include
#include
#define ANGLE 0.6 // ugol
#define SCALE 0.9 // dlina
#define RAND 0.00 //
#define RAZ 10 // iterac
#define RAD 200 // masshtab
void tree(double x1, double y1, double length1, double angle1, int depth)
{
if (depth > 0)
{
double x2 = x1 + (length1) * cos(angle1);
double y2 = y1 + (length1) * sin(angle1);
glVertex2f(x1, y1);
glVertex2f(x2, y2);
double length2 = length1 * SCALE;
double angle2 = angle1 + ANGLE;
tree(x2, y2, length2, angle2, depth-1);
length2 = length1 * SCALE;
angle2 = angle1 - ANGLE ;
tree(x2, y2, length2, angle2, depth-1);
}
}
void init()
{
glClearColor(0.0, 0.0, 50.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
double radius = RAD;
glOrtho(-radius, radius, -radius, radius, -radius, radius);
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINES);
tree(0, -80, 40, 1.6, RAZ);
glEnd();
glFlush();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(500, 500);
glutInitWindowPosition(100, 100);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutCreateWindow("Tree");
glutDisplayFunc(display);
init();
glutMainLoop();
return 0;
}