Skip to content

Instantly share code, notes, and snippets.

@kylecorry31
Last active August 29, 2015 14:21
Show Gist options
  • Save kylecorry31/ffc071a395270c5ab789 to your computer and use it in GitHub Desktop.
Save kylecorry31/ffc071a395270c5ab789 to your computer and use it in GitHub Desktop.
/*
* 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