Calculate Distance Between Two Points in Objective-C

Monday, June 30th, 2008

How to calculate the distance between two points.

CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2)
{
CGFloat dx = point2.x - point1.x;
CGFloat dy = point2.y - point1.y;
return sqrt(dx*dx + dy*dy );
};

Tags: , ,

2 Responses to “Calculate Distance Between Two Points in Objective-C”

  1. Recent URLs tagged Objectivec - Urlrecorder Says:

    [...] Recent public urls tagged “objectivec” → Calculate Distance Between Two Points in Objective-C [...]

  2. imobi Says:

    hi…

    You need more rest i think…

Leave a Reply

You must be logged in to post a comment.