How to use the @turf/turf.bearing function in @turf/turf

To help you get started, we’ve selected a few @turf/turf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uber / xviz / modules / builder / src / builders / helpers / xviz-trajectory-helper.js View on Github external
Math.sqrt(from.x * from.x + from.y * from.y),
    Math.PI / 2 - from.yaw,
    {units: 'meters'}
  );

  const toPoint = turf.destination(
    [to.longitude, to.latitude, to.altitude],
    Math.sqrt(to.x * to.x + to.y * to.y),
    Math.PI / 2 - to.yaw,
    {units: 'meters'}
  );

  const distInMeters = turf.distance(fromPoint, toPoint, {units: 'meters'});

  // Bearing is degrees from north, positive is clockwise
  const bearing = turf.bearing(fromPoint, toPoint);
  const bearingInRadians = turf.degreesToRadians(bearing);

  const diffZ = to.altitude + to.z - from.altitude - from.z;

  return [
    distInMeters * Math.sin(bearingInRadians),
    distInMeters * Math.cos(bearingInRadians),
    diffZ
  ];
}
/* eslint-enable complexity */
github ethantran / react-native-examples / src / screens / ARExample / utils.js View on Github external
export const getBearing = (coord1, coord2) => {
    const point1 = turf.point([coord1.longitude, coord1.latitude]);
    const point2 = turf.point([coord2.longitude, coord2.latitude]);
    const bearingInDegrees = turf.bearing(point1, point2);
    const bearingInRadians = turf.helpers.degreesToRadians(bearingInDegrees);
    return {
        bearingInDegrees,
        bearingInRadians
    };
};