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
def rotation_matrix_to_quaternion(R): | |
"""Convert input 3x3 rotation matrix to unit quaternion. | |
Assuming an orthogonal 3x3 matrix ℛ rotates a vector v such that | |
v' = ℛ * v, | |
we can also express this rotation in terms of a unit quaternion R such that |
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*as e from"three";import{Ray as t,Plane as n,MathUtils as s,EventDispatcher as r,Vector3 as i,MOUSE as o,TOUCH as a,Quaternion as l,Spherical as c,Vector2 as h}from"three";class d{static idGen=0;constructor(e,t){let n,s;this.promise=new Promise(((e,t)=>{n=e,s=t}));const r=n.bind(this),i=s.bind(this);e(((...e)=>{r(...e)}).bind(this),(e=>{i(e)}).bind(this)),this.abortHandler=t,this.id=d.idGen++}then(e){return new d(((t,n)=>{this.promise=this.promise.then(((...n)=>{const s=e(...n);s instanceof Promise||s instanceof d?s.then(((...e)=>{t(...e)})):t(s)})).catch((e=>{n(e)}))}),this.abortHandler)}catch(e){return new d((t=>{this.promise=this.promise.then(((...e)=>{t(...e)})).catch(e)}),this.abortHandler)}abort(e){this.abortHandler&&this.abortHandler(e)}}class p extends Error{constructor(e){super(e)}}!function(){const e=new Float32Array(1),t=new Int32Array(e.buffer)}();const u=function(){const e=new Float32Array(1),t=new Int32Array(e.buffer);return function(n){return e[0]=n,t[0]}}(),m=function(e,t,n=!0){const s=n |
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
#!/usr/bin/env python | |
import os | |
import sys | |
import nbformat | |
import nbformat.sign | |
from nbconvert.preprocessors import ExecutePreprocessor | |
from nbconvert.preprocessors.execute import CellExecutionError | |
import warnings | |
STDIO_CODE = u''' |
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
#!/usr/bin/env python | |
""" | |
This tool simplifies a LaTeX project by removing unused files and removing comments. | |
It also merges tex files into a single file and optionally crops and downscales images | |
to reduce the size of the output. It is useful when you want to prepare an ArXiv submission. | |
Usage: | |
export-latex.py <path> <output> [options] | |
Arguments: |
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 numpy as np | |
def compute_sdf_polygon(vertices, points): | |
vertices = vertices[:, None, ...] | |
points = points[None, :, ...] | |
d = np.sum((points[0] - vertices[0]) * (points[0] - vertices[0]), -1) | |
vert_offset = np.concatenate([vertices[-1:], vertices[:-1]], 0) | |
e = vert_offset - vertices | |
w = points - vertices | |
b = w - e * np.clip(np.sum(w * e, -1) / np.sum(e * e, -1), 0., 1.)[..., None] |