$fs = 0.1; $fa = 0.1; // A5 = 148 page_size_width = 210; // [105, 148, 210] page_size_height = sqrt(2)*page_size_width; notebook_thickness = 3; hinge_radius = 10; hinge_hole_radius = 6; number_of_hinge_segments = 5; hinge_gap = 2; notebook_open_angle = 0; // [0:180] // notebook_open_angle = $t*180; cover_material_colour = [128/255, 165/255, 0]; addtional_cover_material_colour = [255/255, 165/255, 0]; hinge_colour_even = [255/255, 0, 0]; hinge_colour_odd = [255/255, 0, 1]; hinge_segments_length = (page_size_height - hinge_gap * (number_of_hinge_segments - 1)) / number_of_hinge_segments; hinge_offset = [-page_size_width/2-hinge_radius, page_size_height / 2 - hinge_segments_length / 2, hinge_radius - notebook_thickness/2]; function ALTERNATE(i, thing_1, thing_2) = (thing_1*(i % 2) + thing_2*(-(i % 2)+1)); echo(str("page size = ", page_size_height, "x", page_size_width, "mm")); translate([page_size_width/2+hinge_radius, 0, -hinge_radius+notebook_thickness/2]) union(){ color(cover_material_colour) cube(size=[page_size_width, page_size_height, notebook_thickness], center=true); color(addtional_cover_material_colour) translate([-page_size_width/2 - hinge_radius/2 , 0, 0]) cube(size=[hinge_radius, page_size_height, notebook_thickness], center=true); translate(hinge_offset){ for (i=[1:2:number_of_hinge_segments - 1]) { translate([0, -i*(hinge_segments_length+hinge_gap), 0]) rotate([90, 0, 0]) color(hinge_colour_odd) difference() { cylinder(r=hinge_radius, h=hinge_segments_length, center=true); cylinder(r=hinge_hole_radius, h=hinge_segments_length*2, center=true); } } } } rotate([0, -notebook_open_angle, 0]) translate([page_size_width/2+hinge_radius, 0, -hinge_radius+notebook_thickness/2]) union(){ translate([0, 0, hinge_radius*2 - notebook_thickness]){ color(cover_material_colour) cube(size=[page_size_width, page_size_height, notebook_thickness], center=true); color(addtional_cover_material_colour) translate([-page_size_width/2 - hinge_radius/2 , 0, 0]) cube(size=[hinge_radius, page_size_height, notebook_thickness], center=true); } translate(hinge_offset){ for (i=[0:2:number_of_hinge_segments - 1]) { translate([0, -i*(hinge_segments_length+hinge_gap), 0]) rotate([90, 0, 0]) color(hinge_colour_even) difference() { cylinder(r=hinge_radius, h=hinge_segments_length, center=true); cylinder(r=hinge_hole_radius, h=hinge_segments_length*2, center=true); } } } }