Skip to content

Instantly share code, notes, and snippets.

@potpath
potpath / dijkstra.py
Last active March 1, 2023 23:40 — forked from econchick/gist:4666413
Python implementation of Dijkstra's Algorithm using heapq
import heapq
from collections import defaultdict
class Graph:
def __init__(self, n):
self.nodes = set(range(n))
self.edges = defaultdict(list)
self.distances = {}
@potpath
potpath / conesIntersection.py
Last active November 25, 2016 11:23
Check four 3D circular cones intersection
import ecos
import sys
import os
import numpy as np
from scipy.sparse import csc_matrix
_stdout = sys.stdout
def perpendicular_vector(v):
@potpath
potpath / isPositiveSpan.cpp
Last active August 29, 2015 14:07
check positive span for 4 fingers using Qhull
#include<Qhull.h>
#include<QhullFacetList.h>
using namespace orgQhull;
bool isPositiveSpan(const Point3d &n1,const Point3d &n2,const Point3d &n3,const Point3d &n4){
Qhull qhull;
realT points[12]={n1.x,n1.y,n1.z,n2.x,n2.y,n2.z,n3.x,n3.y,n3.z,n4.x,n4.y,n4.z};
qhull.runQhull("",3,4,points,"");
vector<QhullFacet> facets=qhull.facetList().toStdVector();
for(const QhullFacet &facet : qhull.facetList().toStdVector())
if(facet.getFacetT()->offset>=0) return false;
@potpath
potpath / grader.sh
Last active August 29, 2015 14:07
Simple grader written in shell script
#!/bin/bash
ext=sol
if [ "$#" -lt 1 ]
then
echo "Usage: $0 [executable] code [input_output_solution_folder]"
exit 1
fi
if [ -x "`which "$1"`" ]
@potpath
potpath / graspit.patch
Created September 4, 2014 05:22
patch to make GraspIt! 2.2 compilable in Ubuntu 14.04
diff -rupN Graspit/graspit-lib-LINUX.pro GraspitNew/graspit-lib-LINUX.pro
--- Graspit/graspit-lib-LINUX.pro 2012-04-21 01:03:59.000000000 +0700
+++ GraspitNew/graspit-lib-LINUX.pro 2014-09-04 12:06:38.646600227 +0700
@@ -21,7 +21,7 @@ LIBS += -lqhull
LIBS += -lSoQt -lCoin
#add utility libraries
-LIBS += -lGL -lpthread
+LIBS += -lGL -lpthread -ldl