if (m2.x > 0){
glBegin(GL_POINTS);
for (int i = 0; i < numSteps; i++){
float p = (float)i / numSteps;
Vec2d points = LERP(m1,m2,p);
glVertex2f(points.x,points.y);
}
glEnd();
}
}
Problem 2. Create a function that takes as input a number of steps, and draws that many intermediate shapes between a start shape and an end shape. The start shape and end shape should be defined by an array of vectors (i.e points), and should have the same number of points. Extra credit for those who can make this work for two shapes with an unequal number of points.
glPointSize(1);
glBegin(GL_POINTS);
for (float p = 0; p <= 1.0; p+=0.001){
float b = 1.0-p;
Vec2d R = A*(b*b*b) + B*(3*p*b*b) + C*(3*p*p*b) + D*(p*p*p);
glColor3f(1,0,0);
glVertex2f(R.x,R.y);
}
glEnd();
}
void drawProblem3(Vec2d A, Vec2d B, Vec2d C, Vec2d D){
if (m1.y > 0)
drawBezier(A,B,C,D);
}
Problem 4. Create a function that takes as input an array of points (Vec2d *) and the number of points in that array (int), and draws a shape composed of several consecutive Bezier curves.
void manyBeziers(Vec2d pArray[], int points){
for (int i = 0; i < points - 3; i = i + 3){
drawBezier(pArray[i],pArray[i+1],pArray[i+2],pArray[i+3]);
}
}
void drawProblem4(){
int points = 10;
Vec2d pArray[points];
Problem 6. Extra credit: make a bezier drawing tool that works just like the one in Adobe Illustrator.
void manyBeziers2(Vec2d pArray[], int points){
for (int i = 0; i < points - 1; i += 3){
drawBezier(pArray[i],pArray[i+1],pArray[i+2],pArray[i+3]);
printf("%i\n",i);
}
}
Problem 7. Describe and skech (on paper is fine) a computation form that you would like to create for your first class project. Consider all the methods that you know thus far and how they can be combined. Also, feel free to make it interactive or animated or both.
I want to create a sphere that wobbles according to data I feed into it for x, y, and z deformations... the globe should ripple following the variations on the x, y, and z equators