[android-developers] Re: Getting magnetic field results as degrees

2009-12-14 Thread Jeffrey
I got it working, the phone will only need to be lying flat, so that made it a lot easier. It seems like google should mention somewhere that you need to use trig to get degree's from the compass... That doesn't quite seem like general knowledge. Though I had a problem with the activity force

Re: [android-developers] Re: Getting magnetic field results as degrees

2009-12-14 Thread Mark Murphy
Jeffrey wrote: It seems like google should mention somewhere that you need to use trig to get degree's from the compass... That's because you don't. http://github.com/commonsguy/cw-advandroid/tree/master/Sensor/Compass/ Or, to quote from the docs: Sensor.TYPE_ORIENTATION: All values are

[android-developers] Re: Getting magnetic field results as degrees

2009-12-13 Thread Peli
You need basic trigonometry: http://en.wikipedia.org/wiki/Trigonometry if x and y denote the magnetic field strength in microtesla, then you get the angle through the arc tangent function: phi = Math.atan(y/x); or phi = Math.atan2(y,x); phi is then the angle in radians. Note that you may want to

[android-developers] Re: Getting magnetic field results as degrees

2009-12-13 Thread Ethan Rublee
Here's my code for capturing orientation data... This is a snippet so has not been compiled, but should give you and idea. Keep in mind that you should register the sensors with something like this when ever you want to start listening to sensors: sensorMgr = (SensorManager)

[android-developers] Re: Getting magnetic field results as degrees

2009-12-12 Thread Jeffrey
Okay, so I got a little further, I'm now stuck at the point where I can pull values, but they are the micro-tesla measurements. How do I get degrees from this? On Dec 12, 8:13 pm, Jeffrey jeffisagen...@gmail.com wrote: I'm working on an application that will randomly point an arrow in a