Skip to content

Instantly share code, notes, and snippets.

View shancarter's full-sized avatar

Shan Carter shancarter

View GitHub Profile
@shancarter
shancarter / README.md
Last active June 7, 2019 11:42
Using d3 to generate SVGs in node.js

In order to generate some svg with d3 in node.js, you need a dom. This is a bare bones example of using jsdom for said dom.

@shancarter
shancarter / README
Created September 10, 2019 22:57
Images
Storing images.
@shancarter
shancarter / .block
Last active November 28, 2019 02:01
Mister Nester
license: mit
height: 700
@shancarter
shancarter / README.md
Last active November 28, 2019 02:02
Calculating the relative angle difference between two vectors

Here are the math-y bits, courtesy of @ch402:

var a2 = Math.atan2(source.y, source.x);
var a1 = Math.atan2(compare.y, compare.x);
var sign = a1 > a2 ? 1 : -1;
var angle = a1 - a2;
var K = -sign * Math.PI * 2;
var angle = (Math.abs(K + angle) < Math.abs(angle))? K + angle : angle;