Repository navigation
Add Mat44 camera and billboard transforms - #66
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds camera and billboard transforms to Mat44:
orient(position, forward, up)maps local coordinates into world space.look_at(eye, center, up)maps world coordinates into camera space and is the inverse of the corresponding orientation transform.make_billboard(position, camera_position, camera_up)creates a spherical billboard.make_billboard_axis(position, camera_position, axis)creates a cylindrical billboard whose local +Y stays aligned with the supplied axis.All four use right-handed row-vector transforms, with local -Z forward/front, +Y up, and +X right. The view matrix sends the eye to the origin and its target onto negative Z, following the OpenGL viewing convention. Direction inputs are normalized internally, with scaling to handle very large or small magnitudes. Zero directions, coincident positions, and parallel or nearly parallel directions raise
ArithmeticError; the angular degeneracy threshold is documented as a normalized cross-product length of1.0e-12, consistent with the existing orthonormalization tolerance.Float typespecs and explicit float clauses are preserved, with numeric fallback clauses. The docs distinguish local-to-world transforms from view matrices and specify the billboard front direction.
Validation: 579 tests and 5 doctests pass with 100% line coverage. New tests cover known axis-aligned and oblique bases, view/pose inverses, all signed coordinate axes, spherical versus cylindrical behavior, oblique rotation axes, translation and homogeneous coordinates, mixed numeric inputs, magnitude scaling, and degenerate inputs. Formatting, compilation with warnings as errors, and documentation generation pass.
Part of #44. Projection helpers will follow separately.