Loading lib_rend/ivas_orient_trk.c +9 −29 Original line number Diff line number Diff line Loading @@ -367,7 +367,7 @@ void VectorRotationToQuaternion( r->x = cross_product.x; r->y = cross_product.y; r->z = cross_product.z; r->w = 1.0 + dot_product; r->w = 1.0f + dot_product; } QuaternionNormalize( *r, r ); } Loading Loading @@ -665,8 +665,7 @@ ivas_error ivas_orient_trk_Process( float alpha = pOTR->alpha; float ang; ivas_error result; IVAS_QUATERNION absQuat, trkQuat; IVAS_QUATERNION trkEuler; IVAS_QUATERNION absQuat; if ( pOTR == NULL || pTrkRot == NULL ) { Loading @@ -688,7 +687,7 @@ ivas_error ivas_orient_trk_Process( switch ( pOTR->trackingType ) { case OTR_TRACKING_NONE: trkQuat = absQuat; pOTR->trkRot = absQuat; break; case OTR_TRACKING_REF_ORIENT: Loading @@ -699,8 +698,8 @@ ivas_error ivas_orient_trk_Process( pOTR->alpha = sinf( 2.0f * EVS_PI * pOTR->centerAdaptationRate / updateRate ); /* Compute relative orientation = (absolute orientation) - (reference orientation) */ QuaternionInverse( pOTR->refRot, &trkQuat ); QuaternionProduct( trkQuat, absQuat, &trkQuat ); QuaternionInverse( pOTR->refRot, &pOTR->trkRot ); QuaternionProduct( pOTR->trkRot, absQuat, &pOTR->trkRot ); break; case OTR_TRACKING_AVG_ORIENT: Loading @@ -708,14 +707,14 @@ ivas_error ivas_orient_trk_Process( QuaternionSlerp( pOTR->absAvgRot, absQuat, alpha, &pOTR->absAvgRot ); /* Compute relative orientation = (absolute orientation) - (average absolute orientation) */ QuaternionInverse( pOTR->absAvgRot, &trkQuat ); QuaternionProduct( trkQuat, absQuat, &trkQuat ); QuaternionInverse( pOTR->absAvgRot, &pOTR->trkRot ); QuaternionProduct( pOTR->trkRot, absQuat, &pOTR->trkRot ); /* Adapt LPF constant based on orientation excursion relative to current mean: - low cutoff (slow adaptation) for small excursions (around center) - high cutoff (fast adaptation) for large excursions (off-center) */ ang = QuaternionAngle( absQuat, trkQuat ); ang = QuaternionAngle( absQuat, pOTR->trkRot ); normalizedOrientation = ang * ang; relativeOrientationRate = sqrtf( normalizedOrientation ) / pOTR->adaptationAngle; Loading Loading @@ -744,7 +743,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( pOTR->refRot, absQuat, &trkQuat ); QuaternionProduct( pOTR->refRot, absQuat, &pOTR->trkRot ); break; } #endif /* OTR_REFERENCE_VECTOR_TRACKING */ Loading @@ -753,25 +752,6 @@ ivas_error ivas_orient_trk_Process( break; } if ( result == IVAS_ERR_OK ) { pOTR->trkRot = trkQuat; if ( absRot.w == -3.0f ) { Quat2Euler( trkQuat, &trkEuler.z, &trkEuler.y, &trkEuler.x ); trkEuler.x = rad2deg( trkEuler.x ); trkEuler.y = rad2deg( trkEuler.y ); trkEuler.z = rad2deg( trkEuler.z ); trkEuler.w = -3.0f; *pTrkRot = trkEuler; } else { *pTrkRot = trkQuat; } } return result; } #else Loading lib_rend/ivas_prot_rend.h +8 −10 Original line number Diff line number Diff line Loading @@ -799,16 +799,7 @@ ivas_error ivas_headTrack_open( void ivas_headTrack_close( HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ ); #endif void Quat2Euler( const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ float *yaw, /* o : yaw (z) */ float *pitch, /* o : pitch (y) */ float *roll /* o : roll (x) */ ); #ifdef FIX_I109_ORIENTATION_TRACKING void Euler2Quat( const float roll, /* i : roll (x) */ const float pitch, /* i : pitch (y) */ Loading @@ -818,9 +809,16 @@ void Euler2Quat( float deg2rad( float degrees ); float rad2deg( float radians ); #else void Quat2Euler( const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ float *yaw, /* o : yaw (z) */ float *pitch, /* o : pitch (y) */ float *roll /* o : roll (x) */ ); #endif void QuatToRotMat( const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ Loading lib_rend/ivas_rotation.c +27 −28 Original line number Diff line number Diff line Loading @@ -120,6 +120,29 @@ void QuatToRotMat( ) { float s1, s2, s3, c1, c2, c3; #ifdef FIX_I109_ORIENTATION_TRACKING c1 = cosf( quat.z / _180_OVER_PI ); c2 = cosf( quat.y / _180_OVER_PI ); c3 = cosf( quat.x / _180_OVER_PI ); s1 = sinf( quat.z / _180_OVER_PI ); s2 = sinf( -quat.y / _180_OVER_PI ); s3 = sinf( quat.x / _180_OVER_PI ); Rmat[0][0] = c2 * c3; Rmat[0][1] = -c2 * s3; Rmat[0][2] = s2; Rmat[1][0] = c1 * s3 + c3 * s1 * s2; Rmat[1][1] = c1 * c3 - s1 * s2 * s3; Rmat[1][2] = -c2 * s1; Rmat[2][0] = s1 * s3 - c1 * c3 * s2; Rmat[2][1] = c3 * s1 + c1 * s2 * s3; Rmat[2][2] = c1 * c2; #else #ifdef DEBUGGING /* PrintQuat( quat ); */ #endif Loading Loading @@ -177,10 +200,12 @@ void QuatToRotMat( Rmat[2][1] = c3 * s1 + c1 * s2 * s3; Rmat[2][2] = c1 * c2; } #endif return; } #ifndef FIX_I109_ORIENTATION_TRACKING /*------------------------------------------------------------------------- * Quat2Euler() * Loading @@ -196,15 +221,9 @@ void Quat2Euler( { if ( quat.w != -3.0 ) { #ifdef FIX_I109_ORIENTATION_TRACKING *roll = atan2f( 2 * ( quat.w * quat.x + quat.y * quat.z ), 1 - 2 * ( quat.x * quat.x + quat.y * quat.y ) ); *pitch = asinf( 2 * ( quat.w * quat.y - quat.z * quat.x ) ); *yaw = atan2f( 2 * ( quat.w * quat.z + quat.x * quat.y ), 1 - 2 * ( quat.y * quat.y + quat.z * quat.z ) ); #else // bug: x and z swapped *yaw = atan2f( 2 * ( quat.w * quat.x + quat.y * quat.z ), 1 - 2 * ( quat.x * quat.x + quat.y * quat.y ) ); *pitch = asinf( 2 * ( quat.w * quat.y - quat.z * quat.x ) ); *roll = atan2f( 2 * ( quat.w * quat.z + quat.x * quat.y ), 1 - 2 * ( quat.y * quat.y + quat.z * quat.z ) ); #endif } else { Loading @@ -221,6 +240,7 @@ void Quat2Euler( return; } #endif #ifdef FIX_I109_ORIENTATION_TRACKING /*------------------------------------------------------------------------- Loading Loading @@ -252,7 +272,7 @@ void Euler2Quat( } /*------------------------------------------------------------------------- * rad2deg() * deg2rad() * * Return angle in radians from degrees *------------------------------------------------------------------------*/ Loading @@ -269,29 +289,8 @@ float deg2rad( float degrees ) return PI_OVER_180 * degrees; } /*------------------------------------------------------------------------- * deg2rad() * * Return angle in degrees from radians *------------------------------------------------------------------------*/ float rad2deg( float radians ) { if ( radians >= EVS_PI ) { radians = radians - PI2; } if ( radians <= -EVS_PI ) { radians = radians + PI2; } return _180_OVER_PI * radians; } #endif /*------------------------------------------------------------------------- * rotateAziEle() * Loading Loading
lib_rend/ivas_orient_trk.c +9 −29 Original line number Diff line number Diff line Loading @@ -367,7 +367,7 @@ void VectorRotationToQuaternion( r->x = cross_product.x; r->y = cross_product.y; r->z = cross_product.z; r->w = 1.0 + dot_product; r->w = 1.0f + dot_product; } QuaternionNormalize( *r, r ); } Loading Loading @@ -665,8 +665,7 @@ ivas_error ivas_orient_trk_Process( float alpha = pOTR->alpha; float ang; ivas_error result; IVAS_QUATERNION absQuat, trkQuat; IVAS_QUATERNION trkEuler; IVAS_QUATERNION absQuat; if ( pOTR == NULL || pTrkRot == NULL ) { Loading @@ -688,7 +687,7 @@ ivas_error ivas_orient_trk_Process( switch ( pOTR->trackingType ) { case OTR_TRACKING_NONE: trkQuat = absQuat; pOTR->trkRot = absQuat; break; case OTR_TRACKING_REF_ORIENT: Loading @@ -699,8 +698,8 @@ ivas_error ivas_orient_trk_Process( pOTR->alpha = sinf( 2.0f * EVS_PI * pOTR->centerAdaptationRate / updateRate ); /* Compute relative orientation = (absolute orientation) - (reference orientation) */ QuaternionInverse( pOTR->refRot, &trkQuat ); QuaternionProduct( trkQuat, absQuat, &trkQuat ); QuaternionInverse( pOTR->refRot, &pOTR->trkRot ); QuaternionProduct( pOTR->trkRot, absQuat, &pOTR->trkRot ); break; case OTR_TRACKING_AVG_ORIENT: Loading @@ -708,14 +707,14 @@ ivas_error ivas_orient_trk_Process( QuaternionSlerp( pOTR->absAvgRot, absQuat, alpha, &pOTR->absAvgRot ); /* Compute relative orientation = (absolute orientation) - (average absolute orientation) */ QuaternionInverse( pOTR->absAvgRot, &trkQuat ); QuaternionProduct( trkQuat, absQuat, &trkQuat ); QuaternionInverse( pOTR->absAvgRot, &pOTR->trkRot ); QuaternionProduct( pOTR->trkRot, absQuat, &pOTR->trkRot ); /* Adapt LPF constant based on orientation excursion relative to current mean: - low cutoff (slow adaptation) for small excursions (around center) - high cutoff (fast adaptation) for large excursions (off-center) */ ang = QuaternionAngle( absQuat, trkQuat ); ang = QuaternionAngle( absQuat, pOTR->trkRot ); normalizedOrientation = ang * ang; relativeOrientationRate = sqrtf( normalizedOrientation ) / pOTR->adaptationAngle; Loading Loading @@ -744,7 +743,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( pOTR->refRot, absQuat, &trkQuat ); QuaternionProduct( pOTR->refRot, absQuat, &pOTR->trkRot ); break; } #endif /* OTR_REFERENCE_VECTOR_TRACKING */ Loading @@ -753,25 +752,6 @@ ivas_error ivas_orient_trk_Process( break; } if ( result == IVAS_ERR_OK ) { pOTR->trkRot = trkQuat; if ( absRot.w == -3.0f ) { Quat2Euler( trkQuat, &trkEuler.z, &trkEuler.y, &trkEuler.x ); trkEuler.x = rad2deg( trkEuler.x ); trkEuler.y = rad2deg( trkEuler.y ); trkEuler.z = rad2deg( trkEuler.z ); trkEuler.w = -3.0f; *pTrkRot = trkEuler; } else { *pTrkRot = trkQuat; } } return result; } #else Loading
lib_rend/ivas_prot_rend.h +8 −10 Original line number Diff line number Diff line Loading @@ -799,16 +799,7 @@ ivas_error ivas_headTrack_open( void ivas_headTrack_close( HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ ); #endif void Quat2Euler( const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ float *yaw, /* o : yaw (z) */ float *pitch, /* o : pitch (y) */ float *roll /* o : roll (x) */ ); #ifdef FIX_I109_ORIENTATION_TRACKING void Euler2Quat( const float roll, /* i : roll (x) */ const float pitch, /* i : pitch (y) */ Loading @@ -818,9 +809,16 @@ void Euler2Quat( float deg2rad( float degrees ); float rad2deg( float radians ); #else void Quat2Euler( const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ float *yaw, /* o : yaw (z) */ float *pitch, /* o : pitch (y) */ float *roll /* o : roll (x) */ ); #endif void QuatToRotMat( const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ Loading
lib_rend/ivas_rotation.c +27 −28 Original line number Diff line number Diff line Loading @@ -120,6 +120,29 @@ void QuatToRotMat( ) { float s1, s2, s3, c1, c2, c3; #ifdef FIX_I109_ORIENTATION_TRACKING c1 = cosf( quat.z / _180_OVER_PI ); c2 = cosf( quat.y / _180_OVER_PI ); c3 = cosf( quat.x / _180_OVER_PI ); s1 = sinf( quat.z / _180_OVER_PI ); s2 = sinf( -quat.y / _180_OVER_PI ); s3 = sinf( quat.x / _180_OVER_PI ); Rmat[0][0] = c2 * c3; Rmat[0][1] = -c2 * s3; Rmat[0][2] = s2; Rmat[1][0] = c1 * s3 + c3 * s1 * s2; Rmat[1][1] = c1 * c3 - s1 * s2 * s3; Rmat[1][2] = -c2 * s1; Rmat[2][0] = s1 * s3 - c1 * c3 * s2; Rmat[2][1] = c3 * s1 + c1 * s2 * s3; Rmat[2][2] = c1 * c2; #else #ifdef DEBUGGING /* PrintQuat( quat ); */ #endif Loading Loading @@ -177,10 +200,12 @@ void QuatToRotMat( Rmat[2][1] = c3 * s1 + c1 * s2 * s3; Rmat[2][2] = c1 * c2; } #endif return; } #ifndef FIX_I109_ORIENTATION_TRACKING /*------------------------------------------------------------------------- * Quat2Euler() * Loading @@ -196,15 +221,9 @@ void Quat2Euler( { if ( quat.w != -3.0 ) { #ifdef FIX_I109_ORIENTATION_TRACKING *roll = atan2f( 2 * ( quat.w * quat.x + quat.y * quat.z ), 1 - 2 * ( quat.x * quat.x + quat.y * quat.y ) ); *pitch = asinf( 2 * ( quat.w * quat.y - quat.z * quat.x ) ); *yaw = atan2f( 2 * ( quat.w * quat.z + quat.x * quat.y ), 1 - 2 * ( quat.y * quat.y + quat.z * quat.z ) ); #else // bug: x and z swapped *yaw = atan2f( 2 * ( quat.w * quat.x + quat.y * quat.z ), 1 - 2 * ( quat.x * quat.x + quat.y * quat.y ) ); *pitch = asinf( 2 * ( quat.w * quat.y - quat.z * quat.x ) ); *roll = atan2f( 2 * ( quat.w * quat.z + quat.x * quat.y ), 1 - 2 * ( quat.y * quat.y + quat.z * quat.z ) ); #endif } else { Loading @@ -221,6 +240,7 @@ void Quat2Euler( return; } #endif #ifdef FIX_I109_ORIENTATION_TRACKING /*------------------------------------------------------------------------- Loading Loading @@ -252,7 +272,7 @@ void Euler2Quat( } /*------------------------------------------------------------------------- * rad2deg() * deg2rad() * * Return angle in radians from degrees *------------------------------------------------------------------------*/ Loading @@ -269,29 +289,8 @@ float deg2rad( float degrees ) return PI_OVER_180 * degrees; } /*------------------------------------------------------------------------- * deg2rad() * * Return angle in degrees from radians *------------------------------------------------------------------------*/ float rad2deg( float radians ) { if ( radians >= EVS_PI ) { radians = radians - PI2; } if ( radians <= -EVS_PI ) { radians = radians + PI2; } return _180_OVER_PI * radians; } #endif /*------------------------------------------------------------------------- * rotateAziEle() * Loading