Spatial Rotation in Gmod Expression2.

Posted by Fascia on Stack Overflow See other posts from Stack Overflow or by Fascia
Published on 2009-07-30T23:51:49Z Indexed on 2010/04/19 3:03 UTC
Read the original article Hit count: 551

Filed under:
|

I'm using expression2 to program behavior in Garry's mod (http://wiki.garrysmod.com/?title=Wire_Expression2)

Okay so, to set the precedent. In Gmod I have a block and I am at a complete loss of how to get it to rotate around the 3 up, down and right vectors (Which are local. ie; if I pitch it 45 degrees the forward vector is 0.707, 0.707, 0). Essentially, From the 3 vectors I'd like to be able to get local Pitch/Roll/Yaw. By Local Pitch Roll Yaw I mean that they are completely independent of one another allowing true 3d rotation. So for example; if I place my craft so its nose is parallel to the floor the X,Y,Z would be 0,0,0. If I turn it parallel to the floor (World and Local Yaw) 90 degrees it's now 0, 0, 90. If I then pitch it (World Roll, Local Pitch) it 180 degrees it's now 180, 0, 90. I've already explored quaternions however I don't believe I should post my code here as I think I was re-inventing the wheel.

I know I didn't explain that well but I believe the problem is pretty generic. Any help anyone could offer is greatly appreciated.

Oh, I'd like to avoid gimblelock too.

Essentially calculating the rotation around each of the crafts up/forward/right vectors using the up/forward/right vectors.

To simply the question a generic implementation rather than one specific to Gmod is absolutely fine.

© Stack Overflow or respective owner

Related posts about rotation

Related posts about quaternion