0

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.

bounxye
  • 183
  • 5
  • 13

1 Answers1

0

I return negative -x value => Vector3(-x, y, z), seems like it fixes my issue.

bounxye
  • 183
  • 5
  • 13