Hello I am trying to do a calculator of finding the distance between 2 points. Everything works properly. I just want to make sure that my math is correct for the calculations. I will give you 2 coordinates to plug in and tell me if it is right or wrong. Thanks.
Test Coordinates: lat1: 27.95094 lng1: -82.45404
lat2: 27.9659 lng2: -82.8001
Test Results:
21.13 Miles
I just want to check that I am getting the correct calculations from 1 point to the next or if my math is incorrect. Thanks.
function distance(lat1, lng1, lat2, lng2, unit) {
var radlat1 = Math.PI * lat1/180;
var radlat2 = Math.PI * lat2/180;
var theta = lng1-lng2;
var radtheta = Math.PI * theta/180;
var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta);
if (dist > 1) {
dist = 1;
}
dist = Math.acos(dist);
dist = dist * 180/Math.PI;
dist = dist * 60 * 1.1515;
if (unit=='miles') { dist = (dist * 0.8684) * 1.15077945 }
return dist;
}
travel = distance(lat1, lng1, results.features[0].center[1], results.features[0].center[0], 'miles');
travel = parseInt(travel * 100)/100;
Yes, you seem to have implemented the Haversine formula correctly ( https://en.wikipedia.org/wiki/Haversine_formula )
Firebase Cloud Functions: PubSub, "res.on is not a function"
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
So I have a website about the NBA and the problem is there is 30 teams in the NBAWhen I make a nav bar it takes up half the page because there is 30 teams lol
I have a collection called imported_products with documents as following,
I want to implement regular expression in ObjectBox databaseSomething like -
Want to improve this question? Update the question so it's on-topic for Stack Overflow