Moving around – the easy way

In my recent articles Back to Trigonometry and Move objects in a circle smoothly, I described a formula to move objects around a circle.

Since WatchMaker also offers rotation values in degrees for time, we can simplify those formulas and make them more efficient to calculate.

In the original formulas I’ve used {ds}, which represented the seconds in time, as the input value. It’s much easier to use the rotation value {drs} as input. The only thing to do is to convert the degree values to radian values which can be done by the formula drs * \frac{\pi}{180}. Lua script offers this conversion function math.rad() out of the box. The formula looks like this.

x = \sin(radian(drs))
y = -\cos(radian(drs))

If you compare this with the other formula, you immediately see the difference:

x = \cos((ds * \frac{1}{60} * 2 \pi) - \frac{\pi}{2}) = \sin(radian(drs))
y = \sin((ds * \frac{1}{60} * 2 \pi) - \frac{\pi}{2}) = -\cos(radian(drs))

So in Lua script it looks like this:

x = math.sin(math.rad({drs}))
y = -math.cos(math.rad({drs}))

To define the size of the circle, you just have to multiply the desired size:

x = math.sin(math.rad({drs})) * 25
y = -math.cos(math.rad({drs})) * 25

You can use any rotation value with this formula just by replacing the tag, which is another big advantage compared to my prior formulas, because WatchMaker offers many rotation values.

Therefore you can replace the little complex formula in Move objects in a circle smoothly just by the rotation value {drss} for smooth seconds resulting in the following Lua script code:

x = math.sin(math.rad({drss})) * 200
y = -math.cos(math.rad({drss})) * 200

Update: In the original article Back to trigonometry I’ve described the eye movements of the Homer watch. Of course you do this with the new formula too. It would look like this:

x="-48 + math.sin(math.rad({drs})) * 25"
y="-42 - math.cos(math.rad({drs})) * 25"

Thanks to Brian Scott Oplinger for giving me the hint to add this aspect. 😉

Update: Here you can play around with the formula:

CC BY-NC-SA 4.0 This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Comments

One thought on “Moving around – the easy way

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.