Instantly share code, notes, and snippets.

# jumpjack jumpjack

Last active August 29, 2024 09:59
Find the intersections (two points) of two circles, if they intersect at all
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 // based on the math here: // http://math.stackexchange.com/a/1367732 // x1,y1 is the center of the first circle, with radius r1 // x2,y2 is the center of the second ricle, with radius r2 function intersectTwoCircles(x1,y1,r1, x2,y2,r2) { var centerdx = x1 - x2; var centerdy = y1 - y2; var R = Math.sqrt(centerdx * centerdx + centerdy * centerdy); if (!(Math.abs(r1 - r2) <= R && R <= r1 + r2)) { // no intersection
Last active July 23, 2024 16:01
Snippet to convert html table to json (to be used with google chrome or similiar)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 function tableToJson(table) { var data = []; // first row needs to be headers var headers = []; for (var i=0; i
Created May 9, 2016 19:11
OpenCV SIFT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 import cv2 import numpy as np from matplotlib import pyplot as plt # Import our game board canvas = cv2.imread('./data/box_med.jpg') # Import our piece (we are going to use a clump for now) piece = cv2.imread('./data/piece_small.jpg') # Pre-process the piece