springyui.js
function intersect_line_line(p1, p2, p3, p4) {
		var denom = ((p4.y - p3.y)*(p2.x - p1.x) - (p4.x - p3.x)*(p2.y - p1.y));

		// lines are parallel
		if (denom === 0) {
			return false;
		}

		var ua = ((p4.x - p3.x)*(p1.y - p3.y) - (p4.y - p3.y)*(p1.x - p3.x)) / denom;
		var ub = ((p2.x - p1.x)*(p1.y - p3.y) - (p2.y - p1.y)*(p1.x - p3.x)) / denom;

		if (ua < 0 || ua > 1 || ub < 0 || ub > 1) {
			return false;
		}

		return new Springy.Vector(p1.x + ua * (p2.x - p1.x), p1.y + ua * (p2.y - p1.y));
	}
function intersect_line_line(p1, p2, p3, p4) {
		var denom = ((p4.y - p3.y)*(p2.x - p1.x) - (p4.x - p3.x)*(p2.y - p1.y));

		// lines are parallel
		if (denom === 0) {
			return false;
		}

		var ua = ((p4.x - p3.x)*(p1.y - p3.y) - (p4.y - p3.y)*(p1.x - p3.x)) / denom;
		var ub = ((p2.x - p1.x)*(p1.y - p3.y) - (p2.y - p1.y)*(p1.x - p3.x)) / denom;

		if (ua < 0 || ua > 1 || ub < 0 || ub > 1) {
			return false;
		}

		return new Springy.Vector(p1.x + ua * (p2.x - p1.x), p1.y + ua * (p2.y - p1.y));
	}
function intersect_line_line ( p1 , p2 , p3 , p4 ) { var denom = ( ( p4 . y - p3 . y ) * ( p2 . x - p1 . x ) - ( p4 . x - p3 . x ) * ( p2 . y - p1 . y ) ) ; // lines are parallel if ( denom === 0 ) { return false ; } var ua = ( ( p4 . x - p3 . x ) * ( p1 . y - p3 . y ) - ( p4 . y - p3 . y ) * ( p1 . x - p3 . x ) ) / denom ; var ub = ( ( p2 . x - p1 . x ) * ( p1 . y - p3 . y ) - ( p2 . y - p1 . y ) * ( p1 . x - p3 . x ) ) / denom ; if ( ua < 0 || ua > 1 || ub < 0 || ub > 1 ) { return false ; } return new Springy . Vector ( p1 . x + ua * ( p2 . x - p1 . x ) , p1 . y + ua * ( p2 . y - p1 . y ) ) ; }
helpers for figuring out where to draw arrows
helpers for figuring out where to draw arrows