Still scratching my head in regards to spaces

Started by
12 comments, last by Dahkex 13 years, 7 months ago
Quote:
Matrix.CreateTranslation( 0, 0, -1.0 ) * rocketMat;

Won't multiplying the rocketMatrix and then by CreateTranslation be a world transformation or would that only occur if I did rocketMat * Matrix.CreateTranslation(0,0,-1.0)? Aside from that, what you would be doing would be positioning the flame above the rocket one unit in the z-direction on the object's[\b] local z-axis correct?

Sure, it is a "world transformation" but all transformations end up in the world.
See, you have your OBJECTS matrix "rocketMat", and you wanted some point in world space that is RELATIVE to your OBJECT. So, you take the OBJECT matrix, and use it as the starting point. If you don't care about any one object, you take the ORIGIN (matrix.identity) as your starting point.

Quote:
Like I mentioned in the previous post, very helpful into understanding that my origin can be whatever I want it to define but I need clarification as to what exactly I would use to represent my object space through a matrix...that's probably the remaining thing I'm confused about.

Yeah. Your "Object space" of the rocket is rocketMat. If you took the columns (rows in directx?) of the matrix, you'd get the X,Y,Z, axis and position of the rocket. Multiplying in another translation after your object's matrix is equivelent to using those local XYZ axis to move away from the local position described in the rocketMat.

Maybe picking up some reading on linear algebra would help?
Advertisement
Quote:Original post by KulSeran
Quote:
Matrix.CreateTranslation( 0, 0, -1.0 ) * rocketMat;

Won't multiplying the rocketMatrix and then by CreateTranslation be a world transformation or would that only occur if I did rocketMat * Matrix.CreateTranslation(0,0,-1.0)? Aside from that, what you would be doing would be positioning the flame above the rocket one unit in the z-direction on the object's[\b] local z-axis correct?

Sure, it is a "world transformation" but all transformations end up in the world.
See, you have your OBJECTS matrix "rocketMat", and you wanted some point in world space that is RELATIVE to your OBJECT. So, you take the OBJECT matrix, and use it as the starting point. If you don't care about any one object, you take the ORIGIN (matrix.identity) as your starting point.

Quote:
Like I mentioned in the previous post, very helpful into understanding that my origin can be whatever I want it to define but I need clarification as to what exactly I would use to represent my object space through a matrix...that's probably the remaining thing I'm confused about.

Yeah. Your "Object space" of the rocket is rocketMat. If you took the columns (rows in directx?) of the matrix, you'd get the X,Y,Z, axis and position of the rocket. Multiplying in another translation after your object's matrix is equivelent to using those local XYZ axis to move away from the local position described in the rocketMat.

Maybe picking up some reading on linear algebra would help?


I finally get it I believe.

Relating to the rotation and translation thing vs translation then rotation:

My object space is initially aligned with my world space. If I do a rotation at the beginning, both my X and Y axis will rotate around my local space's origin. It spins because I am literally shifting the axis as I rotate and thus I can achieve the spinning motion. If I then do a translation, I am now in my world space which makes sense, I am just saying "here is my object origin in relation to the world origin" which in my case is set the same as my screen space at (0,0). When I specify to rotate in this space, I am actually rotating the object itself, not the axis as I was doing in local space which is why it orbits.

In relation to to the transformations of the missile let's say above the carriage. I first can do something like this (doing this from left to right):

Rotate carriage 50 degrees around local space's origin, translate to (10,10,0)

Now, if I want some missile to be on top of the carriage rotated, I would do:

Rotate missle 50 degrees around local space origin, Translate to (1,1,0).

Now, reading from left to right, I would then multiply my world transformation for my carriage by the world transformation of my rocket and will get this rocket above.

So my order is if I wanted to do it out (from left to right):

rotMatrixCarriage(50) * tranMatrixCarriage(10,10,0) * rotMatrixRocket(50) * tranMatrixRocket(1,1,0).

or

1.Rotate my rocket 50 degrees around the local origin.
2.Put the rocket (10,10,0) in the world space
3. Rotate rocket by 50 degrees (I'm assuming this is in local space but am unsure)
4. Put the rocket above the carriage so right 1 and up 1

I would apply this sequence to my origin of my rocket and end up where I want.

One final question. After the first two transformations of the carriage, is rotMatrixRocket doing 50 around the world origin or my local object origin? I ask because after my two matrix transformations for the carriage, I am now in world space so naturally in my head I would think that something like a rotation in the world space would orbit around the world origin. If it is in the local space, why does rotation occur in the local space vs the world space?
Quote:rotMatrixCarriage(50) * tranMatrixCarriage(10,10,10) * rotMatrixRocket(50) * tranMatrixRocket(1,1,0).

Not quite there yet. That would rotate the rocket twice.

You're right about the carriage - rotate it 50 degs, then translate it where you want it.

If you want a rocket on top of it - rotate the rocket by 50 degs, translate it where you want it.

If you want to use the carriage's orientation, which is a good idea - since the carriage may move:
Set the carriageMatrix = rotate(50)*translate(10,10,0)

Set the rocketMatrix = carriageMatrix * translate(1,1,0)

The rocket matrix is now rotate(50)*translate(10,10,0)*translate(1,1,0)

Since consequetive translations can be "additive" the rocket is rotated 50 degress, like the carriage, and translated 11,11,0. That puts it in the same direction as the carriage, and 1 unit above it.

EDIT: You're worrying a bit too much about which "space" you're in right now. Just visualize the object starting at the origin. Now decide how much you want it to be rotated when it's at its final location. Then translate it to its final location.

EDIT2:
Quote:is rotMatrixRocket doing 50 around the world origin or my local object origin?

When the rocket is at the origin, its local axes coincide with the world axes. However, you should think of it as rotating the axes of the rocket. After you rotate it 50 degrees (for example, about the Y axis), the rocket's local X and Z axis will now be rotated with respect to the world.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Quote:Original post by Buckeye
Quote:rotMatrixCarriage(50) * tranMatrixCarriage(10,10,10) * rotMatrixRocket(50) * tranMatrixRocket(1,1,0).

Not quite there yet. That would rotate the rocket twice.

You're right about the carriage - rotate it 50 degs, then translate it where you want it.

If you want a rocket on top of it - rotate the rocket by 50 degs, translate it where you want it.

If you want to use the carriage's orientation, which is a good idea - since the carriage may move:
Set the carriageMatrix = rotate(50)*translate(10,10,0)

Set the rocketMatrix = carriageMatrix * translate(1,1,0)

The rocket matrix is now rotate(50)*translate(10,10,0)*translate(1,1,0)

Since consequetive translations can be "additive" the rocket is rotated 50 degress, like the carriage, and translated 11,11,0. That puts it in the same direction as the carriage, and 1 unit above it.

EDIT: You're worrying a bit too much about which "space" you're in right now. Just visualize the object starting at the origin. Now decide how much you want it to be rotated when it's at its final location. Then translate it to its final location.

EDIT2:
Quote:is rotMatrixRocket doing 50 around the world origin or my local object origin?

When the rocket is at the origin, its local axes coincide with the world axes. However, you should think of it as rotating the axes of the rocket. After you rotate it 50 degrees (for example, about the Y axis), the rocket's local X and Z axis will now be rotated with respect to the world.


Awesome, played around in XNA passing in my custom transformation and luckily it worked as I expected. Thanks

[Edited by - Dahkex on August 30, 2010 12:23:57 AM]

This topic is closed to new replies.

Advertisement