elm-linear-algebra
elm-linear-algebra copied to clipboard
Allow to manually construct a matrix from a list
The idea is to be able to construct a matrix as follows:
identityMatrix = mat4 [
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]]
Where
mat4 : List (List Float) -> Mat4
I would do it such that the number of arguments are guaranteed, at least in the core API, but I guess there's not something like this exposed.
identityMatrix =
mat4
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
I get the benefits from guaranteeing the number of arguments but it just feels weird to pass in 16 arguments.
How about something like:
fromRows : Vec4 -> Vec4 -> Vec4 -> Vec4 -> Mat4
looks good.
And then just for completeness we can also add fromColumns which, if you're too lazy, you can just do
fromColumns = fromRows >> transpose