-
-
Notifications
You must be signed in to change notification settings - Fork 468
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
ngeom library #23
Comments
Some comments about your two last items. I will read your articles before commenting the first one.
While I am aware of the benefit of encoding the angular unit on the type (avoiding mixups between degrees and gradiants), I am not sure this benefit is enough to justify making the API more complicated. In fact, I am not sure anybody use degrees instead of radians in serious projects; and using both on the same project feels even less probable (but I might be mistaken).
Is it necessary to use structures instead of free functions (like One more thing that has to be added to nalgebra: quaternions. I never took the time to implement them… |
I guess less so degrees - more so the distinction between angles and scalars. I understand your hesitation in terms of API complexity though.
cc. @kvark |
I don't think that a whole structure is justified, but some utility functions to build common matrices are definitely useful. For example here is a code with |
@bjz No I don't have a
@tomaka nalgebra does have functions to build common matrices. See the constructors of let rot = Rot2::new(Vec1::new(self.rotation.to_radians()));
// Convert to a Mat4.
let rot_mat = na::to_homogeneous(&na::to_homogeneous(&rot)); You have to call The equivalent of your translation-rotation-scale matrix construction https://github.com/tomaka/spine-rs/blob/09123d9763933ec48f8a369370b34fd07a67ee99/src/lib.rs#L430-L434 is: let scale = Mat4::new(self.scale.0, 0.0, 0.0, 0.0, 0.0, self.scale.1, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
let rot_with_trans = Iso2::new(Vec2::new(self.position.0, self.position.1), Vec1::new(self.rotation.to_radians()));
let rot_with_trans_mat = na::to_homogeneous(&na::to_homogeneous(&rot_with_trans));
rot_with_trans_mat * scale |
I highly value the points @bjz mentions that are missing in nalgebra. Point and angle types bode well with typed oriented programming. As for the projection structs - I find them quite useful. First, because you can store them in, to say, cameras and lights, publicly for the user to play with (how do you expect the user to modify your matrix?). Second, because not everyone needs matrices in the end. In my past project I was doing the projection in the shader manually, no matrices involved. |
About
|
@sebcrozet I mostly agree. The thing about |
I am currently mucking around with some type level units atm, but it might be tricky without some type system features borrowed from Haskell land. Also the lack of multiple operator overloads is painful. @cmr Do you know what the status of |
I do not. |
@bjz we should be able to drop the double dispatch trick as soon as rust-lang/rust#17669 lands. After multiple experiments, here is what I will do. About
|
I agree with all of your design decisions here! :) |
Points and projections structures are now part of |
@sebcrozet what do you think about |
I am seriously considering transitioning from my
cgmath
library to nalgebra, seeing as it is now insanely well polished, and it would allow me to use your collision and physics stuff without having to re-invent the wheel. Some of the things I love aboutcgmath
though is:(*) : Point a -> a -> Point a
(/) : Point a -> a -> Point a
(+) : Point a -> Vector a -> Point a
(-) : Point a -> Point a -> Vector a
These things don't really make sense for a linear algebra library, but is it possible that we could have a separate library for these?
The text was updated successfully, but these errors were encountered: