Commit f35b6229 authored by sagnowski's avatar sagnowski
Browse files

Return early with OK when given valid Euler angles

parent 34ced5ee
Loading
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -49,12 +49,18 @@ ivas_error validate_quaternion( IVAS_QUATERNION q )
    epsilon = 1e-5f;

    // Euler angles if w == -3
    if ( q.w == -3.0f )
    {
        // We only limit pitch range. Yaw and roll can have any value as they safely wrap around.
    if ( q.w == -3.0f && ( q.y < -90.0f || 90.0f < q.y ) )
        if ( q.y < -90.0f || 90.0f < q.y )
        {
            return IVAS_ERR_INVALID_QUATERNION;
        }

        return IVAS_ERR_OK;
    }

    // For quaternions, check if the norm is close to 1.0
    norm_squared = q.w * q.w + q.x * q.x + q.y * q.y + q.z * q.z;
    if ( epsilon < fabsf( norm_squared - 1.0f ) )
    {