Quantcast

Jump to content

» «
Photo

IPL file; quaternion to euler parameters

5 replies to this topic
gokuta
  • gokuta

    Square Civilian

  • Members
  • Joined: 24 Apr 2014
  • Afghanistan

#1

Posted 11 May 2014 - 03:28 AM

Hello! I desperately need to convert quaternion rotations, that are found in .ipl files, to euler parameters! Now,... not every function is going to do this, because the correct conversion depends on correct rotation sequence. And the question is... which one is correct!? As far as I tested, it's Y-X-Z, but it also does not convert all object correctly; miscalculations are being made when rotation of an object is complex (like rotating around every axis more than half the turn).

Ok, whatever... please suggest some working quaternion to euler conversion methods for .ipl objects. Thanks 


Silent
  • Silent

    Chief Vision™ Alterer

  • GTA Mods Staff
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [Modding] 2016
    Contribution Award [Mods]
    Best Script/Plugin 2014 [SilentPatch]
    Most Respected 2014
    Most Helpful [Mods] 2014
    Most Helpful [GTA] 2013
    Most Helpful [Mods] 2013
    Most Talented [Modding] 2013
    Best Map 2013 [ViceCityStories PC Edition]
    Best Vehicle 2013 [III Aircraft]
    Most Helpful [Mods] 2012
    Modder of the Year 2012

#2

Posted 11 May 2014 - 10:01 AM Edited by Silent, 11 May 2014 - 10:01 AM.

Extracted this quaternion -> matrix function from SA, left it in a pseudocode form. May be helpful.
 
ImagVec.x = quat->imag.x + quat->imag.x;
ImagVec.y = quat->imag.y + quat->imag.y;
ImagVec.z = quat->imag.z + quat->imag.z;

v5 = ImagVec.x * quat->imag.x;
v6 = ImagVec.y * quat->imag.x;
v7 = ImagVec.z * quat->imag.x;
v8 = ImagVec.y * quat->imag.y;
v9 = ImagVec.z * quat->imag.y;
v10 = ImagVec.z * quat->imag.z;

v11 = ImagVec.x * quat->real;
v12 = ImagVec.y * quat->real;
v13 = ImagVec.z * quat->real;

matrix->right.x = 1.0f - (v10 + v8);
matrix->top.x = v6 - v13;
matrix->at.x = v12 + v7;

matrix->right.y = v13 + v6;
matrix->top.y = 1.0f - (v10 + v5);
matrix->at.y = v9 - v11;

matrix->right.z = v7 - v12;
matrix->top.z = v11 + v9;
matrix->at.z = 1.0f - (v8 + v5);
Note that GTA uses up as at and at as up ;)
  • Concavax and pogo_01 like this

gokuta
  • gokuta

    Square Civilian

  • Members
  • Joined: 24 Apr 2014
  • Afghanistan

#3

Posted 11 May 2014 - 07:20 PM

Thanks. But one question... as I dont fully understand:

 

right means the upper row, right? What rows does top and at represent? Sorry, if you could explain more about conventions of rotation matrices


Silent
  • Silent

    Chief Vision™ Alterer

  • GTA Mods Staff
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [Modding] 2016
    Contribution Award [Mods]
    Best Script/Plugin 2014 [SilentPatch]
    Most Respected 2014
    Most Helpful [Mods] 2014
    Most Helpful [GTA] 2013
    Most Helpful [Mods] 2013
    Most Talented [Modding] 2013
    Best Map 2013 [ViceCityStories PC Edition]
    Best Vehicle 2013 [III Aircraft]
    Most Helpful [Mods] 2012
    Modder of the Year 2012

#4

Posted 11 May 2014 - 07:32 PM

Yeah, GTA matrix is

right
top
at

and 4th entry in 1st row holds internal flags.

Frank.s
  • Frank.s

    R.I.P.ingPang

  • Feroci
  • Joined: 15 Apr 2008
  • None
  • Best Total Overhaul 2016 [Shine o' Vice] [Contribution]

#5

Posted 11 May 2014 - 07:57 PM Edited by Frank.s, 11 May 2014 - 07:57 PM.

What is the advantage of GTA using Quat instead of Euler rotations?

NTAuthority
  • NTAuthority

    hell, no, tunnel, no

  • Feroci
  • Joined: 09 Sep 2008
  • European-Union
  • Best Script or Plugin 2016 [SkyGfx] [Contribution]
    Best Conversion 2014 [ViIV for GTANY]
    Most Knowledgeable [Tech] 2013
    Best Map 2013 [ViceCityStories PC Edition]
    Contribution Award [Mods]

#6

Posted 11 May 2014 - 08:10 PM

What is the advantage of GTA using Quat instead of Euler rotations?

https://en.wikipedia...iki/Gimbal_lock
 
The animations do a great job at explaining it; basically it's a state where a certain axis alignment causes changes to other axes to not allow for individual rotation in the desired direction.
  • Frank.s likes this




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users