2024-12-22 01:07:14 +10:30
include < common.scad >
2024-12-26 13:14:01 +10:30
include < UBassTuner.scad >
2024-12-23 13:36:52 +10:30
// Guitar_Scale_Length_mm = 610; // millimetres, slightly over 24inch (609.6mm) Jaguar scale, should be fine for guitar and u-bass
// assert(fret_scale_length(0) == 610); // Make sure the function correctly uses our changed global
2024-12-22 01:07:14 +10:30
CF_Tube_Dia = 5.0 ;
CF_Square_Width = 6.0 ;
// Philippians 4:8
// Gideon 真実な, 尊ぶべき, 正しい, 清い, 愛すべき, 評判の良い, 徳とされる, 称賛に値する
// ShinKaiYaku65 最後に、兄弟たち。すべての真実なこと、すべての誉れあること、すべての正しいこと、すべてのきよいこと、すべての愛すべきこと、すべての評判の良いこと、そのほか徳と言われること、称賛に値することがあるならば、そのようなことに心を留めなさい。
// I swapped 愛 and 評判 because 12th fret should be the biggest marker, and having only 15 as a 2char marker would be too disorienting
// going with 良 for 21
fret_inlays = [ [ 3 , "真" ] , [ 5 , "尊" ] , [ 7 , "正" ] , [ 9 , "清" ] , [ 12 , "評判" ] , [ 15 , "愛" ] , [ 17 , "徳" ] , [ 19 , "賛" ] , [ 21 , "良" ] , [ 24 , "主イエス" ] ] ;
2024-12-24 21:31:02 +10:30
module neck ( string_spacing = 18 , string_margin = 4.5 , num_strings = 3 , target_neck_thickness = 15 , scallop_depth = 3 , num_frets = 24 , fret_width = 2.4 , filler = false ) {
2024-12-23 14:47:47 +10:30
fw2 = fret_width / 2 ;
neck_length = fret_scale_length ( 0 ) + fw2 ;
2024-12-22 01:07:14 +10:30
neck_width = ( num_strings - 1 ) * string_spacing + string_margin * 2 ;
module neck_stock ( ) {
2024-12-23 14:47:47 +10:30
angle_excess = asin ( ( scallop_depth + fw2 ) / target_neck_thickness ) ;
a0 = 90 - angle_excess ;
a1 = 270 + angle_excess ;
2024-12-22 01:07:14 +10:30
rotate ( [ - 90 , 0 , 0 ] )
linear_extrude ( neck_length )
2024-12-23 14:47:47 +10:30
polygon ( [ for ( i = [ 0 : 300 ] ) let ( a = lerp ( a0 , a1 , i / 300.0 ) ) [ neck_width * 0.5 * sin ( a ) , - target_neck_thickness * cos ( a ) ] ] ) ;
2024-12-22 01:07:14 +10:30
}
2024-12-24 21:31:02 +10:30
module scallop ( fret ) {
2024-12-23 14:47:47 +10:30
x0 = fret_scale_length ( fret - 1 ) - fw2 ;
x1 = fret_scale_length ( fret ) + fw2 ;
2024-12-22 01:07:14 +10:30
xmid = lerp ( x0 , x1 , 0.5 ) ;
// Radius it?
arc = arc_points ( [ [ x0 , scallop_depth ] , [ x1 , scallop_depth ] , [ xmid , 0 ] ] ) ;
2024-12-23 13:36:52 +10:30
// echo(arc);
2024-12-22 01:07:14 +10:30
rotate ( [ 90 , 0 , 90 ] ) linear_extrude ( neck_width , center = true ) polygon ( arc ) ;
2024-12-24 21:31:02 +10:30
}
module scallops ( ) {
for ( fret = [ 0 : num_frets ] ) {
scallop ( fret ) ;
2024-12-22 01:07:14 +10:30
}
}
module fret_bumps ( ) {
for ( fret = [ 0 : num_frets ] ) {
translate ( [ 0 , fret_scale_length ( fret ) , scallop_depth ] )
rotate ( [ 0 , 90 ] ) cylinder ( d = fret_width , h = neck_width , center = true , $fn = 200 ) ;
}
}
module fret_inlays ( ) {
for ( num_text = fret_inlays ) {
fret = num_text [ 0 ] ;
x0 = fret_scale_length ( fret - 1 ) ;
x1 = fret_scale_length ( fret ) ;
diff = x0 - x1 ;
translate ( [ 0 , lerp ( x0 , x1 , 0.5 ) , - 0.5 ] )
linear_extrude ( 30 )
text ( text = num_text [ 1 ] , font = JP_Serif_Font , halign = "center" , valign = "center" , size = clamp ( 2 , diff - fret_width * 2 - 2 , 10 ) ) ;
}
}
module fret_side_markers ( ) {
for ( num_text = fret_inlays ) {
fret = num_text [ 0 ] ;
x0 = fret_scale_length ( fret - 1 ) ;
x1 = fret_scale_length ( fret ) ;
diff = x0 - x1 ;
rotate ( [ 0 , - 90 , 0 ] )
translate ( [ 0 , x1 , neck_width / 2 - 3 ] )
linear_extrude ( 50 )
rotate ( - 35 )
text ( text = str ( fret ) , font = JP_Serif_Font , halign = "right" , valign = "center" , size = 5 ) ;
}
}
2024-12-24 21:31:02 +10:30
if ( filler ) { // Somewhat placeholder for now
difference ( ) {
neck_stock ( ) ;
scallop ( 25 ) ;
translate ( [ - neck_width , 0 , scallop_depth ] ) cube ( [ neck_width * 2 , Guitar_Scale_Length_mm * 3 , target_neck_thickness * 3 ] ) ;
translate ( [ - neck_width , 0 , 0 ] ) cube ( [ neck_width * 2 , ( fret_scale_length ( 25 ) + fret_scale_length ( 24 ) ) / 2 , target_neck_thickness * 3 ] ) ;
}
} else {
render ( ) difference ( ) {
neck_stock ( ) ;
scallops ( ) ;
fret_inlays ( ) ;
fret_side_markers ( ) ;
translate ( [ - neck_width , 0 , scallop_depth ] ) cube ( [ neck_width * 2 , Guitar_Scale_Length_mm * 3 , target_neck_thickness * 3 ] ) ;
}
intersection ( ) {
fret_bumps ( ) ;
neck_stock ( ) ;
}
2024-12-22 01:07:14 +10:30
}
}
2024-12-26 13:14:01 +10:30
module bridge ( string_spacing = 18 , string_margin = 4.5 , num_strings = 3 , target_neck_thickness = 15 , scallop_depth = 3 , fret_width = 2.4 * 6 ) {
fw2 = fret_width / 2 ;
neck_length = 120 ;
neck_width = ( num_strings - 1 ) * string_spacing + string_margin * 2 ;
module neck_stock ( ) {
angle_excess = asin ( ( scallop_depth + fw2 ) / target_neck_thickness ) ;
a0 = 90 - angle_excess ;
a1 = 270 + angle_excess ;
rotate ( [ - 90 , 0 , 0 ] )
linear_extrude ( neck_length )
polygon ( [ for ( i = [ 0 : 300 ] ) let ( a = lerp ( a0 , a1 , i / 300.0 ) ) [ neck_width * 0.5 * sin ( a ) , - target_neck_thickness * cos ( a ) ] ] ) ;
}
module scallop ( fret ) {
x0 = fret_scale_length ( fret - 1 ) - fw2 ;
x1 = fret_scale_length ( fret ) + fw2 ;
xmid = lerp ( x0 , x1 , 0.5 ) ;
// Radius it?
arc = arc_points ( [ [ x0 , scallop_depth ] , [ x1 , scallop_depth ] , [ xmid , 0 ] ] ) ;
// echo(arc);
rotate ( [ 90 , 0 , 90 ] ) linear_extrude ( neck_width , center = true ) polygon ( arc ) ;
}
module fret_bumps ( ) {
translate ( [ 0 , neck_length - fw2 , scallop_depth ] ) rotate ( [ 0 , 90 ] ) cylinder ( d = fret_width , h = neck_width , center = true , $fn = 200 ) ;
}
// render() difference() {
// neck_stock();
// translate([-neck_width, 0, scallop_depth]) cube([neck_width*2, Guitar_Scale_Length_mm*3, target_neck_thickness*3]);
// translate([0, 40, 0]) rotate([90, 90, 90]) UBassTuner();
// }
// intersection() {
// fret_bumps();
// neck_stock();
// }
module differences ( ) {
t_offset = 2.7 ;
t_z = - 23 ;
mirror ( [ 1 , 0 , 0 ] ) translate ( [ t_offset , 80 , t_z ] ) rotate ( [ 90 , - 90 , 90 ] ) UBassTuner ( ) ;
translate ( [ t_offset , 45 , t_z ] ) rotate ( [ 90 , - 90 , 90 ] ) UBassTuner ( ) ;
mirror ( [ 1 , 0 , 0 ] ) translate ( [ t_offset , 10 , t_z ] ) rotate ( [ 90 , - 90 , 90 ] ) UBassTuner ( ) ;
for ( i = [ - 1 : 2 : 1 ] )
translate ( [ i * 15 , 0 , - 4 ] )
cf_tube ( neck_length , 0 , tolerance = 0.4 ) ;
translate ( [ 0 , 0 , - 10 ] )
cf_tube ( neck_length , 0 , tolerance = 0.4 ) ;
}
difference ( ) {
color ( [ 1 , 1 , 1 , 0.3 ] ) translate ( [ - neck_width / 2 , 0 , - 25 + scallop_depth ] ) cube ( [ neck_width , neck_length , 25 ] ) ;
differences ( ) ;
}
// color([1,1,1,0.3]) neck_stock();
}
2024-12-26 18:42:39 +10:30
module cf_tube ( x1 , x2 , tolerance = 0.3 , VLH = false ) {
tolerance = tolerance + ( VLH ? 0.3 : 0 ) ;
2024-12-22 16:01:41 +10:30
translate ( [ 0 , x2 , 0 ] )
rotate ( [ - 90 , 0 , 0 ] )
cylinder ( h = x1 - x2 , d = CF_Tube_Dia + tolerance , $fn = 360 ) ;
hull ( ) {
translate ( [ 0 , x2 ] )
rotate ( [ - 90 , 0 , 0 ] )
cylinder ( h = 0.2 , d = CF_Tube_Dia * 1.2 + tolerance , $fn = 360 ) ;
translate ( [ 0 , x2 + 5 ] )
rotate ( [ - 90 , 0 , 0 ] )
cylinder ( h = 0.2 , d = CF_Tube_Dia + tolerance , $fn = 360 ) ;
}
hull ( ) {
translate ( [ 0 , x1 ] )
rotate ( [ - 90 , 0 , 0 ] )
cylinder ( h = 0.2 , d = CF_Tube_Dia * 1.2 + tolerance , $fn = 360 ) ;
translate ( [ 0 , x1 - 5 ] )
rotate ( [ - 90 , 0 , 0 ] )
cylinder ( h = 0.2 , d = CF_Tube_Dia + tolerance , $fn = 360 ) ;
}
2024-12-22 01:07:14 +10:30
}
2024-12-23 14:47:47 +10:30
module cf_square ( x1 , x2 , tolerance = 0.2 , taper_x1 = true , taper_x2 = true ) {
2024-12-22 01:07:14 +10:30
x = CF_Square_Width + tolerance ;
2024-12-22 16:01:41 +10:30
translate ( [ - x / 2 , x2 , - x / 2 ] )
cube ( [ x , x1 - x2 , x ] ) ;
2024-12-23 14:47:47 +10:30
if ( taper_x1 ) {
hull ( ) {
translate ( [ 0 , x1 , 0 ] )
cube ( [ x * 1.2 , 0.2 , x * 1.2 ] , center = true ) ;
translate ( [ 0 , x1 - 5 , 0 ] )
cube ( [ x , 0.2 , x ] , center = true ) ;
}
2024-12-22 16:01:41 +10:30
}
2024-12-23 14:47:47 +10:30
if ( taper_x2 ) {
hull ( ) {
translate ( [ 0 , x2 , 0 ] )
cube ( [ x * 1.2 , 0.2 , x * 1.2 ] , center = true ) ;
translate ( [ 0 , x2 + 5 , 0 ] )
cube ( [ x , 0.2 , x ] , center = true ) ;
}
2024-12-22 16:01:41 +10:30
}
2024-12-22 01:07:14 +10:30
}
2024-12-22 16:01:41 +10:30
module fret_tube ( from_fret , to_fret , fret_width = 2.4 ) {
fw2 = fret_width / 2 ;
x0 = fret_scale_length ( 0 ) + fw2 ;
x1 = fret_scale_length ( from_fret ) + ( ( from_fret = = 0 ) ? fw2 : ( - fw2 ) ) ;
x2 = fret_scale_length ( to_fret ) - fw2 ;
render ( ) difference ( ) {
neck ( fret_width = fret_width ) ;
for ( i = [ - 1 : 2 : 1 ] )
translate ( [ i * 15 , 0 , - 4 ] )
cf_tube ( x1 , x2 ) ;
for ( i = [ - 1 : 2 : 1 ] )
translate ( [ i * 7.5 , 0 , - 7 ] )
cf_square ( x1 , x2 ) ;
translate ( [ 0 , 0 , - 10 ] )
cf_tube ( x1 , x2 ) ;
translate ( [ - 50 , 0 , - 50 ] ) cube ( [ 100 , x2 , 100 ] ) ;
translate ( [ - 50 , x1 , - 50 ] ) cube ( [ 100 , x0 - x1 , 100 ] ) ;
2024-12-22 01:07:14 +10:30
2024-12-22 16:01:41 +10:30
// αβγδεζ
2024-12-23 13:36:52 +10:30
rotate ( [ 90 , 0 , 0 ] ) linear_extrude ( ( x2 + 0.3 ) * 2 , center = true ) text ( text = "01β" , font = "Deja Vu Sans" , halign = "center" , valign = "center" , size = 4 ) ;
2024-12-22 16:01:41 +10:30
}
2024-12-22 01:07:14 +10:30
}
2024-12-22 16:01:41 +10:30
2024-12-26 18:42:39 +10:30
module fret_tube_filler ( from_fret , to_fret , fret_width = 2.4 , belthole_length = 140 , VLH = true ) {
2024-12-24 21:31:02 +10:30
fw2 = fret_width / 2 ;
x0 = fret_scale_length ( 0 ) + fw2 ;
x1 = fret_scale_length ( from_fret ) + ( ( from_fret = = 0 ) ? fw2 : ( - fw2 ) ) ;
x2 = ( to_fret < 100 ) ? ( fret_scale_length ( to_fret ) - fw2 ) : 0 ;
render ( ) difference ( ) {
neck ( fret_width = fret_width , filler = true ) ;
2024-12-26 18:42:39 +10:30
for ( i = [ - 1 : 1 ] )
translate ( [ i * 15 , 0 , ( i = = 0 ) ? ( - 10 ) : ( - 4 ) ] )
cf_tube ( x1 , x2 , VLH = VLH ) ;
2024-12-24 21:31:02 +10:30
translate ( [ - 50 , 0 , - 50 ] ) cube ( [ 100 , x2 , 100 ] ) ;
translate ( [ - 50 , x1 , - 50 ] ) cube ( [ 100 , x0 - x1 , 100 ] ) ;
// Add a belt hole
arc = arc_points ( [ [ 16 , - 20 ] , [ - 16 , - 20 ] , [ 0 , - 4 ] ] ) ;
belthole_r = 2.5 ;
belthole_fn = 72 ;
belthole_x0 = x1 - belthole_r - 5 ;
belthole_x1 = belthole_x0 - belthole_length ;
render ( ) for ( i = [ 0 : len ( arc ) - 2 ] ) {
hull ( ) {
translate ( [ arc [ i ] [ 0 ] , belthole_x0 , arc [ i ] [ 1 ] ] ) sphere ( belthole_r , $fn = belthole_fn ) ;
translate ( [ arc [ i + 1 ] [ 0 ] , belthole_x0 , arc [ i + 1 ] [ 1 ] ] ) sphere ( belthole_r , $fn = belthole_fn ) ;
translate ( [ arc [ i ] [ 0 ] , belthole_x1 , arc [ i ] [ 1 ] ] ) sphere ( belthole_r , $fn = belthole_fn ) ;
translate ( [ arc [ i + 1 ] [ 0 ] , belthole_x1 , arc [ i + 1 ] [ 1 ] ] ) sphere ( belthole_r , $fn = belthole_fn ) ;
}
}
// αβγδεζ
2024-12-26 18:42:39 +10:30
t = "01β.β" ;
2024-12-24 21:31:02 +10:30
translate ( [ 0 , 0 , - 3.5 ] ) rotate ( [ 90 , 0 , 0 ] ) linear_extrude ( ( x2 + 0.3 ) * 2 , center = true ) text ( text = t , font = "Deja Vu Sans" , halign = "center" , valign = "center" , size = 4 ) ;
translate ( [ 0 , x1 - 0.3 , - 3 ] ) rotate ( [ 90 , 0 , 180 ] ) linear_extrude ( ( 0.3 ) * 2 , center = true ) text ( text = t , font = "Deja Vu Sans" , halign = "center" , valign = "center" , size = 4 ) ;
}
}
2024-12-23 14:47:47 +10:30
module headpiece ( string_spacing = 18 , string_margin = 4.5 , num_strings = 3 , target_neck_thickness = 15 , scallop_depth = 3 , fret_width = 2.4 ) {
headpiece_length = 36 ;
cf_square_length = 32 ;
fw2 = fret_width / 2 ;
x0 = fret_scale_length ( 0 ) + fw2 ;
neck_width = ( num_strings - 1 ) * string_spacing + string_margin * 2 ;
bend_radius = 24 ;
module stock ( ) {
angle_excess = asin ( scallop_depth / target_neck_thickness ) ;
a0 = 90 - angle_excess ;
a1 = 270 + angle_excess ;
translate ( [ 0 , x0 , 0 ] )
rotate ( [ - 90 , 0 , 0 ] )
linear_extrude ( headpiece_length )
polygon ( [ for ( i = [ 0 : 300 ] ) let ( a = lerp ( a0 , a1 , i / 300.0 ) ) [ neck_width * 0.5 * sin ( a ) , - target_neck_thickness * cos ( a ) ] ] ) ;
}
2024-12-23 19:26:08 +10:30
module string_tubes ( tolerance = 1.0 ) {
2024-12-23 14:47:47 +10:30
string_thicknesses = [ 4.9 , 4.2 , 3.0 ] ;
module string_tube ( diameter , fn = 36 ) {
hole_r = diameter / 2 ;
bend_r = bend_radius + hole_r ;
union ( ) {
for ( a = [ 0 : 89 ] ) {
hull ( ) {
translate ( [ 0 , bend_r * sin ( a ) , bend_r * cos ( a ) ] ) sphere ( hole_r , $fn = fn ) ;
translate ( [ 0 , bend_r * sin ( a + 1 ) , bend_r * cos ( a + 1 ) ] ) sphere ( hole_r , $fn = fn ) ;
}
}
hull ( ) {
translate ( [ 0 , bend_r * sin ( 90 ) , bend_r * cos ( 90 ) ] ) sphere ( hole_r , $fn = fn ) ;
translate ( [ 0 , bend_r * sin ( 90 ) , - target_neck_thickness ] ) sphere ( hole_r , $fn = fn ) ;
}
}
} ;
for ( i = [ 0 : num_strings - 1 ] ) {
2024-12-23 19:26:08 +10:30
string_diameter = string_thicknesses [ i ] + tolerance ;
2024-12-23 14:47:47 +10:30
x = - neck_width / 2 + string_margin + ( i * string_spacing ) ;
2024-12-24 03:59:26 +10:30
translate ( [ x , x0 + 2 , - bend_radius + scallop_depth ] ) string_tube ( string_diameter ) ;
2024-12-23 14:47:47 +10:30
}
}
difference ( ) {
stock ( ) ;
string_tubes ( ) ;
for ( i = [ - 1 : 2 : 1 ] )
translate ( [ i * 7.5 , 0 , - 7 ] )
cf_square ( x0 + cf_square_length , x0 , taper_x1 = false ) ;
// αβγδεζ
2024-12-24 03:59:26 +10:30
translate ( [ 0 , x0 + headpiece_length , - 5 ] ) rotate ( [ 90 , 0 , 180 ] ) linear_extrude ( 0.3 , center = true ) text ( text = "01β.γ " , font = "Deja Vu Sans" , halign = "center" , valign = "center" , size = 4 ) ;
2024-12-23 14:47:47 +10:30
}
}
2024-12-22 16:01:41 +10:30
echo ( fret_scale_length ( 0 ) - fret_scale_length ( 8 ) ) ; // 225.724
echo ( fret_scale_length ( 8 ) - fret_scale_length ( 24 ) ) ; // 240.335
2024-12-23 14:47:47 +10:30
// fret_tube(0, 8);
// //translate([30, 0, 0])
// fret_tube(8, 24);
2024-12-24 03:59:26 +10:30
// headpiece();
2024-12-24 21:31:02 +10:30
// UBassTuner();
fret_tube_filler ( 24 , 100 ) ;
2024-12-26 13:14:01 +10:30
// bridge();