Skip to content

Instantly share code, notes, and snippets.

@tmpvar
tmpvar / round-corners.js
Last active August 29, 2015 14:00
polygon snippets
var roundCorner = function(p, c, n) {
var v = Vec2(1, 0);
var oangle = v.angleTo(p.subtract(c, true))
var ae1 = v.angleTo(c.subtract(p, true));
var ae2 = v.angleTo(n.subtract(c, true))
var range = (ae2 > ae1) ? ae2-ae1 : TAU-(ae1 - ae2);
oangle += TAU/4
@tmpvar
tmpvar / timestep.js
Last active August 29, 2015 14:01
in-memory datastore with rewind/forward support
function Timestep() {
this.start = Date.now();
this.ops = [];
this.store = {};
this.index = -1;
}
Timestep.prototype.op = function(type, path, value, store) {
var oldValue = null;
var loc = this.path(path);
@tmpvar
tmpvar / camp.js
Created May 27, 2014 23:07
campjs gcode generator with gcanvas
function main(ctx) {
ctx.toolDiameter = 1.6;
ctx.scale(-.1, -.1);
ctx.translate(-600, -135);
//ctx.map('-xyz');
// ctx.retract = 10;
// ctx.ramping = false;
ctx.depth= -2.5;
ctx.depthOfCut = .1;
@tmpvar
tmpvar / text2gcode.js
Last active August 29, 2015 14:01
turn TTF + text into a a toolpath
node text2gcode.js --font=/Users/tmpvar/Desktop/sg12-webfont.ttf "hello world"
Error 3427 error LNK2005: "public: __cdecl v8::Persistent<class v8::Object>::Persistent<class v8::Object>(void)" (??0?$Persistent@VObject@v8@@@v8@@QEAA@XZ) already defined in node.lib(node.exe) C:\Users\tmpvar\work\node-boosh\build\context2d-static.lib(context2d.obj) boosh
Error 3428 error LNK2005: "public: class v8::Object * __cdecl v8::Handle<class v8::Object>::operator*(void)const " (??D?$Handle@VObject@v8@@@v8@@QEBAPEAVObject@1@XZ) already defined in node.lib(node.exe) C:\Users\tmpvar\work\node-boosh\build\context2d-static.lib(context2d.obj) boosh
Error 3429 error LNK2005: "public: class v8::Object * __cdecl v8::Handle<class v8::Object>::operator->(void)const " (??C?$Handle@VObject@v8@@@v8@@QEBAPEAVObject@1@XZ) already defined in node.lib(node.exe) C:\Users\tmpvar\work\node-boosh\build\context2d-static.lib(context2d.obj) boosh
Error 3430 error LNK2005: "public: bool __cdecl v8::Handle<class v8::Object>::IsEmpty(void)const " (?IsEmpty@?$Handle@VObject@v8@@@v8@@QEBA_NXZ) already defined in node.lib(node.exe
@tmpvar
tmpvar / offset-minkowski-surface-nets.js
Last active August 29, 2015 14:02
offsetting adventures (run these with beefy!)
var Polygon = require('polygon');
var fc = require('fc');
var Vec2 = require('vec2');
var ndarray = require('ndarray');
var sn = require('surface-nets');
var cwise = require('cwise');
var fill = require('ndarray-fill');
var poly = new Polygon([
@tmpvar
tmpvar / intersect-lines.js
Created June 20, 2014 20:24
interesect a polygon with an expanding grid of lines
var Polygon = require('polygon');
var fc = require('fc');
var Vec2 = require('vec2');
var Line2 = require('line2');
var poly = new Polygon([
Vec2(-100, -100),
Vec2(100, -100),
Vec2(200, -200),
Vec2(100, 0),
@tmpvar
tmpvar / bitmap2gcode.js
Last active August 29, 2015 14:02
bitmap2gcode experiment
var context2d = require('context2d');
var Image = require('htmlimage');
var args = require('yargs')(process.argv.slice(2)).argv;
var img = new Image();
console.log(args);
if (!args.url) {
console.log('usage: node bitmap2gcode.js --url="http|file://path/to/thingy.png --dpi=90 --depth=5 --depthPerPass')
}
@tmpvar
tmpvar / remarks.md
Last active August 29, 2015 14:04
solidworks vs inventor pro 2015

initial remarks about inventor

  • rotation about a face seems to be an afterthought. As it stands you need to hold shift and middle mouse to rotate around the scene. Not sure if there is even a way to orient around a face or object. This is particularly frustrating in assembly mode when you want to see how parts are being constrained against each other and test those constraints.

this reminds me of every other horrible 3d tool that I've used that ends up landing you with a insanely rotated object that you have to hunt for a "reset this viewport for the love of god please!" button. Either that or deal with that fact that you're gimbal locked and just try to unwind the frantic mouse movements you just made.

@tmpvar
tmpvar / robust-split.js
Created July 28, 2014 16:14
attempt at robust-split for robust geometric predicates
var SPLITTER = +(Math.pow(2, 27) + 1.0)
var rsplit = function(a) {
var ret = new Array(2);
var c = SPLITTER*a
ret[1] = c - (c - a);
ret[0] = a - ret[1];
return ret;
}