Android phone orientation overview including compass

You might want to check out the One Screen Turn Deserves Another article. It explains why you need the rotation matrix. In a nutshell, the phone’s sensors always use the same coordinate system, even when the device is rotated. In applications that are not locked to a single orientation, the screen coordinate system changes when … Read more

Calculate compass bearing / heading to location in Android

Ok I figured this out. For anyone else trying to do this you need: a) heading: your heading from the hardware compass. This is in degrees east of magnetic north b) bearing: the bearing from your location to the destination location. This is in degrees east of true north. myLocation.bearingTo(destLocation); c) declination: the difference between … Read more

Haversine Formula in Python (Bearing and Distance between two GPS points)

Here’s a Python version: from math import radians, cos, sin, asin, sqrt def haversine(lon1, lat1, lon2, lat2): “”” Calculate the great circle distance in kilometers between two points on the earth (specified in decimal degrees) “”” # convert decimal degrees to radians lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2]) # haversine formula … Read more

tech