Skip to content

Instantly share code, notes, and snippets.

View mikolalysenko's full-sized avatar

Mikola Lysenko mikolalysenko

View GitHub Profile
'use strict'
var gauss = require('gauss-random')
var uniq = require('uniq')
var alphaShape = require('alpha-shape')
var graphToPolygons = require('planar-graph-to-polyline')
var delaunay = require('delaunay-triangulate')
var circumradius = require('circumradius')
function coalphaComplex(alpha, points) {
//Sets all components equal, works in place
function toRGBA (glyph) {
return ndarray(
glyph.data,
[glyph.shape[0], glyph.shape[1], 4],
[glyph.stride[0], glyph.stride[1], 0],
glyph.offset)
}
var ops = require('ndarray-ops')
function toRGBA (glyph) {
var output = ndarray(
new Uint8ClampedArray(glyph.size*4),
[glyph.shape[0], glyph.shape[1], 4])
var glyphPad = ndarray(
glyph.data,
var ops = require('ndarray-ops')
function toRGBA (glyph) {
var output = ndarray(
new Uint8ClampedArray(glyph.size*4),
[glyph.shape[0], glyph.shape[1], 4])
for(var i=0; i<3; ++i) {
ops.assign(output.pick(-1,-1,i), glyph)
}
ops.assigns(output.pick(-1,-1,3), 0xff)
@mikolalysenko
mikolalysenko / index.js
Last active August 29, 2015 14:18
requirebin sketch
//Hacky experiment with Ken Clarkson-style L1 shortest path finding
// This sketch just visualizes the graph/data structures which are built by the algorithm.
// The green node is the source node and the red is the sink
// Magenta nodes/edges are nodes in the graph which is searched
// The total number of magenta nodes/edges is at most O(n log(n)), n = number of corners
// Worst case time to search the graph using A* is O(n log^2(n)), but in practice it might
// be way faster.
//
// Reference:
// "Rectilinear shortest paths through polygonal obstacles". K.L. Clarkson, S. Kapoor, P.M. Vaidya.

I should not tell you of Berenice, the unjust city, which crowns with triglyphs, abaci, metopes the gears of its meat-grinding machines (the men assigned to polishing, when they raise their chins over the balustrades and contemplate the atria, stairway, porticos, feel even more imprisoned and short of stature). Instead, I should tell you of the hidden Berenice, the city of the just, handling makeshift materials in the shadowy rooms behind the shops and beneath the stairs, linking a network of wires and pipes, pulleys and pistons and counterweights that infiltrates like a climbing plant among the great cogged wheels (when they jam, a subdued ticking gives warning that a new precision mechanism is governing the city). Instead of describing to you the perfumed pools of the baths where the unjust of Berenice recline and weave their intrigues with rotund eloquence and observe with a proprietary eye the rotund flesh of the bathing odalisques, I should say to you how the just, always cautious to evade the spying syc

@mikolalysenko
mikolalysenko / index.js
Created March 18, 2015 23:05
requirebin sketch
var createScene = require('gl-plot3d')
var createMesh = require('gl-mesh3d')
var bunny = require('bunny')
var sc = require('simplicial-complex')
var scene = createScene()
var mesh = createMesh({
gl: scene.gl,
cells: sc.skeleton(bunny.cells, 1),
@mikolalysenko
mikolalysenko / index.js
Last active August 29, 2015 14:17
requirebin sketch
var createScene = require('gl-plot3d')
var createMesh = require('gl-mesh3d')
var bunny = require('bunny')
var scene = createScene()
var mesh = createMesh({
gl: scene.gl,
cells: bunny.cells,
positions: bunny.positions,
@mikolalysenko
mikolalysenko / index.js
Last active August 29, 2015 14:17
requirebin sketch
var createScene = require('gl-plot3d')
var createSurface = require('gl-surface3d')
var ndarray = require('ndarray')
var scene = createScene()
var size = 64
var coords = [
ndarray(new Float32Array(4*(size+1)*(size+1)), [2*size+1,2*size+1]),
ndarray(new Float32Array(4*(size+1)*(size+1)), [2*size+1,2*size+1]),
@mikolalysenko
mikolalysenko / index.js
Last active August 29, 2015 14:17
requirebin sketch
var createScene = require('gl-plot3d')
var createSurfacePlot = require('gl-surface3d')
var ndarray = require('ndarray')
var fill = require('ndarray-fill')
var diric = require('dirichlet')
var scene = createScene()
//Initialize surface data
var field = ndarray(new Float32Array(512*512), [512,512])