Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

McZ

how to test my matrix class?

This topic is 5278 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m updating my own simple 3D math library for my engine and now I got a question. how do I know my matrix and quaternion classes work correct? is there any easy way to test this?

Share this post


Link to post
Share on other sites
Advertisement
yes. include it in your app, and run it.

if the results are borked, your library doesnt work.
if it aint broke, dont fix it.

Share this post


Link to post
Share on other sites
quote:
Original post by Eelco
yes. include it in your app, and run it.

if the results are borked, your library doesnt work.
if it aint broke, dont fix it.


Obviously, not a good answer.

Share this post


Link to post
Share on other sites
What I did was create random data and see if my results matched D3DX.

CreateVariousTranslation, Scale, YawPitchRoll matricies. Multiply them, Create more, multiply them. Do the two methods match? Create random quaterions via matrices, yawpitchroll, etc. Compare to D3DX. Multiply a bunch of random quaternions. Do my results match D3DX?

I found a bug or two this way, and it ensures my test data isn''t biased towards single axis operations or something else human testing would do. In some cases I was off by 0.000001f, which I considered acceptable random floating point precision issues.

Share this post


Link to post
Share on other sites
That small difference in your results is from floating point errors/inefficiencies. Its wasted time to concern yourself with such details. To me, testing something such as this seems sort of obvious. Before you begin writing such a maths lib, you should understand the basic concepts behind simple matrix math (multiplications). Use a TI-83 or even write it out on paper. In all honesty, this is sort of a silly question.

[edited by - samgzman on June 5, 2004 7:12:56 PM]

Share this post


Link to post
Share on other sites
Testing actually makes sense with SIMD versions of matrix code, they can sometimes hide some obscure bugs. I''ve seen a few implementations of SIMD matrix classes on the net that produced clearly wrong or highly inaccurate results. Although matching them against the C++ functions should be rather straightforward.

If you aren''t going ASM, then the only mathematically involved method of a typical matrix class is matrix inversion. I''d recommend testing it with various types of input matrices, since depending on the algorithm and your implementation, it can work on some matrices, and fail on others.

Everything else should be rather trivial.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!