Page 1 of 1

Total chaos in Euler Rotation convention (closed)

Posted: Tue Feb 28, 2017 1:49 am
by devsh
There is a total convention chaos, sometimes the arguments are called pitch-yaw-roll sometimes pitch-roll-yaw etc.

Please clean this up, and say rotationAboutX, rotationAboutY, rotationAboutZ and clarify all rotations are anti-clockwise around the axis and XYZ is a right-handed system with rotation around the z axis occuring first, y second and x third



All below is untrue and irrelevant to Irrlicht 1.8.4 (my bad, my bug)

I fixed the set() function which has been shrouded by _IRR_TEST_BROKEN_QUATERION_USE_

Code: Select all

 
// sets new quaternion based on euler angles
inline quaternion& quaternion::set(const float& roll, const float& pitch, const float& yaw)
{
    f64 angle;
 
    angle = roll * 0.5;
    const f64 sr = sin(angle);
    const f64 cr = cos(angle);
 
    angle = pitch * 0.5;
    const f64 sp = sin(angle);
    const f64 cp = cos(angle);
 
    angle = yaw * 0.5;
    const f64 sy = sin(angle);
    const f64 cy = cos(angle);
 
    const f64 cpcy = cp * cy;
    const f64 spcy = sp * cy;
    const f64 cpsy = cp * sy;
    const f64 spsy = sp * sy;
 
    *reinterpret_cast<vectorSIMDf*>(this) = vectorSIMDf(sr,cr,cr,cr)*vectorSIMDf(cpcy,spcy,cpsy,cpcy)+vectorSIMDf(-cr,sr,-sr,sr)*vectorSIMDf(spsy,cpsy,spcy,spsy);
 
    return *this;
}
 
P.S. Personally I will remove all mention of P-Y-R and euler angles and require quaternion use throughout, and the only way to set euler angles will be just in the quaternion constructor!

Re: Broken Quaternion From Euler (and total chaos in convent

Posted: Tue Feb 28, 2017 5:00 am
by CuteAlien
Maybe I'm just too tired.. but I don't see Irrlicht using roll/pitch/yaw anywhere in quaternions. Is this maybe one of your own changes you did for your version?

Re: Broken Quaternion From Euler (and total chaos in convent

Posted: Tue Feb 28, 2017 12:41 pm
by devsh
yeah you're right its my own function, its because I made it from the 3x3 matrix conversion functions above it
and the conversion to 4x4 matrix and back is definitely broken (as the flag indicates)

your fromEuler function is correct

Code: Select all

inline quaternion& quaternion::set(f32 x, f32 y, f32 z)
{
    f64 angle;
 
    angle = x * 0.5;
    const f64 sr = sin(angle);
    const f64 cr = cos(angle);
 
    angle = y * 0.5;
    const f64 sp = sin(angle);
    const f64 cp = cos(angle);
 
    angle = z * 0.5;
    const f64 sy = sin(angle);
    const f64 cy = cos(angle);
 
    const f64 cpcy = cp * cy;
    const f64 spcy = sp * cy;
    const f64 cpsy = cp * sy;
    const f64 spsy = sp * sy;
 
    X = (f32)(sr * cpcy - cr * spsy);
    Y = (f32)(cr * spcy + sr * cpsy);
    Z = (f32)(cr * cpsy - sr * spcy);
    W = (f32)(cr * cpcy + sr * spsy);
 
    return normalize();
}
 

Re: Total chaos in Euler Rotation convention (closed)

Posted: Sat Mar 04, 2017 2:59 pm
by Mel
Quaternion to XYZ Euler... BRRR! i just get goosebumps remembering when i tried to get something straight out of it from the internet... Looks like everybody deliberately avoids the XYZ Euler rotation order! D:

Re: Total chaos in Euler Rotation convention (closed)

Posted: Sat Mar 04, 2017 4:00 pm
by devsh
Its because there are at least 6 different conventions you could use regarding the order in which the rotations about the axes get applied, a quaternion removes this ambiguity by specifying a single rotation axis and requiring the rotation to be anti-clockwise