andykorth / opentk

The Open Toolkit is a low-level C# library that wraps OpenGL, OpenCL and OpenAL. This fork has been superseded by https://github.com/thefiddler/opentk Please direct your attention to that official repository.
71 stars 27 forks source link

API for getting subsections of a matrix #4

Closed Robmaister closed 11 years ago

Robmaister commented 11 years ago

Not sure what the proper term for it is, but I think there should be some API exposed for getting the upper-left 3x3 of a Matrix4 as there are some fairly common uses for it, like calculating a normal matrix.

The main question is how do we expose it? Should there be UpperLeft, UpperRight, LowerLeft, and LowerRight properties? In that case, would any of them besides UpperLeft be useful?

Should we create a new constructor in Matrix3 that accepts a Matrix4, or will that not be clear enough? (Though it does match the GLSL way of doing it)

Any other ideas?

andykorth commented 11 years ago

After giving this some thought, I think a constructor might be the best way to do this. I do think it's occasionally easy to miss overloaded constructors, but keeping it in line with GLSL is nice. Also, then we don't have to worry about method names, although I think UpperLeft would be fine.

I can't really think of any use for other subsections of a matrix, so my rule of thumb is always to leave out the speculative features until someone actually has a demonstrated need for it.

Robmaister commented 11 years ago

Alright, awesome. I'll incorporate it in my fork and include it in the next pull request when everything's nice and stable.

Robmaister commented 11 years ago

Implemented in GoldBlockGames/opentk@94c7ad4. Going to tidy up a few more things and send a pull request in a few hours.