Skip to content

Conversation

@hexawyz
Copy link
Contributor

@hexawyz hexawyz commented Jan 6, 2026

📝 Description of the Change

This removes the reliance on trigonometric functions to draw a directional arrow. Trigonometric functions would generally be more expensive than other operations and introduce tiny inaccuracies in results where otherwise avoidable.
Instead, we can use pure vector math to achieve the same result in a more straightforward way.
The only expensive operation remaining after this change is the Normalize operation, which should still be cheaper than the Atan2, Cos and Sin combo used before.
The change should give a few extra FPS in case there are many animated arrows on sceen, but I have not measured this with ultra high precision.
The new code here would also benefit from optimizations if WPF's Vector is improved to support AVX. (Which does not seem to be the case at the moment)

This is the small change I mentioned here: #249

🐛 Possible Drawbacks

  • I assume that the length is non-zero, which will hopefully always be the case. More sensible checks can be added in the calling code if this is ever a problem.
  • I have not checked if the new code is drawing the arrow in the same order as before (CW or CCW), but I don't think it matters a lot.

@hexawyz hexawyz force-pushed the directional-arrow-remove-trig branch from 1380e49 to 5bd263f Compare January 6, 2026 12:54
@miroiu miroiu merged commit 19efd9f into miroiu:master Jan 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants