Skip to content

Instantly share code, notes, and snippets.

View arnholm's full-sized avatar

Carsten Arnholm arnholm

View GitHub Profile
@arnholm
arnholm / solid_math.md
Last active January 11, 2018 20:27
AngelCAD code (angelscript) - generate solid from math functions
// AngelCAD
double f(double sign, double x, double n)
{
   double xn  = pow(x,n);
   double x1n = pow(1-x,n);
   return sign*(xn/(xn+x1n) + 0.5);
}

shape@ main_shape()
@arnholm
arnholm / mayan_haab_15_inch.scad
Created January 4, 2018 14:01
Mayan Haab calendar - OpenSCAD
This file has been truncated, but you can view the full file.
// OpenSCAD script
extrude_height = 0.5;
scale_factor = 1.0;
linear_extrude(height=extrude_height)
scale(scale_factor)
mayan_haab_15_inch_dxf();
module mayan_haab_15_inch_dxf()
{
@arnholm
arnholm / wikipedia_csg.md
Last active May 6, 2019 07:57
AngelCAD code for Wikipedia CSG model

Drop with sweep (AngelCAD source code)

double pi = 4.0*atan(1.0);

// radius and height
double r(double t) { return 0.5*(1-cos(pi*t))*sin(pi*t) + 0.005; }
double z(double t) { return 80 + 80*cos(pi*t); }

// profile direction 
vec3d@ dir(double t, double exp) 

Cube minus sphere

shape@ main_shape()
{
   solid@ myShape = cube(size:100,center:true) - sphere(r:64);
   return myShape;
}

void main()
{