TheOpenSpaceProgram / osp-magnum

A spaceship game
https://www.openspaceprogram.org/
MIT License
216 stars 32 forks source link

Implement rotations for CoordTransformer #203

Closed Capital-Asterisk closed 2 years ago

Capital-Asterisk commented 2 years ago

Planets rotate, the Active Area rotates, and transforming coordinates between them will lead to a rapid decline in sanity when taking the wrong approach. Luckily, there is now CoordTransformer.

CoordTransformer is useful for almost every operation involving coordinate spaces. eg:

The implementation is quite algebra-heavy, and may take a while to fully understand. I find it quite mathematically elegant how some parts 'just work' or cancel out. I put heavy considerations in respecting integer range and floating point precision.

I did not intend to put this on the main repo, but oh well.