• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      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.
Sign in to follow this  
Followers 0
L. Spiro

Left-Handed Euler Rotation Matrices

6 posts in this topic

I am trying to emulate the FBX system of determining an object’s local transform (described here).
For simplification, I only need to worry about the local Euler rotations of the object—the scale, pivots, pre-rotate, post-rotate, etc., are all “identity” and do not contribute to the result for my test work.
 
That means I only have to take an X-rotation matrix, Y-rotation matrix, and Z-rotation matrix and combine them in that order (because I am using row-major matrices whereas they are using column-major matrices).
 
When I actually construct these 3 matrices and combine them in that order, it works fine.  Code for the way I construct them (only upper 3×3 shown):
 
MatrixRotationX( _tType _tAngle ) {
    LSREAL fS;
    LSREAL fC;
    CMathLib::SinCos( static_cast<LSREAL>(_tAngle), fS, fC );
    _11 = 1.0;
    _12 = 0.0;
    _13 = 0.0;
 
    _21 = 0.0;
    _22 = fC;
    _23 = fS;
 
    _31 = 0.0;
    _32 = -fS;
    _33 = fC;
}
MatrixRotationY( _tType _tAngle ) {
    LSREAL fS;
    LSREAL fC;
    CMathLib::SinCos( static_cast<LSREAL>(_tAngle), fS, fC );
    _11 = fC;
    _12 = 0.0;
    _13 = -fS;
    
    _21 = 0.0;
    _22 = 1.0;
    _23 = 0.0;
    
    _31 = fS;
    _32 = 0.0;
    _33 = fC;
}
MatrixRotationZ( _tType _tAngle ) {
    LSREAL fS;
    LSREAL fC;
    CMathLib::SinCos( static_cast<LSREAL>(_tAngle), fS, fC );
    _11 = fC;
    _12 = fS;
    _13 = 0.0;
    
    _21 = -fS;
    _22 = fC;
    _23 = 0.0;
    
    _31 = 0.0;
    _32 = 0.0;
    _33 = 1.0;
}
According to this, this is a left-handed system that has been transposed for my row-major matrices (theirs are column-major).  My assignments are grouped by rows, and my row [_11, _12, _13] matches their first column except that the sign of the sine’s are reversed, making it left-handed (I guess?).
 
In any case, if I use these to manually combine the XYZ Euler rotations from the FBX data the result is correct.
But I don’t want to construct 3 matrices and multiply them together when I know there is a way to get the result directly.
 
So I checked here to get some direct conversions.
My code for their Tait-Bryan XYZ set follows (exactly the same but transposed into row-major):
MatrixRotationXYZ( _tType _tX, _tType _tY, _tType _tZ ) {
    LSREAL fS1, fC1;
    CMathLib::SinCos( static_cast<LSREAL>(_tX), fS1, fC1 );

    LSREAL fS2, fC2;
    CMathLib::SinCos( static_cast<LSREAL>(_tY), fS2, fC2 );

    LSREAL fS3, fC3;
    CMathLib::SinCos( static_cast<LSREAL>(_tZ), fS3, fC3 );

    _11 = fC2 * fC3;
    _12 = fC1 * fS3 + fC3 * fS1 * fS2;
    _13 = fS1 * fS3 - fC1 * fC3 * fS2;

    _21 = -fC2 * fS3;
    _22 = fC1 * fC3 - fS1 * fS2 * fS3;
    _23 = fC3 * fS1 + fC1 * fS2 * fS3;

    _31 = fS2;
    _32 = -fC2 * fS1;
    _33 = fC1 * fC2;
}
Obviously, this is not going to work, as it is right-handed and transposing is not enough.
How do I make this left-handed? I need at least this one, but best would be a table of all combinations (YZX, XZY, ZYX, etc., as on Wikipedia).


Thank you,
L. Spiro
0

Share this post


Link to post
Share on other sites

M' = ScaleMatrix(1, 1, -1) * M * ScaleMatrix(1, 1, -1)
 

Edited by RobTheBloke
0

Share this post


Link to post
Share on other sites

I tried it; the model vanishes completely.  Besides I am specifically trying to avoid any matrix multiplication.

 

 

L. Spiro

0

Share this post


Link to post
Share on other sites

I did the multiplication and got

 

_11 = c2c3

_12 = c2s3

_13 = -s2

_21 = s1s2c3 - c1s3

_22 = s1s2s3 + c1c3

_23 = s1c2

_31 = c1s2c3 + s1s3

_32 = c1s2s3 - s1c3

_33 = c1c2

 

I may have made a mistake though. Just multiply the matrices together...

1

Share this post


Link to post
Share on other sites
Doing the math by hand is my plan for the rest of them too. I’m planning to make some temporary code that will print the whole multiplication process for each matrix to make it easy and accurate.

But first I will try yours and get back.


L. Spiro


[EDIT]
Yours works.
I will do the rest by myself and post the results later for anyone who needs them all.
[/EDIT] Edited by L. Spiro
0

Share this post


Link to post
Share on other sites

You might want to remember that when dealing with products of transposed matrices, the following formula applies:

 

(AB)T = BT * AT

 

EDIT: Proof here: http://www.proofwiki.org/wiki/Transpose_of_Matrix_Product

 

And for multiple products of transposes

 

(A1A2...An-1An)T = AnT * An-1T * ... * A2T * A1T

 

Which is very similar to the product of inverses formula too (replace AT with A-1). The inverse formula is trivial to prove.

 

EDIT2: So, since your X, Y, Z rotation matrices are transposed, you should find that XTYTZT = (ZYX)T

 

i.e. your XYZ rotation matrix will be the other library's ZYX rotation matrix, transposed.

Edited by Paradigm Shifter
1

Share this post


Link to post
Share on other sites

I didn’t think of it that way.

I hadn’t had time to get around to my method of printing them out and simplifying due to health issues, so this will definitely save me some time.  Thank you.

 

 

L. Spiro

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0