Ashley
Ashley

Reputation: 5947

Phonegap Accelerometer y value to degrees

Phonegap accelerometer seems to return y values as below:

// +10 y axis = straight up = 0/360 deg
// -10 y axis = straight down = 180 deg
// flat y axis = 90/270 deg

My question is, how do I convert this y axis to the given degrees?

Also, as it's phonegap, I'm assuming these values are the same for all devices. if anyone knows otherwise please let me know.

Upvotes: 2

Views: 1197

Answers (1)

sirmdawg
sirmdawg

Reputation: 2579

Try this:

deg = acceleration.y / 10 * 90; 

I think that worked for me when I was doing something similar.

Upvotes: 1

Related Questions