Flutter/ARKit - Show node on GPS location

120 Views Asked by At

Would like to show object on GPS location using ARKit in Flutter. I get my position from Geolocator.getCurrentPosition. Then I calculate distance and bearing also using Geolocator

double distance = Geolocator.distanceBetween(position.latitude, position.longitude, g.latitude, g.longitude);
double bearing = Geolocator.bearingBetween(position.latitude, position.longitude, g.latitude, g.longitude);

Then I calculate device bearing towards object using compass and return radians:

double myBearing = (bearing - _compassDirection) * degrees2Radians;

To place object into ArKitView I calculate position as follow:

double x = distance * cos(myBearing);
double y = 0.0;
double z = 1 - distance * sin(myBearing);

ARKitNode(
  position: vector.Vector3(x, y, z),
  eulerAngles: vector.Vector3.zero(),
);

Unfortunatelly object is showing up on very wrong locations. I am sure I am missing something in calculation. Thank you for your help!

0

There are 0 best solutions below