Profile image

List of Useful Formulas and Terms

10.1k PilotOfFuture  3.4 years ago

Welcome to my useful fromulas post. If you haven't already, check out the build i uploaded to explain everything more intuitively. There's some stuff there i'm not gonna get into here because it aint all that interesting maths-wise.

FunkyTreesStuffz
HomungCompass (comming)

My first useful formula is
clamp(Activate1,0,1)
It seems a bit silly to even put here, but it's pretty cool. This term turns 0 when Ag1 is deactivated and 1 if it's activated. If you multiply an input, say VTOL, you can activate and deactivate it. The true usefulness comes to the surface when you use multiple inputs tho
Example:
(clamp(Activate1,0,1) * VTOL) + (clamp(-Activate1,0,1) * Throttle)
Activating or deactivating Ag1 makes the input switch between VTOL and Throttle. You could also for example excange Throttle for a PID function

Next is a counter function:
sum(abs(rate(Activate1)))/2
The value of this function increases by 1 every time you hit Ag1. You can use it to stage multiple detachers, parachutes, engines etc. using just one boolean input. to get a proper high or low, you just have to compare it to a number, like this:
(sum(abs(rate(Activate1)))/2)>=1

another thing i love are non-linear functions. They increase the acuracy and stability of any vehicle, without limiting the agility
sign(Pitch)*pow(abs(Pitch),2)
This function behaves just like Pitch, 0 is 0 and 1 is 1. However, anything in between is non linear. A 0.5 input outputs a 0.25, Thus making you plane pitch slower the smaller your input is. You can change the "2" for any positive number you like, but 1.5 - 2 work best. Numbers below 1 would invert the non linear effect

Do you miss working with piston engines? i don't.
sum(Throttle*2)
can be used as an input to a rotator to make it spin continuously without having the problem of it going reverse when you power down- Thank me later

have you been bugged out that there's no easy way to make choppers super stable? Well adding a PID to the main rotor to stabilize altitude ain't that hard, but x and y movement are a bit more complicated
i present:
cos(Heading)*rate(Latitude)+sin(Heading)*rate(Longitude)
and
cos(Heading)*rate(Longitude)-sin(Heading)*rate(Latitude)
the first formula outputs the speed at which you're moving forewards in metres per second. A number below 0 means that you're moving backwards
the 2nd formula indicated movement to the right, again in metres per second. A number below 0 shows that you're moving to the left

If you're ever lost, just use this handy formula an put it into a rotator:
((atan( (sum(rate(Latitude)*clamp((Time>1),0,1))) / (sum(rate(-Longitude)*clamp((Time>1),0,1))) )+sign( (sum(rate(-Longitude)*clamp((Time>1),0,1))) )*90)-Heading)/90
it shows you the way back to the location where you started (in 2d space), just like a compass in minecraft. You have to set the rotation angle to 90 degrees
this one was quite alot harder to create than i woulda thought, because of the nature of tan functions

last and perhaps least, a timing function
smooth(Activate1,0.5)=1
this delightful function activates 2 seconds after the input turns high. For higher delays, change the 0.5 for a lower number above 0

  • Log in to leave a comment
  • Profile image

    @drift hunters In 2003, the Poincaré Conjecture was proven by Russian mathematician Grigori Perelman.

    1.1 years ago
  • Profile image
    0 mira34

    There are a lot of terms that confuse me, I still can't fully understand dinosaur game them

    1.1 years ago
  • Profile image

    Thank you for sharing your useful formulas post! It seems like you've come up with some interesting and clever mathematical expressions to achieve various functionalities in different scenarios.
    Bitlife

    1.4 years ago
  • Profile image
    9,409 Tookan

    @PilotOfFuture
    Ok then

    3.4 years ago
  • Profile image

    @Tookan you know what? I'm not even gonna pretend i'm any better in my native language

    3.4 years ago
  • Profile image
    9,409 Tookan

    @PilotOfFuture
    Ah, I see

    3.4 years ago
  • Profile image

    @Tookan english ain't my first language, please foregive me (:

    3.4 years ago
  • Profile image
    9,409 Tookan

    What's "Usefull"?

    3.4 years ago
  • Profile image
    162k spefyjerbf

    No problem! I’m happy to share code :)

    +2 3.4 years ago
  • Profile image

    @spefyjerbf good formula! This will probably make it into one of my builds. I didn't expect there was something for me to learn through making this post :D

    +1 3.4 years ago
  • Profile image
    162k spefyjerbf

    Nice list! The delay function will unfortunately not work as intended if used multiple times in a short timespan. To fix this issue, you can modify the code as shown:
    smooth(Activate1, Activate1 ? 0.5 : pow(10,10)) = 1
    This code removes the smooth function’s linear behavior as it recedes to the value 0. Removing such behavior is best practice for delays that only occur when the activation group is on — the delay now works in only one direction.

    +3 3.4 years ago
  • Profile image
    16.5k edensk

    first one can be simplified to clamp01(Activate1)

    +3 3.4 years ago
  • Profile image

    @MrGreen thanks ^^

    3.4 years ago
  • Profile image
    16.7k MrGreen

    Good job mate

    +2 3.4 years ago