A ballistics simulation tool for the Create: Big Cannons addon.
Features:
- Trajectory visualisation
- Firing solution calculator (with target lead)
- Reverse-locating a cannon's position
Check it out at: https://tornc.github.io/mc_ballistics/.
- Click on the link.
- Use the sidebar to set simulation parameters.
- The 'Calculator' section can fire at coordinates or a moving target.
- The 'Reverse calculator' has settings that affect the calculator's performance.
- The main view ('Plot' tab) displays an interactive 3D plot, in which you can move around with the camera.
- The 'Results' tab shows information required for firing solutions.
Cannon stats and manual firing option (left) and interactive plot (right).
Enemy cannon muzzle locator (left) and firing solution information (right).
Tip
- Inputting drag and gravity values will guarantee 100% success rate, and allows you to only need 2 observations.
- Set the minimum, maximum velocity bounds and velocity multiple. It will reduce computation cost by a bunch.
With the radar having a 20% drop rate, but I rerolled the observations if there were less than 3. As you can see, providing drag and gravity values is important. You can compensate for that with a low interval, but it's still not 100% guaranteed. (<0.025% fail chance). Low trajectories are harder because there's less information to be gotten, especially if your samples are at the top of the trajectory.
Through the drag coefficient (Cd) and gravity (G), we know the shape of the trajectory (arc). Then, all we need to know is how far along the arc the muzzle is located. We accomplish this by simulating the projectile in reverse step by step (bruteforce), starting from our first observation. To know when to stop, we simulate an arc of the same shape forwards at every step and see if this arc lines up exactly with our observations.
Visualisation on how it works, drawn by yours truly. Sorry, I'm not an artist 💀.
Note
We don't forward simulate the entire arc, only parts that correspond to an observation - and only if the velocity is plausible.
Plotly figures are pretty and WebApps are cool.
I guess I got sidetracked 😅.
Anyways, the initial goal was to make a proof of concept that demonstrated the possibility of automated counter-battery systems. This is done through a Some Peripherals' Radar or anything equivalent. The key requirement is that the peripheral has to detect entities and record their positions.
- Download the repository.
git clone https://github.com/Tornc/mc_ballistics.git- Install the requirements.
pip install -r requirements.txt- Run the app.
streamlit run app.pyOr run script.cmd (it does the exact same thing as streamlit run app.py).
- The app will open in your browser.
@sashafiesta: Formulas for trajectory simulation. See the pinned message in the showcase channel of the CBC discord.
@malexy: Major inspiration was taken from brute-force pitch calculator while I was still figuring things out.
@endal: The pitch calculator is based entirely on their Desmos calculator. It's very fast and laser-accurate.
If you're interested in CBC ballistics, I highly recommend taking a look at their works.
- Link the specific Discord message from @sashafiesta.
- Make target lead function not inefficient as fuck + fix high trajectory bug where it doesn't find a solution sometimes.
- Commenting in simulation.py for estimating cd and g.
- Create a proper binary without: 1) Pyodide / package load times. 2) fugly Electron bar.



