• ### Announcements

GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

#### Archived

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

# transformations question

## 14 posts in this topic

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?
0

##### Share on other sites
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.
0

##### Share on other sites
d''oh! a typo...yeah the way you said it is correct.
0

##### Share on other sites
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)

0

##### Share on other sites
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.
0

##### Share on other sites
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
0

##### Share on other sites
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.
0

##### Share on other sites
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.
0

##### Share on other sites
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
0

##### Share on other sites
(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
0

##### Share on other sites
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
0

##### Share on other sites
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
0

##### Share on other sites
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.
0

##### Share on other sites
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

0

##### Share on other sites
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.
0