Profile image

FT turret stabilized code

15.0k SenSkysh  3.2 years ago

For cannons

Elevation

clamp((acos((cos(RollAngle) * (-sin(-PitchAngle)) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * sin(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/Velocity) * (TargetDistance + rate(TargetDistance)*TargetDistance/Velocity) * 9.81)/(Velocity * Velocity))/2))) * cos((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/Velocity))) + sin(RollAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * sin(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/Velocity) * (TargetDistance + rate(TargetDistance)*TargetDistance/Velocity) * 9.81)/(Velocity * Velocity))/2))) * sin((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/Velocity))) + cos(RollAngle) * cos(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * cos(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/Velocity) * (TargetDistance + rate(TargetDistance)*TargetDistance/Velocity) * 9.81)/(Velocity * Velocity))/2))))) / (TargetDistance + rate(TargetDistance) * TargetDistance/Velocity)) - 90),negativeAngle,positiveAngle)

Heading

clamp(deltaangle(turretAngle,
atan((sin(RollAngle) * sin(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * sin(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/Velocity) * (TargetDistance + rate(TargetDistance)*TargetDistance/Velocity) * 9.81)/(Velocity * Velocity))/2))) * cos((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/Velocity))) + cos(RollAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * sin(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/Velocity) * (TargetDistance + rate(TargetDistance)*TargetDistance/Velocity) * 9.81)/(Velocity * Velocity))/2))) * sin((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/Velocity))) + cos(-PitchAngle) * (-sin(RollAngle)) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * cos(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/Velocity) * (TargetDistance + rate(TargetDistance)*TargetDistance/Velocity) * 9.81)/(Velocity * Velocity))/2))))) / (cos(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * sin(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/Velocity) * (TargetDistance + rate(TargetDistance)*TargetDistance/Velocity) * 9.81)/(Velocity * Velocity))/2))) * cos((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/Velocity))) + sin(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * cos(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/Velocity) * (TargetDistance + rate(TargetDistance)*TargetDistance/Velocity) * 9.81)/(Velocity * Velocity))/2)))))) + (((cos(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * sin(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/Velocity) * (TargetDistance + rate(TargetDistance)*TargetDistance/Velocity) * 9.81)/(Velocity * Velocity))/2))) * cos((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/Velocity))) + sin(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * cos(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/Velocity) * (TargetDistance + rate(TargetDistance)*TargetDistance/Velocity) * 9.81)/(Velocity * Velocity))/2))))) < 0) ? (((sin(RollAngle) * sin(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * sin(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/Velocity) * (TargetDistance + rate(TargetDistance)*TargetDistance/Velocity) * 9.81)/(Velocity * Velocity))/2))) * cos((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/Velocity))) + cos(RollAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * sin(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/Velocity) * (TargetDistance + rate(TargetDistance)*TargetDistance/Velocity) * 9.81)/(Velocity * Velocity))/2))) * sin((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/Velocity))) + cos(-PitchAngle) * (-sin(RollAngle)) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * cos(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/Velocity) * (TargetDistance + rate(TargetDistance)*TargetDistance/Velocity) * 9.81)/(Velocity * Velocity))/2)))))>0) ? 180 : -180) : 0)),negativeAngle,positiveAngle)

For guns

Elevation

clamp((acos((cos(RollAngle) * (-sin(-PitchAngle)) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * sin((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity)) * cos((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/Velocity))) + sin(RollAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * sin((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity)) * sin((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/Velocity))) + cos(RollAngle) * cos(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * cos((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity)))) / (TargetDistance + rate(TargetDistance) * TargetDistance/Velocity)) - 90),negativeAngle, positiveAngle)

Heading

clamp(deltaangle(turretAngle,
atan((sin(RollAngle) * sin(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * sin((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity)) * cos((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/Velocity))) + cos(RollAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * sin((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity)) * sin((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/Velocity))) + cos(-PitchAngle) * (-sin(RollAngle)) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * cos((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity)))) / (cos(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * sin((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity)) * cos((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/Velocity))) + sin(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * cos((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity))))) + (((cos(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * sin((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity)) * cos((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/Velocity))) + sin(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * cos((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity)))) < 0) ? (((sin(RollAngle) * sin(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * sin((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity)) * cos((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/Velocity))) + cos(RollAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * sin((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity)) * sin((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/Velocity))) + cos(-PitchAngle) * (-sin(RollAngle)) * ((TargetDistance + rate(TargetDistance) * TargetDistance/Velocity) * cos((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/Velocity))))>0) ? 180 : -180) : 0)),negativeAngle, positiveAngle)

example of a car with two turrets

Source

Elevation

clamp((acos((cos(RollAngle) * (-sin(-PitchAngle)) * (R * sin(O) * cos(F)) + sin(RollAngle) * (R * sin(O) * sin(F)) + cos(RollAngle) * cos(-PitchAngle) * (R * cos(O))) / R) - 90),negativeAngle,positiveAngle)

Heading

clamp(deltaangle(turretAngle,
atan((sin(RollAngle) * sin(-PitchAngle) * (R * sin(O) * cos(F)) + cos(RollAngle) * (R * sin(O) * sin(F)) + cos(-PitchAngle) * (-sin(RollAngle)) * (R * cos(O))) / (cos(-PitchAngle) * (R * sin(O) * cos(F)) + sin(-PitchAngle) * (R * cos(O)))) + (((cos(-PitchAngle) * (R * sin(O) * cos(F)) + sin(-PitchAngle) * (R * cos(O))) < 0) ? (((sin(RollAngle) * sin(-PitchAngle) * (R * sin(O) * cos(F)) + cos(RollAngle) * (R * sin(O) * sin(F)) + cos(-PitchAngle) * (-sin(RollAngle)) * (R * cos(O)))>0) ? 180 : -180) : 0)),negativeAngle,positiveAngle)

How it works?

It's hard to explain ... In short, a spherical coordinate system is converted to a cartesian one, multiplied by the rotation matrix and returned back
Before transfer to FT, it looked something like this

  • Log in to leave a comment
  • Profile image
    15.0k SenSkysh
    Pinned 2.1 years ago
  • Profile image
    15.0k SenSkysh

    even two
    Table two, xlsx

    Pinned 2.6 years ago
  • Profile image
    15.0k SenSkysh

    Hmm. Should have done it before - autocomplete table

    Pinned 3.0 years ago
  • Profile image
    15.0k SenSkysh

    Oh... &lt; it's <
    Sorry

    Pinned 3.1 years ago
  • Profile image

    @ThomasRoderick

    Basically, what you guys are supposed to do with this is to make a copy of it yourselves and use it, since unlocking it for all to use exposes it to vandals and users with a lot of skill issue, myself included. Yep, that's a good solution

    22 days ago
  • Profile image

    @RichardScepton @SenSkysh

    Here is my personal backup of table 1.

    To make sure the table would not get damaged again through either accident or vandalism, the sheet is protected this time.

    23 days ago
  • Profile image

    To anyone who wants to use this table:
    Unfortunately, for some unknown reason, most likely the spreadsheet itself being mangled by inexperienced users who didn't know what they were doing, the table itself was rendered offline, most likely for a long time in the future. Same applies for table 2, apparently, as it was set to read-only. However, I have found an archived copy of the second table on my PC last night as I was clearing it out, and so, I will put it below. It's all in Russian, AFAIK, but it should still suffice to fit your needs. Remember to use it properly this time or else imma have to deal with a migraine fixing it
    !link to my archived table

    @natemomog
    @SiBangsatYa

    +2 7 months ago
  • Profile image
    14.9k SiBangsatYa

    @SenSkysh I cant access

    10 months ago
  • Profile image
    28.6k natemomog

    @SenSkysh yo, I can't access the original table.

    1.3 years ago
  • Profile image
    180 EasyEight

    Thanks bruddah! Now I just need to manage how should it work with naval designs with LOTS of shooting stuff.

    1.5 years ago
  • Profile image

    This should come in handy, Thanks!

    1.9 years ago
  • Profile image

    I tried it. Didn't work. But probably because I had both a cannon and a machine guns.

    2.3 years ago
  • Profile image
    15.0k SenSkysh

    @OtakuNekoToT If I knew, I would post the appropriate code right away

    2.4 years ago
  • Profile image
    9,502 416

    @SenSkysh So what should I do and how do I fix it?

    2.4 years ago
  • Profile image
    15.0k SenSkysh

    @OtakuNekoToT Maybe you're right

    2.4 years ago
  • Profile image
    9,502 416

    @SenSkysh I forgot to tell you that this code is used for the auto targeting m102 howitzer mounted on ac-130 and the target is an aircraft carrier or any ground target that does not have fast travelling speed. Only the elevation code have this problem, which seems to be due to the bullet drop.

    2.4 years ago
  • Profile image
    15.0k SenSkysh

    @OtakuNekoToT during the flight of the projectile, the enemy has time to change the trajectory or speed. it cannot be fixed. Is it possible to increase the speed of the projectile

    2.4 years ago
  • Profile image
    9,502 416

    @SenSkysh The elevation code for cannon works well on the ground but there's a problem. The higher altitudes and greater distance, the greater distance between hit point and target. How do I fix it?

    2.4 years ago
  • Profile image
    15.0k SenSkysh

    @Dysonchipss em?

    2.5 years ago
  • Profile image

    @SenSkysh how do we fix it then?

    2.5 years ago
  • Profile image
    15.0k SenSkysh

    @mitsuki the problem is probably in the settings of the rotator, it should rotate 1 ° for every 1 in input

    2.5 years ago
  • Profile image
    1,173 mitsuki

    I seem to have the same problem as DysonChipss, as the turret leads too much. For example: If I target a plane on my 12 o clock my turret rotates 180 degrees away from it

    2.5 years ago
  • Profile image
    15.0k SenSkysh

    @mitsuki yes, approximately

    2.5 years ago
  • Profile image
    1,173 mitsuki

    is turret x,y,z the coords of the rotator connected to the craft?

    2.5 years ago
  • Profile image
    15.0k SenSkysh

    @Dysonchipss come on show me the craft on which you check the code

    2.5 years ago
  • Log in to see more comments