ios - Method to check all points within a closed path -


i have 4 or more points make closed path. want each point in image within closed path. if there method this?

 - (bool)ispointcontain:(nsarray *)vertices point:(cgpoint)test {     nsuinteger nvert = [vertices count];     nsinteger i, j, c = 0;     cgpoint verti, vertj;      (i = 0, j = nvert-1; < nvert; j = i++) {         verti = [(nsvalue *)[vertices objectatindex:i] cgpointvalue];         vertj = [(nsvalue *)[vertices objectatindex:j] cgpointvalue];         if (( (verti.y > test.y) != (vertj.y > test.y) ) &&         ( test.x < ( vertj.x - verti.x ) * ( test.y - verti.y ) / ( vertj.y - verti.y ) + verti.x) )             c = !c;     }      return (c ? yes : no); }   nsarray *vertices = [nsarray arraywithobjects:                             [nsvalue valuewithcgpoint:cgpointmake(10, 40)],                             [nsvalue valuewithcgpoint:cgpointmake(30, 48)],                             [nsvalue valuewithcgpoint:cgpointmake(50, 80)],                             [nsvalue valuewithcgpoint:cgpointmake(45, 100)],                              nil                             ];  cgpoint point = cgpointmake(30, 28); if ([self ispointcontain:vertices point:point]) {     nslog(@"yes"); } else {     nslog(@"no"); } 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -