I was following this tutorial and when I tried to use it for AR compass, I got wrong positions for East and West (I get West on left side (270°)).
Problematic part:
fun Place.getPositionVector(azimuth: Float, latLng: LatLng): Vector3 {
val placeLatLng = this.geometry.location.latLng
val heading = latLng.sphericalHeading(placeLatLng)
val r = -2f
val x = r * sin(azimuth + heading).toFloat()
val y = 1f
val z = r * cos(azimuth + heading).toFloat()
return Vector3(x, y, z)
}
I see that: (-1) * sin(270) = 1 makes wrong result but I don't know how to fix it.