
OpenTK 0.3.13 Matrix4 errata
Posted Sunday, 9 December, 2007 - 20:10 by the Fiddler.JTalton has uncovered some errors in the OpenTK.Math.Matrix4 implementation. Specifically, the Frustrum, Perspective, Rotate, RotateX, and Multiply methods return incorrect results.
Attached is the program used to test these functions, kindly povided by JTalton. Note that the multiply test may be wrong, so don't rely on its results.
Please use the equivalent Glu methods until the OpenTK 0.3.14 release.
| Attachment | Size |
|---|---|
| Program.cs | 14.96 KB |


Comments
Hello, sorry I havn't
Hello, sorry I havn't replied sooner, I was ill and then on holiday.
It's perfectly possible I've messed up somewhere, I did throw it all together rather quickly, what are the issues?
Hey, no problem! I haven't
Hey, no problem! I haven't had time to look into this either. Here are the failing functions:
(Edit: attached the program used to check at the first post)
Ok, I've had a quick
Ok, I've had a quick look.
The LookAt output seems to be the same apart from precision differences.
Remember that all the OpenTK.Math functions take angles in radians not degrees. Changing the calls appropriately gives the correct results for the rotate functions. The Perspective function did have an error in the implementation, if you change the first line from:
float yMax = near * (float)System.Math.Tan(fovy);
to:
float yMax = near * (float)System.Math.Tan(0.5f * fovy);
then that should clear that one up (as long as you remember to use radians).
Frustum is curious, it's used by the Perspective function, so it's definitely doing something right. I've been using it for ages without any problem. A quick google for glFrustum brought me to this page: http://www.gambasdoc.org/help/comp/gb.opengl/gl/frustum
which implies that the OpenTK.Math result is the correct one.
The Math classes are meant as a general purpose maths library, not as a drop in equivalent to the gl/glu functions. Hence the row major matrices and angles in radians. With that in mind I'm not all that bothered if the results differ from the opengl implementations as long as they do what they say on the tin. As I said, I haven't noticed any problems with the Frustum function in practice (if you've had a different experience please let me know).
Hope that helps.
Alright then! I've commited
Alright then! I've commited the Perspective fix, and the rest isn't anything that cannot be handled by the documentation. Many thanks!