Profile image

Useful FT Codes 2.0

57.2k bjac0  11 months ago

Redux of an older post

Target Data

Target Altitude [Meters]

Altitude+(TargetDistance*sin(TargetElevation))

.
Target Longitude [Meters]

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

.
Target Latitude [Meters]

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

.
Target Speed [Meter/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

3D Tachometer [Meters]

sum(GS)

Provides a scalar quantity for the distance your craft has travelled in 3D space.

.
Horizontal Component of Forward/Aft Velocity Vector [Meter/s]

(rate(Latitude)*cos(Heading)+rate(Longitude)*sin(Heading))

Gives the horizontal component of your craft's velocity but strictly in the forward/aft direction as a vector constraint.
Thanks to @KSB24 for this code!

.
Velocity-Based Heading [Degrees]

atan2(rate(Longitude),rate(Latitude))

Gives a heading output based off of your plane's trajectory rather than the direction its actually facing. Operates like AngleOfSlip if it were a global function.
Thanks to @KSB24 for this code!

.
Non-Quaternion Heading Output [Degrees]

Heading+(Heading<0?360:0)

Translates the typical output of the Heading variable from a quaternion output [-180,180] to a more understandable [0,360] degree range.

.
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 less than 90°.
True = Forwards (1)
False = Backwards (-1)

.
Angle Of Descent [Degrees]

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

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

.
Turn Radius [Meters]

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
    57.2k bjac0

    @KSB24 I have now added your comments to the forum post

    +1 19 hours ago
  • Profile image
    122k KSB24

    @bjac0 i definitely will love it if it happened

    +1 yesterday
  • Profile image
    57.2k bjac0

    @verxzl likely not too many (leaving this vague in case someone has a good idea for a code), this post mostly follows code for things that should have a related funky-trees shorthand function (ie: GForce, AngleOfAttack, etc).

    yesterday
  • Profile image
    57.2k bjac0

    @KSB24 yo could I add your codes to the forum post?

    +1 yesterday
  • Profile image
    1,197 verxzl

    I have a question, is there any waiting functions?

    yesterday
  • Profile image

    I'm sure someone already did that, but for the simplicity of things i'll post it anyway. Here's an Estimated AoA using Speed vectors and pitch: (PitchAngle - atan(rate(Altitude) / sqrt(pow(Speed_ms, 2) - pow(rate(Altitude), 2))))*-1

    18 days ago
  • Profile image

    @KSB24 and you make repeat(..., 360) for normalization, right?

    Also, could you help me with something?
    I wanna make Waypoint system where my plane does pylon turns around a selected target at specific Altitude. It's for my upcoming modification on AC-130...

    one month ago
  • Profile image
    122k KSB24

    i was need a code working like "direction where my self going to", so i just "remixed" the "target velocity heading" code to do the thing what i need.
    atan2(rate(Longitude),rate(Latitude))

    one month ago
  • Profile image
    122k KSB24

    not sure is similar thing already exist but
    i made a code that tells your forward and backward speed.
    (rate(Latitude)*cos(Heading)+rate(Longitude)*sin(Heading))
    just imagine it is just same asGS but while the original GS is just keep telling you the same speed no matter the direction you going to, this code will output the minus speed when you moving backward, plus when forward.
    for better understanding:
    50 km/h forward " ↑ " = 50 km/h
    50 km/h slide " ↔ " = 0 km/h
    50 km/h backward " ↓ " = -50 km/h
    usage is just same as normal GS. multiplying by 3.6 is a kilometer.
    i named this as "ForwardSpeed" in my own XD

    one month ago
  • Profile image
    138k BaconEggs

    -clamp(clamp(sqrt(pow(rate(Latitude),2)+pow(rate(Longitude),2)),0.05,999999)/clamp(rate(Altitude),-999999,-0.05),-999,0) glide ratio

    +2 7 months ago
  • Profile image

    Can anyone tell me, if TAS, IAS, GS, GEFORCE, AngleOfAttack are global functions? Like. I have a carrier which is host to the primary cockpit. But I also have flight computers on each plane and helicopter on it. Now what I want to know is if the before mentioned Funktions can each be used on whatever I build as long as it has wings and a cockpit/flight computer.

    7 months ago
  • Profile image

    @bjac0 ok

    11 months ago
  • Profile image
    57.2k 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

    11 months ago
  • Profile image

    @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?

    11 months ago
  • Profile image
    29.3k YarisSedan

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

    11 months ago
  • Profile image
    30.8k 32

    @bjac0 epic

    11 months ago
  • Profile image
    57.2k bjac0

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

    11 months ago
  • Profile image
    122k KSB24

    This is totally useful, and interesting codes for me.

    11 months ago
  • Profile image
    57.2k bjac0

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

    +1 11 months ago
  • Profile image
    30.8k 32

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

    +1 11 months ago
  • Profile image
    27.2k ToeTips

    If only there was a way to bookmark forum posts

    +1 11 months ago
  • Profile image
    0 LL54

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

    +1 11 months ago
  • Profile image
    138k BaconEggs

    the underground vehicle of the blood god!

    +1 11 months ago