Advanced Math Module
The advanced_math
module is a PubNub Functions utility for distance calculations.
Distance calculation methods
Use getDistance()
to return the distance, in miles, between two latitude/longitude coordinates.
Usage: getDistance(lat1, lon1, lat2, lon2)
where:
lat1
: latitude of the first pointlon1
: longitude of the first pointlat2
: latitude of the second pointlon2
: longitude of the second point
const advancedMath = require('advanced_math');
const distanceInMiles = advancedMath.getDistance(43.7001100, -79.4163000, 37.7749300, -122.4194200);
Degrees to radians
Use deg2rad()
to convert degrees to radians.
Usage: deg2rad(deg)
where:
deg
: degrees to convert
const advancedMath = require('advanced_math');
const radians = advancedMath.deg2rad(30);
Functions support
Functions provides a rich set of tools, and this documentation may not cover every situation. If you need help with a case not covered here, please contact PubNub Support.