Skip to content

Instantly share code, notes, and snippets.

View gordonwoodhull's full-sized avatar
🖋️
learning

Gordon Woodhull gordonwoodhull

🖋️
learning
View GitHub Profile
// Adapted from http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect/1968345#1968345
var eps = 0.0000001;
function between(a, b, c) {
return a-eps <= b && b <= c+eps;
}
function segment_intersection(x1,y1,x2,y2, x3,y3,x4,y4) {
var x=((x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*x4)) /
((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4));
var y=((x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*x4)) /
((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4));
@gordonwoodhull
gordonwoodhull / gvparse.hpp
Last active August 29, 2015 14:22
Parse graphviz graph description at C++ compile time using metaparse! (incomplete)
#define MPLLIBS_LIMIT_SEQUENCE_SIZE 7
#define MPLLIBS_LIMIT_STRING_SIZE 256
#include <mpllibs/metaparse/string.hpp>
#include <mpllibs/metaparse/keyword.hpp>
#include <mpllibs/metaparse/token.hpp>
#include <mpllibs/metaparse/lit_c.hpp>
#include <mpllibs/metaparse/any.hpp>
#include <mpllibs/metaparse/alphanum.hpp>
#include <mpllibs/metaparse/sequence.hpp>
@gordonwoodhull
gordonwoodhull / readme.md
Last active December 23, 2015 06:59 — forked from jlewin/readme.md

Want to fork your own gists? No fork button? No problem! Install this user script by clicking refork.user.js' "raw" link down below:

Starting with Chrome 21, userscript installation is blocked on all sites other than the Chrome Web Store. The new approach requires the user to download the script file and drag & drop it into the Extensions tab.

GW - updated to URL changes of 2013 which add the username