Radians to Degrees

latcc

Banned
I have been messing with the internal compass function of the SensorExtended library. It returns directions in radians.

What code do I use to display this magnetic direction in degrees?


The demo program gives these values in radians:

N = 0
W = -90
S = 180 or -180
E = 90

I have tried this code:

degrees = radians * (180 / PI)

actual code is: NumberFormat(ORi(0),0,2) * (180 / PI) where ORi is the direction-radians returned by the sensor library.

But this doesn't return values in 360 degrees.
 

latcc

Banned
Try this code:
B4X:
 NumberFormat(ORi(0)* 180 / cPI, 1, 2)
Did you declare PI?
The PI constant in B4A is cPI.
Best regards.
That doesn't work either, Klaus.

It shows correct compass headings from north (0) through east (090) to south (180) but then it turns negative and works backward through west to zero (north).

It should show increasing values through west all the way up to 360 (0) at north again.

So the west 180 half circle is a minus version of the east half circle.

I attach the program and would appreciate any help.
 

Attachments

  • Sensor Extender.zip
    275.3 KB · Views: 305
Upvote 0
Top