Merge branch 'sa-rounding' of https://github.com/rsheldiii/openSCAD-projects into sa-rounding

This commit is contained in:
Bob - Home - Windows 2017-09-25 00:07:48 -04:00
commit 1d2187223c
2 changed files with 68 additions and 0 deletions

View File

@ -12,7 +12,12 @@
* Pregenerated keysets for DCS (rounded tops too intense) WITH rounded spacebar [ ] 60% [ ] TKL [ ] full * Pregenerated keysets for DCS (rounded tops too intense) WITH rounded spacebar [ ] 60% [ ] TKL [ ] full
* Add inset stem to all profiles that need it (DCS?) * Add inset stem to all profiles that need it (DCS?)
* generate dishes via math? kind of hard * generate dishes via math? kind of hard
<<<<<<< HEAD
* customizer version where everything is copy/pasted in * customizer version where everything is copy/pasted in
=======
* sideways cylindrical dish needs to be used for some spacebars but not others. currently none of them use it
* customizer version where everything is copy/pasted in. needs to be last.
>>>>>>> 0013b2aa1744926a5f9f9f7ce11d46d0f986dd69
*/ */
use <key.scad> use <key.scad>

63
polyhedrons.scad Normal file
View File

@ -0,0 +1,63 @@
function cat(L1, L2) = [for (i=[0:len(L1)+len(L2)-1])
i < len(L1)? L1[i] : L2[i-len(L1)]] ;
module dish(type = "sphere", sides = 10, length = 10){
//TODO length scaling
function pointyDish(x,y) = (x == 0 || y == 0 || x== sides || y == sides ) ? 0 : abs(5-x) + abs(5-y);
/*
matrix looks like this:
[
[0, 0, 0], [0, 1, 0], [0, 2, 0],
[1, 0, 0], [1, 1, 0], [1, 2, 0],
[2, 0, 0], [2, 1, 0], [2, 2, 0]
]
*/
// row is how many verts are actually in a row
row = sides + 1;
// first make an x-first matrix of points. (0,0), (1,0) etc
matrix = cat([
for ( y = [0 : sides], x = [ 0 : sides ]) [x, y, pointyDish(x,y)]
], [[sides / 2, sides / 2, 0]]);
echo(matrix);
echo(matrix[121]);
echo(len(matrix));
translate([sides / 2, sides / 2, 0]) sphere(r=1);
// then make 2 faces for each set of four points: (0,1,4), (0,4,3)
// sides - 1 because we are doing this fromt the bottom left corner and extending up and out 1 vertex
// so the rightmost and topmost vertexes are already covered
f1 = [
for (y = [0 : sides-1], x = [ 0 : sides-1 ], num = [0, 1]) (
num == 0 ?
[(x + row * y), (x + row * y + 1), (x + row * y + 1 + row)] :
[(x + row * y), (x + row * y + 1 + row), (x + row * y + row)])
];
f2 = cat(f1, [for (n = [0: sides-1]) [n, n+1, len(matrix) - 1]]);
faces = cat(f2, [for (n = [len(matrix) - sides-1 : len(matrix)]) [n-1, n, len(matrix) - 1]]);
// add
/*
faces needs to start like this:
[
[0,1,4,3],
[1,2,5,4]
]*/
/*index, index + 1, index + 1 + row, index + row*/
polyhedron(points = matrix, faces=faces);
}
dish();