elm-linear-algebra icon indicating copy to clipboard operation
elm-linear-algebra copied to clipboard

Allow to manually construct a matrix from a list

Open TheSeamau5 opened this issue 11 years ago • 4 comments

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

TheSeamau5 avatar Dec 14 '14 16:12 TheSeamau5

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

evancz avatar Dec 14 '14 20:12 evancz

I get the benefits from guaranteeing the number of arguments but it just feels weird to pass in 16 arguments.

TheSeamau5 avatar Dec 14 '14 20:12 TheSeamau5

How about something like:

fromRows : Vec4 -> Vec4 -> Vec4 -> Vec4 -> Mat4

johnpmayer avatar Dec 14 '14 23:12 johnpmayer

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

TheSeamau5 avatar Dec 15 '14 00:12 TheSeamau5