Archived

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

The unProfessional

Bit of a Linear Algebra question

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.

Tom

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
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
Well, it was a couple of things. For one, the physics library I''m using was causing a small problem. In addition to that; yes, it''s dumb, but I wasn''t ordering my multiplications incorrectly. The original way I had it was correct, but the physics library bug was convincing me that I was incorrect. After I discovered that problem, and put everything else back to it''s original state, all was well.

Thanks =]

Share this post


Link to post
Share on other sites