Matrix Rotation Around Local Axes

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Matrix Rotation Around Local Axes

Post by CuteAlien »

I can't remember right now what I needed the quaternion one for. Maybe was just a stupid solution (I also struggled with this ... back then even more). getRelativeRotation with setting old rotation to 0,0,0 and then using result in applyRelativeRotation might kinda work for what you need, not sure.

Matrix order is very important, you have to get that one right. As it means "apply this operation after the previous one". And as you noticed already order of rotations matters.

edit: Maybe you can simplify it for your case by kicking out the scale parts (if you know they are 1,1,1).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Re: Matrix Rotation Around Local Axes

Post by Acki »

I can't get it to work... :cry:

I tried each possible multiplication order (TXYZ, TZYX, XYZT, ZYXT)...
I also tried with/without scale...
I ported all needed functions from the Irrlicht matrix to Java...
no success !!! :(

I have no clue what's wrong...
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Matrix Rotation Around Local Axes

Post by CuteAlien »

Put a few test-cases around each function and check if you really get same results.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Re: Matrix Rotation Around Local Axes

Post by Acki »

what test cases?

I don't get the same results when I change the order...
but it's always wrong...
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Matrix Rotation Around Local Axes

Post by CuteAlien »

Well - you ported the functions to Java. Just call them with a bunch of random parameter to see if you really get same results.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Re: Matrix Rotation Around Local Axes

Post by Acki »

ok, I made some test cases on Irrlicht, and then the same with my Java code...
and it turned out, the calculations were correct (same results)... :shock:

and now I get THIS:
https://www.youtube.com/watch?v=VrErHDAswP0

I hope you don't mind having one last look at this video...
I won't bother you with this anymore, promised !!! ;)

thanks for the help !!!
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Matrix Rotation Around Local Axes

Post by CuteAlien »

haha - thanks, nice to see :-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Re: Matrix Rotation Around Local Axes

Post by Acki »

I had to reverse my rotation order in the render loop from ZYX to XYZ...
but when I change the order in the matrix instead the calculation gives wrong values...

no big deal I can live with the render order XYZ...
but I have to change a few other things also now...

for example...
now I get wrong results calculating the absolute transformation of a scene node... :roll:
but I think I should get this to work...
or it may be another topic to bother you with... :P

bye!
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
smso
Posts: 246
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: Matrix Rotation Around Local Axes

Post by smso »

I wrote something similar long time ago, these may be of some help:

To rotate / revolve node in world space & in local space:
http://irrlicht.sourceforge.net/forum/v ... =9&t=47924
Look at rotateNodeInLocalSpace() or revolveNodeInLocalSpace()

Regards,
smso
Post Reply