cgmath icon indicating copy to clipboard operation
cgmath copied to clipboard

3x4 and 4x3 matrix support

Open pedrocr opened this issue 8 years ago • 4 comments

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.

pedrocr avatar Oct 02 '16 00:10 pedrocr

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.

brendanzab avatar Oct 03 '16 11:10 brendanzab

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?

pedrocr avatar Oct 04 '16 18:10 pedrocr

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

brendanzab avatar Oct 06 '16 23:10 brendanzab

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.

Osspial avatar Apr 22 '18 00:04 Osspial