The "magic factor that you're talking about is 57,295779524 that is number is the result of dividing 360 degrees between 2*
pi. That means that 57,295779524 is the amount of degrees of a
radian. (You're right Jahnocli and it is not the firs time...)
So, don't convert the angles given in radians in lua script to degrees unless you need to show to the user a numerical value or an input value. Work internally always with radians.
FORMULAS
To convert a rotation into a translation.
Case A) I rotate a bone from alpha= 0 to alpha=360 (from 0 to 2*pi radians) and want other bone to translate from X0 to X0+L and to X0-L (being L a known value and X0 the center of oscillation) I assume that we are talking always to modify the x coordinate of the slave bone:
X=X0+L*sin(alpha)
where sin =
sine a trigonometric function. the alpha value must be in radians when write the script. You should look the lua API to be sure of that.
For this case if you continue rotating the master bone until let say 480 degrees the slave bone would continue oscillating properly between X0 + L and X0 -L.
Case B) I rotate a bone from alpha = 0 to alpha = ANY VALUE and want the slave bone to translate continuously an amount of L for every turn I give to the master bone (like a car jack). In this case you have to make the calculus in two steps.
Let's do N=alpha/(2*pi) and truncate N to an integer number. Now N have the amount of turns that you have done with the master bone. It is important that you
truncate and not round N
Then now you can do:
X= X0 + L*N + L*sin(alpha)
NOTE: I assume that master bone angle is 0 at frame 0. If not alpha is the difference between the current angle and the angle at frame 0.
To convert a translation into a rotation.
I think it make sense only the inverse of the case B).
Case B) I translate a bone and then other bone rotates (like if you pull a car jack)
Let's make the inverse formula:
Let's be X0 the original place of the bone (at frame 0) and X the current position.
N=(X0-X)/L you should truncate N also to be integer. N can be negative of course.
alpha = alpha0 + N*2*pi + arcsine((X-X0)/L -N)
where arcsine =
arcsine a trigonometric function (inverse of sine)
Where alpha0 is the angle at frame 0 and L have the same meaning that previously.
SOME HINTS WITH THE SCALE TOOL:
Let's be M0 the length of a bone at frame 0. It untouched scale is 1.
Let's make S the scale of the bone at any other frame than 0.
Then its length becomes:
M=M0*S (simple isn't it?)
So to convert a rotation into a bone scale is as simple as making the scale of the bone equal to the sine of the angle of the master bone:
S=sin(alpha)
The inverse is also easy you have only to do the same steps than in the B case o f rotate by translation but now X0=0 and L=M0.
One curios thing:
If a bone is constrained by other in the scale value then the formula is different than the easy one.
M=master length; L=slave length
M=M0*S
-->> L = L0(1+S). SO THE SLAVE SCALE VALUE IS (1+S) AND NOT 'S' AS YOU CAN IMAGINE.

Last remark: HOW A BONE SCALE AFFECT TO A MESH:
Please watch this file:
http://genetita.googlepages.com/flipbone.anme
The scale of a bone affects the same to all the points in its local coordinate system. But more away are the point more quick is the movement of the point for the same scale and vice versa. Same comment applies to any other bone that is linked to the bone that is being scaled.
Hope this quick math lesson help you in your script an definitively you can post those cool scripts that you have done in your sticky are in the Scripting forum (copy / paste bones, rotate trans, trans rotate, scale rotate, rotate switch, and so on...)
Best
Genete