Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Bayan

macrumors newbie
Original poster
Apr 13, 2012
23
0
I'm writing a code in which I ask the user to mark dots on a picture by touching the screen then I link each two to create a straight line..
What I want to do now is to calculate/measure the length of each line, is there a method to do that? or should I do it myself? if so, can someone give me a basic idea of how such method works?

Thanks in advance!
 
Distance

It's the pythagorean theorem:

Code:
 float distance = sqrtf( powf(x1-x2, 2) + powf(y1-y2, 2) );

where (x1, y1) and (x2, y2) are the two points that are connected.

Edit: Thanks for the tip, chown33 :)
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.