Distance Calculator
Calculate distances in 2D, 3D, and on Earth (latitude/longitude). Free online calculator with step-by-step solutions and canvas visualization.
Recent Calculations
Distance Calculator
This free online distance calculator computes the distance between two points in 2D Cartesian space, 3D Cartesian space, and on Earth using geographic coordinates. All calculations run entirely in your browser with no signup, no ads, and no server uploads.
$$d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}$$
This formula is a direct application of the Pythagorean theorem. For 3D space with coordinates $(x_1, y_1, z_1)$ and $(x_2, y_2, z_2)$, the distance extends naturally:
$$d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}$$
The slope of the line in 2D is given by $m = \frac{y_2 - y_1}{x_2 - x_1}$, and the angle from the horizontal is $\theta = \arctan(m)$.
$$d = 2R \cdot \arcsin\left(\sqrt{\sin^2\left(\frac{\Delta\phi}{2}\right) + \cos\phi_1 \cos\phi_2 \sin^2\left(\frac{\Delta\lambda}{2}\right)}\right)$$
where $R = 6371$ km is the mean Earth radius, $\phi$ is latitude, $\lambda$ is longitude, $\Delta\phi = \phi_2 - \phi_1$, and $\Delta\lambda = \lambda_2 - \lambda_1$.
$$d \approx R \cdot \sqrt{(\Delta\phi)^2 + (\cos\phi_m \cdot \Delta\lambda)^2}$$
where $\phi_m = (\phi_1 + \phi_2) / 2$ is the mean latitude. The Lambert formula typically agrees with more rigorous geodetic calculations to within 0.1%.
Frequently Asked Questions
Got questions about distance calculation, coordinate systems, or how to use this tool? We've got answers.
What is Euclidean distance?
Euclidean distance is the straight-line distance between two points in Euclidean space. In 2D, it's $d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}$. In 3D, it's $d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}$. It is derived from the Pythagorean theorem.
How does the Haversine formula work?
The Haversine formula calculates the great-circle distance between two points on a sphere given their latitudes and longitudes: $d = 2R \cdot \arcsin(\sqrt{\sin^2(\Delta\phi/2) + \cos\phi_1 \cos\phi_2 \sin^2(\Delta\lambda/2)})$, where $R$ is the Earth's radius (6371 km), $\Delta\phi$ is the latitude difference, and $\Delta\lambda$ is the longitude difference.
What is the difference between Euclidean and great-circle distance?
Euclidean distance assumes flat space and gives the straight-line distance through the Earth. Great-circle distance follows the Earth's curved surface. For short distances they are similar, but for long distances (e.g., New York to London), the great-circle distance is the correct travel distance along the Earth's surface.
How accurate is the Haversine formula?
The Haversine formula is accurate for most practical purposes with errors typically under 0.5%. For higher accuracy, Lambert's ellipsoidal formula accounts for Earth's oblateness (the WGS-84 ellipsoid), which can improve accuracy by up to 0.1% for long distances.
What coordinate format should I use?
You can use Decimal Degrees (e.g., 48.8566) or Degrees-Minutes-Seconds (DMS, e.g., 48° 51' 24"). For DMS, South latitudes and West longitudes should use the Southern/Western hemisphere toggle. Latitude ranges from -90° to 90°, longitude from -180° to 180°.
What is the Lambert ellipsoidal formula?
Lambert's formula approximates the distance on an ellipsoid (more accurate Earth shape) as $d \approx R \cdot \sqrt{(\Delta\phi)^2 + (\cos\phi_m \cdot \Delta\lambda)^2}$, where $\phi_m$ is the mean latitude. It accounts for Earth's flattening and is more accurate than the spherical Haversine formula.
Is this calculator private?
Yes. All calculations run locally in your browser. No data is transmitted, logged, or stored on any server. Your coordinates never leave your device.