johnpmayer / elm-linear-algebra

BSD 3-Clause "New" or "Revised" License
16 stars 21 forks source link

Add Mat2 and Mat3 types #8

Open TheSeamau5 opened 9 years ago

TheSeamau5 commented 9 years ago

As uniforms, typically, Mat2 is very rarely used, but Mat3 is sometimes used (for example to encode a normal matrix).

Although anything that can be done with 2 and 3 dimensional matrices can be done with a 4 dimensional matrix, allowing for such an affordance can help keep code simple without having to wonder why a 4 dimensional matrix was created with all these 0's and 1's when all you wanted to do was some transform that involved a 2 dimensional matrix.

Also, WebGL is in its essence a 2d API, and thus, if someone is only interested in drawing 2d shapes in WebGL, then Mat3 is more appropriate than Mat4.

Furthermore, elm-linear-algebra does not depend on elm-webgl and thus should be able to be used in any other context where it makes sense (like, 2d and 3d physics simulations).

johnpmayer commented 9 years ago

This is mostly gonna be a lot of copy pasting of the Mat4 MJS stuff, so should be pretty easy. @TheSeamau5, do you want to take a shot at doing this yourself? Wouldn't hurt to increase the bus count

TheSeamau5 commented 9 years ago

Be careful for what you wish for. I love math so I might end up sneaking in some math functions that no one has asked for just cuz why not.

johnpmayer commented 9 years ago

That sounds fine, but try to break them down into sensible, separate PRs.

On Sun, Dec 14, 2014 at 7:28 PM, Hassan Hayat notifications@github.com wrote:

Be careful for what you wish for. I love math so I might end up sneaking in some math functions that no one has asked for just cuz why not.

— Reply to this email directly or view it on GitHub https://github.com/johnpmayer/elm-linear-algebra/issues/8#issuecomment-66937528 .

TheSeamau5 commented 9 years ago

Ok, how about this?

I'll make a pull request per type I add (I'll just add the same functionality as Mat4). And then a few pull requests any time I feel like adding a few functions (so you can judge if what I add doesn't feel too odd).

I mean, the sort of stuff I'm thinking of sneaking in are just common things like convolution (good for edge detection, if you wanna add black cartoon outlines to a toon shaded character) or eigenvalues and eigenvectors (which can help do crazy things like this) or just the missing practical stuff like matrix addition and multiplication that multiplies each element of a matrix by its equivalent in another matrix.

johnpmayer commented 9 years ago

Right, that's largely the split I had in mind. Cool, go for it! (sidenote: I'm checking out the latest of elm-compiler to see what I can do there)

On Sun, Dec 14, 2014 at 7:56 PM, Hassan Hayat notifications@github.com wrote:

Ok, how about this?

I'll make a pull request per type I add (I'll just add the same functionality as Mat4). And then a few pull requests any time I feel like adding a few functions (so you can judge if what I add doesn't feel too odd).

I mean, the sort of stuff I'm thinking of sneaking in are just common things like convolution http://en.wikipedia.org/wiki/Convolution (good for edge detection http://en.wikipedia.org/wiki/Sobel_operator, if you wanna add black cartoon outlines to a toon shaded http://en.wikipedia.org/wiki/Cel_shading character) or eigenvalues and eigenvectors http://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors (which can help do crazy things like this http://en.wikipedia.org/wiki/Eigenface) or just the missing practical stuff like matrix addition and multiplication that multiplies each element of a matrix by its equivalent in another matrix.

— Reply to this email directly or view it on GitHub https://github.com/johnpmayer/elm-linear-algebra/issues/8#issuecomment-66938508 .

imeckler commented 9 years ago

Has there been any progress on this front? I could use a Mat2 type.