Skip to content

Instantly share code, notes, and snippets.

@bmander
bmander / circle.js
Created April 13, 2012 00:39
circle
//demo of the interactive pointer
function translate(tx, ty, func){
return function(x,y){
var xprime = x-tx;
var yprime = y-ty;
return func(xprime,yprime);
}
}
@bmander
bmander / polyline.js
Created April 13, 2012 04:31
polynomial line fitting
function translate(tx, ty, func){
return function(x,y){
var xprime = x-tx;
var yprime = y-ty;
return func(xprime,yprime);
}
}
function rotate(theta, func){
@bmander
bmander / mandelbrot.js
Created April 16, 2012 22:14
Mandelbrot set
function mandlebrot(x0,y0){
var x = 0
var y = 0
var xtemp;
var iteration = 0
var max_iteration = 20
while( x*x + y*y < 4 && iteration < max_iteration ) //Remember: 4 == (2*2)
{
@bmander
bmander / rawimu.ino
Created May 2, 2012 15:41
minimal arduino firmware to pipe accelerometer values from sparkfun SEN-10121 (serial 6DOF breakout) to serial
#define ADXL345_ADDR_ALT_LOW 0x53
#define FIMU_ACC_ADDR ADXL345_ADDR_ALT_LOW
#define ADXL345_POWER_CTL 0x2d
#define ADXL345_DATAX0 0x32
#define TO_READ (6)
#include <Wire.h>
int accelx;
int accely;
@bmander
bmander / sampleexp.pde
Created May 9, 2012 00:51
print probability density function and a samples of the exponential distribution
float sc;
float tau;
void setup(){
size(500,500);
smooth();
strokeWeight(1);
background(255);
sc = height*10;
@bmander
bmander / lumpycircle.js
Created May 15, 2012 15:54
lumpy circle
function makecircle(r){
return function(x,y){
return Math.pow(x,2) + Math.pow(y,2) < Math.pow(r,2);
}
}
function translate(tx, ty, func){
return function(x,y){
//make lumpy circles
function makecircle(r){
return function(x,y){
return Math.pow(x,2) + Math.pow(y,2) < Math.pow(r,2);
}
}
function translate(tx, ty, func){
return function(x,y){
@bmander
bmander / rotatecamera.pde
Created May 18, 2012 22:30
straightforward click drag to rotate camera around object
float theta;
float phi;
float r;
void setup(){
size(640, 360, P3D);
smooth();
theta=0;
phi=0;
r=100;
@bmander
bmander / sphere.js
Created May 19, 2012 00:30
jscad sphere
function makesphere(r){
return function(x,y,z){
return Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2) < Math.pow(r,2);
}
}
emit( makesphere(90) );
@bmander
bmander / lumpysphere.js
Created May 20, 2012 22:32
sphere bulged with gaussian
function dist(x,y,z){
return Math.pow(Math.pow(x,2)+Math.pow(y,2)+Math.pow(z,2),0.5);
}
function max(a,b){
if(a>b){
return a;
}else{
return b;
}