I followed Wikipedia article with the called "chaos" game
Quote
.....Or more simply:
1. Take 3 points in a plane, and form a triangle
2. Randomly select any point inside the triangle and move half the distance from that point to any of the 3 vertex points. Plot the current position.
3. Repeat from step 2.
1. Take 3 points in a plane, and form a triangle
2. Randomly select any point inside the triangle and move half the distance from that point to any of the 3 vertex points. Plot the current position.
3. Repeat from step 2.
when running the program i get something like this:

whats bad with it?
the drawing code is:
#include <stdlib.h>
#include <gl/gl.h>
#include <math.h>
#include "sierpin.h"
point Sierpin::GetRandPoint() {
/*Thanks to the people that helped
in the thread of the
uniform random point inside a triangle problem at:
http://www.devmaster.net/forums/showthread.php?t=10469
*/
float a,b;
do {
a=((float) rand()) / ((float)RAND_MAX);
b=((float) rand()) / ((float)RAND_MAX);
} while ((a+:) >1);
float c=1-a-b;
return point( (points[0]*a + points[1]*b + points[2]*c));
};
void Sierpin::Draw(void) {
glColor3ub(255,100,0); // pen color to orange vomit
int sel=rand() % 3; // get a random number between 0 and 2
point p=points[sel]; // saving a random vertex of the three possible of the triangle
point t=GetRandPoint();//gettin a valid random point in the triangle
for (int k=0; k < iter; k++) {
glBegin(GL_POINTS);
//draw the point between the random trangle vertex and
//the random inner point
glVertex2f((t.x+p.x)/2,(t.y+p.y)/2);
glEnd();
//getting new points
t=GetRandPoint();
sel=rand() % 3;
p=points[sel];
//and repeat
};
};
int Sierpin::iter = 8000; //
thanks...












