• Advertisement

Archived

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

matrices

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

Hi all, i alway's used dx matrices but now i implemented my own. i can rorate ,scale and translate but when i first move my object and then rotate it it seems it moves like this - = object
------------ 
|           |   
|     -     | 
|           |
|------------


------------ 
|           |   
|   \       | 
|           |
|------------


------------ 
|           |   
|   /       | 
|           |
|------------


------------ 
|           |   
|     -     | 
|           |
|------------

------------ 
|           |   
|       \   | 
|           |
|------------
------------ 
|           |   
|       /   | 
|           |
|------------
[\code]
it it turns around his own axis and around the world origin
the order of my transformations is(the same as i used with dx)
world = scale*rotation
world = world*translation

thx in advance

   



[edited by - freaker13 on May 7, 2004 9:40:21 AM]   

Share this post


Link to post
Share on other sites
Advertisement
Make sure that your matrix code is fully DX-compliant, in other words, check to see if DX''s matrices are row-major or column-major, and be sure yours follow the same type.

Also, instead of aplying a whole sequence of transformations to your model, aply just one, and see if the end result matches. Try to see if the problem arises from rotation and/or translation.

Create 2 similar functions, one that renders with DX alone, and another that does the transformation using your matrix class, see how much they are diferent.

Salsa cooked it, your eyes eat it!
[Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD][My DevDiary]
[Yann L.][Enginuity] [Penny Arcade] [MSDN][VS RoadMap][Humus][BSPs][UGP][NeHe]
"our stupidity allways comes back to bite us in the ass... in a white-shark sort of way..." - Prozak

Share this post


Link to post
Share on other sites
I think rotation is normally performed about an axis, which goes through the origin.
So you first have to scale, then rotate, and finally translate an object.

Share this post


Link to post
Share on other sites
its my rotation matrix that's wrong
dx matrix:

0.976588 0 0.215116
0 1 0
-0.215116 0 0.976588


my matrix:

0.976588 0 0.215116
0 1 0
0 0 0.976588

whats my fault? i use this algo to get the rotation matrix:

float A = (float) cos(eulerAngleX);
float B = (float) sin(eulerAngleX);
float C = (float) cos(eulerAngleY);
float D = (float) sin(eulerAngleY);
float E = (float) cos(eulerAngleZ);
float F = (float) sin(eulerAngleZ);
float AD =(float) A * D;
float BD =(float) B * D;

matrix[0][0] = C * E;
matrix[0][1] = -C * F;
matrix[0][2] = D;

matrix[1][0] = BD * E + A * F;
matrix[1][1] = -BD * F + A * E;
matrix[1][2] = -B * C;

matrix[2][0] = -AD * E + B * F;
matrix[2][1] = AD * F + B * E;
matrix[2][2] = A * C;



[edited by - freaker13 on May 7, 2004 6:38:31 PM]

[edited by - freaker13 on May 7, 2004 6:39:21 PM]

Share this post


Link to post
Share on other sites

  • Advertisement