Robmaister's picture

Implementing Matrix2/Matrix3

I've been using OpenTK for a few months now, and I have to say that it's very intuitive to use and gets rid of a lot of the grunt work needed to get OpenGL to work on multiple platforms. OpenTK already has a pretty nice name for itself as the best OpenGL bindings for .NET, and I want to see things stay that way in the future. In order to do that, I want to contribute to OpenTK with the currently missing Matrix classes.

In one of my projects, I need to calculate a normal matrix for each object, but because of the lack of a Matrix3 class I would simply calculate the matrix in the vertex shader. This annoyed me quite a bit as I had to raise the GLSL version up to 150, and one of my friends who was working on this project with me couldn't run it on his laptop because it only supported GLSL 130. I could either grab a float array and do the math myself, but I figured I could do that same work in a Matrix3 class and help everyone.

So I checked out the SVN trunk and took a look at the current Matrix3d class. I'm pretty much ready to start implementing, but I noticed that the Matrix3d class uses R0C0 to R2C2 notation whereas the current Matrix4 uses M11-M33 notation. Which notation should I standardize between all the Matrix classes?

After I get a response, I'll start releasing implementations of each Matrix as I complete it. I'll also try and fix as many of the Matrix bug reports as I can.

EDIT: I took a look at the SVN log, it seems like the M11-M44 notation is newer, I'll use that.

EDIT2: I'll apply that new optimization that were added to r3080 to all the Matrix methods that prefer M11-M44 over Row0-Row3 and test them.

Also what's going on with CraeteFromAxisAngle/Rotate and CreateRotation[XYZ]/Rotate[XYZ]? The methods are exact copies of one another. Should I mark one set as obsolete or have one set point to the other? Or should I just leave it alone?