I’ve been trying to create a formula to have 3 dots move on each of the following 3 paths:
First off, I want to thank @Mellin for his great tutorial about circular motion as it gave me a place to start!
Now on to the actual tutorial.
For the black dot, it’s not that hard. You’ll use something like this (based entirely on Mellin’s explanations which explain what all the elements in the below formulas are):
x: ((33*(sin((#DWFMS#/180)pi)))+160)
y: ((140(cos((#DWFMS#/180)*pi)))+160)
For the next 2 paths it gets a bit tricky. Here’s a bit of background.
How is an ellipse defined?
x: asin(t)
y: bcos(t)
In the above example, a=33 (the “width” of the ellipse), b=140 (the “heigth” of the ellipse) and t=(#DWFMS#/180)*pi (the angle, measured in Radians).
How do you rotate an ellipse?
Intuitively, you might say that you could use something like this:
x: asin(t + u)
y: bcos(t + u)
where u=the angle to rotate the ellipse by.
Unfortunately, it’s not that easy and the above formula would give you basically the same motion as the original one. In order to rotate the ellipse, you actually have to rotate your system of coordinates!
So, if x and y are your original coordinates, x’ and y’ after rotating the coordinate system by an angle “u” would be the following:
x’ = xcos(u) - ysin(u)
y’ = xsin(u) + ycos(u)
Replacing the x and y from the “original” ellipse formula, you get this:
x’ = acos(t) cos(u) - bsin(t)sin(u)
y’ = acos(t) sin(u) + b*sin(t)*cos(u)
Back to our example
The blue dot
By replacing our values for a, b and t from the black dot and determining the wanted “u” angle (I know it’s 30 degrees), we get the following formula:
x: ((140cos((#DWFM#/180) pi)* cos(pi/6)-33sin((#DWFM#/180) pi)sin(pi/6))+160)
y: ((140cos((#DWFM#/180)* pi)* sin(pi/6)+33sin((#DWFM#/180) pi)*cos(pi/6))+160)
The red dot
This is similar with the blue dot just that my angle is 150 degrees (or -30 degrees) and as such, I use 5pi/6 for “u”:
x: (((140cos(-(#DWFM#/180)* pi)* cos(5pi/6))-(33sin((#DWFM#/180)* pi)sin(5pi/6)))+160)
y: (((140cos(-(#DWFM#/180) pi)* sin(5pi/6))+(33sin((#DWFM#/180)* pi)cos(5pi/6)))+160)
I also changed the direction of the movement by using a “-” sign.
Angles to Radians (how do I get “u”)
The sin and cos formulas actually work with Radians, not Degrees. In order to convert Degrees to Radians you have to consider that 2*pi radians equals 360 degrees. This means that 1 radian = 180/pi degrees, and 1 degree = pi/180 radians. You can also use the image below for some “common” angles.
Conclusion
I hope you find this useful and that you’ll come up with some awesome designs! Can’t wait to see them! Also, if there’s any feedback to this tutorial, don’t hesitate to leave a comment.
Enjoy,
Mircea