You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

220 lines
9.0 KiB

include <config.scad>;
include <constant.scad>;
use <switch_cutout.scad>;
use <switch_holder.scad>;
use <switch.scad>;
use <pcb/amoeba-royale.scad>;
for(c=[0:len(switch_r[0])-1],r=[0:len(switch_r)-1]) {
echo("switches c",c,"d",r);
translate(switch_t[r][c])
rotate(switch_r[r][c]) {
if($show_switches == true)
switch(0, $show_keycaps ? switch_keycap[r][c][0]: "none", switch_keycap[r][c][1] );
if($show_switch_pcb == true)
translate([0,0,-switch_holder_height-amoeba_royale_pcb_h-$c])
amoeba_royale_pcb();
switch_holder_with_cutouts(type="B");
}
}
function switch_rc_point(row,colum,a,h,offset=[0,0,0]) = v_rot(switch_r[row][colum]) * (switch_point(a,h) + offset) + switch_t[row][colum];
function switch_bz(row,colum,a,h,offset=[0,-10,0]) = [
[
switch_rc_point(row,colum,a[0],h,[0,0,0]),
switch_rc_point(row,colum,a[1],h,[0,0,0]),
],
[
switch_rc_point(row,colum,a[0],h,offset),
switch_rc_point(row,colum,a[1],h,offset),
],
[
zero_axis("z", switch_rc_point(row,colum,a[0],h,offset), -20),
zero_axis("z", switch_rc_point(row,colum,a[1],h,offset), -20)
],
];
function switch_bz_edge(row,colum,a,h,offset1=[0,-10,0],offset2=[0,-10,0]) = [
[
switch_rc_point(row,colum,a,h,$e*offset1),
switch_rc_point(row,colum,a,h, 0*offset1),
switch_rc_point(row,colum,a,h,$e*offset2),
],
[
switch_rc_point(row,colum,a,h,offset1),
switch_rc_point(row,colum,a,h,offset1+offset2),
switch_rc_point(row,colum,a,h,offset2),
],
[
zero_axis("z", switch_rc_point(row,colum,a,h,offset1), -20),
zero_axis("z", switch_rc_point(row,colum,a,h,offset1+offset2), -20),
zero_axis("z", switch_rc_point(row,colum,a,h,offset2), -20)
],
];
function switch_bz_offset(a)= (
(a == "N" ) ? [ 10, 0, 0] :
(a == "S" ) ? [-10, 0, 0] :
(a == "O" ) ? [ 0, 10, 0] :
(a == "W" ) ? [ 0,-10, 0] :
undef
);
function switch_bz_between(rows,colums,a,h,offset_bz=[2,0,0],offset_out=[0,-10,0]) = [
[
switch_rc_point(rows[0],colums[0],a[0],h,[0,0,0]),
switch_rc_point(rows[0],colums[0],a[0],h,[0,0,0]+offset_bz),
switch_rc_point(rows[len(rows) == 1 ? 0 : 1],colums[len(colums) == 1 ? 0 : 1],a[1],h,[0,0,0]-offset_bz),
switch_rc_point(rows[len(rows) == 1 ? 0 : 1],colums[len(colums) == 1 ? 0 : 1],a[1],h,[0,0,0]),
],
[
switch_rc_point(rows[0],colums[0],a[0],h,[0,0,0]+offset_out),
switch_rc_point(rows[0],colums[0],a[0],h,[0,0,0]+offset_bz+offset_out),
switch_rc_point(rows[len(rows) == 1 ? 0 : 1],colums[len(colums) == 1 ? 0 : 1],a[1],h,[0,0,0]-offset_bz+offset_out),
switch_rc_point(rows[len(rows) == 1 ? 0 : 1],colums[len(colums) == 1 ? 0 : 1],a[1],h,[0,0,0]+offset_out),
],
[
zero_axis("z", switch_rc_point(rows[0],colums[0],a[0],h,[0,0,0]+offset_out), -20),
zero_axis("z", switch_rc_point(rows[0],colums[0],a[0],h,[0,0,0]+offset_bz+offset_out), -20),
zero_axis("z", switch_rc_point(rows[len(rows) == 1 ? 0 : 1],colums[len(colums) == 1 ? 0 : 1],a[1],h,[0,0,0]-offset_bz+offset_out), -20),
zero_axis("z", switch_rc_point(rows[len(rows) == 1 ? 0 : 1],colums[len(colums) == 1 ? 0 : 1],a[1],h,[0,0,0]+offset_out), -20),
],
];
function switch_bz_connection(rows,colums,a,h,offset_bz=[2,0,0]) = [
[
switch_rc_point(rows[0],colums[0],a[0][0],h,[0,0,0]-$e*offset_bz),
switch_rc_point(rows[0],colums[0],a[0][1],h,[0,0,0]-$e*offset_bz),
],
[
switch_rc_point(rows[0],colums[0],a[0][0],h,[0,0,0]),
switch_rc_point(rows[0],colums[0],a[0][1],h,[0,0,0]),
],
[
switch_rc_point(rows[0],colums[0],a[0][0],h,[0,0,0]+offset_bz),
switch_rc_point(rows[0],colums[0],a[0][1],h,[0,0,0]+offset_bz),
],
[
switch_rc_point(rows[len(rows) == 1 ? 0 : 1],colums[len(colums) == 1 ? 0 : 1],a[1][0],h,[0,0,0]-offset_bz),
switch_rc_point(rows[len(rows) == 1 ? 0 : 1],colums[len(colums) == 1 ? 0 : 1],a[1][1],h,[0,0,0]-offset_bz),
],
[
switch_rc_point(rows[len(rows) == 1 ? 0 : 1],colums[len(colums) == 1 ? 0 : 1],a[1][0],h,[0,0,0]),
switch_rc_point(rows[len(rows) == 1 ? 0 : 1],colums[len(colums) == 1 ? 0 : 1],a[1][1],h,[0,0,0]),
],
[
switch_rc_point(rows[len(rows) == 1 ? 0 : 1],colums[len(colums) == 1 ? 0 : 1],a[1][0],h,[0,0,0]+$e*offset_bz),
switch_rc_point(rows[len(rows) == 1 ? 0 : 1],colums[len(colums) == 1 ? 0 : 1],a[1][1],h,[0,0,0]+$e*offset_bz),
],
];
function switch_bz_connection_cross(rows,colums,a,h,offset_bz=[2,0,0]) = [
[
switch_rc_point(rows[0],colums[0],a[0][0],h,[0,0,0]-$e*offset_bz),
switch_rc_point(rows[1],colums[0],a[0][1],h,[0,0,0]-$e*offset_bz),
],
[
switch_rc_point(rows[0],colums[0],a[0][0],h,[0,0,0]),
switch_rc_point(rows[1],colums[0],a[0][1],h,[0,0,0]),
],
[
switch_rc_point(rows[0],colums[0],a[0][0],h,[0,0,0]+offset_bz),
switch_rc_point(rows[1],colums[0],a[0][1],h,[0,0,0]+offset_bz),
],
[
switch_rc_point(rows[0],colums[1],a[1][0],h,[0,0,0]-offset_bz),
switch_rc_point(rows[1],colums[1],a[1][1],h,[0,0,0]-offset_bz),
],
[
switch_rc_point(rows[0],colums[1],a[1][0],h,[0,0,0]),
switch_rc_point(rows[1],colums[1],a[1][1],h,[0,0,0]),
],
[
switch_rc_point(rows[0],colums[1],a[1][0],h,[0,0,0]+$e*offset_bz),
switch_rc_point(rows[1],colums[1],a[1][1],h,[0,0,0]+$e*offset_bz),
],
];
function reverse_bz(points) = [for(i = [len(points)-1:-1:0]) points[i], ];
function switch_bz_all_w(colum,a,h,offset=[0,-10,0]) = [for (r=[0:3]) switch_bz(row, colum, a, h, offset),];
t_step = 0.1;
thickness = switch_holder_height+1;
ctrl_pts_S = [
// S curve
switch_bz(3,0,["SW","SO"],"top",[0,-10,0]),
switch_bz(3,1,["SW","SO"],"top",[0,-10,0]),
switch_bz_between([3], [0,1],["SO","SW"],"top",[1,0,0],[0,-10,0]),
// N curve
switch_bz(0,0,["NO","NW"],"top",[0,10,0]),
switch_bz(0,1,["NO","NW"],"top",[0,10,0]),
switch_bz_between([0], [1,0],["NW","NO"],"top",[-1,0,0],[0,+10,0]),
// within OW
switch_bz_connection([0], [1,0],[ ["NW", "SW"],["NO", "SO"] ],"top",[-1,0,0]),
switch_bz_connection([1], [1,0],[ ["NW", "SW"],["NO", "SO"] ],"top",[-1,0,0]),
switch_bz_connection([2], [1,0],[ ["NW", "SW"],["NO", "SO"] ],"top",[-1,0,0]),
switch_bz_connection([3], [1,0],[ ["NW", "SW"],["NO", "SO"] ],"top",[-1,0,0]),
// within NS
switch_bz_connection([0,1], [0],[ ["SW", "SO"],["NW", "NO"] ],"top",[0,-1,0]),
switch_bz_connection([1,2], [0],[ ["SW", "SO"],["NW", "NO"] ],"top",[0,-1,0]),
switch_bz_connection([2,3], [0],[ ["SW", "SO"],["NW", "NO"] ],"top",[0,-1,0]),
switch_bz_connection([0,1], [1],[ ["SW", "SO"],["NW", "NO"] ],"top",[0,-1,0]),
switch_bz_connection([1,2], [1],[ ["SW", "SO"],["NW", "NO"] ],"top",[0,-1,0]),
switch_bz_connection([2,3], [1],[ ["SW", "SO"],["NW", "NO"] ],"top",[0,-1,0]),
switch_bz_connection_cross([1,0], [0,1],[ [ "NO", "SO"],["NW", "SW"] ],"top",[1,0,0]),
switch_bz_connection_cross([2,1], [0,1],[ [ "NO", "SO"],["NW", "SW"] ],"top",[1,0,0]),
switch_bz_connection_cross([3,2], [0,1],[ [ "NO", "SO"],["NW", "SW"] ],"top",[1,0,0]),
// W curve
switch_bz(0,0,["NW","SW"],"top",[-10,0,0]),
switch_bz(1,0,["NW","SW"],"top",[-10,0,0]),
switch_bz(2,0,["NW","SW"],"top",[-10,0,0]),
switch_bz(3,0,["NW","SW"],"top",[-10,0,0]),
switch_bz_between([0,1], [0],["SW","NW"],"top",[1,0,0],[-10,0,0]),
switch_bz_between([1,2], [0],["SW","NW"],"top",[1,0,0],[-10,0,0]),
switch_bz_between([2,3], [0],["SW","NW"],"top",[1,0,0],[-10,0,0]),
switch_bz_between([1,0], [1],["NO","SO"],"top",[1,0,0],[10,0,0]),
switch_bz_between([2,1], [1],["NO","SO"],"top",[1,0,0],[10,0,0]),
switch_bz_between([3,2], [1],["NO","SO"],"top",[1,0,0],[10,0,0]),
// O curve
switch_bz(0,1,["SO","NO"],"top",[+10,0,0]),
switch_bz(1,1,["SO","NO"],"top",[+10,0,0]),
switch_bz(2,1,["SO","NO"],"top",[+10,0,0]),
switch_bz(3,1,["SO","NO"],"top",[+10,0,0]),
// edge
switch_bz_edge(3,0,"SW","top",[-10,0,0],[0,-10,0]),
reverse_bz(switch_bz_edge(3,1,"SO","top",[ 10,0,0],[0,-10,0])),
reverse_bz(switch_bz_edge(0,0,"NW","top",[-10,0,0],[0, 10,0])),
switch_bz_edge(0,1,"NO","top",[ 10,0,0],[0, 10,0]),
];
for(k=[0:len(ctrl_pts_S)-1]) {
g_S = bezier_surface(t_step, ctrl_pts_S[k]);
// g_S = sf_splines(t_step, ctrl_pts_S);
sf_thicken(g_S, thickness,"FORWARD");
//function_grapher(g_S,thickness,"FORWARD");
}
// draw bezier_points
color("black")
for(k=[0:len(ctrl_pts_S)-1])
for(i=[0:len(ctrl_pts_S[k])-1])
for(j=[0:len(ctrl_pts_S[k][i])-1])
translate(ctrl_pts_S[k][i][j])
{
%sphere(d=0.5);
}