Giter VIP home page Giter VIP logo

dreamfarer / arma-3-artillery-calculator-ares Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 0.0 177.57 MB

The advanced artillery computer for Bohemia Interactive's Arma III. Supports both classic artillery systems like the 2S9 Sochor and M4 Scorcher, but also redneck artillery with the MAAWS rocket launcher.

Home Page: https://arma.openlink.bot/ares

HTML 4.65% Python 4.45% Ruby 1.31% CSS 3.33% JavaScript 85.23% SQF 1.03%
arma3 artillery artillery-calculator scorcher sochor koth

arma-3-artillery-calculator-ares's Introduction

About ARES

ARES is a web service to calculate the elevation, heading, and fire mode needed to precisely hit desired targets in Bohemia Interactive's Arma 3. When loading the web app, you get to choose between the classic artillery computer for the 2S9 Sochor and M4 Scorcher, or, you are finally able to opt for the redneck artillery version designed for the MAAWS Mk4 Mod 0Be the real King of the Hill!

Get ARES

It is as simple as cloning this repository and double-clicking the .html file. However, there is yet a more convenient way: Head straight to the live version of this artillery calculator found HERE - Free of charge and no nasty trackers nor advertisements!

Controls

When first loading up the web app, you are prompted to choose between the calculator for the 2S9 Sochor and M4 Scorcher or the redneck artillery version for the MAAWS Mk4 Mod 0.
First off, perform a right-click to add your artillery unit to the map. By right-clicking anywhere on the map again, a target for your artillery unit is created. Artillery units and targets can be distinguished by color or text inside the respective popup. Simply right-click on a marker to delete it. (Note: Left-click is equivalent to one press on mobile / Right-click is equivalent to long-press on mobile)
Hold the left mouse button to drag the before placed markers around.

What Extra Features Does ARES Have to Offer?

ARES has more to offer than what you notice at a first glance.

Altitude API
I have created an API to get the height data of a given coordinate on Altis. It's effortless to use: Transmit a 'x' and 'y' coordinate to the API, and it will return the altitude above sea level in JSON format at this specified point.
Let's go for an example: If you would like to know the altitude at 10'000, 10'000 on Altis, make a call to the API like this: https://api.openlink.bot/ares.php?x=10000&y=10000

Download Map Data
Unfortunately, the map tiles exceed the GitHub upload limit. You can get them HERE. Unzip map.zip and drag-and-drop the map folder into the root project folder

The Magic Behind It

The following documentation is split in two sections. The first section deals with the flight path of artillery shells shot by self-propelled artillery like the 2S9 Sochor and M4 Scorcher. Fortunately, in Arma 3, artillery shells are the only projectiles not affected by external force such as wind or air friction.
In the much more difficult second section, we will go over the projectile motion of the MAAWS Mk4 Mod 0 rocket, which, in contrast to artillery shells, is affected by air resistance, making the calculations much more exhausting.

Self-Propelled Artillery
Will be added on a later date. I know you want the juicy MAAWS rocket science. 🤣

MAAWS Mk4 Mod 0 (Redneck Artillery)
The Arma 3 wiki states that the only properties that influence trajectory are initSpeed (CfgMagazines), airFriction (CfgAmmo) and coefGravity (CfgAmmo). Such projectiles travel based on their muzzle velocity (initSpeed) and aerodynamic drag (airFriction), along with gravity-induced vertical drop.

Fortunately, there is another post on the Arma 3 wiki giving us an insight into the formula used to calculate projectile motion with air resistance. However, it is badly written and formatted to the point of almost no recognition. After further inspection and some guesswork, I decoded the formula to be:

$a= v* \sqrt{v_x^2+v_y^2} * Friction$

While reading through the Projectile Motion on Wikipedia, I have found a somewhat matching formula. However, the variable names are different, and a differential equation is now being introduced because we want to compute the current state instead of the rate of change.

$v = \frac{d}{dt} x$(velocity is the first derivative of displacement)
$a = \frac{d}{dt} v$(acceleration is the first derivative of velocity)
$\mu = - Friction$

Armed with this knowledge, we rearrange the above equation and split it into $x$ and $y$ components.

$\frac{d}{dt} x = v_x$
$\frac{d}{dt} y = v_y$
$\frac{d}{dt} v_x = - \mu * v_x * \sqrt{v_x^2 + v_y^2}$
$\frac{d}{dt} v_y = - g - \mu * v_y * \sqrt{v_x^2 + v_y^2}$

To actually get the current state instead of the rate of change, we need to solve the ordinary differential equations depicted by $\frac{d}{dt}$. But how?
The Wikipedia article further states that the equations of motion can not be easily solved analytically. Through the sheer amount of research I had done, I came across a YouTube video using the Euler method to approximate the projectile path.

Now, I have never been a good student in mathematics, so the explanation might be a bit lacking. What we do with the Euler method is essentially approximating the analytical solution by computing the same equation over and over again while taking the before calculated result into account. The smaller the step size (in our case, time) $h$, the more accurate the approximation will be. The only thing stopping you from reaching infinite precision is the infite computing time needed. You absolutely need to find a balance between the two.

Enough talking, here are the above equations while using the Euler method. Notice that the equation did not change, except I have added the step size multiplication ( $h$ ) and the before state of each variable ( e.g. $x_{before}$ ) on the right side of the equation.

$x = v_{x} * h + x_{before}$
$y = v_{y} * h + y_{before}$
$v_{x}= (v_{x-before} * \sqrt{v_{x-before} ^ 2 + v_{y-before} ^ 2} * - \mu) * h + v_{x-before}$
$v_{y}= (v_{y-before} * \sqrt{v_{x-before} ^ 2 + v_{y-before} ^ 2} * - \mu - g) * h + v_{y-before}$

You would now loop over these equations, each time pushing the new variable (e.g. $v_{x}$ ) into the before variable (e.g. $v_{x-before}$ ) until a certain criteria is met. In our case, it is when the desired distance ( $x$ ) at a given height ( $y$ ) has been reached. Note that the elevation change can be done by shifting the height ( $y$ ) target up or down.

We next need to find a way to incorporate the shooting angle into the equation. As luck would have it, we forgot to define a before state of these variables: $x$, $y$, $v_{x}$ and $v_{y}$. How else would the Euler method be able to start when there is no before value?

Because each component is being calculated separately, we only need to split the rocket's absolute velocity into its x and y components once at the start of the calculation. The Euler method will take care of the rest. We will take 5° gun elevation as an example.

$\mu = 0.000132$(friction for MAAWS Mk4 Mod 0 found through testing)
$x = 0$   (starting at 0m displacement)
$y = 1.53$   (starting at 1.53m because the MAAWS is held at that height)
$v_{x} = 350 * \cos(5 * \frac{\pi}{180})$   (starting with 5° gun elevation $v_{init} = 350 \frac{m}{s}$)
$v_{y} = 350 * \sin(5 * \frac{\pi}{180})$   (starting with 5° gun elevation and $v_{init} = 350 \frac{m}{s}$)

You now might ask; how do we actually find the angle required to fire a MAAWS rocket, let's say, precisely 2000m. The painfully simple answer is: guessing and testing. What my application will do is calculate a specific gun elevation and adjust its error through eliminating the worse chosen angle. Let us walk you through an example:

In this case, the script starts at gun elevation 5° and 10° and will calculate where the rockets impacts. For this angle, it will calculate around 1827m (for 5°) and 3142m (for 10°). 1827m is 173m away from our goal, 2000 m, which translates to 5° being roughly 0.65° away from our unknown goal angle.

My program would then replace 10° with 5.65° and would try again. This time it results in 1827m (for 5°) and 2018m (for 5.65°). 2018m is still 18m away from our goal, 2000m, which now translates to 5.65° being roughly 0.06° away from our unknown goal angle.

My program would then replace 5° with 5.588° and would try again. This time it results in 1999m (for 5.58°) and 2018m (for 5.65°).

As you can see, we are arriving at our unknown goal angle pretty fast. The only thing you would need to specify further is when the precision is enough to stop the recursive execution of this code and print the found angle onto the map.

You can use my Excel file to play around with the now newly acquired knowledge. You can safely ignore Stokes Drag.

arma-3-artillery-calculator-ares's People

Contributors

dreamfarer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

arma-3-artillery-calculator-ares's Issues

Target Inside Minimal Firing Range

You are able to force a calculation error if you place the artillery system on top of a before placed target, failing to reach the minimum firing range.

RangeError: Maximum call stack size exceeded

If too large distances are chosen for the MAAWS Mk4 Mod 0, currently, the browser throws a RangeError: Maximum call stack size exceeded visible in the developer console.
This happens due to the numerical approximation (Euler method) not yielding a result in the fixed number of calculation steps.

MAAWS Implementation Request

Is there any way to get the maws calculator running? Or would you have to re-code the system? I really want to redneck artillery on Koth for shits and gigs. It would be fun. I already love it for the scorcher but the maws would be great.

⚠️ Website Will Be Under Maintenance for a Couple of Days ⚠️

I am transitioning from my web hosting subscription to a virtual server with root access because I require additional functionality for future projects, such as Websockets. However, as this is my first time undertaking such a task, I anticipate needing some time to familiarize myself with the process and set everything up correctly. I aim to have it up and running within a couple of days, or I at least hope so.

Support More Maps

Currently, only Altis is implemented. I am afraid this will stay this way because adding altitude data and creating high-resolution imagery of Arma 3 maps is a painful process.

Shells hitting off target

Hello ! I got this issue on Arma 3 solo
I place my artillery, then my target. I use the exact elevation the website gave me.
But then when I watch the target it lands usually between 100-200m off the target.
Strange thing is when I go to KOTH and I use the same value it works. Since KOTH display a different elevation than the arma 3 one.
Last time I tried. The website said 26.02 elevation and I had to be at 24.09 to hit my target.
I am doing something wrong here ? I still don't understand why the value is correct with the koth hud but not with the arma one.
Thanks !

⚠️ Reconfiguring of Web Server ⚠️

⚠️ ARES will be down for some time! ⚠️

I've recently given the orders to re-install and re-configure my web server. It will take one or two days to get it back into shape again.
I am sorry for the inconvinience.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.