Calculateur de longueur de segment
Résultats
Formules utilisées dans Calculateur de longueur de segment
In-Depth Tutorial: Calculateur de longueur de segment
A line segment is the straight portion of a line between two endpoints. Its length is the straight-line distance between those endpoints — measured by the distance formula:
d = √((x₂ − x₁)² + (y₂ − y₁)²)
This Segment Length Calculator takes the two endpoint coordinates and returns the segment's length. The formula is a direct application of the Pythagorean theorem to the horizontal and vertical differences between the points. This tutorial explains the derivation, walks through examples, and shows how segment length relates to displacement, distance, and the broader concept of metric.
How the formula comes from Pythagoras
Given two points P₁ = (x₁, y₁) and P₂ = (x₂, y₂), draw a right triangle whose:
- Horizontal leg has length |x₂ − x₁| (the difference in x-coordinates)
- Vertical leg has length |y₂ − y₁| (the difference in y-coordinates)
- Hypotenuse is the segment from P₁ to P₂
By the Pythagorean theorem: d² = (x₂ − x₁)² + (y₂ − y₁)². Taking the positive square root: d = √((x₂ − x₁)² + (y₂ − y₁)²).
The absolute value bars in the legs disappear when we square — squaring eliminates signs. So we can drop the absolute values in the formula.
Worked example 1 — first quadrant
Find the length of the segment from P₁ = (3, 1) to P₂ = (7, 4).
Δx = 7 − 3 = 4, Δy = 4 − 1 = 3.
d = √(4² + 3²) = √(16 + 9) = √25 = 5.
Notice this is the 3-4-5 right triangle hidden inside coordinate geometry.
Worked example 2 — negative coordinates
Find the length from P₁ = (−2, 1) to P₂ = (3, −4).
Δx = 3 − (−2) = 5, Δy = −4 − 1 = −5.
d = √(25 + 25) = √50 ≈ 7.07.
Subtracting a negative is the same as adding the positive — 3 − (−2) = 5, not 1. Same for Δy: −4 − 1 = −5, which squared is 25.
Worked example 3 — vertical segment
Find the length from P₁ = (5, 2) to P₂ = (5, 8).
Δx = 0, Δy = 6.
d = √(0 + 36) = 6.
For purely vertical (or horizontal) segments, one of the coordinate differences is 0, and the formula simplifies to just the absolute value of the other difference.
The 3D extension
For two 3D points P₁ = (x₁, y₁, z₁) and P₂ = (x₂, y₂, z₂):
d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)
The pattern extends: add the z-coordinate squared difference. In any number of dimensions, the formula has the same "sum of squared differences under a square root" form.
Distance vs displacement
Two related but distinct concepts:
- Distance (segment length): always a positive number. The magnitude of the segment. d = √(Δx² + Δy²).
- Displacement: a vector with both magnitude AND direction. Written as (Δx, Δy). Can be "negative" in either component.
This calculator computes the distance (length) — a scalar. To get the vector displacement, look at the signed differences (x₂ − x₁) and (y₂ − y₁) separately.
Properties of segment length
- Non-negative: length is always ≥ 0. The only "0-length" segment is one where both endpoints are the same point.
- Symmetric: length(P₁, P₂) = length(P₂, P₁). Direction does not matter.
- Triangle inequality: for any three points P, Q, R, length(P, R) ≤ length(P, Q) + length(Q, R). Going "through" Q is never shorter than going directly P to R.
These three properties are the defining axioms of a "metric space" — a generalization of distance to abstract mathematical spaces.
Related calculations
- Midpoint of segment: M = ((x₁+x₂)/2, (y₁+y₂)/2). See Distance and Midpoint Calculator.
- Slope of segment: m = (y₂−y₁)/(x₂−x₁). See Slope Calculator.
- Section point: finding a point dividing the segment in a given ratio. See Section Formula Calculator.
- Perpendicular bisector: the line that crosses the segment at its midpoint at 90°. See Segment Bisector Calculator.
Real-world applications
- Navigation. Computing straight-line distance between two GPS positions (for small distances on a flat-Earth approximation; spherical geometry for global scale).
- Physics — kinematics. Distance moved between two times = segment length between two position vectors.
- Computer graphics. Distance between any two screen pixels uses this formula directly.
- Robotics. Path planning algorithms use segment length to evaluate route lengths.
- Animation. Interpolating between two keyframes at constant speed requires computing segment length to map time to position.
Distance in non-Euclidean spaces
The Euclidean distance formula assumes a flat (Euclidean) coordinate plane. Other geometries use different distance formulas:
- Manhattan distance (taxicab): d = |Δx| + |Δy|. Distance along a grid (like Manhattan streets) rather than diagonal.
- Spherical distance (Earth-scale): use the haversine formula, which accounts for the Earth's curvature.
- Hyperbolic distance: used in special relativity and non-Euclidean geometries.
For everyday school and engineering work, the Euclidean formula is what you want.
Common mistakes
- Forgetting to square. The formula squares the differences, not just absolutes them. Forgetting to square gives a wrong (linear) result.
- Forgetting to square-root at the end. The Pythagorean form gives d², not d. Take √ at the end.
- Negative under the root. The expression (x₂−x₁)² + (y₂−y₁)² is always ≥ 0 because it's a sum of squares. If you got a negative, you made an algebra error.
- Mixing 2D and 3D formulas. 2D has 2 squared terms, 3D has 3. Using the wrong formula gives the wrong dimension answer.
Questions fréquentes – Calculateur de longueur de segment
La formule de distance : d = √((x₂−x₁)² + (y₂−y₁)²), dérivée du théorème de Pythagore appliqué aux différences horizontales et verticales.
Oui — la formule élève au carré les deux différences, donc les coordonnées négatives sont correctement prises en compte. Les points de tous les quadrants sont pris en charge.
La distance (longueur du segment) est toujours positive. Le déplacement est un vecteur avec direction — il peut être négatif. Cette calculatrice calcule la distance.
Oui — gratuit et illimité.