This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BOOL AGLineIntersection(AGLine l1, AGLine l2, AGPoint *out_pointOfIntersection) | |
{ | |
// http://stackoverflow.com/a/565282/202451 | |
AGPoint p = l1.start; | |
AGPoint q = l2.start; | |
AGPoint r = AGPointSubtract(l1.end, l1.start); | |
AGPoint s = AGPointSubtract(l2.end, l2.start); | |
double s_r_crossProduct = AGPointCrossProduct(r, s); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void dispatch_repeated_internal(dispatch_time_t firstPopTime, double intervalInSeconds, dispatch_queue_t queue, void(^work)(BOOL *stop)) | |
{ | |
__block BOOL shouldStop = NO; | |
dispatch_time_t nextPopTime = dispatch_time(firstPopTime, (int64_t)(intervalInSeconds * NSEC_PER_SEC)); | |
dispatch_after(nextPopTime, queue, ^{ | |
work(&shouldStop); | |
if(!shouldStop) | |
{ | |
dispatch_repeated_internal(nextPopTime, intervalInSeconds, queue, work); | |
} |