mattb
The way I look at it the angles of the two gears are related like this:
gearB.angle = (gearA.angle-gearA.initialAngle)*ratio + gearB.initialAngle
So when gearA.angle is zero gearB.angle is:
= -gear.InitialAngle*ratio + gearB.initialAngle
Make that negative and we get the phase:
phase = gear.initialAngle*ratio-gearB.initialAngle
Ok, to simplify the angle calculations make sure the angle of every gear is between 0 and 180 degrees. Then using the following makes rotations spot on in your capx:
phase = -gear.Angle+fGear.n/Gear.n*-fgear.Angle