Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Hi I'm trying to do a game with real time simulations of gears. There is a big Gear with inside a smaller gear.

I managed to draw gears with different diameters but equal size teeth, but if i try to move the smaller one inside the bigger one the movement is odd.

see the animated gif.

the biggest gear is in center C1 and the small in the center C2. I calculate C2 position in this way:

C2.x = C1.x + C1_RADIUS-C2_RADIUS) * cos(t);
C2.y = C1.y - C1_RADIUS-C2_RADIUS) * sin(t);

for t that goes from 0 to TWO_PI in n steps.

I apply as rotation the angle t, but maybe it is wrong and i have to calculate another rotation for get a perfect joint.

EDIT:

I am using radians for rotations and i think this is OK.

My main problem is that i want to achive a perfect joint between teeth like this example. My teeth are overlapping in some odd way.

EDIT

a working example can be found here: http://www.openprocessing.org/sketch/83665

share|improve this question
    
I only see the small gear teeth rotating very slowly. But the inner green cross spinning at what looks like the correct speed. Is the main problem getting the drawing of the teeth rotating or finding the correct rotation speed? Common issue to check here is if you're using radians. –  Byte56 Dec 12 '12 at 17:46
    
i have edited the question a little bit.. –  nkint Dec 12 '12 at 18:36
    
It reminds a shader i wrote some time ago : glsl.heroku.com/e#3738.0. what you should take in account here is gear ratio. ratio = number of teeth gear A / number of teeth gear B. use that ratio to scale rotation speed of main gear vs second gear. –  tigrou Dec 12 '12 at 20:33
    
Can you please make a new animated GIF when your problem is fixed? Looking at the “wrong” one is so frustrating :-) –  Sam Hocevar Dec 12 '12 at 21:08
    
still some problem if the gear is outside. i have found some dirty number to add to try to resolve problem but nothing do to.. if you have some idea.. –  nkint Dec 17 '12 at 16:16
add comment

1 Answer 1

up vote 6 down vote accepted

The large gear has circumference 2πR1 and the small one has circumference 2πR2, so when the small gear has made a full circle, it has turned R1/R2 times around itself, minus one time because it turned inside the large gear (it would be plus one if the gear was outside).

So when the centre of the inner gear is rotated by angle t, the gear itself needs to be rotated by angle (R1/R2-1)t.

If the values you handle are tooth counts N1 and N2 you can replace R1/R2 with N1/N2.

There is also the issue of the initial rotation. Let a be the angle value atan2(C2.y - C1.y, C2.x - C1.x). Apply initial rotation a to gear 1. If gear 2 is inside, apply rotation a to it, too. If gear 2 is outside, apply a π+a+h rotation where h = π/(2*N2) is the half angle of a tooth.

share|improve this answer
    
thanks. this did the trick perfectly. can you give me more information on how to find this formula? –  nkint Dec 12 '12 at 21:00
2  
I must admit my knowledge of gear mathematics only comes from 30 years of playing with Legos. If I come across a meaningful resource I will add it to my answer. –  Sam Hocevar Dec 12 '12 at 21:11
    
@nkint It is the number of teeth that counts. You can just replace the radius ratio R1/R2 with the tooth count ration N1/N2. –  Sam Hocevar Dec 13 '12 at 13:21
    
ok perfect, thanks, now it is more clear. i have googled for "gear ratio" but i don't find anywhere the +1 or -1 for outside/inside –  nkint Dec 13 '12 at 13:22
    
tue to the fact that there are still some problems i unchecked the correct answer.. and i have upload all the code, maybe someone one day will have a look to the last unresolved problem! –  nkint Dec 17 '12 at 16:18
show 9 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.