Profile image

Elliptical Motion

Dev WNP78  7.6 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
    50.2k Graingy

    @BRNavyPilot no idea

    +1 22 days ago
  • Profile image

    @Graingy I just said it... BTW HOW MANY HOURS OF UR LIFE DO U SPEND IN THIS WEBSITE??? U just keep replyin... (btw imma go study now byeeeeeee)

    22 days ago
  • Profile image
    50.2k Graingy

    @BRNavyPilot Crikey that’s an old meme

    22 days ago
  • Profile image

    @Graingy YESSSSSSSS IT WORKED

    22 days ago
  • Profile image

    @Graingy k lemme retry that... laughs in ethics that keep me from being sworn about

    22 days ago
  • Profile image
    50.2k Graingy

    @BRNavyPilot First ask yourself how you accessed this forum.

    23 days ago
  • Profile image

    @Graingy what markdown

    23 days ago
  • Profile image
    50.2k Graingy

    @BRNavyPilot check the markdown tutorial.

    23 days ago
  • Profile image

    @Graingy teech miiiiiiiiiiiiiiii

    23 days ago
  • Profile image
    50.2k Graingy

    @BRNavyPilot Learn to hyperlink.

    28 days ago
  • Profile image

    @Graingy laughs in ethics that keep me from being sworn about https://ibb.co/MxR4nPMn

    28 days ago
  • Profile image
    50.2k Graingy

    @BRNavyPilot … alright listen here you little-

    28 days ago
  • Profile image

    @Graingy YOU MEANT FUNKY?

    29 days ago
  • Profile image
    50.2k Graingy

    I like your funny words magic man

    one month ago
  • Profile image
    302 Noobtato

    My brain just exploded rn

    1.2 years ago
  • Profile image
    18.3k Thomasj041

    @CalebRepublic Yes.

    4.2 years ago
  • Profile image

    @Thomasj041 yes

    4.2 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)
    4.5 years ago
  • Profile image
    360 Damirruki

    @Thomasj041 yes.

    4.6 years ago
  • Profile image
    18.0k AtlasSP

    Don't understand lol 😂😂

    4.7 years ago
  • Profile image
    3,594 RPC3503

    wha

    4.7 years ago
  • Profile image

    @Thomasj041 Yes

    5.3 years ago
  • Profile image
    18.3k Thomasj041

    Is the input in seconds for weapon firing delay?

    +1 5.8 years ago
  • Profile image
    Dev WNP78

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

    6.2 years ago
  • Profile image

    How did you do the smoke trail?

    6.2 years ago
  • Log in to see more comments