What am I doing wrong?!
The asin() function computes the principal value of the arc sine of __x. The returned value is in the range [-pi/2, pi/2] radians. A domain error occurs for arguments not in the range [-1, +1].
float pitchRadians = atan2 (accX, accZ) ; float rollRadians = atan2 (accY, accZ) ;
That tutorial sensibly uses atan2 for compass orientation, but for some obscure reason resorts to asin for tilt. The atan2 approach is superior, since you don't need to calibrate the accelerometer/compass nor to scale its output and it will work with the sensor upside down.Code: [Select] float pitchRadians = atan2 (accX, accZ) ; float rollRadians = atan2 (accY, accZ) ;
Please enter a valid email to subscribe
We need to confirm your email address.
To complete the subscription, please click the link in the
email we just sent you.
Thank you for subscribing!
via Egeo 16