Profile image

Useful FT Codes 2.0

56.8k bjac0  2 months ago

Redux of an older post

Target Data

Target Altitude [m]

Altitude+(TargetDistance*sin(TargetElevation))

.
Target Longitude [m]

Longitude+((TargetDistance*cos(TargetElevation))*sin(TargetHeading))

.
Target Latitude [m]

Latitude+((TargetDistance*cos(TargetElevation))*cos(TargetHeading))

.
Target Speed [m/s] (Written by ChatGPT 3.5)

sqrt(pow(rate(TargetDistance*cos(TargetElevation)*sin(TargetHeading)+Longitude),2)+pow(rate(TargetDistance*cos(TargetElevation)*cos(TargetHeading)+Latitude),2))

Generates a velocity output in meters per second of a target by calculating it's longitude, latitude and altitude and using the rate of those to calculate for a hypotenuse between all 3.

.
Target Velocity Heading [degrees]

atan2(rate(TargetDistance*cos(TargetElevation)*sin(TargetHeading)+Longitude),rate(TargetDistance*cos(TargetElevation)*cos(TargetHeading)+Latitude))

Provides an approximation for the heading of a target by calculating the heading of it's vector.
Thanks to @DarDragon for this code!


More Flight Data

Forward/Reverse Differentiation [Boolean]

abs(AngleOfAttack)<90

This nifty bit of code gives a Boolean output depending on whether your craft is moving forward or not by determining if the angle of attack is greater than 90°. True = Forward. False = Backward.

.
Glide Angle [degrees]

atan2(rate(Altitude),sqrt(pow(rate(Longitude),2)+pow(rate(Latitude),2)))

Provides an angle relative to the horizon based on the hypotenuse of your plane's current horizontal and vertical velocity.

.
Turn Radius [m]

abs(pow(GS,2)/((GForce-1)*9.81))

Provides a radius to an imaginary circle formed when your plane is changing, heading, pitch angle, or anything between.

.
Mach number [Mach]

TAS/(340-clamp((Altitude*0.003937),0,43))

Generates an accurate mach reading that adjusts based on altitude.
Credit to @edensk for this code!


Ammo

Absolute ammo depletion [Boolean]

clamp01(sum((BOOLEAN?clamp01(ammo("WEAPON NAME")=0):0)))

This code gives a permanent output of 1 when a certain ammo type is depleted. Ignores inaccurate depletion reading caused by deactivation of a given weapon's Boolean operator(s).
Ex weapon is activated by action group 1, the code would look like

clamp01(sum((Activate1?clamp01(ammo("WEAPON NAME")=0):0)))

Thanks to @DarDragon for helping tremendously with writing this code!


*Side note. Formatting is a little janky cause for whatever reason some characters don't play nice with markdown. Ie quotation marks and less than signs look like this &quot; &lt;

Comment below ideas for generally useful functions and I'll add them to this forum post.
(Disclaimer I'm not gonna code super specific stuff like engine PID controllers, gear shifting, etc. but stuff that can be reused on many different planes such as target info and flight info I will definitely do)

Lmk if you want to be tagged whenever the forum updates

  • Log in to leave a comment
  • Profile image
    15.4k L3FT2R1GHT

    @bjac0 ok

    2 months ago
  • Profile image
    56.8k bjac0

    @L3FT2R1GHT yeah I'll add them back, wasn't sure if anyone was using them tbh. And unfortunately no, the codes aren't averages, they're rather just instantaneous approximations. I might make some updated versions in the future

    2 months ago
  • Profile image
    15.4k L3FT2R1GHT

    @bjac0 could you add the rest of the codes from the original post (e.g. fuel consumption), so that it can be rendered obsolete (although keep the original)
    Also, would L/100km be
    (smooth(rate(-Fuel*FUEL CAPACITY IN LITRES),0.05))/(GS/1000)*100 ?
    and are they average readings?

    2 months ago
  • Profile image

    My stupid brain could not comprehend this, like... at all.

    2 months ago
  • Profile image
    27.9k 32

    @bjac0 epic

    2 months ago
  • Profile image
    56.8k bjac0

    @32
    Mach reading added
    Forward/Reverse Differentiation code improved
    Improved post formatting

    2 months ago
  • Profile image
    75.2k KSB24

    This is totally useful, and interesting codes for me.

    2 months ago
  • Profile image
    56.8k bjac0

    @dardragon forgot to mention when I uploaded the post, my bad

    +1 2 months ago
  • Profile image
    27.9k 32

    Tag me if you change anything, this is massively useful.

    +1 2 months ago
  • Profile image
    24.3k ToeTips

    If only there was a way to bookmark forum posts

    +1 2 months ago
  • Profile image
    0 LL54

    You're back I can't wait to see your latest build

    +1 2 months ago
  • Profile image
    125k BaconEggs

    the underground vehicle of the blood god!

    +1 2 months ago