Skip to content

Instantly share code, notes, and snippets.

@bmander
Created April 7, 2012 22:21
Show Gist options
  • Save bmander/2332471 to your computer and use it in GitHub Desktop.
Save bmander/2332471 to your computer and use it in GitHub Desktop.
biohazard symbol
//print biohazard symbol, at http://fab.cba.mit.edu/classes/S62.12/people/martinanderson.brandon/solver2.html
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){
var xprime = x-tx;
var yprime = y-ty;
return func(xprime,yprime);
}
}
function rotate(theta, func){
return function(x,y){
var xprime = Math.cos(theta)*x-Math.sin(theta)*y;
var yprime = Math.sin(theta)*x+Math.cos(theta)*y;
return func(xprime,yprime);
}
}
function union(funcs){
var metaargs=arguments;
return function(x,y) {
var ret=false;
for(var i=0; i<metaargs.length;i++){
ret = ret || metaargs[i](x,y);
}
return ret;
}
}
function cut( pos, neg ){
return function(x,y){ return pos(x,y) && !neg(x,y); };
}
function triple( func ){
return union(
rotate( 0,
func
),
rotate( 2*(2*Math.PI)/3,
func
),
rotate( 1*(2*Math.PI)/3,
func
)
);
}
function makering(inner, outer){
return cut(
makecircle(outer),
makecircle(inner)
);
}
function makerectangle(ll,bb,rr,tt){
return function(x,y){
return x>ll && x<rr && y>bb && y<tt;
}
}
function nothing(){
return function(x,y){return false};
}
var r=70;
var cutwidth=5;
var crescentid=0.8;
var highlight=0.92;
function crescent(){
return cut(makecircle(r),
translate(0,-r*0.21,
makecircle(r*crescentid)
)
);
}
function solids(){
return union(
triple(
translate( 0, -r, crescent() )
),
makering(r-15, r)
);
}
function finishcuts(){
return union( triple(
union(
translate(0,-r*1.21,
makering(r*crescentid*highlight, r*crescentid)
),
rotate(2*Math.PI/6,
makerectangle(-cutwidth/2,0,cutwidth/2,50)
)
)
), makecircle(20))
}
function skew(tx, ty, func){
return function(x,y){
var xprime = x-(tx*y*y);
var yprime = y-(ty*x*x);
return func(xprime,yprime);
}
}
function scale(sx, sy, func){
return function(x,y){
return func(x/sx, y/sy);
}
}
emit( translate(250,250,
scale(1.6,1.6,cut(
solids(),
finishcuts()
))
) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment