go-gl / mathgl

A pure Go 3D math library.
BSD 3-Clause "New" or "Revised" License
554 stars 65 forks source link

Extractors and type converters #17

Closed krux02 closed 10 years ago

krux02 commented 10 years ago

First of all, I changed the api of Cols() and Rows() to use non fixed size arrays. The reason for that is, that in a real application, if you want to extract them, you want to give them names, otherwise you could simply keep on working on the matrix directly. Also for the constructors, you almost never have fixed size arrays of vectors in your code, so you would end up typing [N]VecN{...} always when you want to use that constructor. Note that code written in the test cases of Rows/Cols here is not representative for real usage of Rows/Cols.

Then I added methods to resize Vectors and square matrices. Shrinking vectors always keep their beginning, and shrinking matrices always keep ther top left cornes. Growing Vectors have arguments to fill the new elements and Growing Matrices are filled with elements from the Identity Matrix.

krux02 commented 10 years ago

I saw now that vector and matrix are generated, so yea my bad. Maybe a comment "this file is generatey by ... do not edit" would be nice.

UserAB1236872 commented 10 years ago

Thanks. I am familiar with how rows are normally used, I just wasn't thinking. I tried to make the autogenerated thing clear in the README, but I should probably add that disclaimer to the file headers too.