-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use newtype idiom to generate Hyperbolic Space-specific matrix and vector types #264
Comments
Let's continue the nalgebra convention and use |
I like that idea. I'll edit the description from |
Another option is to call it |
I like that concision. Given the broad scope of these types I think that's justified. Another thought: for the "unit" types, would it make sense to represent w implicitly, since it's uniquely determined by the other components? Also, to avoid confusion with vectors of unit length, would it make sense to name them differently (perhaps LorentzHPoint)? |
My first inclination would be to say that w should not be implicit. It cannot be implicit in For the unit type, it might make sense to use |
SGTM. Maybe "Normal" for concision. |
That makes sense to me. "normal" means a lot of things in math, so there is the risk of confusing it with surface normals, but I think the benefits of that concision outweigh this risk. I'll edit the issue description. |
If we're careful, we may be able to use the proper mathematical terms for things, which may help for people who want to google things. For instance, we could lean into the "Minkowski" terminology and use something like This could also potentially reopen the "unit" vs "normal" question, since it seems likely that Minkowski space already would have a term for vectors whose Minkowski product with themselves is 1 or -1. Based on https://en.wikipedia.org/wiki/Minkowski_space#Pseudo-Euclidean_metrics, the answer might be that "unit vector" is the right term after all, and we would use the term "space" and "time" to distinguish between the two types of unit vector. This would give us something like Fortunately, renaming things is easy, so this can be decided later. |
Partial fix for #264 Adds `MVector` in math.rs generally for points and directions in hyperbolic space, replacing `na::Vector4` when appropriate Adds `MIsometry` in math.rs representing hyperbolic isometries, replacing `na::Matrix4` when appropriate Authored-by: strawberry <[email protected]>
To help avoid mistakes and make code easier to read and write, we should consider creating types to enforce the various invariants Hyperbolic vectors can have, much like nalgebra's
Point
vs.Vector
vs.UnitVector
types.For example, we could have the following types (names subject to change):
HPoint
: A vector that can represent a point in hyperbolic space. The invariant isx^2 + y^2 + z^2 < w^2
andw > 0
.HVector
: A vector that can represent a direction in hyperbolic space. The invariant isx^2 + y^2 + z^2 > w^2
.NormalHPoint
: A Lorentz-normalizedHPoint
. The invariant isx^2 + y^2 + z^2 - w^2 = -1
andw > 0
.NormalHVector
: A Lorentz-normalizedHVector
. The invariant isx^2 + y^2 + z^2 - w^2 = 1
.HIsometry
: A matrix representing an isometry in Hyperbolic space. All columns are Lorentz-orthogonal to each other. The first three columns areNormalHVector
s, and the last column is aNormalHPoint
.Under normal use, it should be pretty easy to enforce these invariants. There can be convenient helper and impl functions for common operations and conversions. For exceptional cases, functions with
unchecked
in their name can be added to opt out of this extra safety.The text was updated successfully, but these errors were encountered: