PDA

View Full Version : Translation using Math



Smithy566
10-29-2009, 11:08 AM
Hello,

My apologies if this post is in the wrong forum. I am currently creating a model of a train which is my first openGL project.

I have a set of large wheels which I wish to be connected together with a bar - imagine an old steam train.

Below is a screenshot of what I have so far.
http://scott-smith.co.uk/images/train.JPG

I want the blue bar to give the impression that is is connected to the 3 large wheels, however I am not the best at maths, and do not know how to perform the sin & cos calculations to make it translate in a circle! I need to be able to control the speed of the movement so that it matches the rotation of the wheels

Any advice would be appreciated

overlay
10-29-2009, 12:05 PM
Not really OpenGL question but... I guess you are saying that the wheels kind of slide on the bar instead of really rolling over it.

The train should translate by the arc length matching the angle of rotation of the big wheel. If you are controlling the angle, you want to compute the translation (arc length):

Formula: s = r*angle;

s = arc length (in the unit you want)
r = radius of the circle (in the same unit as arc length)
angle = angle in radians

Or if you are controlling the translation, you want to compute the angle: angle=s/r.

MaxH
10-29-2009, 04:02 PM
If I understand your question, this diagram should give you the relations you need to move the rod as if it were attached to the wheels. Actually, I see now that you have to rotate the wheel in the other direction to make the train move to the right. But the equations still hold (never was too good at the mechanical stuff :)). The forum has shrunk my diagram a bit. For a full sized version go to:

Wheel & Rod Relations (http://www.mfwweb.com/OpenGL/Train.jpg)

http://www.mfwweb.com/OpenGL/Train.jpg