rustgd / cgmath

A linear algebra and mathematics library for computer graphics.
https://docs.rs/cgmath
Apache License 2.0
1.12k stars 155 forks source link

3x4 and 4x3 matrix support #384

Open pedrocr opened 7 years ago

pedrocr commented 7 years ago

Would 3x4 and 4x3 matrix support (including pseudo invert between them) make sense as an addition to this library? I'm working on a raw loading library that uses those sizes to deal with 4 color images being converted into 3 color ones:

https://github.com/pedrocr/rawloader/blob/4ba0a7a992f6d6c9384f68cf25f81c6ee71621b7/src/imageops/colorspaces.rs

It would be nice if I could move to using a library instead of doing these things by hand.

brendanzab commented 7 years ago

This would be super cool. Not sure how best to do it though. The traits have been designed in such a way as to allow that though.

pedrocr commented 7 years ago

The pseudo-inverse code is half there (only does one direction) and the multiplication code would be easy. What else would be needed for proper support for this?

brendanzab commented 7 years ago

Not sure! Feel free to chat to me on Gitter: https://gitter.im/brendanzab/cgmath

Osspial commented 6 years ago

One potential option would be to make matrices generic over InnerSpace, so that the number in the Matrix type's name represents the number of rows and the number of columns is represented by the vector's dimensions. That would make a 4x3 matrix Matrix4<Vector3<_>>, and a 3x4 matrix Matrix3<Vector4<_>>. The current, square matrices would then be typedefs of those types.