AlgoScope

Distance

Euclidean distance sqrt(dx^2 + dy^2). Compare squared distances to avoid the root.

Computational geometry, mathematics, beginner
Squared distance 25, length about 5.AB
Squared distance 25, length about 5.AB

Plane Geometry: Points, a vector and a distance

Decision, step 2 of 4

Distance: the segment is the hypotenuse of a right triangle with legs 4 and 3, so the squared length is 4^2 + 3^2 = 25 and the length is sqrt(25), about 5. Comparing squared distances avoids the square root and stays exact in integers.

Cost

Space
O(1)

Leads to

Topics that need this one first.

Taught by the same lesson

Plane Geometry covers these too, in the same run.