Bezier

Posted by s on Sept. 4, 2008, 7:21 p.m.

void glBezier(int x1,int y1,int x2,int y2,int x3,int y3,double z=1){

glBegin(glLS);

z/=max(ptdis(x1,y1,x3,y3),ptdis(x2,y2,x3,y3));

for(double i=0;i<=1;i+=z){

if(i>1) i=1;

glVertex2f(x1+((x2-x1)*2+(x1-x2*2+x3)*i)*i,y1+((y2-y1)*2+(y1-y2*2+y3)*i)*i);}

glEnd();

}

void glBeziers(vector<int>&X,double z=1){

glBegin(glLS);

vector<int>Y;

int s=X.size()-2;

z/=ptdis(X[0],X[1],X[s-1],X);

for(double i=0;i<=1;i+=z){

Y=X;

for(int V=s;V;V-=2){

for(int v=0;v<V;v+=2){

Y[v]+=int((Y[v+2]-Y[v])*i);

Y[v+1]+=int((Y[v+3]-Y[v+1])*i);

}}

glVertex2i(Y[0],Y[1]);

}

glEnd();

}

glBeziers lacks proper precision still. Makes sense, probably has to sum some weirdness or something bleh

No matter how much I learn, I'll still know nothing of the infinity of knowledge. I'll still be lonely, but maybe I'll be able to determine the validity of (my) existence

Comments

GearGOD 16 years, 11 months ago

Do it with shaders

PY 16 years, 11 months ago

but if the validity of your existence can be determined, is it really valid?

s 16 years, 11 months ago

I should probably learn about these shaders you speak of first, I've delayed such knowledge long enough

Validity is valid