Skip to content

Attempt to fix/improve fixed angle Parabola trajectory#2214

Open
Starkku wants to merge 1 commit into
Phobos-developers:developfrom
Starkku:fix/parabola
Open

Attempt to fix/improve fixed angle Parabola trajectory#2214
Starkku wants to merge 1 commit into
Phobos-developers:developfrom
Starkku:fix/parabola

Conversation

@Starkku
Copy link
Copy Markdown
Contributor

@Starkku Starkku commented May 17, 2026

This change specifically concerns Trajectory=Parabola combined with Trajectory.Parabola.OpenFireMode=Angle.

Examples of faulty/corrected trajectory behaviour courtesy of Gen.Ari:
Before PR changes
After PR changes

The previous implementation for finding velocity for a fixed-angle trajectory involved using Newton's method to iteratively find approximations for roots. It is useful for approximating solutions to complex equations which might be impossible to solve algebraically. However, we're talking about parabolic arc with almost no external constraints or additional factors like air resistance here, just standard inputs for kinematic equations like horizontal and vertical distance, angle and gravity. Pretty much all sane inputs have valid algebraic solutions.

Or at least should have, to my understanding.

So apparently what the old method is essentially doing is using more unstable approximation method to guess solutions that converge in same results as an algebraic formula would give, which is evidenced by the fact that comparing the two methods yields identical results in cases where Newton's method doesn't just flat-out fail. This PR just ditches it in favour of just directly calculating the solutions with a formula. It will still fail under certain nonsense conditions like vertical launch angles but will also output an error message in log in such cases rather than fail completely silently.

[Phobos] Failed to solve fixed angle Parabola trajectory velocity: BulletType: [MarauderGunProj] - Source: 17000,22865,279 - Target: 13440,23680,936 - Angle: 90.00 - Gravity: 6.00

Because:

And my knowledge is mostly constrained to algebra and basic calculus and ability to do research on the Internet, someone should probably double check that any of this shit is making sense. In addition to testing that it works as expected in-game.

No Documentation Needed is currently here per still current policy of not writing changes to changelog for changes within same version (Parabola trajectory was introduced after 0.4 and patches)

@Starkku Starkku added Bugfix This is a bugfix that does not need documentation beyond mention in changelog No Documentation Needed No documentation needed whatsoever labels May 17, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 17, 2026

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

@TaranDahl TaranDahl requested a review from CrimRecya May 17, 2026 15:00
Copy link
Copy Markdown
Contributor

@CrimRecya CrimRecya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The analytical formula seems correct: v = √((g*x²) / (2·cos²θ·(x·tanθ - z))).
And I would be extremely grateful if you rewrite the comments of ParabolaTrajectory::SearchFixedHeightMeetTime and ParabolaTrajectory::SearchFixedAngleMeetTime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugfix This is a bugfix that does not need documentation beyond mention in changelog No Documentation Needed No documentation needed whatsoever

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants