I am working on an assignment for school and i seem to be having some issues. I am using OpenGl with free glut, and attempting to animate a pendulum. I can draw out the pendulum, but cannot determine how to make it swing. I have to make it swing from -45 degrees to 45 degrees, and i have the line and ball drawn. I have tried several ways to animate it and make it smooth, but i don't completely understand the process of it. I can set it up in a state where it would be at the right spot on both sides, but cannot animate it smooth. I can just make it jump from the two points. Not hitting the points in-between. I have also tried using the rotate and translate function, but it never rotates the line correctly, it always rotates at the axis, but thats not working. I could really use some help if anyone has any experience.
Thanks

If you can draw it at 45 degrees and -45 degrees, can you also draw it at 44 and -44 degrees? And all the angles inbetween?

How about something as simple as this:

Draw it at 45 degrees.
Wait a tenth of a second.
Draw it at 44 degrees.
Wait a tenth of a second.
Draw it at 43 degrees.
etc.
etc.
Until -45 degrees.

This is crying out to be in a loop of some kind, where each iteration changes the angle.

Ahh right that makes sense... but i couldn't put this in the rotate function right? When i try to use the rotate and translations, it always tries to rotate my top end of my line, where i want it to rotate moving my second vertex point.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.