4 ms·
Show HN: A real-time ballistic solver for moving targets under drag (C++)
Hi HN,
I’m sharing a small open-source project I’ve been working on: a native C++ ballistic solver that computes launch angles to intercept moving targets in real time, under gravity and air drag.
Instead of relying on vacuum assumptions, closed-form equations, or lookup tables, the solver formulates the intercept as a nonlinear problem and solves it numerically using time integration and iterative methods.
The motivation came from game and simulation scenarios where simpler approaches tend to break down:
- moving targets
- strongly curved trajectories due to drag
- real-time constraints
The solver simulates projectile motion (RK-style integration), tracks the closest approach to the target, and iteratively adjusts the launch direction until an intercept is achieved.
It’s written in C++ and exposed through a stable C ABI, so it can be used from environments like Python or game engines (e.g. Unity) without rewriting the core logic.
Project page: https://github.com/ujinf74/ballistic-solver https://github.com/ujinf74/ballistic-solver
I’d be very interested in feedback, criticism, or discussion around the numerical approach, performance trade-offs, or edge cases I might have missed.
- carlosjobim 10mo agoCongratulations on your project! I've vouched for your post, since somebody had marked it as [dead].
- ujinf74 10mo agoThanks a lot, I really appreciate it!