There are two points on a line segment.
The coordinate of A is A(x₁, y₁)
The coordinate of B is B(x₂, y₂)
Draw AE ⊥ BD
Here, The length of CD is (OD - OC).
i.e., CD = x₂ - x₁
Since AE || CD, so AE = x₂ - x₁
The length of BE is (BD - ED).
i.e., BE = y₂ - y₁
In ΔAEB, ∠AEB = 90°
By using Pythagoras Theorem,
(AB)² = (AE)² + (BE)²
(AB)² = (x₂ - x₁)² + (y₂ - y₁)²