dimforge / nalgebra

Linear algebra library for Rust.
https://nalgebra.org
Apache License 2.0
3.91k stars 464 forks source link

Allow reducing dimensions of Isometry #570

Open sadmac7000 opened 5 years ago

sadmac7000 commented 5 years ago

I'd like to be able to reduce an Isometry3 to an Isometry2 by removing a dimension.

This is useful for, for example, bridging Amethyst with ncollide2d. Amethyst can be used for 2d work but has no specific 2d mode, so it uses 3d transforms even when rendering in 2d. Being able to turn a 3d Amethyst transform into a 2d Isometry for ncollide is useful

KappaDistributive commented 5 years ago

Can you provide more details?

In general, a 3d isometry doesn't restrict to a 2d isometry in any natural way that I can think of but there are of course many 3d isometries that, restricted to some 2d plane, are 2d isometries as well. And those that do so on a place spanned by basis vectors, have natural representations as 2d matrices as well.

The latter is probably what you have in mind. But even then:

sadmac7000 commented 5 years ago

My particular use case involves 3d isometries for which the transform is guaranteed to have a z component of 0 and for which rotation is guaranteed to be around the z axis only, which I would like to turn into a 2d isometry by removing the unused components. I would imagine it makes sense to implement something a bit more general than that for clarity/elegance's sake, but I have no opinions on what that should look like.