This file contains hidden or 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
#include "lex.h" | |
#include <iostream> | |
struct ParserState { | |
lex::UserFnRegistry<const char*> user_fns; | |
std::vector<double> stack; | |
void push( const double & v ){ | |
stack.push_back( v ); |
This file contains hidden or 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
#pragma once | |
#include <array> | |
#include <tuple> | |
#include <iostream> | |
// use this namespace to expose operators | |
namespace ostream_helpers { | |
namespace { |
This file contains hidden or 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
''' | |
[email protected] | |
A pretty small 3D IK solver, < 100 lines of code but > 100 lines of comments. | |
Low dependency (numpy, opencv-python, matplotlib) and includes visualization. | |
Not particularly fast. | |
Solves for joint rotations needed in a kinematic skeleton to minimize errors of a set | |
of end-effectors with respect to a corresponding set of target positions. Assumes |
This file contains hidden or 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
'''Finite difference Jacobians | |
Author: James Gregson | |
Date: 2020-10-04 | |
Utility function to differentiate numeric functions with finite differences. | |
Useful for checking analytically derived Jacobian & gradient computations. | |
See bottom of file for example usage. |
This file contains hidden or 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 unittest | |
import numpy as np | |
import scipy.sparse as sparse | |
class Filter2D: | |
def __init__( self, offy, offx, vals ): | |
'''2D filtering operation with spatial, fourier and matrix features | |
Args: | |
- offy (integer sequence): vertical offsets of filter coefficients |
This file contains hidden or 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
'''Very simplified JSON-RPC server with endpoint registration | |
Try with: | |
curl -X POST -H "Content-type: application/json" -d '{"jsonrpc": "2.0", "id": 1, "method": "say_hello", "params": {"name": "James", "age": 11}}' http://127.0.0.1:8000 | |
curl -X POST -H "Content-type: application/json" -d '{"jsonrpc": "2.0", "id": 1, "method": "say_hello", "params": {"name": "James"}}' http://127.0.0.1:8000 | |
curl -X POST -H "Content-type: application/json" -d '{"jsonrpc": "2.0", "id": 1, "method": "say_hello", "params": ["James", 10]}' http://127.0.0.1:8000 | |
curl -X POST -H "Content-type: application/json" -d '{"jsonrpc": "2.0", "id": 1, "method": "say_hello", "params": ["James"]}' http://127.0.0.1:8000 | |
''' |
This file contains hidden or 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
from typing import * | |
import time | |
import numpy as np | |
import scipy.sparse as sparse | |
import scipy.sparse.linalg as spla | |
def build_cotan_laplacian( points: np.ndarray, tris: np.ndarray ): | |
a,b,c = (tris[:,0],tris[:,1],tris[:,2]) | |
A = np.take( points, a, axis=1 ) | |
B = np.take( points, b, axis=1 ) |
This file contains hidden or 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 inspect | |
def contract( expects=[], ensures=[] ): | |
def func_wrapper( func ): | |
return Contract(function=func,preconditions=expects,postconditions=ensures ) | |
return func_wrapper | |
class Contract: | |
class Args: |
This file contains hidden or 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 time | |
import base64 | |
from http.server import BaseHTTPRequestHandler, HTTPServer | |
class MyHandler(BaseHTTPRequestHandler): | |
def do_HEAD(self): | |
self.send_response(200) | |
self.send_header('Content-type', 'text/html') | |
self.end_headers() |
This file contains hidden or 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 http.server import BaseHTTPRequestHandler,HTTPServer | |
import io | |
import socket | |
import time | |
capture0 = None | |
capture1 = None |
NewerOlder