Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotation matrix formula inconsistency? #58

Open
MKimiSH opened this issue Dec 27, 2018 · 2 comments
Open

Rotation matrix formula inconsistency? #58

MKimiSH opened this issue Dec 27, 2018 · 2 comments

Comments

@MKimiSH
Copy link

MKimiSH commented Dec 27, 2018

Hi,

I am trying to understand how rotation works in Tungsten. I notice that there are 2 rotation functions in Mat4f, namely rotXYZ() and rotYXZ(). I did not find documentation for the formula so I tried to compose 3 rotation matrices (w.r.t. x, y, and z axes) to reconstruct these 2 functions. However, I found some inconsistency between these 2 functions.

For a certain rotation vector [x_angle, y_angle, z_angle], Assume the rotation matrices are named rot_x(x_angle), rot_y(y_angle) and rot_z(z_angle). Also assume that rot_*.dot(v) is the correct way to rotate a vector v (same convention as in Tungsten). The rotXYZ() function can be reconstructed as rot_z.dot(rot_y).dot(rot_x). However, the rotYXZ() function cannot be reconstructed as rot_z.dot(rot_x).dot(rot_y), as expected, but can be reconstructed by rot_y.transpose().dot(rot_x).dot(rot_z).

Could anyone explain the reason of having 2 different rotation functions that are formulated inconsistently?

Thanks in advance.

@chaosink
Copy link
Contributor

Maybe rotYXZ() just want to do rot_y(-y_angle) * rot_x(x_angle) * rot_z(z_angle).

But I don't know why this function is called rotYXZ()...

@MKimiSH
Copy link
Author

MKimiSH commented Dec 27, 2018

I know it actually does rot_y(-y_angle) * rot_x(x_angle) * rot_z(z_angle), and it is the method called when reading the scene config files (see src/core/io/JsonPtr.cpp). Probably @tunabrain could give a reason of this design?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants