Commit 6fee008f authored by stoutjesdijk's avatar stoutjesdijk 🎧
Browse files

convert reference rotation in ivas_orient_trk_SetReferenceRotation

parent 1f352872
Loading
Loading
Loading
Loading
+15 −20
Original line number Diff line number Diff line
@@ -509,7 +509,17 @@ ivas_error ivas_orient_trk_SetReferenceRotation(
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

    /* check for Euler angle signaling */
    if ( refRot.w == -3.0f )
    {
        Euler2Quat(deg2rad( refRot.x ), deg2rad( refRot.y ), deg2rad( refRot.z ), &pOTR->refRot );
    }
    else
    {
        pOTR->refRot = refRot;
    }
    
    return IVAS_ERR_OK;
}

@@ -655,7 +665,7 @@ ivas_error ivas_orient_trk_Process(
    float alpha = pOTR->alpha;
    float ang;
    ivas_error result;
    IVAS_QUATERNION refQuat, absQuat, trkQuat;
    IVAS_QUATERNION absQuat, trkQuat;
    IVAS_QUATERNION trkEuler;

    if ( pOTR == NULL || pTrkRot == NULL )
@@ -663,20 +673,6 @@ ivas_error ivas_orient_trk_Process(
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

    refQuat.w = 0.0f;
    refQuat.x = 0.0f;
    refQuat.y = 0.0f;
    refQuat.z = 0.0f;
    /* check for Euler angle signaling */
    if ( pOTR->refRot.w == -3.0f )
    {
        Euler2Quat(deg2rad( pOTR->refRot.x ), deg2rad( pOTR->refRot.y ), deg2rad( pOTR->refRot.z ), &refQuat);
    }
    else
    {
        refQuat = pOTR->refRot;
    }

    absQuat.w = 0.0f;
    absQuat.x = 0.0f;
    absQuat.y = 0.0f;
@@ -721,7 +717,7 @@ ivas_error ivas_orient_trk_Process(
            pOTR->alpha = sinf( 2.0f * EVS_PI * pOTR->centerAdaptationRate / updateRate );

            /* Compute relative orientation = (absolute orientation) - (reference orientation) */
            QuaternionInverse( refQuat, &trkQuat );
            QuaternionInverse( pOTR->refRot, &trkQuat );
            QuaternionProduct( trkQuat, absQuat, &trkQuat );
            break;

@@ -737,7 +733,7 @@ ivas_error ivas_orient_trk_Process(
            - low  cutoff (slow adaptation) for small excursions (around center)
            - high cutoff (fast adaptation) for large excursions (off-center)
            */
            ang = QuaternionAngle( absQuat, *pTrkRot );
            ang = QuaternionAngle( absQuat, trkQuat );
            normalizedOrientation = ang * ang;

            relativeOrientationRate = sqrtf( normalizedOrientation ) / pOTR->adaptationAngle;
@@ -766,7 +762,7 @@ ivas_error ivas_orient_trk_Process(
        case OTR_TRACKING_REF_VEC_LEV:
        {
            /* This processing step of the OTR_TRACKING_REF_VEC/OTR_TRACKING_REF_VEC_LEVEL is identical */
            QuaternionProduct( refQuat, absQuat, &trkQuat );
            QuaternionProduct( pOTR->refRot, absQuat, &trkQuat );
            break;
        }
#endif /* OTR_REFERENCE_VECTOR_TRACKING */
@@ -778,7 +774,6 @@ ivas_error ivas_orient_trk_Process(
    if ( result == IVAS_ERR_OK )
    {
        pOTR->trkRot = trkQuat;
        pOTR->refRot = refQuat;

        if ( pAbsRot->w == -3.0f )
        {