Dependents: OBROT_ALL f3rc_3_auto_encode f3rc_3_auto_lintrace_912 EMG_Realtime_Filter ... more
Math.cpp
00001 #include "Math.h" 00002 #include "mbed.h" 00003 00004 const float gPI = 3.1415926536f; 00005 00006 float convertRange( float in, float oldMin, float oldMax, float newMin, float newMax ){ 00007 return ( in - oldMin ) * ( newMax - newMin ) / ( oldMax - oldMin ) + newMin; 00008 } 00009 00010 float convertRangePlusMinusPi( float deg ){ 00011 while ( ( deg > gPI ) || ( deg < -gPI ) ){ 00012 while ( deg > gPI ){ 00013 deg -= 2.0f * gPI; 00014 } 00015 while ( deg < -gPI ){ 00016 deg += 2.0f * gPI; 00017 } 00018 } 00019 00020 return deg; 00021 } 00022 00023 bool isNear( float a, float b, float error ){ 00024 return ( abs( a - b ) < error ); 00025 }
Generated on Tue Jul 19 2022 07:16:09 by 1.7.2