Skip to content

Instantly share code, notes, and snippets.

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);
@hfossli-agens
hfossli-agens / gist:4676773
Created January 30, 2013 20:45
dispatch_after with repeat / loop
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);
}