Profile image

atan2(y,x)

16.4k DarDragon  one year ago

Did you guys know this function existed?

Found this out while I was teaching chatGPT funky trees. I was copy-pasting some code from it to see if it works, and I was surprised that it did. I was also surprised to see that atan2() works in SP since there was no mention of it anywhere(but it is a common math function in other places, so I guess I was not that surprised).

Anyway, for those who want to know:

atan2(y,x)

Calculates the angle(in degrees) between the posititve x-axis and the point (x,y)

Some useful code stuff(The stuff I was teaching chatGPT):

TargetVelocityHeading

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

TargetVelocityElevation

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

Credits to ChatGPT for being an AI I guess and actually writing this(I had to correct it a bit because it reversed Longitude and Latitude and forgot Altitude in the last one)
...
We will all be replaced by AI soon

  • Log in to leave a comment
  • Profile image
    16.4k DarDragon

    @bjac0 yea sure

    3 months ago
  • Profile image
    56.8k bjac0

    would it be cool if I put the target velocity heading code in an updated version of Useful FT Codes forum?(mainly cause my code is super bulky comparison lol) I'll make sure to give you credit

    +1 3 months ago
  • Profile image
    56.8k bjac0

    damn wtf, it did a way better job than me at coding lol

    My "Target velocity heading"
    (rate(Longitude+(TargetDistance*sin(TargetHeading)))>0?atan(rate(Latitude+
    ((TargetDistance*cos(TargetElevation))*cos(TargetHeading)))/rate
    (Longitude+((TargetDistance*cos(TargetElevation))*sin(TargetHeading))))
    -90:atan(rate(Latitude+((TargetDistance*cos(TargetElevation))*cos(TargetHeading)))/rate
    (Longitude+((TargetDistance*cos(TargetElevation))*sin(TargetHeading))))+90)/-1

    AI "target velocity heading"
    atan2(rate(TargetDistance*cos(TargetElevation)*sin(TargetHeading)+ Longitude),
    rate(TargetDistance*cos(TargetElevation)*cos(TargetHeading)+Latitude))

    All hail our robot overlords

    +1 3 months ago
  • Profile image
    16.4k DarDragon

    @L0RR3B0RR3 Yes! That's the spirit! A.I.! Funky Trees! WOOO!(It's pretty cool)

    +1 one year ago
  • Profile image
    4,466 L0RR3B0RR3

    I don't undertad anyting but... YES!

    +2 one year ago
  • Profile image

    @DarDragon Ahh, alright
    I guess I'll try that out too to see if it can be successful or perhaps even fully independent.

    one year ago
  • Profile image
    16.4k DarDragon

    @IceCraftGaming I've just been teaching it some basics of the code. It can solve/make equations by mostly itself, you just have to define the rules and variables properly. I've posted some pics of what I've managed to teach it on the funky trees discord. Unfortunately I've stopped teaching it for a while because I've been a bit busy

    +1 one year ago
  • Profile image

    lmao same
    I, for about ~2 days in total have been trying to teach FT to ChatGPT with Sn0Flak0s' guide.
    Tests haven't gone well so far. What have you been doing exactly?

    one year ago
  • Profile image
    16.4k DarDragon

    @TheFlightGuySP Man, if they were, it would have made my life so much easier. Stupid drag equations

    one year ago
  • Profile image

    Interesting. I'd seen asin() acos() atan() listed in the Funky Trees guide but wasn't aware that an atan2() was present.

    Now I'm curious if sinh() cosh() tanh() are present as well.

    +3 one year ago