Jump to content
  • Advertisement


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

The unProfessional

Bit of a Linear Algebra question

This topic is 5451 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 have a rather embarassing linear algebra question to ask. I always considered this trivial and am rather confused why I''m having any trouble with it whatsoever. But, I figure what better place to embarass myself than with a bunch of other developers, right? Let''s just say the object in question is at 500,250,650 in world space, with some arbitrary rotation applied to it. I''m concatinating a translation matrix (0.0, 3.0, 0.0) representing the position, in body space, of a subobject. Now from what I knew, the first matrix shifts the frame of reference to that of the object, where contacinations to that matrix would act as additional shifts. Here''s some comments on the process. // Build translation/rotation matrix for the "Tank" // Apply this matrix (matRot * matShift = matTank) // Draw the "Tank" // Calculate a translation matrix, in body space, for the "Tank''s Turret", 3 units +y // Apply this: matTank * matTurret // Render "Turret" Now it seems to me that the turret should be rotating and translating WITH the main object, about the same axis. But, it appears as though the concatination of the second matrix also throws off the rotation, meaning the turret is rotating about a slightly different axis than the tank object. What can I do to fix this? Thanks alot!

Share this post

Link to post
Share on other sites
"meaning the turret is rotating about a slightly different axis than the tank object."

Here is the problem (very common). You need to know where your "joint" is for both objects.

Sure as you don't do any x,z translation in body space for the turret, you assume that the origin of the tank and the origin of the turret are on the same vertical axis {Obody,Ybody}. You need to check if you meshes (models) are really aligned as you expect. But normally you need to know exactly where the turret "joint" is on the tank model and then you need to center this joint on the turret model. So these are two translations you don't take into account. Note that you can center dynamically (using matrices) or statically (modifying the mesh vertices so that the turret origin {0,0,0} is actually on the central axis of the turret).

Oh an idea for you : try to render 2 cubes at start. Thus you won't mix problems due to mesh vertices with the rest.

[edited by - Charles B on October 22, 2003 6:51:14 PM]

Share this post

Link to post
Share on other sites
It seems to me that you''re doing the steps in this order:

1. Rotate the tank around origin
2. Move the tank
3. (Optional) Move the turret to edge of tank

Now you see if you rotate the turret before you move it, it will be moving around its own axis, so it won''t be in the right place. You probably want to do the following:

1. Move the turret
2. Rotate the tank
3. Move the tank

Hope this helps.


Share this post

Link to post
Share on other sites
Thanks guys. Everything you're saying makes perfect sense -- but I think I may've explained the problem incorrectly.

I was trying to use the turret to simplify the example. But the turret itself isn't the issue. For instance, Lets take two blocks. One block is large, one is small.

Rotate the large block about the origin (let's say 10,5,6)
Move the large block to a position (100,10,150)
Render large block

Concatinate another matrix to shift a bit more (0,3,0)
Render the small block
// notice no additional rotation for block 2

When I modify the rotation that was first applied, shouldn't the assembly (both blocks) appear to rotate about the same axis? They appear to be rotating about different axis :-\

[edited by - the unprofessional on October 22, 2003 9:05:50 PM]

Share this post

Link to post
Share on other sites
Hmmm. What graphics API are you using? Are your matrices column-wise or row-wise? Are you applying the matrices consistent with the row/column orientation of the API?

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share this post

Link to post
Share on other sites
I''m using D3D. I''m applying the matrices the same way for the main object as for the smaller sub-object.

Is my theory right? If I have matrix (A), where I then render the main object, then a small translation matrix (B), rendering the second object with (A x B), modifying the rotation in matrix A should not rotate the two objects on difference axis. Correct?

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!