Skip to content

Instantly share code, notes, and snippets.

Avatar

Hermann Stamm-Wilbrandt Hermann-SW

View GitHub Profile
@Hermann-SW
Hermann-SW / perm.js
Last active Sep 23, 2022
Generating permutations (in order), with or without abortion
View perm.js
function nth(P) {
var n=P.length; var S = []; var fac=[1];
for(i=1; i<=n; ++i) { S.push(i); fac.push(i*fac[i-1]); }
var p=0;
for(i=0; i<P.length-1; ++i) {
var j = S.indexOf(P[i]);
p += j*fac[n-1-i];
S.splice(j, 1);
}
return p;
@Hermann-SW
Hermann-SW / zcat.html
Created Sep 13, 2022
"zcat C30.txt.gz" in browser JavaScript
View zcat.html
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript" src="pako.js"></script>
<script>
function reqListener () {
var originalInput = pako.ungzip(this.response,{ to: 'string' });
document.write("<pre>"+originalInput+"</pre>");
}
@Hermann-SW
Hermann-SW / octahedron.separating_circle.scad
Created Aug 6, 2022
Separating circle created from Octahedron by removing 6 of its 12 edges
View octahedron.separating_circle.scad
look_inside=false;
diff_last=false;
$vpr = [355, 55, 40];
$fn = 25;
$vpt = [0,0,0];
function map_3D(c) = [cos(c[0])*sin(c[1]), sin(c[0])*sin(c[1]), cos(c[1])];
sc = 7.745966692414834 ;
coords =[
[0,90]
, [90,90]
@Hermann-SW
Hermann-SW / difflast_question.scad
Created Aug 3, 2022
test OpenSCAD file for reddit/r/openscad question
View difflast_question.scad
difflast=false;
$vpr = [355, 45, 0];
$fn = 25;
$vpt = [0,0,0];
function map_3D(c) = [cos(c[0])*sin(c[1]), sin(c[0])*sin(c[1]), cos(c[1])];
sc = 7.745966692414834 ;
coords =[
[270,54.735610317245346]
, [270,32.84136619034721]
, [450,-10.947122063449068]
@Hermann-SW
Hermann-SW / ico.2.scad
Created Aug 2, 2022
dotCSAD icosaeder, prepared for OpenSCAD "animate"
View ico.2.scad
// require https://github.com/JustinSDK/dotSCAD
use <triangle/tri_subdivide.scad>
use <polyhedra/geom_icosahedron.scad>
use <surface/sf_solidifyT.scad>
icosahedron_detail = 0;
subdivided_n = 0;
radius = 10;
thickness = 1;
@Hermann-SW
Hermann-SW / C60.half.mirrors.animate.3.scad
Last active Aug 1, 2022
More than half of C60 fullerene vertices rotating, OpenSCAD with three mirrors
View C60.half.mirrors.animate.3.scad
$vpr = [ 340 , 45, 0 ];
$fn = 25;
$vpt = [0,-6.5,0];
function map_3D(c) = [cos(c[0])*sin(c[1]), sin(c[0])*sin(c[1]), cos(c[1])];
sc = 7.745966692414834 ;
coords =[
[270,54.735610317245346]
, [270,32.84136619034721]
, [90,-10.947122063449068]
, [90,10.947122063449068]
@Hermann-SW
Hermann-SW / C60.half.mirrors.animate.scad
Last active Aug 1, 2022
More than half of C60 fullerene vertices rotating, OpenSCAD with two mirrors
View C60.half.mirrors.animate.scad
$vpr = [ 340 , 45, 0 ];
$fn = 25;
$vpt = [0,3,0];
function map_3D(c) = [cos(c[0])*sin(c[1]), sin(c[0])*sin(c[1]), cos(c[1])];
sc = 7.745966692414834 ;
coords =[
[270,54.735610317245346]
, [270,32.84136619034721]
, [90,-10.947122063449068]
, [90,10.947122063449068]
@Hermann-SW
Hermann-SW / scad_calltree
Created Jul 30, 2022
Generate Graphviz dotfile from OpenSCAD "use" calltree
View scad_calltree
#/bin/bash
if [ "$2" = "" ]; then
echo "digraph G {"
echo "rankdir=LR"
echo "node [shape=none]"
fi
echo \"$2\" "->" \"$1\" "[label=\"`wc --lines $1 | cut -f1 -d\ `\"]"
for f in `grep "^use" $1 | cut -f2 -d\< | cut -f1 -d\>`
do
./scad_calltree `dirname $1`/$f $1
@Hermann-SW
Hermann-SW / wlog.js
Created Jun 25, 2022
OpenSCAD external NodeJS animation demo
View wlog.js
var fs = require("fs");
var writer;
function wait(ms) {
return new Promise(function (resolve) {
setTimeout(resolve, ms);
});
}
function rad2deg(r) {
return r / Math.PI * 180;
@Hermann-SW
Hermann-SW / calc60.ps
Created May 15, 2022
Determination of pentagon fold angle for C60 fullerene (truncated icosahedron)
View calc60.ps
%!
0 setlinewidth
/vertex { 2 copy 5 4 roll dup 4 1 roll
newpath 0 360 arc closepath
gsave 1.0 setgray fill grestore
stroke
12 ge {