diff --git a/Calculators/Geodesic-Distance-Calculator/README.md b/Calculators/Geodesic-Distance-Calculator/README.md new file mode 100644 index 000000000..53d621ae0 --- /dev/null +++ b/Calculators/Geodesic-Distance-Calculator/README.md @@ -0,0 +1,17 @@ +#

Geodesic Distance Calculator

+ +## Description :- + +Calculates the geodesic distance between two points on an ellipsoid. +Inputs: Coordinates of the two points (latitude and longitude). +Outputs: Geodesic distance, path on the ellipsoid. + +## Tech Stacks :- + +- HTML +- CSS +- JavaScript + +## Screenshots :- + +![Image](https://github.com/Rakesh9100/CalcDiverse/assets/154527778/2c087898-3a03-4f59-a2d1-27c9c2a17b66) diff --git a/Calculators/Geodesic-Distance-Calculator/index.html b/Calculators/Geodesic-Distance-Calculator/index.html new file mode 100644 index 000000000..6fc7a2dcf --- /dev/null +++ b/Calculators/Geodesic-Distance-Calculator/index.html @@ -0,0 +1,25 @@ + + + + + + + Geodesic Distance Calculator + + +
+

Geodesic Distance Calculator

+ + + + + + + + + +
+
+ + + diff --git a/Calculators/Geodesic-Distance-Calculator/script.js b/Calculators/Geodesic-Distance-Calculator/script.js new file mode 100644 index 000000000..7742bbeb3 --- /dev/null +++ b/Calculators/Geodesic-Distance-Calculator/script.js @@ -0,0 +1,25 @@ +function toRadians(degrees) { + return (degrees * Math.PI) / 180; +} + +function calculateGeodesicDistance() { + const lat1 = parseFloat(document.getElementById("lat1").value); + const lon1 = parseFloat(document.getElementById("lon1").value); + const lat2 = parseFloat(document.getElementById("lat2").value); + const lon2 = parseFloat(document.getElementById("lon2").value); + const resultDiv = document.getElementById("result"); + + const R = 6371; // Radius of the Earth in kilometers + const dLat = toRadians(lat2 - lat1); + const dLon = toRadians(lon2 - lon1); + const a = + Math.sin(dLat / 2) * Math.sin(dLat / 2) + + Math.cos(toRadians(lat1)) * + Math.cos(toRadians(lat2)) * + Math.sin(dLon / 2) * + Math.sin(dLon / 2); + const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); + const distance = R * c; + + resultDiv.innerText = `Geodesic Distance: ${distance.toFixed(2)} km`; +} diff --git a/Calculators/Geodesic-Distance-Calculator/style.css b/Calculators/Geodesic-Distance-Calculator/style.css new file mode 100644 index 000000000..9c4ec10d5 --- /dev/null +++ b/Calculators/Geodesic-Distance-Calculator/style.css @@ -0,0 +1,65 @@ +body { + font-family: Arial, sans-serif; + background: linear-gradient(135deg, #72edf2, #5151e5); + color: #333; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + margin: 0; +} + +.calculator { + background: rgba(255, 255, 255, 0.9); + border-radius: 15px; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); + padding: 30px; + text-align: center; + max-width: 400px; + width: 100%; +} + +h1 { + color: #333; + font-size: 24px; + margin-bottom: 20px; +} + +label { + display: block; + font-weight: bold; + margin-top: 15px; + color: #555; +} + +input { + width: 100%; + padding: 10px; + margin-top: 5px; + border: 1px solid #ddd; + border-radius: 5px; + box-sizing: border-box; + font-size: 16px; +} + +button { + background: #5151e5; + color: #fff; + border: none; + border-radius: 5px; + padding: 10px 20px; + font-size: 16px; + cursor: pointer; + margin-top: 20px; + transition: background 0.3s; +} + +button:hover { + background: #3333cc; +} + +#result { + margin-top: 20px; + font-size: 18px; + color: #333; +} diff --git a/index.html b/index.html index 2f191bd85..78f75d4d7 100644 --- a/index.html +++ b/index.html @@ -1254,6 +1254,20 @@

Calculates the nth root of a given number upto n precision.

+
+
+

Geodesic Distance Calculator

+

Calculate the geodesic distance between two points on an ellipsoid.

+ +
+

Geometric Progression Calculator