View more

View more

View more

Image of the Day Submit

IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

transformations question

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

14 replies to this topic

#1davidko  Members

Posted 07 October 2001 - 05:46 PM

This question is pretty basic, but I just wanted to make sure I''m not making a mistake. To transform a point from model space to camera space is simple this: X'' = world_to_camera * model_to_world * X; Now, if we want to transform a point in camera space to model space, we simple do this: X = world_to_camera(T) * model_to_world(T) * X'' where the (T) means a transpose of the matrix (we are assuming just rotations and translations here). Let''s call world_to_camera(T) * model_to_world(T) = H Now, since we are dealing with orthogonal matricies, then we should be able to use the rotational part of matrix H to transform a normal vector from camera space to model space, right?

#2silvren  Members

Posted 07 October 2001 - 11:28 PM

quote:
Now, if we want to transform a point in camera space to model space, we simple do this:

X = world_to_camera(T) * model_to_world(T) * X''

Is that really true!?

I think the correct transformation is this:
X = model_to_world(T) * world_to_camera(T) * X''

regards

/Mankind gave birth to God.

#3davidko  Members

Posted 08 October 2001 - 03:51 PM

d''oh! a typo...yeah the way you said it is correct.

#4bpj1138  Members

Posted 09 October 2001 - 03:17 AM

Correct me if I''m wrong, but can''t you compute the inverse only once, and multiply the two matricies.. when you do that the order of multiplication is switched again,

m1(T) * m2(T) = (m2 * m1)(T)

#5silvren  Members

Posted 09 October 2001 - 04:33 AM

to bpj1138:
Ehh, isn''t that what I said (but in other words)!!?
yep, an axiom says:
(A*B)(t) = B(t)*A(t)

cheers

/Mankind gave birth to God.

#6bpj1138  Members

Posted 09 October 2001 - 02:11 PM

hrm, well, the way i remember the order of multiplication is that you multiply the parent transforms first, and local object transform comes last.. so,

world_transform = root_node * node1 * node2 * node3.. * local_object_transform

So, the parent transforms are on the left, just as you''d expect.

--bart

#7silvren  Members

Posted 09 October 2001 - 09:03 PM

bpj1138:
I''m sorry but I don''t know what you mean. I just corrected davidko''s second transformation, which ought to be right now. So, what do you mean?
I haven''t looked up any formulas (no need to) but I''m pretty confident that I have reasoned correctly.

Could you explain a bit more?

/Mankind gave birth to God.

#8LilBudyWizer  Members

Posted 09 October 2001 - 11:55 PM

I take it you mean rotations only and not rotations and translations since I don''t think the transpose and inverse are the same when translations are included. I''m not particularly strong with matrices but when I tried multiplying a matrix that included translation by its transpose I didn''t get the identity matrix.

#9silvren  Members

Posted 10 October 2001 - 12:23 AM

quote:
Original post by LilBudyWizer
I take it you mean rotations only and not rotations and translations since I don't think the transpose and inverse are the same when translations are included. I'm not particularly strong with matrices but when I tried multiplying a matrix that included translation by its transpose I didn't get the identity matrix.

You're right. Ortogonal matrices' inverses are simply the transposes. Rotation matrices are ortogonal, and translation matrices are not ortogonal.

/Mankind gave birth to God.

Edited by - silvren on October 10, 2001 7:26:38 AM

#10grhodes_at_work  Members

Posted 10 October 2001 - 04:55 AM

(Edit - Actually, ignore this post. As silvren pointed out, my statement is wrong - Graham)

quote:
Original post by silvren
You're right. Ortogonal matrices' inverses are simply the transposes.

That's not exactly correct. For example, a scaling transformation matrix is orthogonal:

  [sfx 0 0 ]S =| 0 sfy 0 | [ 0 0 sfz]

But its transpose and inverse are the same only if sfx = sfy = sfz = 1.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Edited by - grhodes_at_work on October 10, 2001 11:55:42 AM

Edited by - grhodes_at_work on October 10, 2001 7:14:12 PM

#11silvren  Members

Posted 10 October 2001 - 10:28 AM

quote:
Original post by grhodes_at_work
That's not exactly correct. For example, a scaling transformation matrix is orthogonal:

[sfx 0 0 ]
S =| 0 sfy 0 |
[ 0 0 sfz]

But its transpose and inverse are the same only if sfx = sfy = sfz = 1.

First, how can you determine that your matrix is orthogonal?
A matrix, if my memory's still with me, is only called orthogonal if its inverse is the same as its transpose, and in your case the orthogonality depends on the variables' values.

Second, the following properties must be true for your matrix to be orthogonal:
sfx = +-1 sfy = +-1 sfz = +-1
So you can in fact get N=2^3=8 different matrices that are orthogonal, not only one.

To sum it up:
A*A(T)=I iff square matrix A is orthogonal.

regards

/Mankind gave birth to God.

Edited by - silvren on October 10, 2001 5:29:39 PM

Edited by - silvren on October 10, 2001 5:30:31 PM

Edited by - silvren on October 10, 2001 5:31:35 PM

#12bpj1138  Members

Posted 10 October 2001 - 10:31 AM

OOPS.. sorry, I realized my message had nothing to do with the discussion. What I was talking about is computing the world transform for a particular node in a scene graph structure, and the order of multiplication involved there, but what this post is talking about is "change of coordinates", between two separate nodes in the scene graph.

It's also better not to talk about this with the word "camera", because it may become confused with a camera transform for a particular coordinate system/device.

So "change of coordinates" is changing between two local coordinate systems, say A, and B. You have a coordinate in A's local system, and you want to interpret it in B's local system.
In this case, you have to multiply A's coordinate first by A's world transform, to get the coordinate into world coordinates. Then multiply it by the inverse of B's world transform. So it's actually A * B(T)? heh, or it might be B(T) * A..

--bart

Edited by - bpj1138 on October 10, 2001 5:34:34 PM

#13grhodes_at_work  Members

Posted 10 October 2001 - 12:13 PM

quote:
Original post by silvren
First, how can you determine that your matrix is orthogonal?
A matrix, if my memory''s still with me, is only called orthogonal if its inverse is the same as its transpose, and in your case the orthogonality depends on the variables'' values.

Second, the following properties must be true for your matrix to be orthogonal:
sfx = +-1 sfy = +-1 sfz = +-1
So you can in fact get N=2^3=8 different matrices that are orthogonal, not only one.

To sum it up:
A*A(T)=I iff square matrix A is orthogonal.

silvren, you are absolutely correct on both points. Thanks for calling me on my error. What the hell was I thinking? (Ever hear of a brain fart?)

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

#14bpj1138  Members

Posted 10 October 2001 - 12:55 PM

It''s true that orientation matrix with a position vector is not "orthogonal square matrix", so you cannot transpose it. To compute the inverse, you can still transpose the 3x3 axis vector matrix, but then you have to negate the position vector and dot it with the three axis vectors.

so if you have the orientation matrix (R = right, U = up, D = direction, P = position):

|Rx Ry Rz 0|
|Ux Uy Uz 0|
|Dx Dy Dz 0|
|Px Py Pz 1|

the inverse orientation matrix is:

|Rx Ux Dx 0|
|Ry Uy Dy 0|
|Rz Uz Dz 0|
|-P*R -P*U -P*D 1|

notice the three axis vectors are still simply transposed from columns to rows. the position vector has to be negated and dotted with the three axis (in the original matrix, not the inverse)

--bart

#15davidko  Members

Posted 10 October 2001 - 03:53 PM

Normally, for graphics stuff, the interest in having an orthogonal matrix stems from wanting to efficiently transform normals, in which case translation doesn''t even factor in (i.e. how do you tranlate a normal)? So the usual textbook answer is, yes, if you have a rotation, translation, and uniform scaling, then your matrix is orthogonal. Of course, they usually say this in the context of normals, since translating a model will not affect its normals.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.