Last active
August 29, 2015 14:21
-
-
Save kylecorry31/ffc071a395270c5ab789 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Paste into Android project | |
*/ | |
/** | |
* Input -> y and z GForce (raw accelerometer data / 9.81) | |
* Output -> Degrees of rotation around x axis | |
*/ | |
public double beta(double y, double z){ | |
if(z >= 0){ | |
if (y >= 0){ | |
return y * 90.0; | |
} else { | |
return 360 + y * 90.0; | |
} | |
} else { | |
return 180 - y * 90; | |
} | |
} | |
/** | |
* Input -> x and y GForce (raw accelerometer data / 9.81) | |
* Output -> Degrees of rotation around z axis | |
*/ | |
public double alpha(double x, double y){ | |
return beta(x, y); | |
} | |
/** | |
* Input -> x and z GForce (raw accelerometer data / 9.81) | |
* Output -> Degrees of rotation around y axis | |
*/ | |
public double gamma(double x, double z){ | |
return beta(z, x); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment