android Programming Glossary: restrictangle
Android getOrientation() method returns bad results http://stackoverflow.com/questions/10192057/android-getorientation-method-returns-bad-results that calculates a filtered angle value y for a given raw angle value x could be something like this private float restrictAngle float tmpAngle while tmpAngle 180 tmpAngle 360 while tmpAngle 180 tmpAngle 360 return tmpAngle x is a raw angle value from.. calculateFilteredAngle float x float y final float alpha 0.1f float diff x y here we ensure that abs diff 180 diff restrictAngle diff y alpha diff ensure that y stays within 180 180 bounds y restrictAngle y return y The function calculateFilteredAngle.. x y here we ensure that abs diff 180 diff restrictAngle diff y alpha diff ensure that y stays within 180 180 bounds y restrictAngle y return y The function calculateFilteredAngle float x float y can then be called periodically using something like this..
|