ios - Objective C compare two CGPoint to see if they are close? -


so location of touch using

cgpoint location = [touch locationinview:self.view]; 

now want check location on next touch see if locations close, 25 points on x or y axis.

there few posts show how compare if 2 touches equivalent there calculate distance between multiple points? info awesome.

to estimate distance between 2 cgpoints, can make use of simple pythagorean formula:

cgfloat dx = (p2.x - p1.x); cgfloat dy = (p2.y - p1.y); cgfloat distance = sqrt((dx * dx) + (dy * dy)); 

Comments