How to find the distance between two CG points?

You can use the hypot() or hypotf() function to calculate the hypotenuse. Given two points p1 and p2:

CGFloat distance = hypotf(p1.x - p2.x, p1.y - p2.y);

And that’s it.

Leave a Comment