Skip to content

Instantly share code, notes, and snippets.

View Alexander-0x80's full-sized avatar

Alexander Malkosh Alexander-0x80

View GitHub Profile
@Alexander-0x80
Alexander-0x80 / triangulate.js
Last active January 5, 2016 19:18 — forked from alanchrt/triangulate.js
Triangulation of three points and radii
function distance(p1, p2) {
// Find the distance between two points
return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
};
function intersect(c1, r1, c2, r2) {
// Find the points of intersection for two circles
// Based on: http://stackoverflow.com/a/3349134
var d = distance(c1, c2);
if (d > r1 + r2) // Circles do not overlap