initial commit
This commit is contained in:
18
server/math.js
Normal file
18
server/math.js
Normal file
@@ -0,0 +1,18 @@
|
||||
export function bearing (latlng1, latlng2) {
|
||||
const rad = Math.PI / 180
|
||||
const lat1 = latlng1.gpsLatitude * rad
|
||||
const lat2 = latlng2.gpsLatitude * rad
|
||||
const lon1 = latlng1.gpsLongitude * rad
|
||||
const lon2 = latlng2.gpsLongitude * rad
|
||||
const y = Math.sin(lon2 - lon1) * Math.cos(lat2)
|
||||
const x = Math.cos(lat1) * Math.sin(lat2) -
|
||||
Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1)
|
||||
|
||||
const bearing = ((Math.atan2(y, x) * 180 / Math.PI) + 360) % 360
|
||||
return bearing >= 180 ? bearing - 360 : bearing
|
||||
}
|
||||
|
||||
export function removeMilis(date) {
|
||||
date.setSeconds(date.getSeconds(), 0);
|
||||
return date;
|
||||
}
|
||||
Reference in New Issue
Block a user