PDA

View Full Version : noob question: want to use splines to draw a gear



newsb
12-24-2011, 07:25 PM
Hi,

Noob question: I have a function that makes approx. 2400 (X,Y)-coordinates for a single tooth on a gear. In order for me to draw the whole gear, I rotate these 2400 points by 14 teeth = more than 30.000 points!

I connect them like this:


int skipPoints = 50;
for (int i=0; i<numRotations; i++)
{
glBegin(GL_LINE_STRIP);
for (int j=0; j< N_kontur; j=j+skipPoints)
glVertex2f( -allX[i][j], allY[i][j] ); // negative X-values
glEnd();

glBegin(GL_LINE_STRIP);
for (int j=0; j< N_kontur; j=j+skipPoints)
glVertex2f( allX[i][j], allY[i][j] ); // positive X-values
glEnd();
}


Finally, I tried to make the gear rotate using gluttimerfunc - BAD idea... The animation is "flashing", due to the high number of points. I then introduced "skipPoints" in the code above, and this kind of solves the flashing problem. My new problem is lack of detail:

Question: How do I interpolate my gear profile, maybe using splines/bezier curves/manipulators (?? whatever they're called) to draw the whole gear using only a fragment of the current (large) number of points?

I read a bit about it - I think I need to figure out the control points - or is there a better option?

awhig
12-29-2011, 12:44 PM
Not clear enough. Can you please post an image of what you achieve by above?

If I get you correctly, interpolation will affect your rotation and movement of gear. To reposition your tooth to create another instance you need to change coordinates of vertices by using blending function of the evaluator ie. X' = X + f(X)...

By "lack of detail" do you point to surface shading of gear teeth ?