Jump to content
  • Advertisement
Sign in to follow this  
clashie

Matrix / transformation questions

This topic is 3033 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

Ok, I'm new to the idea of matricies, but after skimming over some of the D3D documentation, I figured out a rough enough idea to implement the basic stuff. I think I have most stuff right, but I seem to be having a couple problems that I'm not entirely sure on. The projection seems correct for the most part, and I plugged in the numbers for a cube which seems to look right. I initially make a matrix for the 'world' and then translate it back 10z. I want to give the cube the illusion of rotating so I figured I could just rotate the world matrix. Just before I rotate it, I translate it back to 0, 0, 0. Then it gets rotated, and put back to 0, 0, 10. Looks fine... but after a while of rotating the cube seems to get squashed into nothing. Does anything look wrong here? http://www.mediafire.com/?mothhdzzf1r Sorry, I should have sped up the rotation. If you let it sit for a minute, you'll see what I mean. It starts to get skewed / squashed. What am I missing? I've been going off this page for the most part http://msdn.microsoft.com/en-us/library/bb206269(VS.85).aspx

Share this post


Link to post
Share on other sites
Advertisement
Didn't even bother to look at the code. but the problem sounds familiar.
Constantly rotating a matrix is likely to screw it up. Floating point isn't perfect, and errors will build up fairly quickly in your matrix.

You can orthonormalize the matrix every frame (every few frames).
You can rotate with a quaternion (have to normalize that too, but it is cheaper).
You can store the rotation in axis+angle format, and wrap the angle so it stays in the range [-PI,PI).
You can risk gimble-lock, and store your rotation in euler angles. Again, wrapping the angles in the range [-PI,PI).

Share this post


Link to post
Share on other sites
Ahh, I figured it out.
It was a pretty durrr mistake with the way I was doing the multiplication.

Share this post


Link to post
Share on other sites
For floating-point drift, you can also use Doubles. Granted, depending on language it may be a little slower, but it's also a lot more precise.

You'll still need to orthonormalize, but a lot less often.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!