DavidF
DavidF

Reputation: 63

CoreMotion convert Iphone Pitch: raidians to degrees

I am trying to convert radians to degrees. I already know: 1 radian = 180/PI This does give me degrees.

You can check out my code here: github

Here is my problem:

enter image description here

I am getting radian data that only goes from 0 to 1.5 and then back to 0 then from 0 to -1.5 and back to 0. So when I do the conversion I get 0 to 90 and back to 0 and then 0 to -90 and back to 0.

What I want is to be able to go from 0 to 360 as I move the pitch of the Iphone. I am pretty sure its an easy map and when I see it i will slam my hand into my forehead.

Thanks for the help!

Upvotes: 2

Views: 1734

Answers (1)

johnnyclem
johnnyclem

Reputation: 3354

I think your issue is a typo.
The function in your repo is:

var degrees = (radians * M_PI)

but as you noted at the beginning of your question, it should be

var degrees = radians * (180.0 / M_PI)

Upvotes: 3

Related Questions