Having done some research, prompted and assisted by MrMecha (er, I mean, Cream), I figured out the rules governing the speeds of rotator and pistons, with the goal of synchronising them to create elliptical motion.
A rotator rotates at a speed of speed * speed * 270
degrees per second.
Therefore, it completes a full rotation in 360 / (speed * speed * 270)
seconds which more simply put is 4 / (3 * speed * speed)
. This means a rotator with 100% speed rotates 360 degrees in 1.3333 seconds. However a rotator with speed 2 rotates in a quarter of the time (1/3 secs), because the speed is squared.
A piston's movement is altogether quite strange to the onlooker, it doesn't seem to provide an obvious pattern. The actual reason for this is its method of smoothing out the motion. It traces, as it moves, a cosine wave. The cosine function in most programming languages uses radians. A piston moves at 20 * speed
radians per second. A full in/out cycle is 2pi radians (a full circle). So the piston completes a cycle in 2pi / (speed * 20)
seconds, which can be simplified to pi / (speed * 10)
seconds. This means a piston with a speed of 100% completes a full in/out cycle in pi / 10
or 0.314159
seconds.
To synchronise them, both results must be the same. So, we can put it into an equation.
rotator period = piston period
4 / (3 * rotatorSpeed^2) = pi / (10 * pistonSpeed)
This can then be rearranged into a formula for each direction.
pistonSpeed = 0.075 * pi * rotatorSpeed * rotatorSpeed
and
rotatorSpeed = root( (40 * pistonSpeed) / 3pi)
Using the first formula for a rotator with a speed of 1 (100%) returns the piston speed of 0.2356194490
. However, this means that the piston will do a full in/out cycle once per rotation. This creates an offset ellipse. To have a symmetrical ellipse, double the piston speed. This gives a value of 0.471238898038
for the piston speed. Which works. In the future, you could just multiply this by the rotator speed squared. That would be a good shortcut. You thought learning maths would never help you? Well there we go.
Also, due to the different ways pistons and rotators work (piston speed depends on input, rotator doesn't), bind them to an activation group to stop them desynchronising on startup. Oh, and you can't stop it without desynchronising.
Now for a quick demonstration:
What is this useful for, you say?
Mech
tl;dr: 0.471238898038
is the magic number. Multiply it by rotator speed squared to get piston speed.
Or, if you just want to get rid of pistons altogether, you could do something like this
My brain just exploded rn
@CalebRepublic Yes.
@Thomasj041 yes
I haven't posted here in a long long long time but there are some things OP can reconsider before teaching formulas:
@Thomasj041 yes.
Don't understand lol 😂😂
wha
@Thomasj041 Yes
Is the input in seconds for weapon firing delay?
@plane918273645 this. Whether it still works, I don't know.
How did you do the smoke trail?
I made the mech walk on water @PhilipTarpley
This is nice!
Never thought of something like this, Very impressive.
Very useful info, thanks for your research !
Gonna be using this a ton, thanks dude
23333,好喜感啊
Impressive research, physician exploring the nature of the world created by Jundroo.
eeks deeks this is pretty sexy my guy
I just keep staring at the gifs...I'm mesmerized at how beautiful it is.
Edit - Posted to twitter
We should call 0.471238898038 the WNP-Cream Constant. Or the Cream-WNP Constant.
aaaaaaaaaaaaaaaaaaaaaaaaaa
opens brain.exe
kabum
I'll be back in a second, just let me find my brain.
I hope it didn't evaporate
Genius