Profile image

Elliptical Motion

Dev WNP78  6.8 years ago

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

  • Log in to leave a comment
  • Profile image
    280 ItzNooby

    My brain just exploded rn

    4 months ago
  • Profile image
    18.3k Thomasj041

    @CalebRepublic Yes.

    3.4 years ago
  • Profile image

    @Thomasj041 yes

    3.4 years ago
  • Profile image
    2,662 EarthwormJim

    I haven't posted here in a long long long time but there are some things OP can reconsider before teaching formulas:

    1. If we're measuring tilt position, then we can use degrees. Since we're measuring distance travelled (walking is mainly based of finding optimal leg path per energy consumed, ie distance travelled per leg for a given W per sec or calories/joules) we should use radians
    2. The other simpler way to properly calc elliptical motion is to use the rule of thumb - if we have π or float numbers from mult/div operations then we have to use radians (at least for more precision). If numbers are mainly integers, then use degrees
    3. Motion losses induced by slipping, twisting or for example lack of symmetry makes results very unstable. Models should have very high precision in their design/construction to be deterministic in their movement. A week ago checked again and sadly can say that this SP engine still lacks stability in that area (even a perfect symmetrical designs tend to go at left or right). That's why elliptical motion makes models to go in one specific direction
    4. Don't use ^ as power of number (pow) because some ppl don't know that it's bitwise exclusive OR. Better use (a * a) or something like pow(base, exponent)
    3.6 years ago
  • Profile image
    360 Damirruki

    @Thomasj041 yes.

    3.8 years ago
  • Profile image
    18.0k AtlasSP

    Don't understand lol 😂😂

    3.8 years ago
  • Profile image
    3,579 RPC3503

    wha

    3.9 years ago
  • Profile image

    @Thomasj041 Yes

    4.5 years ago
  • Profile image
    18.3k Thomasj041

    Is the input in seconds for weapon firing delay?

    +1 5.0 years ago
  • Profile image
    Dev WNP78

    @plane918273645 this. Whether it still works, I don't know.

    5.4 years ago
  • Profile image

    How did you do the smoke trail?

    5.4 years ago
  • Profile image
    11.6k Pjork
    6.8 years ago
  • Profile image

    This is nice!

    6.8 years ago
  • Profile image
    31.3k Mostly

    Never thought of something like this, Very impressive.

    6.8 years ago
  • Profile image
    106k MisterT

    Very useful info, thanks for your research !

    +4 6.8 years ago
  • Profile image
    39.1k Weaverfish

    Gonna be using this a ton, thanks dude

    6.8 years ago
  • Profile image
    52.9k YL

    23333,好喜感啊

    6.8 years ago
  • Profile image
    51.5k JoshuaW

    Impressive research, physician exploring the nature of the world created by Jundroo.

    6.8 years ago
  • Profile image
    8,340 MrDoolittle

    eeks deeks this is pretty sexy my guy

    6.8 years ago
  • Profile image

    I just keep staring at the gifs...I'm mesmerized at how beautiful it is.

    Edit - Posted to twitter

    +5 6.8 years ago
  • Profile image
    2,940 Cream

    We should call 0.471238898038 the WNP-Cream Constant. Or the Cream-WNP Constant.

    +4 6.8 years ago
  • Profile image

    aaaaaaaaaaaaaaaaaaaaaaaaaa

    +1 6.8 years ago
  • Profile image

    opens brain.exe
    kabum

    6.8 years ago
  • Profile image
    10.5k Xenotriver

    I'll be back in a second, just let me find my brain.
    I hope it didn't evaporate

    +8 6.8 years ago
  • Profile image

    Genius

    +1 6.8 years ago
  • Log in to see more comments