From 68e31e24f69d2717e7199933eb911f6b73c90a28 Mon Sep 17 00:00:00 2001 From: Max O'Cull Date: Wed, 13 Mar 2019 13:28:52 -0400 Subject: [PATCH 1/3] Implement and apply openscad-format --- array/along_curve.scad | 14 +- array/generic-multiply.scad | 8 +- array/mirror.scad | 8 +- array/polar.scad | 66 +- array/rectangular.scad | 55 +- array/translations.scad | 75 +- boxes.scad | 5 +- curves.scad | 20 +- demos/array_along_curve_demo.scad | 33 +- demos/array_linear_demo.scad | 52 +- demos/array_polar_demo.scad | 38 +- demos/array_rectangular_demo.scad | 59 +- demos/bearing_demo.scad | 25 +- demos/constants_demo.scad | 9 +- demos/hardware_demo.scad | 17 +- demos/linear_bearing_demo.scad | 9 +- demos/materials_demo.scad | 12 +- demos/metric_demo.scad | 73 +- demos/polyhole_demo.scad | 29 +- demos/rack_and_pinion_demo.scad | 10 +- demos/stepper_demo.scad | 31 +- demos/string_demo.scad | 116 +- demos/teardrop_demo.scad | 15 +- demos/visibonecolors_demo.scad | 33 +- electronics/ATXpowerSupply.scad | 117 +- extrusions/8020.scad | 72 +- extrusions/extrusions.scad | 119 +- extrusions/makerbeam.scad | 15 +- extrusions/misumi_nfs5.scad | 59 +- extrusions/openbeam.scad | 37 +- fasteners/iso4017.scad | 243 ++-- fasteners/metric_fastners.scad | 124 +- fasteners/nuts_and_bolts.scad | 414 +++--- fasteners/threads.scad | 287 ++-- format.py | 8 + gears/gears.scad | 330 ++--- gears/involute_gears.scad | 1490 ++++++++++---------- gears/rack_and_pinion.scad | 411 +++--- general/constants.scad | 3 +- general/facets.scad | 28 +- general/math.scad | 8 +- general/sweep.scad | 89 +- general/utilities.scad | 183 +-- gridbeam.scad | 382 +++--- hardware/bearing.scad | 119 +- hardware/hardware.scad | 193 +-- hardware/linear_bearing.scad | 151 ++- layout/linear.scad | 19 +- lego_compatibility.scad | 349 +++-- materials/materials.scad | 28 +- materials/visibonecolors.scad | 872 ++++++------ motors/motors.scad | 187 +-- motors/servos.scad | 230 ++-- motors/stepper.scad | 567 ++++---- motors/stepper_mount.scad | 396 +++--- multiply.scad | 19 +- nuts_and_bolts.scad | 18 +- oshw.scad | 53 +- polyhole.scad | 4 +- rounder.scad | 2 +- screw.scad | 96 +- shapes/2Dshapes.scad | 410 +++--- shapes/3Dshapes.scad | 460 ++++--- shapes/3d_triangle.scad | 310 +++-- shapes/cylinder.scad | 124 +- shapes/polyhole.scad | 21 +- shapes/standard_shapes.scad | 64 +- shapes/triangles_pyramids.scad | 188 ++- shapes/trochoids.scad | 512 ++++--- text/alphabet_block.scad | 23 +- text/bitmap.scad | 2105 +++++++++++++++-------------- text/fonts.scad | 553 ++++---- text/height_map.scad | 20 +- text/letter_necklace.scad | 92 +- text/name_tag.scad | 55 +- text/string.scad | 36 +- text/test_name_tag.scad | 26 +- units/default.scad | 1 + units/metric.scad | 21 +- units/us.scad | 105 +- 80 files changed, 7384 insertions(+), 6276 deletions(-) create mode 100755 format.py diff --git a/array/along_curve.scad b/array/along_curve.scad index c20959a6..c0e2d8ea 100644 --- a/array/along_curve.scad +++ b/array/along_curve.scad @@ -1,3 +1,4 @@ +include /* * Multiplication along certain curves * @@ -5,8 +6,6 @@ * Licenced under LGPL2 or later */ -include - /** * Place children $no times around $axis, with the first duplicate being unmoved * from its original spot. $angle is the angle of rotation between children(n) @@ -17,14 +16,13 @@ include * rotation (default: undef) * @param axis Axis to rotate around (default: Z) */ -module mcad_rotate_multiply (no, angle = undef, axis = Z) +module mcad_rotate_multiply(no, angle = undef, axis = Z) { if (no > 0) { angle = (angle == undef) ? 360 / no : angle; for (i = [0:no - 1]) { - rotate (angle * i, axis) - children (); + rotate(angle * i, axis) children(); } } } @@ -34,9 +32,7 @@ module mcad_rotate_multiply (no, angle = undef, axis = Z) * * @param axis Axis of rotation (default: Z) */ -module mcad_duplicate (axis = Z) +module mcad_duplicate(axis = Z) { - mcad_rotate_multiply (no = 2, axis = axis) - children (); + mcad_rotate_multiply(no = 2, axis = axis) children(); } - diff --git a/array/generic-multiply.scad b/array/generic-multiply.scad index deb32937..f034af04 100644 --- a/array/generic-multiply.scad +++ b/array/generic-multiply.scad @@ -1,3 +1,4 @@ + /* * Copyright (C) 2016 Chow Loong Jin * @@ -24,12 +25,11 @@ * @param transformations List of transformations to apply to children() * @Param keep_original Whether or not to show the original child */ -module mcad_multiply (transformations, keep_original = true) +module mcad_multiply(transformations, keep_original = true) { if (keep_original) - children (); + children(); for (t = transformations) - multmatrix (t) - children (); + multmatrix(t) children(); } diff --git a/array/mirror.scad b/array/mirror.scad index 42b84c82..7d59aee6 100644 --- a/array/mirror.scad +++ b/array/mirror.scad @@ -1,12 +1,12 @@ + /** * Render an object as well as its mirror. * * @param axis Vector representing axis to mirror(). */ -module mcad_mirror_duplicate (axis) +module mcad_mirror_duplicate(axis) { - children (); + children(); - mirror (axis) - children (); + mirror(axis) children(); } diff --git a/array/polar.scad b/array/polar.scad index e02ac955..ce7dbb97 100644 --- a/array/polar.scad +++ b/array/polar.scad @@ -1,51 +1,45 @@ -include use use -use +include +use -/** - * Generate polar coordinates for polar-arrayed objects - * - * @param angle Angle increment between each coordinate (negative is clockwise) - * @param number Number of coordinates - * @param radius Radius of coordinates - */ -function mcad_generate_polar_coords (angle, number, radius) = ( - let (total = angle * number) - [ - for (i = [0:number-1]) - [radius, i * total / number] - ] -); + /** + * Generate polar coordinates for polar-arrayed objects + * + * @param angle Angle increment between each coordinate (negative is + * clockwise) + * @param number Number of coordinates + * @param radius Radius of coordinates + */ + function mcad_generate_polar_coords(angle, number, radius) = (let( + total = + angle * + number)[for (i = [0:number - 1])[radius, i* total / number]]); /** - * Polar array, i.e. place objects in a circular arc - * - * @param angle Angle between each copy (negative is clockwise) - * @param number Number of copies - * @param radius Radius of array path - */ -module mcad_array_polar (angle, number, radius, preserve_orientation = false) + * Polar array, i.e. place objects in a circular arc + * + * @param angle Angle between each copy (negative is clockwise) + * @param number Number of copies + * @param radius Radius of array path + */ +module mcad_array_polar(angle, number, radius, preserve_orientation = false) { - polar_coords = mcad_generate_polar_coords (angle, number, radius); + polar_coords = mcad_generate_polar_coords(angle, number, radius); if (preserve_orientation) - mcad_place_at ([for (coord = polar_coords) - conv2D_polar2cartesian (coord)]) - children (); + mcad_place_at([for (coord = polar_coords) + conv2D_polar2cartesian(coord)]) children(); else for (coord = polar_coords) - rotate (coord[1], Z) - translate ([coord[0], 0]) - children (); + rotate(coord[1], Z) translate([ coord[0], 0 ]) children(); } -module test_mcad_array_polar () +module +test_mcad_array_polar() { - mcad_array_polar (angle = 30, - number = 3, - radius = 10, - preserve_orientation = true) - cube (2, center = true); + mcad_array_polar( + angle = 30, number = 3, radius = 10, preserve_orientation = true) + cube(2, center = true); } diff --git a/array/rectangular.scad b/array/rectangular.scad index b43184ac..27abc0f4 100644 --- a/array/rectangular.scad +++ b/array/rectangular.scad @@ -1,25 +1,23 @@ -/** - * Copyright (C) 2016 Chow Loong Jin - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - - use include +/** + * Copyright (C) 2016 Chow Loong Jin + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ /** * Rectangular array, i.e. place objects on a grid. @see mcad_generate_grid @@ -28,12 +26,11 @@ include * @param separation 2- or 3-vector indicating separation in respective axes * @param center Boolean or vector indicating which axes to center */ -module mcad_array_rectangular (grid_size, separation, center = true) +module mcad_array_rectangular(grid_size, separation, center = true) { - mcad_place_at (mcad_generate_grid (grid_size = grid_size, - separation = separation, - center = center)) - children (); + mcad_place_at(mcad_generate_grid( + grid_size = grid_size, separation = separation, center = center)) + children(); } /** @@ -44,12 +41,10 @@ module mcad_array_rectangular (grid_size, separation, center = true) * @param separation Separation between centers of adjacent copies * @param axis Direction to project toward */ -module mcad_linear_multiply (no, separation, axis = Z, center = false) +module mcad_linear_multiply(no, separation, axis = Z, center = false) { centering_offset = -1 * axis * (no - 1) * separation / 2; - translate (center ? centering_offset : [0, 0, 0]) - for (i = [0:no - 1]) - translate (i * separation * axis) - children (); + translate(center ? centering_offset : [ 0, 0, 0 ]) for (i = [0:no - 1]) + translate(i * separation * axis) children(); } diff --git a/array/translations.scad b/array/translations.scad index 9b6ec65f..0f8570b9 100644 --- a/array/translations.scad +++ b/array/translations.scad @@ -1,3 +1,4 @@ + /* * Copyright (C) 2016 Chow Loong Jin * @@ -17,19 +18,17 @@ * 02110-1301 USA */ -use -use +use + use -/** - * Convert vector of points to vector of translation matrices - * - * @param points Vector of points - * @returns Vector of translation matrices - **/ -function mcad_points2translations (points) = [ - for (point = points) - translation (point) -]; + /** + * Convert vector of points to vector of translation matrices + * + * @param points Vector of points + * @returns Vector of translation matrices + **/ + function mcad_points2translations(points) = [for (point = points) + translation(point)]; /** * Generate vector of points that represents grid @@ -38,48 +37,42 @@ function mcad_points2translations (points) = [ * @param separation 2- or 3-vector indicating separation in respective axes * @param center Boolean or vector indicating which axes to center */ -function mcad_generate_grid (grid_size, separation, center = false) = ( - let ( - sep = len (separation) > 0 ? separation : [1, 1, 1] * separation, - g = grid_size, - center = len(center) > 0 ? center : [center, center, center], - - center_offset = [ - for (i = [0:len(g)]) - (center[i]) ? (g[i] - 1) * sep[i] / 2 : 0 - ] - ) +function mcad_generate_grid(grid_size, separation, center = false) = + (let(sep = len(separation) > 0 ? separation : [ 1, 1, 1 ] * separation, + g = grid_size, + center = len(center) > 0 ? center : [ center, center, center ], - (len (grid_size) == 2) ? [ - for (x = [0 : g[0] - 1]) - for (y = [0 : g[1] - 1]) - [x * sep[0], y * sep[1]] - center_offset - ] : - (len (grid_size) == 3) ? [ - for (x = [0 : g[0] - 1]) - for (y = [0 : g[1] - 1]) - for (z = [0 : g[2] - 1]) - [x * sep[0], y * sep[1], z * sep[2]] - center_offset - ] : [] -); + center_offset = [for (i = [0:len(g)])(center[i]) + ? (g[i] - 1) * sep[i] / 2 + : 0]) + (len(grid_size) == 2) + ? [for (x = [0:g[0] - 1]) for (y = [0:g[1] - + 1])[x * sep[0], y* sep[1]] - + center_offset] + : (len(grid_size) == 3) + ? [for (x = [0:g[0] - 1]) for (y = [0:g[1] - 1]) for ( + z = [0:g[2] - 1])[x * sep[0], y* sep[1], z* sep[2]] - + center_offset] + : []); /** * Place children at points * * @param List of points. */ -module mcad_place_at (points) +module mcad_place_at(points) { - mcad_multiply (mcad_points2translations (points), keep_original = false) - children (); + mcad_multiply(mcad_points2translations(points), keep_original = false) + children(); } /** * Test mcad_place_at module */ -module mcad_test_place_at () +module +mcad_test_place_at() { - mcad_place_at (mcad_generate_grid ([10, 10, 10], separation = $t * 10, - center = true)); + mcad_place_at(mcad_generate_grid( + [ 10, 10, 10 ], separation = $t * 10, center = true)); } diff --git a/boxes.scad b/boxes.scad index 40d2e9e9..5d266449 100644 --- a/boxes.scad +++ b/boxes.scad @@ -1,5 +1,4 @@ use - // @deprecated -module roundedBox (size, radius, sidesonly, center = true) -mcad_rounded_box (size, radius, sidesonly, center); +module roundedBox(size, radius, sidesonly, center = true) + mcad_rounded_box(size, radius, sidesonly, center); diff --git a/curves.scad b/curves.scad index 0e20005f..b439d948 100644 --- a/curves.scad +++ b/curves.scad @@ -1,21 +1,15 @@ +include +use // Parametric curves, to be used as paths // Licensed under the MIT license. // © 2010 by Elmo Mäntynen -use -include - - -/* A circular helix of radius a and pitch 2πb is described by the following parametrisation: -x(t) = a*cos(t), -y(t) = a*sin(t), -z(t) = b*t +/* A circular helix of radius a and pitch 2πb is described by the following +parametrisation: x(t) = a*cos(t), y(t) = a*sin(t), z(t) = b*t */ - -function b(pitch) = pitch/(const_tau); -function t(pitch, z) = z/b(pitch); +function b(pitch) = pitch / (const_tau); +function t(pitch, z) = z / b(pitch); function helix_curve(pitch, radius, z) = - [radius*cos(deg(t(pitch, z))), radius*sin(deg(t(pitch, z))), z]; - + [ radius * cos(deg(t(pitch, z))), radius* sin(deg(t(pitch, z))), z ]; diff --git a/demos/array_along_curve_demo.scad b/demos/array_along_curve_demo.scad index eadaf023..0ce252c6 100644 --- a/demos/array_along_curve_demo.scad +++ b/demos/array_along_curve_demo.scad @@ -1,22 +1,23 @@ -include ; -//center reference point -translate([0,0,0]) -#cube([5,5,5],center=true); +include; -spin(3,30,Z) +// center reference point +translate([ 0, 0, 0 ]) +#cube([ 5, 5, 5 ], center = true); + + spin(3, 30, Z) { - translate([5,5,5]) -#cube([5,5,5],center=true); - // square([25,10]); - // square([25,10]); - // square([25,10]); - // square([25,10]); - // square([25,10]); + translate([ 5, 5, 5 ]) +#cube([ 5, 5, 5 ], center = true); + // square([25,10]); + // square([25,10]); + // square([25,10]); + // square([25,10]); + // square([25,10]); } -//cubic array of 5*5*5 objects spaced 10*10*10 center relative -//array_linear(20) +// cubic array of 5*5*5 objects spaced 10*10*10 center relative +// array_linear(20) //{ // sphere(2.5,center=true,$fn=60); // cylinder(h=10,r=.5,center=true); @@ -26,8 +27,8 @@ spin(3,30,Z) // cylinder(h=10,r=.5,center=true); //} // -//translate([0,0,10]) -//array_linear_grid(30,15,false,3) +// translate([0,0,10]) +// array_linear_grid(30,15,false,3) //{ // square([25,10]); // square([25,10]); diff --git a/demos/array_linear_demo.scad b/demos/array_linear_demo.scad index ca14dfa7..8f547c34 100644 --- a/demos/array_linear_demo.scad +++ b/demos/array_linear_demo.scad @@ -1,38 +1,36 @@ -include ; -//center reference point -translate([0,0,0]) -#cube([5,5,5],center=true); +include; -array_linear(25) +// center reference point +translate([ 0, 0, 0 ]) +#cube([ 5, 5, 5 ], center = true); + + array_linear(25) { - square([25,10]); - square([25,10]); - square([25,10]); - square([25,10]); - square([25,10]); + square([ 25, 10 ]); + square([ 25, 10 ]); + square([ 25, 10 ]); + square([ 25, 10 ]); + square([ 25, 10 ]); } -//cubic array of 5*5*5 objects spaced 10*10*10 center relative +// cubic array of 5*5*5 objects spaced 10*10*10 center relative array_linear(20) { - sphere(2.5,center=true,$fn=60); - cylinder(h=10,r=.5,center=true); - rotate([90,0,0]) - cylinder(h=10,r=.5,center=true); - rotate([0,90,0]) - cylinder(h=10,r=.5,center=true); + sphere(2.5, center = true, $fn = 60); + cylinder(h = 10, r = .5, center = true); + rotate([ 90, 0, 0 ]) cylinder(h = 10, r = .5, center = true); + rotate([ 0, 90, 0 ]) cylinder(h = 10, r = .5, center = true); } - translate([0,0,10]) -array_linear_grid(30,15,false,3) +translate([ 0, 0, 10 ]) array_linear_grid(30, 15, false, 3) { - square([25,10]); - square([25,10]); - square([25,10]); - square([25,10]); - square([25,10]); - square([25,10]); - square([25,10]); - square([25,10]); + square([ 25, 10 ]); + square([ 25, 10 ]); + square([ 25, 10 ]); + square([ 25, 10 ]); + square([ 25, 10 ]); + square([ 25, 10 ]); + square([ 25, 10 ]); + square([ 25, 10 ]); } diff --git a/demos/array_polar_demo.scad b/demos/array_polar_demo.scad index bf3c6311..596707b7 100644 --- a/demos/array_polar_demo.scad +++ b/demos/array_polar_demo.scad @@ -1,29 +1,25 @@ -include ; -include ; -//center reference point -translate([0,0,0]) -#cube([5,5,5],center=true); +include; +include; - //radial array of 32 objects rotated though 10 degrees - translate([0,0,0]) -array_polar(10,32,40) +// center reference point +translate([ 0, 0, 0 ]) +#cube([ 5, 5, 5 ], center = true); + + // radial array of 32 objects rotated though 10 degrees + translate([ 0, 0, 0 ]) array_polar(10, 32, 40) { - cube([2,4,6],center=true); + cube([ 2, 4, 6 ], center = true); } -// a radial array of linear arrays +// a radial array of linear arrays - rotate([45,45,45]) -array_polar(10,36,40) +rotate([ 45, 45, 45 ]) array_polar(10, 36, 40) { - translate([0,10,0]) - array_rectangular(0,10,0,1,5,1,center=false) - { - cube([2,3,4],center=true); - cylinder(h=10,r=.5,center=true); - rotate([90,0,0]) - cylinder(h=10,r=.5,center=true); - } + translate([ 0, 10, 0 ]) array_rectangular(0, 10, 0, 1, 5, 1, center = false) + { + cube([ 2, 3, 4 ], center = true); + cylinder(h = 10, r = .5, center = true); + rotate([ 90, 0, 0 ]) cylinder(h = 10, r = .5, center = true); + } } - diff --git a/demos/array_rectangular_demo.scad b/demos/array_rectangular_demo.scad index 0d3195c9..855384ea 100644 --- a/demos/array_rectangular_demo.scad +++ b/demos/array_rectangular_demo.scad @@ -1,43 +1,38 @@ -include ; -//center reference point -translate([0,0,0]) -#cube([5,5,5],center=true); +include; - //cubic array of 5*5*5 objects spaced 10*10*10 center relative -array_rectangular(10,10,10,5,5,5,center=true) +// center reference point +translate([ 0, 0, 0 ]) +#cube([ 5, 5, 5 ], center = true); + + // cubic array of 5*5*5 objects spaced 10*10*10 center relative + array_rectangular(10, 10, 10, 5, 5, 5, center = true) { - sphere(2.5,center=true,$fn=60); - cylinder(h=10,r=.5,center=true); - rotate([90,0,0]) - cylinder(h=10,r=.5,center=true); - rotate([0,90,0]) - cylinder(h=10,r=.5,center=true); + sphere(2.5, center = true, $fn = 60); + cylinder(h = 10, r = .5, center = true); + rotate([ 90, 0, 0 ]) cylinder(h = 10, r = .5, center = true); + rotate([ 0, 90, 0 ]) cylinder(h = 10, r = .5, center = true); } -//a linear array allong x can be derived from the cubic array simply - translate([60,0,0]) -array_rectangular(10,0,0,5,1,1,center=false) +// a linear array allong x can be derived from the cubic array simply +translate([ 60, 0, 0 ]) array_rectangular(10, 0, 0, 5, 1, 1, center = false) { - cube([5,5,5],center=true); -} -//a linear array allong y can be derived from the cubic array simply - translate([0,60,0]) -array_rectangular(0,10,0,1,5,1,center=false) + cube([ 5, 5, 5 ], center = true); +} +// a linear array allong y can be derived from the cubic array simply +translate([ 0, 60, 0 ]) array_rectangular(0, 10, 0, 1, 5, 1, center = false) { - cube([5,5,5],center=true); -} + cube([ 5, 5, 5 ], center = true); +} -//a linear array allong z can be derived from the cubic array simply - translate([0,0,60]) -array_rectangular(0,0,10,1,1,5,center=false) +// a linear array allong z can be derived from the cubic array simply +translate([ 0, 0, 60 ]) array_rectangular(0, 0, 10, 1, 1, 5, center = false) { - cube([5,5,5],center=true); -} + cube([ 5, 5, 5 ], center = true); +} -//a grid array allong x,y can be derived from the cubic array simply - translate([0,0,-60]) -array_rectangular(10,10,0,5,5,1,center=true) +// a grid array allong x,y can be derived from the cubic array simply +translate([ 0, 0, -60 ]) array_rectangular(10, 10, 0, 5, 5, 1, center = true) { - cube([5,5,5],center=true); -} + cube([ 5, 5, 5 ], center = true); +} diff --git a/demos/bearing_demo.scad b/demos/bearing_demo.scad index e2933cec..95a132fc 100644 --- a/demos/bearing_demo.scad +++ b/demos/bearing_demo.scad @@ -1,18 +1,25 @@ -include ; + +include; // Example, uncomment to view test_bearing(); -translate([0,40,0]) test_bearing_hole(); +translate([ 0, 40, 0 ]) test_bearing_hole(); -module test_bearing(){ +module +test_bearing() +{ bearing(); - bearing(pos=[5*length_cm, 0,0], angle=[90,0,0]); - bearing(pos=[-2.5*length_cm, 0,0], model=624); + bearing(pos = [ 5 * length_cm, 0, 0 ], angle = [ 90, 0, 0 ]); + bearing(pos = [ -2.5 * length_cm, 0, 0 ], model = 624); } -module test_bearing_hole(){ - difference(){ - translate([0, 0, 3.5]) cube(size=[30, 30, 7-10*epsilon], center=true); - bearing(outline=true); +module +test_bearing_hole() +{ + difference() + { + translate([ 0, 0, 3.5 ]) + cube(size = [ 30, 30, 7 - 10 * epsilon ], center = true); + bearing(outline = true); } } \ No newline at end of file diff --git a/demos/constants_demo.scad b/demos/constants_demo.scad index b581bb2d..a9ed9746 100644 --- a/demos/constants_demo.scad +++ b/demos/constants_demo.scad @@ -1,12 +1,13 @@ -include ; + +include; echo(const_e = const_e); echo(const_pi = const_pi); echo(const_tau = const_tau); echo(const_phi = const_phi); echo(const_sqrt2 = const_sqrt2); -echo(const_sqrt2 * const_sqrt2); +echo(const_sqrt2* const_sqrt2); echo(const_sqrt3 = const_sqrt3); -echo(const_sqrt3 * const_sqrt3); +echo(const_sqrt3* const_sqrt3); echo(const_sqrt5 = const_sqrt5); -echo(const_sqrt5 * const_sqrt5); +echo(const_sqrt5* const_sqrt5); diff --git a/demos/hardware_demo.scad b/demos/hardware_demo.scad index 7cc3be41..8f0967e0 100644 --- a/demos/hardware_demo.scad +++ b/demos/hardware_demo.scad @@ -1,10 +1,11 @@ -include ; + +include; rod(20); -translate([rodsize * 2.5, 0, 0]) rod(20, true); -translate([rodsize * 5, 0, 0]) screw(10, true); -translate([rodsize * 7.5, 0, 0]) bearing(); -translate([rodsize * 10, 0, 0]) rodnut(); -translate([rodsize * 12.5, 0, 0]) rodwasher(); -translate([rodsize * 15, 0, 0]) nut(); -translate([rodsize * 17.5, 0, 0]) washer(); \ No newline at end of file +translate([ rodsize * 2.5, 0, 0 ]) rod(20, true); +translate([ rodsize * 5, 0, 0 ]) screw(10, true); +translate([ rodsize * 7.5, 0, 0 ]) bearing(); +translate([ rodsize * 10, 0, 0 ]) rodnut(); +translate([ rodsize * 12.5, 0, 0 ]) rodwasher(); +translate([ rodsize * 15, 0, 0 ]) nut(); +translate([ rodsize * 17.5, 0, 0 ]) washer(); \ No newline at end of file diff --git a/demos/linear_bearing_demo.scad b/demos/linear_bearing_demo.scad index 3b5bbc4c..38f133fb 100644 --- a/demos/linear_bearing_demo.scad +++ b/demos/linear_bearing_demo.scad @@ -1,5 +1,6 @@ -include ; -//examples -linearBearing(model="LM8UU"); -translate([20,0,0]) linearBearing(model="LM10UU"); \ No newline at end of file +include; + +// examples +linearBearing(model = "LM8UU"); +translate([ 20, 0, 0 ]) linearBearing(model = "LM10UU"); \ No newline at end of file diff --git a/demos/materials_demo.scad b/demos/materials_demo.scad index 7a109c78..afd5d1f2 100644 --- a/demos/materials_demo.scad +++ b/demos/materials_demo.scad @@ -1,9 +1,12 @@ -include ; + +include; // Example, uncomment to view color_demo(); -module color_demo(){ +module +color_demo() +{ // Wood colorTest(Oak, 0, 0); colorTest(Pine, 1, 0); @@ -22,6 +25,7 @@ module color_demo(){ colorTest(BlackPaint, 0, 3); } -module colorTest(col, row=0, c=0) { - color(col) translate([row * 30,c*30,0]) sphere(r=10); +module colorTest(col, row = 0, c = 0) +{ + color(col) translate([ row * 30, c * 30, 0 ]) sphere(r = 10); } diff --git a/demos/metric_demo.scad b/demos/metric_demo.scad index fc2980bf..061b622b 100644 --- a/demos/metric_demo.scad +++ b/demos/metric_demo.scad @@ -1,34 +1,51 @@ -include ; + +include; module metric_ruler(millimeters) { - difference() - { - // Body of ruler - color("Beige") - cube(size = [length_mm(millimeters), length_cm(3), length_mm(1)]); - // Centimeter markings - for (i = [0:length_cm(1):length_mm(millimeters) + epsilon]) - { - translate([i,length_cm(2.5),length_mm(0.75)]) - color("Red") - cube(size = [length_mm(0.5), length_cm(1) + epsilon, length_mm(0.5) + epsilon], center = true); - } - // Half centimeter markings - for (i = [length_cm(0.5):length_cm(1):length_mm(millimeters) + epsilon]) - { - translate([i,length_cm(2.7),length_mm(0.875)]) - color("Red") - cube(size = [length_mm(0.5), length_cm(0.6) + epsilon, length_mm(0.25) + epsilon], center = true); - } - // Millimeter markings - for (i = [length_mm(1):length_mm(1):length_mm(millimeters) + epsilon]) - { - translate([i,length_cm(2.85),length_mm(0.9375)]) - color("Red") - cube(size = [length_mm(0.5), length_cm(0.3) + epsilon, length_mm(0.125) + epsilon], center = true); - } - } + difference() + { + // Body of ruler + color("Beige") + cube(size = [ length_mm(millimeters), length_cm(3), length_mm(1) ]); + // Centimeter markings + for (i = [0:length_cm(1):length_mm(millimeters) + epsilon]) { + translate([ i, length_cm(2.5), length_mm(0.75) ]) color("Red") + cube(size = + [ + length_mm(0.5), + length_cm(1) + epsilon, + length_mm(0.5) + + epsilon + ], + center = true); + } + // Half centimeter markings + for (i = [length_cm(0.5):length_cm(1):length_mm(millimeters) + + epsilon]) { + translate([ i, length_cm(2.7), length_mm(0.875) ]) color("Red") + cube(size = + [ + length_mm(0.5), + length_cm(0.6) + epsilon, + length_mm(0.25) + + epsilon + ], + center = true); + } + // Millimeter markings + for (i = [length_mm(1):length_mm(1):length_mm(millimeters) + epsilon]) { + translate([ i, length_cm(2.85), length_mm(0.9375) ]) color("Red") + cube(size = + [ + length_mm(0.5), + length_cm(0.3) + epsilon, + length_mm(0.125) + + epsilon + ], + center = true); + } + } } metric_ruler(100); diff --git a/demos/polyhole_demo.scad b/demos/polyhole_demo.scad index 37e15914..b5dbe532 100644 --- a/demos/polyhole_demo.scad +++ b/demos/polyhole_demo.scad @@ -1,19 +1,22 @@ include +module +polyhole_demo() +{ + difference() + { + cube(size = [ 100, 27, 3 ]); + union() + { + for (i = [1:10]) { + translate([ (i * i + i) / 2 + 3 * i, 8, -1 ]) + mcad_polyhole(h = 5, d = i); -module polyhole_demo(){ -difference() { - cube(size = [100,27,3]); - union() { - for(i = [1:10]) { - translate([(i * i + i)/2 + 3 * i , 8,-1]) - mcad_polyhole(h = 5, d = i); - - assign(d = i + 0.5) - translate([(d * d + d)/2 + 3 * d, 19,-1]) - mcad_polyhole(h = 5, d = d); - } + assign(d = i + 0.5) + translate([ (d * d + d) / 2 + 3 * d, 19, -1 ]) + mcad_polyhole(h = 5, d = d); + } + } } } -} polyhole_demo(); diff --git a/demos/rack_and_pinion_demo.scad b/demos/rack_and_pinion_demo.scad index ddb03434..c16ffb13 100644 --- a/demos/rack_and_pinion_demo.scad +++ b/demos/rack_and_pinion_demo.scad @@ -1,10 +1,14 @@ -include ; + +include; // examples of usage // include this in your code: // use // then: // a simple rack -rack(4,20,10,1);//CP (mm/tooth), width (mm), thickness(of base) (mm), # teeth +rack(4, + 20, + 10, + 1); // CP (mm/tooth), width (mm), thickness(of base) (mm), # teeth // a simple pinion and translation / rotation to make it mesh the rack -translate([0,-8.5,0])rotate([0,0,360/10/2]) pinion(4,10,10,5); \ No newline at end of file +translate([ 0, -8.5, 0 ]) rotate([ 0, 0, 360 / 10 / 2 ]) pinion(4, 10, 10, 5); \ No newline at end of file diff --git a/demos/stepper_demo.scad b/demos/stepper_demo.scad index 08bd6425..fc9db053 100644 --- a/demos/stepper_demo.scad +++ b/demos/stepper_demo.scad @@ -1,24 +1,27 @@ -include ; + +include; // Demo, uncomment to show: nema_demo(); -module test_nema14() +module +test_nema14() { - motor(Nema14, NemaLong, dualAxis=false); - //motor(); + motor(Nema14, NemaLong, dualAxis = false); + // motor(); } - -module nema_demo(){ - for (size = [NemaShort, NemaMedium, NemaLong]) { - translate([-100,size*100,0]) motor(Nema34, size, dualAxis=true); - translate([0,size*100,0]) motor(Nema23, size, dualAxis=true); - translate([100,size*100,0]) motor(Nema17, size, dualAxis=true); - translate([200,size*100,0]) motor(Nema14, size, dualAxis=true); - translate([300,size*100,0]) motor(Nema11, size, dualAxis=true); - translate([400,size*100,0]) motor(Nema08, size, dualAxis=true); +module +nema_demo() +{ + for (size = [ NemaShort, NemaMedium, NemaLong ]) { + translate([ -100, size * 100, 0 ]) motor(Nema34, size, dualAxis = true); + translate([ 0, size * 100, 0 ]) motor(Nema23, size, dualAxis = true); + translate([ 100, size * 100, 0 ]) motor(Nema17, size, dualAxis = true); + translate([ 200, size * 100, 0 ]) motor(Nema14, size, dualAxis = true); + translate([ 300, size * 100, 0 ]) motor(Nema11, size, dualAxis = true); + translate([ 400, size * 100, 0 ]) motor(Nema08, size, dualAxis = true); } } -//test_nema14(); +// test_nema14(); diff --git a/demos/string_demo.scad b/demos/string_demo.scad index c3e6560a..fd36ebae 100644 --- a/demos/string_demo.scad +++ b/demos/string_demo.scad @@ -1,59 +1,63 @@ -include ; + +include; // Uncomment this bloc to see how to use this library. - // strToInt(string [,base]) - - // Resume : Converts a number in string. - // string : The string you wants to converts. - // base (optional) : The base conversion of the number : 2 for binay, 10 for decimal (default), 16 for hexadecimal. - echo("*** strToInt() ***"); - echo(strToInt("491585")); - echo(strToInt("01110", 2)); - echo(strToInt("D5A4", 16)); - echo(strToInt("-15")); - echo(strToInt("-5") + strToInt("10") + 5); - - // strcat(vector [,insert]) - - // Resume : Concatenates a vector of words into a string. - // vector : A vector of string. - // insert (optional) : A string which will added between each words. - echo("*** strcat() ***"); - v_data = ["OpenScad", "is", "a", "free", "CAD", "software."]; - echo(strcat(v_data)); // ECHO: "OpenScadisafreeCADsoftware." - echo(strcat(v_data, " ")); // ECHO: "OpenScad is a free CAD software." - - // substr(str, pos [,length]) - - // Resume : Substract a substring from a bigger string. - // str : The original string - // pos : The index of the position where the substring will begin. - // length (optional) : The length of the substring. If not specified, the substring will continue until the end of the string. - echo("*** substr() ***"); - str = "OpenScad is a free CAD software."; - echo(str); // ECHO: "OpenScad is a free CAD software." - echo(substr(str, 0, 11)); // ECHO: "OpenScad is" - echo(substr(str, 12)); // ECHO: "a free CAD software." - echo(substr(str, 12, 10)); // ECHO: "a free CAD" - - // fill(string, occurrences) - - // Resume : Fill a string with several characters (or strings). - // string : the character or string which will be copied. - // occurrences : The number of occurences of the string. - echo("*** Fill() ***"); - echo(fill("0", 4)); // ECHO: "0000" - echo(fill("hey", 3)); // ECHO: "heyheyhey" - - // getsplit(string, index [,separator]) - - // Resume : Split a string in several words. - // string : The original string. - // index : The index of the word to get. - // separator : The separator which cut the string (default is " "). - // Note : Nowadays it's impossible to get a vector of words because we can't append data in a vector. - echo("*** getsplit() ***"); - echo(getsplit(str)); - echo(getsplit(str, 3)); - echo(getsplit("123, 456, 789", 1, ", ")); \ No newline at end of file +// strToInt(string [,base]) + +// Resume : Converts a number in string. +// string : The string you wants to converts. +// base (optional) : The base conversion of the number : 2 for binay, 10 for +// decimal (default), 16 for hexadecimal. +echo("*** strToInt() ***"); +echo(strToInt("491585")); +echo(strToInt("01110", 2)); +echo(strToInt("D5A4", 16)); +echo(strToInt("-15")); +echo(strToInt("-5") + strToInt("10") + 5); + +// strcat(vector [,insert]) + +// Resume : Concatenates a vector of words into a string. +// vector : A vector of string. +// insert (optional) : A string which will added between each words. +echo("*** strcat() ***"); +v_data = [ "OpenScad", "is", "a", "free", "CAD", "software." ]; +echo(strcat(v_data)); // ECHO: "OpenScadisafreeCADsoftware." +echo(strcat(v_data, " ")); // ECHO: "OpenScad is a free CAD software." + +// substr(str, pos [,length]) + +// Resume : Substract a substring from a bigger string. +// str : The original string +// pos : The index of the position where the substring will begin. +// length (optional) : The length of the substring. If not specified, the +// substring will continue until the end of the string. +echo("*** substr() ***"); +str = "OpenScad is a free CAD software."; +echo(str); // ECHO: "OpenScad is a free CAD software." +echo(substr(str, 0, 11)); // ECHO: "OpenScad is" +echo(substr(str, 12)); // ECHO: "a free CAD software." +echo(substr(str, 12, 10)); // ECHO: "a free CAD" + +// fill(string, occurrences) + +// Resume : Fill a string with several characters (or strings). +// string : the character or string which will be copied. +// occurrences : The number of occurences of the string. +echo("*** Fill() ***"); +echo(fill("0", 4)); // ECHO: "0000" +echo(fill("hey", 3)); // ECHO: "heyheyhey" + +// getsplit(string, index [,separator]) + +// Resume : Split a string in several words. +// string : The original string. +// index : The index of the word to get. +// separator : The separator which cut the string (default is " "). +// Note : Nowadays it's impossible to get a vector of words because we can't +// append data in a vector. +echo("*** getsplit() ***"); +echo(getsplit(str)); +echo(getsplit(str, 3)); +echo(getsplit("123, 456, 789", 1, ", ")); \ No newline at end of file diff --git a/demos/teardrop_demo.scad b/demos/teardrop_demo.scad index cc737512..26cd2254 100644 --- a/demos/teardrop_demo.scad +++ b/demos/teardrop_demo.scad @@ -1,10 +1,13 @@ -include ; -module teardrop_demo(){ - translate([0, -30, 0]) flat_teardrop(5, 20, 90); - translate([0, -15, 0]) teardrop(5, 20, 90); - translate([0, 0, 0]) teardrop(5, 20, 60); - translate([0, 15, 0]) teardrop(5, 20, 45); +include; + +module +teardrop_demo() +{ + translate([ 0, -30, 0 ]) flat_teardrop(5, 20, 90); + translate([ 0, -15, 0 ]) teardrop(5, 20, 90); + translate([ 0, 0, 0 ]) teardrop(5, 20, 60); + translate([ 0, 15, 0 ]) teardrop(5, 20, 45); } teardrop_demo(); diff --git a/demos/visibonecolors_demo.scad b/demos/visibonecolors_demo.scad index 29351590..91e22901 100644 --- a/demos/visibonecolors_demo.scad +++ b/demos/visibonecolors_demo.scad @@ -1,14 +1,16 @@ -include ; -module visibonecolorstest() +include; + +module +visibonecolorstest() { - /* - 216 colors: 12 x 18 matrix - Not all colors are tested because OpenSCAD has limited support - for variable re-assignment :( - 'nuff said! - */ - colors = + /* + 216 colors: 12 x 18 matrix + Not all colors are tested because OpenSCAD has limited support + for variable re-assignment :( + 'nuff said! + */ + colors = [PPR, PPM, RRP, MMP, DRP, DMP, LRP, LMP, DPR, DPM, LPR, LPM, MPR, MPM, OOY, OOR, YYO, RRO, DYO, DRO, LYO, LRO, DOY, DOR, LOY, LOR, MOY, MOR, SSG, SSY, GGS, YYS, DGS, DYS, LGS, LYS, @@ -28,13 +30,12 @@ module visibonecolorstest() ODT, DDT, LDT, PDT, DHT, LHT, ODA, DDA, LDA, PDA, DHA, LHA, ODV, DDV, LDV, PDV, DHV, LHV, K, OG, DG, LG, PG, W]; - for (i=[1:12]) - { - for (j=[1:18]) - { - color(colors[i*j]) translate([(i-1)*4,(j-1)*4,0]) sphere(2); - } - } + for (i = [1:12]) { + for (j = [1:18]) { + color(colors[i * j]) translate([ (i - 1) * 4, (j - 1) * 4, 0 ]) + sphere(2); + } + } } visibonecolorstest(); diff --git a/electronics/ATXpowerSupply.scad b/electronics/ATXpowerSupply.scad index c99108a0..bb82fae2 100644 --- a/electronics/ATXpowerSupply.scad +++ b/electronics/ATXpowerSupply.scad @@ -1,3 +1,4 @@ +include /* * Copyright (C) 2012 Krallinger Sebastian * @@ -15,63 +16,83 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -*/ - -include + */ +ATX_outlines = [ 86, 140, 150 ]; //!< metal box outline -ATX_outlines = [86,140,150]; //!< metal box outline - -ATX_threadedHoles = [[6,30],[16,144],[80,6],[80,144]]; //!< thread hols M4 in the x,z Coordinates 0:@powerconector corner +ATX_threadedHoles = [ + [ 6, 30 ], + [ 16, 144 ], + [ 80, 6 ], + [ 80, 144 ] +]; //!< thread hols M4 in the x,z Coordinates 0:@powerconector corner ATX_threadedHoleDiameter = 4; -ATX_threadedHoleDepth = 10; +ATX_threadedHoleDepth = 10; -ATX_fanPos = [43,100]; -ATX_fanDiameter = 74; -ATX_fanDepth = 5; +ATX_fanPos = [ 43, 100 ]; +ATX_fanDiameter = 74; +ATX_fanDepth = 5; -ATX_powConPos = [24,30]; -ATX_powConSize = [22,40]; -ATX_powHeight = 5; +ATX_powConPos = [ 24, 30 ]; +ATX_powConSize = [ 22, 40 ]; +ATX_powHeight = 5; -ATX_wireHarnesPos = [53,16]; -ATX_wireHarnesDiameter = 14; -ATX_wireHarnesLenght = 10; +ATX_wireHarnesPos = [ 53, 16 ]; +ATX_wireHarnesDiameter = 14; +ATX_wireHarnesLenght = 10; /** -* @brief ATX power Suply. -* -* http://www.formfactors.org/developer/specs/ATX12V_PSDG_2_2_public_br2.pdf. -* @param[in,out] VALUE DESCRIPTION -* @return DESCRIPTION -**/ -module powerSuplyATX() { - difference() { - union(){ - // box - color("Gainsboro") cube(size=ATX_outlines, center=false); + * @brief ATX power Suply. + * + * http://www.formfactors.org/developer/specs/ATX12V_PSDG_2_2_public_br2.pdf. + * @param[in,out] VALUE DESCRIPTION + * @return DESCRIPTION + **/ +module +powerSuplyATX() +{ + difference() + { + union() + { + // box + color("Gainsboro") cube(size = ATX_outlines, center = false); - // wireHarnest - color("DarkOrange") translate([ATX_wireHarnesPos[0], ATX_outlines[1]+ATX_wireHarnesLenght-OS, ATX_wireHarnesPos[1]]) rotate(a=90,v=X) - cylinder(r=ATX_wireHarnesDiameter/2, h=ATX_wireHarnesLenght+OS, center=false); + // wireHarnest + color("DarkOrange") translate([ + ATX_wireHarnesPos[0], + ATX_outlines[1] + ATX_wireHarnesLenght - OS, + ATX_wireHarnesPos[1] + ]) rotate(a = 90, v = X) cylinder(r = ATX_wireHarnesDiameter / 2, + h = ATX_wireHarnesLenght + OS, + center = false); - // power - color("DarkSlateGray") translate([ATX_powConPos[0], -OS, ATX_powConPos[1]]) - cube(size=[ATX_powConSize[0], ATX_powHeight, ATX_powConSize[1]], center=true); - } - union(){ - // thread holse - for (i=ATX_threadedHoles) { - color("Black") translate([i[0], +ATX_threadedHoleDepth-OS, i[1]]) rotate(a=90,v=X) - cylinder(r=ATX_threadedHoleDiameter/2, h=ATX_threadedHoleDepth+OS, center=false); - } + // power + color("DarkSlateGray") + translate([ ATX_powConPos[0], -OS, ATX_powConPos[1] ]) cube( + size = + [ ATX_powConSize[0], ATX_powHeight, ATX_powConSize[1] ], + center = true); + } + union() + { + // thread holse + for (i = ATX_threadedHoles) { + color("Black") + translate([ i[0], +ATX_threadedHoleDepth - OS, i[1] ]) + rotate(a = 90, v = X) + cylinder(r = ATX_threadedHoleDiameter / 2, + h = ATX_threadedHoleDepth + OS, + center = false); + } - // fan - color("Black") translate([ATX_fanPos[0], +ATX_fanDepth-OS, ATX_fanPos[1]]) rotate(a=90,v=X) - cylinder(r=ATX_fanDiameter/2, h=ATX_fanDepth+OS, center=false); - - - } - } + // fan + color("Black") + translate([ ATX_fanPos[0], +ATX_fanDepth - OS, ATX_fanPos[1] ]) + rotate(a = 90, v = X) cylinder(r = ATX_fanDiameter / 2, + h = ATX_fanDepth + OS, + center = false); + } + } } -//powerSuplyATX(); +// powerSuplyATX(); diff --git a/extrusions/8020.scad b/extrusions/8020.scad index 40b2d681..46a5e4cf 100644 --- a/extrusions/8020.scad +++ b/extrusions/8020.scad @@ -1,50 +1,78 @@ -module profile_8020_fractional_1010 () { - profile_tslot_generic (pitch = 1, slot = 0.26, lip = 0.1, web = 0.13, core = 0.45, hole = 0.28); + +module +profile_8020_fractional_1010() +{ + profile_tslot_generic(pitch = 1, + slot = 0.26, + lip = 0.1, + web = 0.13, + core = 0.45, + hole = 0.28); } // module extrusion_8020_1001(h) { - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("8020/8020-1001.dxf"); - } + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0) + { + import("8020/8020-1001.dxf"); + } } // module extrusion_8020_1002(h) { - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("8020/8020-1002.dxf"); - } + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0) + { + import("8020/8020-1002.dxf"); + } } // module extrusion_8020_1003(h) { - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("8020/8020-1003.dxf"); - } + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0) + { + import("8020/8020-1003.dxf"); + } } // module extrusion_8020_1004(h) { - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("8020/8020-1004.dxf"); - } + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0) + { + import("8020/8020-1004.dxf"); + } } module 8020_line_up_and_wait() { - extrusion_8020_1001(20, $fn=36); - translate([30,0,0]) extrusion_8020_1002(20, $fn=36); - translate([60,0,0]) extrusion_8020_1003(20, $fn=36); - translate([90,0,0]) extrusion_8020_1004(20, $fn=36); + extrusion_8020_1001(20, $fn = 36); + translate([ 30, 0, 0 ]) extrusion_8020_1002(20, $fn = 36); + translate([ 60, 0, 0 ]) extrusion_8020_1003(20, $fn = 36); + translate([ 90, 0, 0 ]) extrusion_8020_1004(20, $fn = 36); } 8020_line_up_and_wait(); \ No newline at end of file diff --git a/extrusions/extrusions.scad b/extrusions/extrusions.scad index 2c269218..6d7f278b 100644 --- a/extrusions/extrusions.scad +++ b/extrusions/extrusions.scad @@ -1,3 +1,4 @@ + // ============================================== // Miscellaneous profiles (aluminum etc) // By Vitaly Mankevich / contraptor.org, (c) 2012 @@ -21,71 +22,91 @@ // linear_extrude (height = 3.5) profile_square_tube(1.5, 1/8); // -include ; -include ; -include ; -include ; +include; +include; +include; +include; $fn = 24; -module profile_angle_equal(side, wall) { - difference () { - square (side); - translate([wall, wall, 0]) square (side - wall); - } +module profile_angle_equal(side, wall) +{ + difference() + { + square(side); + translate([ wall, wall, 0 ]) square(side - wall); + } } -module profile_angle_unequal(side_x, side_y, wall) { - difference () { - square ([side_x, side_y]); - translate ([wall, wall, 0]) square ([side_x - wall, side_y - wall]); - } +module profile_angle_unequal(side_x, side_y, wall) +{ + difference() + { + square([ side_x, side_y ]); + translate([ wall, wall, 0 ]) square([ side_x - wall, side_y - wall ]); + } } -module profile_square_tube(side, wall) { - difference () { - square (side, center = true); - square (side-wall*2, center = true); - } +module profile_square_tube(side, wall) +{ + difference() + { + square(side, center = true); + square(side - wall * 2, center = true); + } } -module profile_rect_tube(side_x, side_y, wall) { - difference () { - square ([side_x, side_y], center = true); - square ([side_x - wall*2, side_y - wall*2], center = true); - } +module profile_rect_tube(side_x, side_y, wall) +{ + difference() + { + square([ side_x, side_y ], center = true); + square([ side_x - wall * 2, side_y - wall * 2 ], center = true); + } } -module profile_channel(base, side, wall) { - translate ([0, side/2, 0]) difference () { - square ([base, side], center = true); - translate ([0, wall/2, 0]) square ([base - wall*2, side - wall], center = true); - } +module profile_channel(base, side, wall) +{ + translate([ 0, side / 2, 0 ]) difference() + { + square([ base, side ], center = true); + translate([ 0, wall / 2, 0 ]) + square([ base - wall * 2, side - wall ], center = true); + } } -module profile_tslot_generic (pitch, slot, lip, web, hole) { - // pitch = side width, slot = slot width, lip = thickness of the lip, web = thickness of the web, core = side of the center square, hole = center hole diameter - difference () { - union() { - difference () { - square (pitch, center=true); - square (pitch - lip*2, center=true); - square ([pitch, slot], center=true); - square ([slot, pitch], center=true); - } - rotate ([0, 0, 45]) square ([pitch*1.15, web], center=true); - rotate ([0, 0, -45]) square ([pitch*1.15, web], center=true); - square (core, center=true); - } - circle (hole/2, center = true); - } +module profile_tslot_generic(pitch, slot, lip, web, hole) +{ + // pitch = side width, slot = slot width, lip = thickness of the lip, web = + // thickness of the web, core = side of the center square, hole = center + // hole diameter + difference() + { + union() + { + difference() + { + square(pitch, center = true); + square(pitch - lip * 2, center = true); + square([ pitch, slot ], center = true); + square([ slot, pitch ], center = true); + } + rotate([ 0, 0, 45 ]) square([ pitch * 1.15, web ], center = true); + rotate([ 0, 0, -45 ]) square([ pitch * 1.15, web ], center = true); + square(core, center = true); + } + circle(hole / 2, center = true); + } } -module profile_misumi_metric_2020 () { - profile_tslot_generic (pitch = 20, slot = 5.2, lip = 2, web = 2.6, core = 9, hole = 5.6); +module +profile_misumi_metric_2020() +{ + profile_tslot_generic( + pitch = 20, slot = 5.2, lip = 2, web = 2.6, core = 9, hole = 5.6); } // Line up and wait extrusion_makerbeam(30); -translate([17.5, 0, 0]) extrusion_openbeam_v1(30); -translate([37.5, 0, 0]) extrusion_openbeam_v2(30, $fn=36); +translate([ 17.5, 0, 0 ]) extrusion_openbeam_v1(30); +translate([ 37.5, 0, 0 ]) extrusion_openbeam_v2(30, $fn = 36); diff --git a/extrusions/makerbeam.scad b/extrusions/makerbeam.scad index 7b573763..b8d90fe5 100644 --- a/extrusions/makerbeam.scad +++ b/extrusions/makerbeam.scad @@ -1,9 +1,12 @@ -module extrusion_makerbeam(h) -{ - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("MakerBeam_Cross_Section_Metric.DXF"); - } + +module extrusion_makerbeam(h){ + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0){ import("MakerBeam_Cross_Section_Metric.DXF"); +} } *extrusion_makerbeam(30); diff --git a/extrusions/misumi_nfs5.scad b/extrusions/misumi_nfs5.scad index 4ccf859b..4831bd35 100644 --- a/extrusions/misumi_nfs5.scad +++ b/extrusions/misumi_nfs5.scad @@ -1,40 +1,61 @@ + // module extrusion_misumi_nfs5_2525(h) { - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("MISUMI/nfs5-2525.dxf"); - } + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0) + { + import("MISUMI/nfs5-2525.dxf"); + } } // module extrusion_misumi_nfs5_2550(h) { - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("MISUMI/nfs5-2550.dxf"); - } + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0) + { + import("MISUMI/nfs5-2550.dxf"); + } } // module extrusion_misumi_nfs5_4060(h) { - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("MISUMI/nfs5-4060.dxf"); - } + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0) + { + import("MISUMI/nfs5-4060.dxf"); + } } // module extrusion_misumi_nfs5_4080(h) { - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("MISUMI/nfs5-4080.dxf"); - } + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0) + { + import("MISUMI/nfs5-4080.dxf"); + } } extrusion_misumi_nfs5_2525(25); -translate([40,0,0]) extrusion_misumi_nfs5_2550(25); -translate([100,0,0]) extrusion_misumi_nfs5_4060(25); -translate([175,0,0]) extrusion_misumi_nfs5_4080(25); \ No newline at end of file +translate([ 40, 0, 0 ]) extrusion_misumi_nfs5_2550(25); +translate([ 100, 0, 0 ]) extrusion_misumi_nfs5_4060(25); +translate([ 175, 0, 0 ]) extrusion_misumi_nfs5_4080(25); \ No newline at end of file diff --git a/extrusions/openbeam.scad b/extrusions/openbeam.scad index 53a6fe60..edc15d5c 100644 --- a/extrusions/openbeam.scad +++ b/extrusions/openbeam.scad @@ -1,27 +1,36 @@ -//module extrusion_openbeam_v1_generate_dxf() + +// module extrusion_openbeam_v1_generate_dxf() //{ // // Original STL has origin in lower left // translate([-7.5, -7.5, 0]) -// projection(cut = true) import("TL-400-0101-001CLR_-_OpenBeam_1515_Extrusion_Clear_Anodized.STL"); +// projection(cut = true) +//import("TL-400-0101-001CLR_-_OpenBeam_1515_Extrusion_Clear_Anodized.STL"); // export("TL-400-0101-001.DXF"); //} module extrusion_openbeam_v1(h) { - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("TL-400-0101-001.DXF"); - } + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0) + { + import("TL-400-0101-001.DXF"); + } } -module extrusion_openbeam_v2(h) -{ - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("TL-400-0101-002.DXF"); - } +module extrusion_openbeam_v2(h){ + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0){ import("TL-400-0101-002.DXF"); +} } -//extrusion_openbeam_v1_generate_dxf(); +// extrusion_openbeam_v1_generate_dxf(); *extrusion_openbeam_v1(30); -*translate([20, 0, 0]) extrusion_openbeam_v2(30, $fn=36); +*translate([ 20, 0, 0 ]) extrusion_openbeam_v2(30, $fn = 36); diff --git a/fasteners/iso4017.scad b/fasteners/iso4017.scad index 8873e9a1..59bb2a4f 100644 --- a/fasteners/iso4017.scad +++ b/fasteners/iso4017.scad @@ -1,3 +1,6 @@ +include +include +include // ISO 4017 — Hexagon head screws — Product grades A and B // // d = basic major diameter (nominal diameter) of thread @@ -5,125 +8,115 @@ // // β = angle of the chamfer (hexagon head) -include -include -include - $fn = 36; module iso_hexagon_head_screw(diameter, length, grade = "A", tolerance = false) { - dimensions = iso_hexagon_head_screw_dimensions(diameter); - hex_side_nom = dimensions[18] / const_sqrt3; - hex_side_grade_a = dimensions[19] / const_sqrt3; - hex_side_grade_b = dimensions[20] / const_sqrt3; + dimensions = iso_hexagon_head_screw_dimensions(diameter); + hex_side_nom = dimensions[18] / const_sqrt3; + hex_side_grade_a = dimensions[19] / const_sqrt3; + hex_side_grade_b = dimensions[20] / const_sqrt3; - echo(dimensions); - echo(dimensions[8] / 2, hex_side_nom); + echo(dimensions); + echo(dimensions[8] / 2, hex_side_nom); - if (grade == "A") - { - if (tolerance) - { - // Use minimum dimensions - linear_extrude(height = dimensions[12]) - { - polygon(points = [ - [0, dimensions[8] / 2], - [dimensions[19] / 2, hex_side_grade_a / 2], - [dimensions[19] / 2, -hex_side_grade_a / 2], - [0, -dimensions[8] / 2], - [-dimensions[19] / 2, -hex_side_grade_a / 2], - [-dimensions[19] / 2, hex_side_grade_a / 2] - ], - paths = [[0,1,2,3,4,5]] - ); - } - // Ghost in maximum dimensions - %linear_extrude(height = dimensions[11]) - { - polygon(points = [ - [0, hex_side_nom], - [dimensions[18] / 2, hex_side_nom / 2], - [dimensions[18] / 2, -hex_side_nom / 2], - [0, -hex_side_nom], - [-dimensions[18] / 2, -hex_side_nom / 2], - [-dimensions[18] / 2, hex_side_nom / 2] - ], - paths = [[0,1,2,3,4,5]] - ); - } - } - // Use nominal dimensions - else - { - linear_extrude(height = dimensions[10]) - { - polygon(points = [ - [0, hex_side_nom], - [dimensions[18] / 2, hex_side_nom / 2], - [dimensions[18] / 2, -hex_side_nom / 2], - [0, -hex_side_nom], - [-dimensions[18] / 2, -hex_side_nom / 2], - [-dimensions[18] / 2, hex_side_nom / 2] - ], - paths = [[0,1,2,3,4,5]] - ); - } - } - } - else if (grade == "B") - { - if (tolerance) - { - // Use minimum dimensions - linear_extrude(height = dimensions[14]) - { - polygon(points = [ - [0, dimensions[9] / 2], - [dimensions[20] / 2, hex_side_grade_b / 2], - [dimensions[20] / 2, -hex_side_grade_b / 2], - [0, -dimensions[9] / 2], - [-dimensions[20] / 2, -hex_side_grade_b / 2], - [-dimensions[20] / 2, hex_side_grade_b / 2] - ], - paths = [[0,1,2,3,4,5]] - ); - } - // Ghost in nominal/maximum dimensions - %linear_extrude(height = dimensions[13]) - { - polygon(points = [ - [0, hex_side_nom], - [dimensions[18] / 2, hex_side_nom / 2], - [dimensions[18] / 2, -hex_side_nom / 2], - [0, -hex_side_nom], - [-dimensions[18] / 2, -hex_side_nom / 2], - [-dimensions[18] / 2, hex_side_nom / 2] - ], - paths = [[0,1,2,3,4,5]] - ); - } - } - // Use nominal dimensions - else - { - linear_extrude(height = dimensions[10]) - { - polygon(points = [ - [0, hex_side_nom], - [dimensions[18] / 2, hex_side_nom / 2], - [dimensions[18] / 2, -hex_side_nom / 2], - [0, -hex_side_nom], - [-dimensions[18] / 2, -hex_side_nom / 2], - [-dimensions[18] / 2, hex_side_nom / 2] - ], - paths = [[0,1,2,3,4,5]] - ); - } - rotate([180,0,0]) cylinder(h = length, d = dimensions[21], center = false); - } - } + if (grade == "A") { + if (tolerance) { + // Use minimum dimensions + linear_extrude(height = dimensions[12]) + { + polygon(points = + [ + [ 0, dimensions[8] / 2 ], + [ dimensions[19] / 2, hex_side_grade_a / 2 ], + [ dimensions[19] / 2, -hex_side_grade_a / 2 ], + [ 0, -dimensions[8] / 2 ], + [ -dimensions[19] / 2, -hex_side_grade_a / 2 ], + [ -dimensions[19] / 2, hex_side_grade_a / 2 ] + ], + paths = [[ 0, 1, 2, 3, 4, 5 ]]); + } + // Ghost in maximum dimensions + % linear_extrude(height = dimensions[11]) + { + polygon(points = + [ + [ 0, hex_side_nom ], + [ dimensions[18] / 2, hex_side_nom / 2 ], + [ dimensions[18] / 2, -hex_side_nom / 2 ], + [ 0, -hex_side_nom ], + [ -dimensions[18] / 2, -hex_side_nom / 2 ], + [ -dimensions[18] / 2, hex_side_nom / 2 ] + ], + paths = [[ 0, 1, 2, 3, 4, 5 ]]); + } + } + // Use nominal dimensions + else { + linear_extrude(height = dimensions[10]) + { + polygon(points = + [ + [ 0, hex_side_nom ], + [ dimensions[18] / 2, hex_side_nom / 2 ], + [ dimensions[18] / 2, -hex_side_nom / 2 ], + [ 0, -hex_side_nom ], + [ -dimensions[18] / 2, -hex_side_nom / 2 ], + [ -dimensions[18] / 2, hex_side_nom / 2 ] + ], + paths = [[ 0, 1, 2, 3, 4, 5 ]]); + } + } + } else if (grade == "B") { + if (tolerance) { + // Use minimum dimensions + linear_extrude(height = dimensions[14]) + { + polygon(points = + [ + [ 0, dimensions[9] / 2 ], + [ dimensions[20] / 2, hex_side_grade_b / 2 ], + [ dimensions[20] / 2, -hex_side_grade_b / 2 ], + [ 0, -dimensions[9] / 2 ], + [ -dimensions[20] / 2, -hex_side_grade_b / 2 ], + [ -dimensions[20] / 2, hex_side_grade_b / 2 ] + ], + paths = [[ 0, 1, 2, 3, 4, 5 ]]); + } + // Ghost in nominal/maximum dimensions + % linear_extrude(height = dimensions[13]) + { + polygon(points = + [ + [ 0, hex_side_nom ], + [ dimensions[18] / 2, hex_side_nom / 2 ], + [ dimensions[18] / 2, -hex_side_nom / 2 ], + [ 0, -hex_side_nom ], + [ -dimensions[18] / 2, -hex_side_nom / 2 ], + [ -dimensions[18] / 2, hex_side_nom / 2 ] + ], + paths = [[ 0, 1, 2, 3, 4, 5 ]]); + } + } + // Use nominal dimensions + else { + linear_extrude(height = dimensions[10]) + { + polygon(points = + [ + [ 0, hex_side_nom ], + [ dimensions[18] / 2, hex_side_nom / 2 ], + [ dimensions[18] / 2, -hex_side_nom / 2 ], + [ 0, -hex_side_nom ], + [ -dimensions[18] / 2, -hex_side_nom / 2 ], + [ -dimensions[18] / 2, hex_side_nom / 2 ] + ], + paths = [[ 0, 1, 2, 3, 4, 5 ]]); + } + rotate([ 180, 0, 0 ]) + cylinder(h = length, d = dimensions[21], center = false); + } + } } // Definitions from ISO 225 — Fasteners — Bolts, screws, studs and @@ -131,15 +124,15 @@ module iso_hexagon_head_screw(diameter, length, grade = "A", tolerance = false) // // For a given d: // 0:P: pitch of the thread -// 1:a max: maximum distance from the bearing face to the first full form (full profile) thread (screw) -// 2:a min: minimum distance from the bearing face to the first full form (full profile) thread (screw) -// 3:c max: maximum height of the washer-faced portion or thickness of the flange or collar -// 4:c min: minimum height of the washer-faced portion or thickness of the flange or collar -// 5:da max: maximum inner diameter of the bearing face -// 6:dw grade a min: minimum outer diameter of the washer face (bearing face) -// 7:dw grade b min: minimum outer diameter of the washer face (bearing face) -// 8:e grade a min: minimum width across corners -// 9:e grade b min: minimum width across corners +// 1:a max: maximum distance from the bearing face to the first full form (full +// profile) thread (screw) 2:a min: minimum distance from the bearing face to +// the first full form (full profile) thread (screw) 3:c max: maximum height of +// the washer-faced portion or thickness of the flange or collar 4:c min: +// minimum height of the washer-faced portion or thickness of the flange or +// collar 5:da max: maximum inner diameter of the bearing face 6:dw grade a min: +// minimum outer diameter of the washer face (bearing face) 7:dw grade b min: +// minimum outer diameter of the washer face (bearing face) 8:e grade a min: +// minimum width across corners 9:e grade b min: minimum width across corners // 10:k nom: nominal height of the head // 11:k grade a max: maximum height of the head // 12:k grade a min: minimum height of the head @@ -167,6 +160,6 @@ function iso_hexagon_head_screw_dimensions(diameter) = [8*length_mm, 22*length_mm, 7*length_mm]; // this is the default iso_hexagon_head_screw("M1.6", 20, "A", true); -translate([5,0,0]) iso_hexagon_head_screw("M1.6", 20, "A", false); -translate([0,5,0]) iso_hexagon_head_screw("M1.6", 20, "B", true); -translate([5,5,0]) iso_hexagon_head_screw("M1.6", 20, "B", false); \ No newline at end of file +translate([ 5, 0, 0 ]) iso_hexagon_head_screw("M1.6", 20, "A", false); +translate([ 0, 5, 0 ]) iso_hexagon_head_screw("M1.6", 20, "B", true); +translate([ 5, 5, 0 ]) iso_hexagon_head_screw("M1.6", 20, "B", false); \ No newline at end of file diff --git a/fasteners/metric_fastners.scad b/fasteners/metric_fastners.scad index 7134c743..441e1805 100644 --- a/fasteners/metric_fastners.scad +++ b/fasteners/metric_fastners.scad @@ -1,3 +1,4 @@ + /* * OpenSCAD Metric Fastners Library (www.openscad.org) * Copyright (C) 2010-2011 Giles Bathgate @@ -16,96 +17,93 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * -*/ + */ // $fn=50; -apply_chamfer=true; +apply_chamfer = true; -module cap_bolt(dia,len) +module cap_bolt(dia, len) { - e=1.5*dia; - h1=1.25*dia; - cylinder(r=dia/2,h=len); - translate([0,0,-h1]) cylinder(r=e/2,h=h1); + e = 1.5 * dia; + h1 = 1.25 * dia; + cylinder(r = dia / 2, h = len); + translate([ 0, 0, -h1 ]) cylinder(r = e / 2, h = h1); } -module csk_bolt(dia,len) +module csk_bolt(dia, len) { - h1=0.6*dia; - h2=len-h1; - cylinder(r=dia/2,h=h2); - cylinder(r1=dia,r2=dia/2,h=h1); + h1 = 0.6 * dia; + h2 = len - h1; + cylinder(r = dia / 2, h = h2); + cylinder(r1 = dia, r2 = dia / 2, h = h1); } module washer(dia) { - t=0.1*dia; - difference() - { - cylinder(r=dia,h=t); - translate([0,0,-t/2])cylinder(r=dia/2,h=t*2); - } + t = 0.1 * dia; + difference() + { + cylinder(r = dia, h = t); + translate([ 0, 0, -t / 2 ]) cylinder(r = dia / 2, h = t * 2); + } } module flat_nut(dia) { - m=0.8*dia; - e=1.8*dia; - c=0.2*dia; - difference() - { - cylinder(r=e/2,h=m,$fn=6); - translate([0,0,-m/2])cylinder(r=dia/2,h=m*2); - if(apply_chamfer) - translate([0,0,c])cylinder_chamfer(e/2,c); - } + m = 0.8 * dia; + e = 1.8 * dia; + c = 0.2 * dia; + difference() + { + cylinder(r = e / 2, h = m, $fn = 6); + translate([ 0, 0, -m / 2 ]) cylinder(r = dia / 2, h = m * 2); + if (apply_chamfer) + translate([ 0, 0, c ]) cylinder_chamfer(e / 2, c); + } } -module bolt(dia,len) +module bolt(dia, len) { - e=1.8*dia; - k=0.7*dia; - c=0.2*dia; - difference() - { - cylinder(r=e/2,h=k,$fn=6); - if(apply_chamfer) - translate([0,0,c])cylinder_chamfer(e/2,c); - } - - cylinder(r=dia/2,h=len); + e = 1.8 * dia; + k = 0.7 * dia; + c = 0.2 * dia; + difference() + { + cylinder(r = e / 2, h = k, $fn = 6); + if (apply_chamfer) + translate([ 0, 0, c ]) cylinder_chamfer(e / 2, c); + } + cylinder(r = dia / 2, h = len); } -module cylinder_chamfer(r1,r2) +module cylinder_chamfer(r1, r2) { - t=r1-r2; - p=r2*2; - rotate_extrude() - difference() - { - translate([t,-p])square([p,p]); - translate([t,0])circle(r2); - } + t = r1 - r2; + p = r2 * 2; + rotate_extrude() difference() + { + translate([ t, -p ]) square([ p, p ]); + translate([ t, 0 ]) circle(r2); + } } -module chamfer(len,r) +module chamfer(len, r) { - p=r*2; - linear_extrude(height=len) - difference() - { - square([p,p]); - circle(r); - } + p = r * 2; + linear_extrude(height = len) difference() + { + square([ p, p ]); + circle(r); + } } union() { -//csk_bolt(3,14); -//washer(3); -//flat_nut(3); -//bolt(4,14); -//cylinder_chamfer(8,1); -//chamfer(10,2); + // csk_bolt(3,14); + // washer(3); + // flat_nut(3); + // bolt(4,14); + // cylinder_chamfer(8,1); + // chamfer(10,2); } diff --git a/fasteners/nuts_and_bolts.scad b/fasteners/nuts_and_bolts.scad index a4cf8d54..4992ec35 100644 --- a/fasteners/nuts_and_bolts.scad +++ b/fasteners/nuts_and_bolts.scad @@ -6,213 +6,184 @@ include // This library is dual licensed under the GPL 3.0 and the GNU Lesser General // Public License as per http://creativecommons.org/licenses/LGPL/2.1/ . -module mcad_test_nuts_and_bolts_1 () +module +mcad_test_nuts_and_bolts_1() { - $fn = 360; + $fn = 360; - translate ([0, 15]) - mcad_nut_hole (3, proj = -1); - - mcad_bolt_hole (3, length = 30,tolerance =10, proj = -1); + translate([ 0, 15 ]) mcad_nut_hole(3, proj = -1); + mcad_bolt_hole(3, length = 30, tolerance = 10, proj = -1); } -//mcad_test_nuts_and_bolts_1 (); +// mcad_test_nuts_and_bolts_1 (); -module mcad_test_nuts_and_bolts_2 () +module +mcad_test_nuts_and_bolts_2() { - $fn = 360; - - difference(){ - cube(size = [10, 20, 10], center = true); - union(){ - translate ([0, 15]) - mcad_nut_hole (3, proj = 2); - - linear_extrude (height = 20, center = true, convexity = 10, - twist = 0) - mcad_bolt_hole (3, length = 30, proj = 2); - } - } + $fn = 360; + + difference() + { + cube(size = [ 10, 20, 10 ], center = true); + union() + { + translate([ 0, 15 ]) mcad_nut_hole(3, proj = 2); + + linear_extrude( + height = 20, center = true, convexity = 10, twist = 0) + mcad_bolt_hole(3, length = 30, proj = 2); + } + } } -//mcad_test_nuts_and_bolts_2 (); +// mcad_test_nuts_and_bolts_2 (); -module mcad_test_nuts_and_bolts_3 () +module +mcad_test_nuts_and_bolts_3() { - $fn = 360; + $fn = 360; - mcad_bolt_hole_with_nut ( - size = 3, - length = 10 - ); + mcad_bolt_hole_with_nut(size = 3, length = 10); } -//mcad_test_nuts_and_bolts_3 (); - -//Based on: http://www.roymech.co.uk/Useful_Tables/Screws/Hex_Screws.htm -METRIC_NUT_AC_WIDTHS = -[ - -1, //0 index is not used but reduces computation - -1, - 4.32, //m2 - 6.40,//m3 - 8.10,//m4 - 9.20,//m5 - 11.50,//m6 - -1, - 15.00,//m8 - -1, - 19.60,//m10 - -1, - 22.10,//m12 - -1, - -1, - -1, - 27.70,//m16 - -1, - -1, - -1, - 34.60,//m20 - -1, - -1, - -1, - 41.60,//m24 - -1, - -1, - -1, - -1, - -1, - 53.1,//m30 - -1, - -1, - -1, - -1, - -1, - 63.5//m36 +// mcad_test_nuts_and_bolts_3 (); + +// Based on: http://www.roymech.co.uk/Useful_Tables/Screws/Hex_Screws.htm +METRIC_NUT_AC_WIDTHS = [ + -1, // 0 index is not used but reduces computation + -1, + 4.32, // m2 + 6.40, // m3 + 8.10, // m4 + 9.20, // m5 + 11.50, // m6 + -1, + 15.00, // m8 + -1, + 19.60, // m10 + -1, + 22.10, // m12 + -1, -1, -1, + 27.70, // m16 + -1, -1, -1, + 34.60, // m20 + -1, -1, -1, + 41.60, // m24 + -1, -1, -1, -1, -1, + 53.1, // m30 + -1, -1, -1, -1, -1, + 63.5 // m36 ]; -METRIC_NUT_THICKNESS = -[ - -1, //0 index is not used but reduces computation - -1, - 1.6,//m2 - 2.40,//m3 - 3.20,//m4 - 4.00,//m5 - 5.00,//m6 - -1, - 6.50,//m8 - -1, - 8.00,//m10 - -1, - 10.00,//m12 - -1, - -1, - -1, - 13.00,//m16 - -1, - -1, - -1, - 16.00//m20 - -1, - -1, - -1, - 19.00,//m24 - -1, - -1, - -1, - -1, - -1, - 24.00,//m30 - -1, - -1, - -1, - -1, - -1, - 29.00//m36 +METRIC_NUT_THICKNESS = [ + -1, // 0 index is not used but reduces computation + -1, + 1.6, // m2 + 2.40, // m3 + 3.20, // m4 + 4.00, // m5 + 5.00, // m6 + -1, + 6.50, // m8 + -1, + 8.00, // m10 + -1, + 10.00, // m12 + -1, + -1, + -1, + 13.00, // m16 + -1, + -1, + -1, + 16.00 // m20 + - 1, + -1, + -1, + 19.00, // m24 + -1, + -1, + -1, + -1, + -1, + 24.00, // m30 + -1, + -1, + -1, + -1, + -1, + 29.00 // m36 ]; METRIC_BOLT_CAP_DIAMETERS = [ - -1, - -1, - -1, - 5.5, // m3 - 7, // m4 - 8.5, // m5 - 10, // m6 - -1, - 13, // m8 - -1, - 16, // m10 - -1, - 18, // m12 - -1, - -1, - -1, - 24, // m16 - -1, - -1, - -1, - 30, // m20 - -1, - -1, - -1, - 36 // m24 + -1, -1, -1, + 5.5, // m3 + 7, // m4 + 8.5, // m5 + 10, // m6 + -1, + 13, // m8 + -1, + 16, // m10 + -1, + 18, // m12 + -1, -1, -1, + 24, // m16 + -1, -1, -1, + 30, // m20 + -1, -1, -1, + 36 // m24 ]; -function mcad_metric_nut_ac_width (size) = METRIC_NUT_AC_WIDTHS[size]; -function mcad_metric_nut_thickness (size) = METRIC_NUT_THICKNESS[size]; -function mcad_metric_bolt_major_diameter (size) = size; -function mcad_metric_bolt_cap_height (size) = size; -function mcad_metric_bolt_cap_diameter (size) = ( - METRIC_BOLT_CAP_DIAMETERS[size] -); +function mcad_metric_nut_ac_width(size) = METRIC_NUT_AC_WIDTHS[size]; +function mcad_metric_nut_thickness(size) = METRIC_NUT_THICKNESS[size]; +function mcad_metric_bolt_major_diameter(size) = size; +function mcad_metric_bolt_cap_height(size) = size; +function mcad_metric_bolt_cap_diameter(size) = + (METRIC_BOLT_CAP_DIAMETERS[size]); -module mcad_nut_hole (size, tolerance = +0.0001, proj = -1) +module mcad_nut_hole(size, tolerance = +0.0001, proj = -1) { - //takes a metric screw/nut size and looksup nut dimensions - radius = mcad_metric_nut_ac_width (size) / 2 + tolerance; - height = mcad_metric_nut_thickness (size) + tolerance; + // takes a metric screw/nut size and looksup nut dimensions + radius = mcad_metric_nut_ac_width(size) / 2 + tolerance; + height = mcad_metric_nut_thickness(size) + tolerance; - if (proj == -1) { - cylinder (r = radius, h = height, $fn = 6, center = [0, 0]); - } + if (proj == -1) { + cylinder(r = radius, h = height, $fn = 6, center = [ 0, 0 ]); + } - else if (proj == 1) { - circle(r = radius, $fn = 6); - } + else if (proj == 1) { + circle(r = radius, $fn = 6); + } - else if (proj == 2) - { - translate ([-radius/2, 0]) - square ([radius*2, height]); - } + else if (proj == 2) { + translate([ -radius / 2, 0 ]) square([ radius * 2, height ]); + } } -module mcad_bolt_hole (size, length, cap_extra_length, tolerance = +0.0001, - proj = -1) +module mcad_bolt_hole(size, + length, + cap_extra_length, + tolerance = +0.0001, + proj = -1) { - radius = mcad_metric_bolt_major_diameter (size) / 2 + tolerance; - - cap_height = mcad_metric_bolt_cap_height (size) + tolerance; - cap_radius = mcad_metric_bolt_cap_diameter (size) / 2 + tolerance; - - if (proj == -1) - { - translate([0, 0, -cap_height - cap_extra_length]) - cylinder(r = cap_radius, h = cap_height + cap_extra_length); - cylinder(r = radius, h = length); - } - if (proj == 1) - { - circle(r = radius); - } - if (proj == 2) - { - translate([-cap_radius, - cap_height]) - square([cap_radius * 2, cap_height]); - translate([-radius, 0]) - square([radius * 2, length]); - } + radius = mcad_metric_bolt_major_diameter(size) / 2 + tolerance; + + cap_height = mcad_metric_bolt_cap_height(size) + tolerance; + cap_radius = mcad_metric_bolt_cap_diameter(size) / 2 + tolerance; + + if (proj == -1) { + translate([ 0, 0, -cap_height - cap_extra_length ]) + cylinder(r = cap_radius, h = cap_height + cap_extra_length); + cylinder(r = radius, h = length); + } + if (proj == 1) { + circle(r = radius); + } + if (proj == 2) { + translate([ -cap_radius, -cap_height ]) + square([ cap_radius * 2, cap_height ]); + translate([ -radius, 0 ]) square([ radius * 2, length ]); + } } /** @@ -224,42 +195,51 @@ module mcad_bolt_hole (size, length, cap_extra_length, tolerance = +0.0001, * @param align_with Alignment of whole set (above_head, below_head, center, * below_nut, above_nut) */ -module mcad_bolt_hole_with_nut (size, length, nut_projection = "axial", - align_with = "above_head", - screw_extra_length = 9999, - head_extra_length = 9999, - nut_projection_length = 100, - bolt_tolerance = 0.15, - nut_tolerance = 0.001) +module mcad_bolt_hole_with_nut(size, + length, + nut_projection = "axial", + align_with = "above_head", + screw_extra_length = 9999, + head_extra_length = 9999, + nut_projection_length = 100, + bolt_tolerance = 0.15, + nut_tolerance = 0.001) { - cap_head_d = mcad_metric_bolt_cap_diameter (size); - cap_head_h = size; - - nut_thickness = mcad_metric_nut_thickness (size); - - elevation = ( - (align_with == "above_head") ? 0 : - (align_with == "below_head") ? cap_head_h : - (align_with == "center") ? cap_head_h + length / 2 : - (align_with == "below_nut") ? cap_head_h + length : - (align_with == "above_nut") ? cap_head_h + length + nut_thickness : 0 - ); - - translate ([0, 0, -elevation]) { - /* screw head */ - translate ([0, 0, cap_head_h]) - mcad_bolt_hole (size = size, length = length + screw_extra_length, - cap_extra_length = head_extra_length, - tolerance = bolt_tolerance); - - /* nut */ - translate ([0, 0, cap_head_h + length - epsilon]) - hull () { - axis = (nut_projection == "axial") ? +Z : +X; - - mcad_linear_multiply (no = 2, separation = nut_projection_length, - axis = axis) - mcad_nut_hole (size = size, tolerance = nut_tolerance); - } - } + cap_head_d = mcad_metric_bolt_cap_diameter(size); + cap_head_h = size; + + nut_thickness = mcad_metric_nut_thickness(size); + + elevation = + ((align_with == "above_head") + ? 0 + : (align_with == "below_head") + ? cap_head_h + : (align_with == "center") + ? cap_head_h + length / 2 + : (align_with == "below_nut") + ? cap_head_h + length + : (align_with == "above_nut") + ? cap_head_h + length + nut_thickness + : 0); + + translate([ 0, 0, -elevation ]) + { + /* screw head */ + translate([ 0, 0, cap_head_h ]) + mcad_bolt_hole(size = size, + length = length + screw_extra_length, + cap_extra_length = head_extra_length, + tolerance = bolt_tolerance); + + /* nut */ + translate([ 0, 0, cap_head_h + length - epsilon ]) hull() + { + axis = (nut_projection == "axial") ? +Z : +X; + + mcad_linear_multiply( + no = 2, separation = nut_projection_length, axis = axis) + mcad_nut_hole(size = size, tolerance = nut_tolerance); + } + } } diff --git a/fasteners/threads.scad b/fasteners/threads.scad index 29527f84..3f91a10f 100644 --- a/fasteners/threads.scad +++ b/fasteners/threads.scad @@ -1,3 +1,6 @@ +use +use +use /* * Dan Kirshner - dan_kirshner@yahoo.com * Chow Loong Jin - hyperair@debian.org @@ -5,132 +8,115 @@ * You are welcome to make free use of this software. Retention of my * authorship credit would be appreciated. * - * Version 1.3. 2013-12-01 Correct loop over turns -- don't have early cut-off - * Version 1.2. 2012-09-09 Use discrete polyhedra rather than linear_extrude() - * Version 1.1. 2012-09-07 Corrected to right-hand threads! + * Version 1.3. 2013-12-01 Correct loop over turns -- don't have early + * cut-off Version 1.2. 2012-09-09 Use discrete polyhedra rather than + * linear_extrude() Version 1.1. 2012-09-07 Corrected to right-hand threads! */ // Examples: -test_threads (); +test_threads(); -module test_threads ($fa=5, $fs=0.1) +module test_threads($fa = 5, $fs = 0.1) { // M8 metric_thread(8, 1.5, 10); - translate ([10, 0, 0]) - square_thread(8, 1.5, 10); + translate([ 10, 0, 0 ]) square_thread(8, 1.5, 10); - translate ([20, 0, 0]) - acme_thread(8, 1.5, 10); + translate([ 20, 0, 0 ]) acme_thread(8, 1.5, 10); - translate ([30, 0, 0]) - buttress_thread(8, 1.5, 10); + translate([ 30, 0, 0 ]) buttress_thread(8, 1.5, 10); - translate ([40, 0, 0]) - english_thread(1/4, 20, 1); + translate([ 40, 0, 0 ]) english_thread(1 / 4, 20, 1); // Rohloff hub thread: - translate ([65, 0, 0]) - metric_thread(34, 1, 10, internal=true, n_starts=6); + translate([ 65, 0, 0 ]) + metric_thread(34, 1, 10, internal = true, n_starts = 6); } // ---------------------------------------------------------------------------- -use -use -use -use - -// ---------------------------------------------------------------------------- -// internal - true = clearances for internal thread (e.g., a nut). -// false = clearances for external thread (e.g., a bolt). -// (Internal threads should be "cut out" from a solid using -// difference()). -// n_starts - Number of thread starts (e.g., DNA, a "double helix," has -// n_starts=2). See wikipedia Screw_thread. -module metric_thread ( - diameter = 8, - pitch = 1, - length = 1, - internal = false, - n_starts = 1 -) +use + + // ---------------------------------------------------------------------------- + // internal - true = clearances for internal thread (e.g., a nut). + // false = clearances for external thread (e.g., a bolt). + // (Internal threads should be "cut out" from a solid using + // difference()). + // n_starts - Number of thread starts (e.g., DNA, a "double helix," has + // n_starts=2). See wikipedia Screw_thread. + module metric_thread(diameter = 8, + pitch = 1, + length = 1, + internal = false, + n_starts = 1) { - trapezoidal_thread ( - pitch = pitch, - length = length, - upper_angle = 30, lower_angle = 30, - outer_flat_length = pitch / 8, - major_radius = diameter / 2, - minor_radius = diameter / 2 - 5/8 * cos(30) * pitch, - internal = internal, - n_starts = n_starts - ); + trapezoidal_thread(pitch = pitch, + length = length, + upper_angle = 30, + lower_angle = 30, + outer_flat_length = pitch / 8, + major_radius = diameter / 2, + minor_radius = diameter / 2 - 5 / 8 * cos(30) * pitch, + internal = internal, + n_starts = n_starts); } -module square_thread ( - diameter = 8, - pitch = 1, - length = 1, - internal = false, - n_starts = 1 -) +module square_thread(diameter = 8, + pitch = 1, + length = 1, + internal = false, + n_starts = 1) { - trapezoidal_thread ( - pitch = pitch, - length = length, - upper_angle = 0, lower_angle = 0, - outer_flat_length = pitch / 2, - major_radius = diameter / 2, - minor_radius = diameter / 2 - pitch / 2, - internal = internal, - n_starts = n_starts - ); + trapezoidal_thread(pitch = pitch, + length = length, + upper_angle = 0, + lower_angle = 0, + outer_flat_length = pitch / 2, + major_radius = diameter / 2, + minor_radius = diameter / 2 - pitch / 2, + internal = internal, + n_starts = n_starts); } -module acme_thread ( - diameter = 8, - pitch = 1, - length = 1, - internal = false, - n_starts = 1 -) +module acme_thread(diameter = 8, + pitch = 1, + length = 1, + internal = false, + n_starts = 1) { - trapezoidal_thread ( - pitch = pitch, - length = length, - upper_angle = 29/2, lower_angle = 29/2, - outer_flat_length = 0.3707 * pitch, - major_radius = diameter / 2, - minor_radius = diameter / 2 - pitch / 2, - internal = internal, - n_starts = n_starts - ); + trapezoidal_thread(pitch = pitch, + length = length, + upper_angle = 29 / 2, + lower_angle = 29 / 2, + outer_flat_length = 0.3707 * pitch, + major_radius = diameter / 2, + minor_radius = diameter / 2 - pitch / 2, + internal = internal, + n_starts = n_starts); } -module buttress_thread ( - diameter = 8, - pitch = 1, - length = 1, - internal = false, - n_starts = 1, - buttress_angles = [3, 33], - pitch_flat_ratio = 6, // ratio of pitch to flat length - pitch_depth_ratio = 3/2 // ratio of pitch to thread depth +module buttress_thread(diameter = 8, + pitch = 1, + length = 1, + internal = false, + n_starts = 1, + buttress_angles = [ 3, 33 ], + pitch_flat_ratio = 6, // ratio of pitch to flat length + pitch_depth_ratio = 3 / + 2 // ratio of pitch to thread depth ) { - trapezoidal_thread ( - pitch = pitch, - length = length, - upper_angle = buttress_angles[0], lower_angle = buttress_angles[1], - outer_flat_length = pitch / pitch_flat_ratio, - major_radius = diameter / 2, - minor_radius = diameter / 2 - pitch / pitch_depth_ratio, - internal = internal, - n_starts = n_starts - ); + trapezoidal_thread(pitch = pitch, + length = length, + upper_angle = buttress_angles[0], + lower_angle = buttress_angles[1], + outer_flat_length = pitch / pitch_flat_ratio, + major_radius = diameter / 2, + minor_radius = diameter / 2 - pitch / pitch_depth_ratio, + internal = internal, + n_starts = n_starts); } /** @@ -147,17 +133,15 @@ module buttress_thread ( * internal = if true, generates a thread suitable for difference() to make nuts * n_starts = number of threads winding the screw */ -module trapezoidal_thread ( - pitch, - length, - upper_angle, - lower_angle, - outer_flat_length, - major_radius, - minor_radius, - internal = false, - n_starts = 1 -) +module trapezoidal_thread(pitch, + length, + upper_angle, + lower_angle, + outer_flat_length, + major_radius, + minor_radius, + internal = false, + n_starts = 1) { // trapezoid calculation: /* @@ -177,69 +161,68 @@ module trapezoidal_thread ( left_angle = 90 - upper_angle; right_angle = 90 - lower_angle; upper_flat = outer_flat_length; - left_flat = tooth_height / tan (left_angle); - right_flat = tooth_height / tan (right_angle); + left_flat = tooth_height / tan(left_angle); + right_flat = tooth_height / tan(right_angle); lower_flat = upper_flat + left_flat + right_flat; - clearance = 0.3/8 * tooth_height; + clearance = 0.3 / 8 * tooth_height; tooth_profile = [ - [0, 0], - [tooth_height + 0.001, right_flat], - [tooth_height + 0.001, right_flat + upper_flat], - [0, lower_flat] + [ 0, 0 ], + [ tooth_height + 0.001, right_flat ], + [ tooth_height + 0.001, right_flat + upper_flat ], + [ 0, lower_flat ] ]; // convert length along the tooth profile to angle of twist of the screw - function length2twist (length) = length / pitch * (360 / n_starts); - function twist2length (angle) = angle / (360 / n_starts) * pitch; + function length2twist(length) = length / pitch * (360 / n_starts); + function twist2length(angle) = angle / (360 / n_starts) * pitch; // facet calculation - facets = get_fragments_from_r (minor_radius); + facets = get_fragments_from_r(minor_radius); fa = 360 / facets; - slices = length2twist (length) / fa; - - path_transforms = [ - for (i=[0:slices + length2twist (pitch) / fa]) - let (a=i * fa) - ( - rotation (axis=[0, 0, a]) * - translation ([0, 0, twist2length (a) - pitch]) * - translation ([minor_radius - 0.001, 0, 0]) * - rotation (axis=[90, 0, 0]) - ) - ]; + slices = length2twist(length) / fa; + + path_transforms = [for (i = [0:slices + length2twist(pitch) / fa]) + let(a = i * fa)(rotation(axis = [ 0, 0, a ]) * + translation([ 0, 0, twist2length(a) - pitch ]) * + translation([ minor_radius - 0.001, 0, 0 ]) * + rotation(axis = [ 90, 0, 0 ]))]; - cylinder (r=minor_radius, h=length); + cylinder(r = minor_radius, h = length); - difference () { - for (i=[0:n_starts]) - rotate ([0, 0, i / n_starts * 360]) - sweep (tooth_profile, path_transforms); + difference() + { + for (i = [0:n_starts]) + rotate([ 0, 0, i / n_starts * 360 ]) + sweep(tooth_profile, path_transforms); - translate ([0, 0, length + pitch / 2]) - cube ([major_radius * 2 + .1, major_radius * 2+ .1, pitch], - center=true); + translate([ 0, 0, length + pitch / 2 ]) + cube([ major_radius * 2 + .1, major_radius * 2 + .1, pitch ], + center = true); - translate ([0, 0, -pitch / 2]) - cube ([major_radius * 2 + .1, major_radius * 2+ .1, pitch], - center=true); + translate([ 0, 0, -pitch / 2 ]) + cube([ major_radius * 2 + .1, major_radius * 2 + .1, pitch ], + center = true); } } // ---------------------------------------------------------------------------- // Input units in inches. // Note: units of measure in drawing are mm! -module english_thread(diameter=0.25, threads_per_inch=20, length=1, - internal=false, n_starts=1) +module english_thread(diameter = 0.25, + threads_per_inch = 20, + length = 1, + internal = false, + n_starts = 1) { - // Convert to mm. - mm_diameter = diameter*25.4; - mm_pitch = (1.0/threads_per_inch)*25.4; - mm_length = length*25.4; - - echo(str("mm_diameter: ", mm_diameter)); - echo(str("mm_pitch: ", mm_pitch)); - echo(str("mm_length: ", mm_length)); - metric_thread(mm_diameter, mm_pitch, mm_length, internal, n_starts); + // Convert to mm. + mm_diameter = diameter * 25.4; + mm_pitch = (1.0 / threads_per_inch) * 25.4; + mm_length = length * 25.4; + + echo(str("mm_diameter: ", mm_diameter)); + echo(str("mm_pitch: ", mm_pitch)); + echo(str("mm_length: ", mm_length)); + metric_thread(mm_diameter, mm_pitch, mm_length, internal, n_starts); } diff --git a/format.py b/format.py new file mode 100755 index 00000000..33d43840 --- /dev/null +++ b/format.py @@ -0,0 +1,8 @@ +#!/usr/bin/python3 + +import os +import shutil + +if shutil.which("openscad-format") is None: + os.system("npm install -g openscad-format") +os.system("openscad-format -i './**/*.scad'") diff --git a/gears/gears.scad b/gears/gears.scad index eb2a7d9b..613ae866 100644 --- a/gears/gears.scad +++ b/gears/gears.scad @@ -1,10 +1,10 @@ + // Copyright 2010 D1plo1d // LGPL 2.1 - -//test_involute_curve(); -//test_gears(); -//demo_3d_gears(); +// test_involute_curve(); +// test_gears(); +// demo_3d_gears(); // Geometry Sources: // http://www.cartertools.com/involute.html @@ -12,187 +12,197 @@ // Usage: // Diametral pitch: Number of teeth per unit length. // Circular pitch: Length of the arc from one tooth to the next -// Clearance: Radial distance between top of tooth on one gear to bottom of gap on another. +// Clearance: Radial distance between top of tooth on one gear to bottom of gap +//on another. -function pitch_circular2diameter(number_of_teeth,circular_pitch) = number_of_teeth * circular_pitch / 180; -function pitch_diametral2diameter(number_of_teeth,diametral_pitch) = number_of_teeth / diametral_pitch; +function pitch_circular2diameter(number_of_teeth, circular_pitch) = + number_of_teeth * circular_pitch / 180; +function pitch_diametral2diameter(number_of_teeth, diametral_pitch) = + number_of_teeth / diametral_pitch; module gear(number_of_teeth, - circular_pitch=false, diametral_pitch=false, - pressure_angle=20, clearance = 0, - verbose=false) + circular_pitch = false, + diametral_pitch = false, + pressure_angle = 20, + clearance = 0, + verbose = false) { - if(verbose) { - echo("gear arguments:"); - echo(str(" number_of_teeth: ", number_of_teeth)); - echo(str(" circular_pitch: ", circular_pitch)); - echo(str(" diametral_pitch: ", diametral_pitch)); - echo(str(" pressure_angle: ", pressure_angle)); - echo(str(" clearance: ", clearance)); - } - if (circular_pitch==false && diametral_pitch==false) echo("MCAD ERROR: gear module needs either a diametral_pitch or circular_pitch"); - if(verbose) echo("gear calculations:"); - - //Convert diametrial pitch to our native circular pitch - circular_pitch = (circular_pitch!=false?circular_pitch:180/diametral_pitch); - - // Pitch diameter: Diameter of pitch circle. - pitch_diameter = pitch_circular2diameter(number_of_teeth,circular_pitch); - if(verbose) echo (str(" pitch_diameter: ", pitch_diameter)); - pitch_radius = pitch_diameter/2; - - // Base Circle - base_diameter = pitch_diameter*cos(pressure_angle); - if(verbose) echo (str(" base_diameter: ", base_diameter)); - base_radius = base_diameter/2; - - // Diametrial pitch: Number of teeth per unit length. - pitch_diametrial = number_of_teeth / pitch_diameter; - if(verbose) echo (str(" pitch_diametrial: ", pitch_diametrial)); - - // Addendum: Radial distance from pitch circle to outside circle. - addendum = 1/pitch_diametrial; - if(verbose) echo (str(" addendum: ", addendum)); - - //Outer Circle - outer_radius = pitch_radius+addendum; - outer_diameter = outer_radius*2; - if(verbose) echo (str(" outer_diameter: ", outer_diameter)); - - // Dedendum: Radial distance from pitch circle to root diameter - dedendum = addendum + clearance; - if(verbose) echo (str(" dedendum: ", dedendum)); - - // Root diameter: Diameter of bottom of tooth spaces. - root_radius = pitch_radius-dedendum; - root_diameter = root_radius * 2; - if(verbose) echo (str(" root_diameter: ", root_diameter)); - - half_thick_angle = 360 / (4 * number_of_teeth); - if(verbose) echo (str(" half_thick_angle: ", half_thick_angle)); - - union() - { - rotate(half_thick_angle) circle($fn=number_of_teeth*2, r=root_radius*1.001); - - for (i= [1:number_of_teeth]) - //for (i = [0]) - { - rotate([0,0,i*360/number_of_teeth]) - { - involute_gear_tooth( - pitch_radius = pitch_radius, - root_radius = root_radius, - base_radius = base_radius, - outer_radius = outer_radius, - half_thick_angle = half_thick_angle); - } - } - } + if (verbose) { + echo("gear arguments:"); + echo(str(" number_of_teeth: ", number_of_teeth)); + echo(str(" circular_pitch: ", circular_pitch)); + echo(str(" diametral_pitch: ", diametral_pitch)); + echo(str(" pressure_angle: ", pressure_angle)); + echo(str(" clearance: ", clearance)); + } + if (circular_pitch == false && diametral_pitch == false) + echo("MCAD ERROR: gear module needs either a diametral_pitch or " + "circular_pitch"); + if (verbose) + echo("gear calculations:"); + + // Convert diametrial pitch to our native circular pitch + circular_pitch = + (circular_pitch != false ? circular_pitch : 180 / diametral_pitch); + + // Pitch diameter: Diameter of pitch circle. + pitch_diameter = pitch_circular2diameter(number_of_teeth, circular_pitch); + if (verbose) + echo(str(" pitch_diameter: ", pitch_diameter)); + pitch_radius = pitch_diameter / 2; + + // Base Circle + base_diameter = pitch_diameter * cos(pressure_angle); + if (verbose) + echo(str(" base_diameter: ", base_diameter)); + base_radius = base_diameter / 2; + + // Diametrial pitch: Number of teeth per unit length. + pitch_diametrial = number_of_teeth / pitch_diameter; + if (verbose) + echo(str(" pitch_diametrial: ", pitch_diametrial)); + + // Addendum: Radial distance from pitch circle to outside circle. + addendum = 1 / pitch_diametrial; + if (verbose) + echo(str(" addendum: ", addendum)); + + // Outer Circle + outer_radius = pitch_radius + addendum; + outer_diameter = outer_radius * 2; + if (verbose) + echo(str(" outer_diameter: ", outer_diameter)); + + // Dedendum: Radial distance from pitch circle to root diameter + dedendum = addendum + clearance; + if (verbose) + echo(str(" dedendum: ", dedendum)); + + // Root diameter: Diameter of bottom of tooth spaces. + root_radius = pitch_radius - dedendum; + root_diameter = root_radius * 2; + if (verbose) + echo(str(" root_diameter: ", root_diameter)); + + half_thick_angle = 360 / (4 * number_of_teeth); + if (verbose) + echo(str(" half_thick_angle: ", half_thick_angle)); + + union() + { + rotate(half_thick_angle) + circle($fn = number_of_teeth * 2, r = root_radius * 1.001); + + for (i = [1:number_of_teeth]) + // for (i = [0]) + { + rotate([ 0, 0, i * 360 / number_of_teeth ]) + { + involute_gear_tooth(pitch_radius = pitch_radius, + root_radius = root_radius, + base_radius = base_radius, + outer_radius = outer_radius, + half_thick_angle = half_thick_angle); + } + } + } } - -module involute_gear_tooth( - pitch_radius, - root_radius, - base_radius, - outer_radius, - half_thick_angle - ) +module involute_gear_tooth(pitch_radius, + root_radius, + base_radius, + outer_radius, + half_thick_angle) { - pitch_to_base_angle = involute_intersect_angle( base_radius, pitch_radius ); - - outer_to_base_angle = involute_intersect_angle( base_radius, outer_radius ); - - base1 = 0 - pitch_to_base_angle - half_thick_angle; - pitch1 = 0 - half_thick_angle; - outer1 = outer_to_base_angle - pitch_to_base_angle - half_thick_angle; - - b1 = polar_to_cartesian([ base1, base_radius ]); - p1 = polar_to_cartesian([ pitch1, pitch_radius ]); - o1 = polar_to_cartesian([ outer1, outer_radius ]); - - b2 = polar_to_cartesian([ -base1, base_radius ]); - p2 = polar_to_cartesian([ -pitch1, pitch_radius ]); - o2 = polar_to_cartesian([ -outer1, outer_radius ]); - - // ( root_radius > base_radius variables ) - pitch_to_root_angle = pitch_to_base_angle - involute_intersect_angle(base_radius, root_radius ); - root1 = pitch1 - pitch_to_root_angle; - root2 = -pitch1 + pitch_to_root_angle; - r1_t = polar_to_cartesian([ root1, root_radius ]); - r2_t = polar_to_cartesian([ -root1, root_radius ]); - - // ( else ) - r1_f = polar_to_cartesian([ base1, root_radius ]); - r2_f = polar_to_cartesian([ -base1, root_radius ]); - - if (root_radius > base_radius) - { - //echo("true"); - polygon( points = [ - r1_t,p1,o1,o2,p2,r2_t - ], convexity = 3); - } - else - { - polygon( points = [ - r1_f, b1,p1,o1,o2,p2,b2,r2_f - ], convexity = 3); - } - + pitch_to_base_angle = involute_intersect_angle(base_radius, pitch_radius); + + outer_to_base_angle = involute_intersect_angle(base_radius, outer_radius); + + base1 = 0 - pitch_to_base_angle - half_thick_angle; + pitch1 = 0 - half_thick_angle; + outer1 = outer_to_base_angle - pitch_to_base_angle - half_thick_angle; + + b1 = polar_to_cartesian([ base1, base_radius ]); + p1 = polar_to_cartesian([ pitch1, pitch_radius ]); + o1 = polar_to_cartesian([ outer1, outer_radius ]); + + b2 = polar_to_cartesian([ -base1, base_radius ]); + p2 = polar_to_cartesian([ -pitch1, pitch_radius ]); + o2 = polar_to_cartesian([ -outer1, outer_radius ]); + + // ( root_radius > base_radius variables ) + pitch_to_root_angle = pitch_to_base_angle - + involute_intersect_angle(base_radius, root_radius); + root1 = pitch1 - pitch_to_root_angle; + root2 = -pitch1 + pitch_to_root_angle; + r1_t = polar_to_cartesian([ root1, root_radius ]); + r2_t = polar_to_cartesian([ -root1, root_radius ]); + + // ( else ) + r1_f = polar_to_cartesian([ base1, root_radius ]); + r2_f = polar_to_cartesian([ -base1, root_radius ]); + + if (root_radius > base_radius) { + // echo("true"); + polygon(points = [ r1_t, p1, o1, o2, p2, r2_t ], convexity = 3); + } else { + polygon(points = [ r1_f, b1, p1, o1, o2, p2, b2, r2_f ], convexity = 3); + } } // Mathematical Functions //=============== -// Finds the angle of the involute about the base radius at the given distance (radius) from it's center. -//source: http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html - -function involute_intersect_angle(base_radius, radius) = sqrt( pow(radius/base_radius,2) - 1); - +// Finds the angle of the involute about the base radius at the given distance +// (radius) from it's center. +// source: +// http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html +function involute_intersect_angle(base_radius, + radius) = sqrt(pow(radius / base_radius, 2) - + 1); // Polar coord [angle, radius] to cartesian coord [x,y] -function polar_to_cartesian(polar) = [ - polar[1]*cos(polar[0]), - polar[1]*sin(polar[0]) -]; - +function polar_to_cartesian(polar) = + [ polar[1] * cos(polar[0]), polar[1] * sin(polar[0]) ]; // Test Cases //=============== -module test_gears() +module +test_gears() { - gear(number_of_teeth=51,circular_pitch=200); - translate([0, 50])gear(number_of_teeth=17,circular_pitch=200); - translate([-50,0]) gear(number_of_teeth=17,diametral_pitch=1); + gear(number_of_teeth = 51, circular_pitch = 200); + translate([ 0, 50 ]) gear(number_of_teeth = 17, circular_pitch = 200); + translate([ -50, 0 ]) gear(number_of_teeth = 17, diametral_pitch = 1); } -module demo_3d_gears() +module +demo_3d_gears() { - //double helical gear - // (helics don't line up perfectly - for display purposes only ;) - translate([50,0]) - { - linear_extrude(height = 10, center = true, convexity = 10, twist = -45) - gear(number_of_teeth=17,diametral_pitch=1); - translate([0,0,10]) linear_extrude(height = 10, center = true, convexity = 10, twist = 45) - gear(number_of_teeth=17,diametral_pitch=1); - } - - //spur gear - translate([0,-50]) linear_extrude(height = 10, center = true, convexity = 10, twist = 0) - gear(number_of_teeth=17,diametral_pitch=1); - + // double helical gear + // (helics don't line up perfectly - for display purposes only ;) + translate([ 50, 0 ]) + { + linear_extrude(height = 10, center = true, convexity = 10, twist = -45) + gear(number_of_teeth = 17, diametral_pitch = 1); + translate([ 0, 0, 10 ]) linear_extrude( + height = 10, center = true, convexity = 10, twist = 45) + gear(number_of_teeth = 17, diametral_pitch = 1); + } + + // spur gear + translate([ 0, -50 ]) + linear_extrude(height = 10, center = true, convexity = 10, twist = 0) + gear(number_of_teeth = 17, diametral_pitch = 1); } -module test_involute_curve() +module +test_involute_curve() { - for (i=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]) - { - translate(polar_to_cartesian([involute_intersect_angle( 0.1,i) , i ])) circle($fn=15, r=0.5); - } + for (i = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ]) { + translate(polar_to_cartesian([ involute_intersect_angle(0.1, i), i ])) + circle($fn = 15, r = 0.5); + } } diff --git a/gears/involute_gears.scad b/gears/involute_gears.scad index 73e19f6a..f7833bd7 100644 --- a/gears/involute_gears.scad +++ b/gears/involute_gears.scad @@ -1,738 +1,728 @@ +use // Parametric Involute Bevel and Spur Gears by GregFrost // It is licensed under the Creative Commons - GNU LGPL 2.1 license. // © 2010 by GregFrost, thingiverse.com/Amp -// http://www.thingiverse.com/thing:3575 and http://www.thingiverse.com/thing:3752 - -use +// http://www.thingiverse.com/thing:3575 and +// http://www.thingiverse.com/thing:3752 // Simple Test: -gear ( - number_of_teeth = 30, - circular_pitch=700, - gear_thickness = 12, - rim_thickness = 15, - hub_thickness = 17, - circles=8, - roundsize = 0 - ); - -translate ([700 * PI / 180 * 30 / 2 / PI * 2,0,0]) -rotate (180 + 360 / 30 / 2) -gear ( - number_of_teeth = 30, - circular_pitch=700, - gear_thickness = 12, - rim_thickness = 15, - hub_thickness = 17, - circles=8, - roundsize = 1 - ); - -//Complex Spur Gear Test: -//test_gears (); +gear(number_of_teeth = 30, + circular_pitch = 700, + gear_thickness = 12, + rim_thickness = 15, + hub_thickness = 17, + circles = 8, + roundsize = 0); + +translate([ 700 * PI / 180 * 30 / 2 / PI * 2, 0, 0 ]) rotate(180 + 360 / 30 / 2) + gear(number_of_teeth = 30, + circular_pitch = 700, + gear_thickness = 12, + rim_thickness = 15, + hub_thickness = 17, + circles = 8, + roundsize = 1); + +// Complex Spur Gear Test: +// test_gears (); // Meshing Double Helix: -//test_meshing_double_helix (); +// test_meshing_double_helix (); -module test_meshing_double_helix(){ - meshing_double_helix (); +module +test_meshing_double_helix() +{ + meshing_double_helix(); } // Demonstrate the backlash option for Spur gears. -//test_backlash (); +// test_backlash (); // Demonstrate how to make meshing bevel gears. -//test_bevel_gear_pair(); +// test_bevel_gear_pair(); -module test_bevel_gear_pair(){ - bevel_gear_pair (); +module +test_bevel_gear_pair() +{ + bevel_gear_pair(); } -module test_bevel_gear(){bevel_gear();} +module +test_bevel_gear() +{ + bevel_gear(); +} -//bevel_gear(); +// bevel_gear(); -pi=3.1415926535897932384626433832795; +pi = 3.1415926535897932384626433832795; //================================================== // Bevel Gears: -// Two gears with the same cone distance, circular pitch (measured at the cone distance) -// and pressure angle will mesh. - -module bevel_gear_pair ( - gear1_teeth = 41, - gear2_teeth = 7, - axis_angle = 90, - outside_circular_pitch=1000) +// Two gears with the same cone distance, circular pitch (measured at the cone +// distance) and pressure angle will mesh. + +module bevel_gear_pair(gear1_teeth = 41, + gear2_teeth = 7, + axis_angle = 90, + outside_circular_pitch = 1000) { - outside_pitch_radius1 = gear1_teeth * outside_circular_pitch / 360; - outside_pitch_radius2 = gear2_teeth * outside_circular_pitch / 360; - pitch_apex1=outside_pitch_radius2 * sin (axis_angle) + - (outside_pitch_radius2 * cos (axis_angle) + outside_pitch_radius1) / tan (axis_angle); - cone_distance = sqrt (pow (pitch_apex1, 2) + pow (outside_pitch_radius1, 2)); - pitch_apex2 = sqrt (pow (cone_distance, 2) - pow (outside_pitch_radius2, 2)); - echo ("cone_distance", cone_distance); - pitch_angle1 = asin (outside_pitch_radius1 / cone_distance); - pitch_angle2 = asin (outside_pitch_radius2 / cone_distance); - echo ("pitch_angle1, pitch_angle2", pitch_angle1, pitch_angle2); - echo ("pitch_angle1 + pitch_angle2", pitch_angle1 + pitch_angle2); - - rotate([0,0,90]) - translate ([0,0,pitch_apex1+20]) - { - translate([0,0,-pitch_apex1]) - bevel_gear ( - number_of_teeth=gear1_teeth, - cone_distance=cone_distance, - pressure_angle=30, - outside_circular_pitch=outside_circular_pitch); - - rotate([0,-(pitch_angle1+pitch_angle2),0]) - translate([0,0,-pitch_apex2]) - bevel_gear ( - number_of_teeth=gear2_teeth, - cone_distance=cone_distance, - pressure_angle=30, - outside_circular_pitch=outside_circular_pitch); - } + outside_pitch_radius1 = gear1_teeth * outside_circular_pitch / 360; + outside_pitch_radius2 = gear2_teeth * outside_circular_pitch / 360; + pitch_apex1 = + outside_pitch_radius2 * sin(axis_angle) + + (outside_pitch_radius2 * cos(axis_angle) + outside_pitch_radius1) / + tan(axis_angle); + cone_distance = sqrt(pow(pitch_apex1, 2) + pow(outside_pitch_radius1, 2)); + pitch_apex2 = sqrt(pow(cone_distance, 2) - pow(outside_pitch_radius2, 2)); + echo("cone_distance", cone_distance); + pitch_angle1 = asin(outside_pitch_radius1 / cone_distance); + pitch_angle2 = asin(outside_pitch_radius2 / cone_distance); + echo("pitch_angle1, pitch_angle2", pitch_angle1, pitch_angle2); + echo("pitch_angle1 + pitch_angle2", pitch_angle1 + pitch_angle2); + + rotate([ 0, 0, 90 ]) translate([ 0, 0, pitch_apex1 + 20 ]) + { + translate([ 0, 0, -pitch_apex1 ]) + bevel_gear(number_of_teeth = gear1_teeth, + cone_distance = cone_distance, + pressure_angle = 30, + outside_circular_pitch = outside_circular_pitch); + + rotate([ 0, -(pitch_angle1 + pitch_angle2), 0 ]) + translate([ 0, 0, -pitch_apex2 ]) + bevel_gear(number_of_teeth = gear2_teeth, + cone_distance = cone_distance, + pressure_angle = 30, + outside_circular_pitch = outside_circular_pitch); + } } -//Bevel Gear Finishing Options: +// Bevel Gear Finishing Options: bevel_gear_flat = 0; bevel_gear_back_cone = 1; -module bevel_gear ( - number_of_teeth=11, - cone_distance=100, - face_width=20, - outside_circular_pitch=1000, - pressure_angle=30, - clearance = 0.2, - bore_diameter=5, - gear_thickness = 15, - backlash = 0, - involute_facets=0, - finish = -1) +module bevel_gear(number_of_teeth = 11, + cone_distance = 100, + face_width = 20, + outside_circular_pitch = 1000, + pressure_angle = 30, + clearance = 0.2, + bore_diameter = 5, + gear_thickness = 15, + backlash = 0, + involute_facets = 0, + finish = -1) { - echo ("bevel_gear", - "teeth", number_of_teeth, - "cone distance", cone_distance, - face_width, - outside_circular_pitch, - pressure_angle, - clearance, - bore_diameter, - involute_facets, - finish); - - // Pitch diameter: Diameter of pitch circle at the fat end of the gear. - outside_pitch_diameter = number_of_teeth * outside_circular_pitch / 180; - outside_pitch_radius = outside_pitch_diameter / 2; - - // The height of the pitch apex. - pitch_apex = sqrt (pow (cone_distance, 2) - pow (outside_pitch_radius, 2)); - pitch_angle = asin (outside_pitch_radius/cone_distance); - - echo ("Num Teeth:", number_of_teeth, " Pitch Angle:", pitch_angle); - - finish = (finish != -1) ? finish : (pitch_angle < 45) ? bevel_gear_flat : bevel_gear_back_cone; - - apex_to_apex=cone_distance / cos (pitch_angle); - back_cone_radius = apex_to_apex * sin (pitch_angle); - - // Calculate and display the pitch angle. This is needed to determine the angle to mount two meshing cone gears. - - // Base Circle for forming the involute teeth shape. - base_radius = back_cone_radius * cos (pressure_angle); - - // Diametrial pitch: Number of teeth per unit length. - pitch_diametrial = number_of_teeth / outside_pitch_diameter; - - // Addendum: Radial distance from pitch circle to outside circle. - addendum = 1 / pitch_diametrial; - // Outer Circle - outer_radius = back_cone_radius + addendum; - - // Dedendum: Radial distance from pitch circle to root diameter - dedendum = addendum + clearance; - dedendum_angle = atan (dedendum / cone_distance); - root_angle = pitch_angle - dedendum_angle; - - root_cone_full_radius = tan (root_angle)*apex_to_apex; - back_cone_full_radius=apex_to_apex / tan (pitch_angle); - - back_cone_end_radius = - outside_pitch_radius - - dedendum * cos (pitch_angle) - - gear_thickness / tan (pitch_angle); - back_cone_descent = dedendum * sin (pitch_angle) + gear_thickness; - - // Root diameter: Diameter of bottom of tooth spaces. - root_radius = back_cone_radius - dedendum; - - half_tooth_thickness = outside_pitch_radius * sin (360 / (4 * number_of_teeth)) - backlash / 4; - half_thick_angle = asin (half_tooth_thickness / back_cone_radius); - - face_cone_height = apex_to_apex-face_width / cos (pitch_angle); - face_cone_full_radius = face_cone_height / tan (pitch_angle); - face_cone_descent = dedendum * sin (pitch_angle); - face_cone_end_radius = - outside_pitch_radius - - face_width / sin (pitch_angle) - - face_cone_descent / tan (pitch_angle); - - // For the bevel_gear_flat finish option, calculate the height of a cube to select the portion of the gear that includes the full pitch face. - bevel_gear_flat_height = pitch_apex - (cone_distance - face_width) * cos (pitch_angle); - -// translate([0,0,-pitch_apex]) - difference () - { - intersection () - { - union() - { - rotate (half_thick_angle) - translate ([0,0,pitch_apex-apex_to_apex]) - cylinder ($fn=number_of_teeth*2, r1=root_cone_full_radius,r2=0,h=apex_to_apex); - for (i = [1:number_of_teeth]) -// for (i = [1:1]) - { - rotate ([0,0,i*360/number_of_teeth]) - { - involute_bevel_gear_tooth ( - back_cone_radius = back_cone_radius, - root_radius = root_radius, - base_radius = base_radius, - outer_radius = outer_radius, - pitch_apex = pitch_apex, - cone_distance = cone_distance, - half_thick_angle = half_thick_angle, - involute_facets = involute_facets); - } - } - } - - if (finish == bevel_gear_back_cone) - { - translate ([0,0,-back_cone_descent]) - cylinder ( - $fn=number_of_teeth*2, - r1=back_cone_end_radius, - r2=back_cone_full_radius*2, - h=apex_to_apex + back_cone_descent); - } - else - { - translate ([-1.5*outside_pitch_radius,-1.5*outside_pitch_radius,0]) - cube ([3*outside_pitch_radius, - 3*outside_pitch_radius, - bevel_gear_flat_height]); - } - } - - if (finish == bevel_gear_back_cone) - { - translate ([0,0,-face_cone_descent]) - cylinder ( - r1=face_cone_end_radius, - r2=face_cone_full_radius * 2, - h=face_cone_height + face_cone_descent+pitch_apex); - } - - translate ([0,0,pitch_apex - apex_to_apex]) - cylinder (r=bore_diameter/2,h=apex_to_apex); - } + echo("bevel_gear", + "teeth", + number_of_teeth, + "cone distance", + cone_distance, + face_width, + outside_circular_pitch, + pressure_angle, + clearance, + bore_diameter, + involute_facets, + finish); + + // Pitch diameter: Diameter of pitch circle at the fat end of the gear. + outside_pitch_diameter = number_of_teeth * outside_circular_pitch / 180; + outside_pitch_radius = outside_pitch_diameter / 2; + + // The height of the pitch apex. + pitch_apex = sqrt(pow(cone_distance, 2) - pow(outside_pitch_radius, 2)); + pitch_angle = asin(outside_pitch_radius / cone_distance); + + echo("Num Teeth:", number_of_teeth, " Pitch Angle:", pitch_angle); + + finish = (finish != -1) + ? finish + : (pitch_angle < 45) ? bevel_gear_flat : bevel_gear_back_cone; + + apex_to_apex = cone_distance / cos(pitch_angle); + back_cone_radius = apex_to_apex * sin(pitch_angle); + + // Calculate and display the pitch angle. This is needed to determine the + // angle to mount two meshing cone gears. + + // Base Circle for forming the involute teeth shape. + base_radius = back_cone_radius * cos(pressure_angle); + + // Diametrial pitch: Number of teeth per unit length. + pitch_diametrial = number_of_teeth / outside_pitch_diameter; + + // Addendum: Radial distance from pitch circle to outside circle. + addendum = 1 / pitch_diametrial; + // Outer Circle + outer_radius = back_cone_radius + addendum; + + // Dedendum: Radial distance from pitch circle to root diameter + dedendum = addendum + clearance; + dedendum_angle = atan(dedendum / cone_distance); + root_angle = pitch_angle - dedendum_angle; + + root_cone_full_radius = tan(root_angle) * apex_to_apex; + back_cone_full_radius = apex_to_apex / tan(pitch_angle); + + back_cone_end_radius = outside_pitch_radius - dedendum * cos(pitch_angle) - + gear_thickness / tan(pitch_angle); + back_cone_descent = dedendum * sin(pitch_angle) + gear_thickness; + + // Root diameter: Diameter of bottom of tooth spaces. + root_radius = back_cone_radius - dedendum; + + half_tooth_thickness = + outside_pitch_radius * sin(360 / (4 * number_of_teeth)) - backlash / 4; + half_thick_angle = asin(half_tooth_thickness / back_cone_radius); + + face_cone_height = apex_to_apex - face_width / cos(pitch_angle); + face_cone_full_radius = face_cone_height / tan(pitch_angle); + face_cone_descent = dedendum * sin(pitch_angle); + face_cone_end_radius = outside_pitch_radius - + face_width / sin(pitch_angle) - + face_cone_descent / tan(pitch_angle); + + // For the bevel_gear_flat finish option, calculate the height of a cube to + // select the portion of the gear that includes the full pitch face. + bevel_gear_flat_height = + pitch_apex - (cone_distance - face_width) * cos(pitch_angle); + + // translate([0,0,-pitch_apex]) + difference() + { + intersection() + { + union() + { + rotate(half_thick_angle) + translate([ 0, 0, pitch_apex - apex_to_apex ]) + cylinder($fn = number_of_teeth * 2, + r1 = root_cone_full_radius, + r2 = 0, + h = apex_to_apex); + for (i = [1:number_of_teeth]) + // for (i = [1:1]) + { + rotate([ 0, 0, i * 360 / number_of_teeth ]) + { + involute_bevel_gear_tooth( + back_cone_radius = back_cone_radius, + root_radius = root_radius, + base_radius = base_radius, + outer_radius = outer_radius, + pitch_apex = pitch_apex, + cone_distance = cone_distance, + half_thick_angle = half_thick_angle, + involute_facets = involute_facets); + } + } + } + + if (finish == bevel_gear_back_cone) { + translate([ 0, 0, -back_cone_descent ]) + cylinder($fn = number_of_teeth * 2, + r1 = back_cone_end_radius, + r2 = back_cone_full_radius * 2, + h = apex_to_apex + back_cone_descent); + } else { + translate([ + -1.5 * outside_pitch_radius, + -1.5 * outside_pitch_radius, + 0 + ]) + cube([ + 3 * outside_pitch_radius, + 3 * outside_pitch_radius, + bevel_gear_flat_height + ]); + } + } + + if (finish == bevel_gear_back_cone) { + translate([ 0, 0, -face_cone_descent ]) + cylinder(r1 = face_cone_end_radius, + r2 = face_cone_full_radius * 2, + h = face_cone_height + face_cone_descent + pitch_apex); + } + + translate([ 0, 0, pitch_apex - apex_to_apex ]) + cylinder(r = bore_diameter / 2, h = apex_to_apex); + } } -module involute_bevel_gear_tooth ( - back_cone_radius, - root_radius, - base_radius, - outer_radius, - pitch_apex, - cone_distance, - half_thick_angle, - involute_facets) +module involute_bevel_gear_tooth(back_cone_radius, + root_radius, + base_radius, + outer_radius, + pitch_apex, + cone_distance, + half_thick_angle, + involute_facets) { -// echo ("involute_bevel_gear_tooth", -// back_cone_radius, -// root_radius, -// base_radius, -// outer_radius, -// pitch_apex, -// cone_distance, -// half_thick_angle); - - min_radius = max (base_radius*2,root_radius*2); - - pitch_point = - involute ( - base_radius*2, - involute_intersect_angle (base_radius*2, back_cone_radius*2)); - pitch_angle = atan2 (pitch_point[1], pitch_point[0]); - centre_angle = pitch_angle + half_thick_angle; - - start_angle = involute_intersect_angle (base_radius*2, min_radius); - stop_angle = involute_intersect_angle (base_radius*2, outer_radius*2); - - res=(involute_facets!=0)?involute_facets:($fn==0)?5:$fn/4; - - translate ([0,0,pitch_apex]) - rotate ([0,-atan(back_cone_radius/cone_distance),0]) - translate ([-back_cone_radius*2,0,-cone_distance*2]) - union () - { - for (i=[1:res]) - { - assign ( - point1= - involute (base_radius*2,start_angle+(stop_angle - start_angle)*(i-1)/res), - point2= - involute (base_radius*2,start_angle+(stop_angle - start_angle)*(i)/res)) - { - assign ( - side1_point1 = rotate_2dvector (centre_angle, point1), - side1_point2 = rotate_2dvector (centre_angle, point2), - side2_point1 = mirror_2dvector (rotate_2dvector (centre_angle, point1)), - side2_point2 = mirror_2dvector (rotate_2dvector (centre_angle, point2))) - { - polyhedron ( - points=[ - [back_cone_radius*2+0.1,0,cone_distance*2], - [side1_point1[0],side1_point1[1],0], - [side1_point2[0],side1_point2[1],0], - [side2_point2[0],side2_point2[1],0], - [side2_point1[0],side2_point1[1],0], - [0.1,0,0]], - triangles=[[0,2,1],[0,3,2],[0,4,3],[0,1,5],[1,2,5],[2,3,5],[3,4,5],[0,5,4]]); - } - } - } - } + // echo ("involute_bevel_gear_tooth", + // back_cone_radius, + // root_radius, + // base_radius, + // outer_radius, + // pitch_apex, + // cone_distance, + // half_thick_angle); + + min_radius = max(base_radius * 2, root_radius * 2); + + pitch_point = involute( + base_radius * 2, + involute_intersect_angle(base_radius * 2, back_cone_radius * 2)); + pitch_angle = atan2(pitch_point[1], pitch_point[0]); + centre_angle = pitch_angle + half_thick_angle; + + start_angle = involute_intersect_angle(base_radius * 2, min_radius); + stop_angle = involute_intersect_angle(base_radius * 2, outer_radius * 2); + + res = (involute_facets != 0) ? involute_facets : ($fn == 0) ? 5 : $fn / 4; + + translate([ 0, 0, pitch_apex ]) + rotate([ 0, -atan(back_cone_radius / cone_distance), 0 ]) + translate([ -back_cone_radius * 2, 0, -cone_distance * 2 ]) union() + { + for (i = [1:res]) { + assign(point1 = involute(base_radius * 2, + start_angle + (stop_angle - start_angle) * + (i - 1) / res), + point2 = involute(base_radius * 2, + start_angle + (stop_angle - start_angle) * + (i) / res)) + { + assign(side1_point1 = rotate_2dvector(centre_angle, point1), + side1_point2 = rotate_2dvector(centre_angle, point2), + side2_point1 = mirror_2dvector( + rotate_2dvector(centre_angle, point1)), + side2_point2 = mirror_2dvector( + rotate_2dvector(centre_angle, point2))) + { + polyhedron( + points = + [[back_cone_radius * 2 + 0.1, 0, cone_distance * 2], + [side1_point1 [0], side1_point1 [1], 0], + [side1_point2 [0], side1_point2 [1], 0], + [side2_point2 [0], side2_point2 [1], 0], + [side2_point1 [0], side2_point1 [1], 0], + [0.1, 0, 0]], + triangles = [ + [ 0, 2, 1 ], + [ 0, 3, 2 ], + [ 0, 4, 3 ], + [ 0, 1, 5 ], + [ 1, 2, 5 ], + [ 2, 3, 5 ], + [ 3, 4, 5 ], + [ 0, 5, 4 ] + ]); + } + } + } + } } - - -module gear ( - number_of_teeth=15, - circular_pitch=false, diametral_pitch=false, - pressure_angle=28, - clearance = 0.2, - gear_thickness=5, - rim_thickness=8, - rim_width=5, - hub_thickness=10, - hub_diameter=15, - bore_diameter=5, - circles=0, - backlash=0, - twist=0, - helix_angle=0, - herringbone=false, - involute_facets=0, - flat=false, - roundsize=1, - internal = false) +module gear(number_of_teeth = 15, + circular_pitch = false, + diametral_pitch = false, + pressure_angle = 28, + clearance = 0.2, + gear_thickness = 5, + rim_thickness = 8, + rim_width = 5, + hub_thickness = 10, + hub_diameter = 15, + bore_diameter = 5, + circles = 0, + backlash = 0, + twist = 0, + helix_angle = 0, + herringbone = false, + involute_facets = 0, + flat = false, + roundsize = 1, + internal = false) { - if (circular_pitch==false && diametral_pitch==false) - echo("MCAD ERROR: gear module needs either a diametral_pitch or circular_pitch"); - - //Convert diametrial pitch to our native circular pitch - circular_pitch = (circular_pitch!=false?circular_pitch:180/diametral_pitch); - - // Pitch diameter: Diameter of pitch circle. - pitch_diameter = number_of_teeth * circular_pitch / 180; - pitch_radius = pitch_diameter/2; - pitch_circumference = PI * pitch_diameter; - echo ("Teeth:", number_of_teeth, " Pitch radius:", pitch_radius); - - twist = ( - (twist != 0) ? twist : - (tan (helix_angle) * rim_thickness / - pitch_circumference * 360) - ); - echo ("Twist: ", twist); - - // Base Circle - base_radius = pitch_radius*cos(pressure_angle); - - // Diametrial pitch: Number of teeth per unit length. - pitch_diametrial = number_of_teeth / pitch_diameter; - - // Addendum: Radial distance from pitch circle to outside circle. - addendum = 1/pitch_diametrial + (internal ? clearance : 0); - - //Outer Circle - outer_radius = pitch_radius+addendum; - - // Dedendum: Radial distance from pitch circle to root diameter - dedendum = addendum + (internal ? -clearance : clearance); - - // Root diameter: Diameter of bottom of tooth spaces. - root_radius = pitch_radius-dedendum; - backlash_angle = (internal ? -backlash : backlash) / pitch_radius * 180 / pi; - half_thick_angle = (360 / number_of_teeth - backlash_angle) / 4; - - // Variables controlling the rim. - rim_radius = internal ? outer_radius + rim_width : root_radius - rim_width; - - // Variables controlling the circular holes in the gear. - circle_orbit_diameter=hub_diameter/2+min(rim_radius, root_radius); - circle_orbit_curcumference=pi*circle_orbit_diameter; - - max_thickness = max (rim_thickness, hub_thickness, gear_thickness); - - // Limit the circle size to 90% of the gear face. - circle_diameter= - min ( - 0.70*circle_orbit_curcumference/circles, - (min(rim_radius, root_radius)-hub_diameter/2)*0.9); - - module flat_gear () - { - module _gear_shape () - { - gear_shape ( - number_of_teeth, - pitch_radius = pitch_radius, - root_radius = root_radius, - base_radius = base_radius, - outer_radius = outer_radius, - half_thick_angle = half_thick_angle, - involute_facets=involute_facets); - } - - module rounding_circles () - { - path_radius = internal ? outer_radius : root_radius; - circle_positions = (internal ? - [0:1:number_of_teeth] : - [0.5:1:number_of_teeth - 0.5]); - - if (roundsize > 0) - for (i=circle_positions) { - rotate([0, 0, (i*360/number_of_teeth)]) - translate([path_radius, 0]) - circle(r=((360/number_of_teeth - half_thick_angle)/360) * pi*root_radius/2 * roundsize, $fa = 18, $fs = 0.5); - } - } - - if (internal) - union () { - _gear_shape (); - rounding_circles (); - } else - difference() { - _gear_shape (); - rounding_circles (); + if (circular_pitch == false && diametral_pitch == false) + echo("MCAD ERROR: gear module needs either a diametral_pitch or " + "circular_pitch"); + + // Convert diametrial pitch to our native circular pitch + circular_pitch = + (circular_pitch != false ? circular_pitch : 180 / diametral_pitch); + + // Pitch diameter: Diameter of pitch circle. + pitch_diameter = number_of_teeth * circular_pitch / 180; + pitch_radius = pitch_diameter / 2; + pitch_circumference = PI * pitch_diameter; + echo("Teeth:", number_of_teeth, " Pitch radius:", pitch_radius); + + twist = + ((twist != 0) + ? twist + : (tan(helix_angle) * rim_thickness / pitch_circumference * 360)); + echo("Twist: ", twist); + + // Base Circle + base_radius = pitch_radius * cos(pressure_angle); + + // Diametrial pitch: Number of teeth per unit length. + pitch_diametrial = number_of_teeth / pitch_diameter; + + // Addendum: Radial distance from pitch circle to outside circle. + addendum = 1 / pitch_diametrial + (internal ? clearance : 0); + + // Outer Circle + outer_radius = pitch_radius + addendum; + + // Dedendum: Radial distance from pitch circle to root diameter + dedendum = addendum + (internal ? -clearance : clearance); + + // Root diameter: Diameter of bottom of tooth spaces. + root_radius = pitch_radius - dedendum; + backlash_angle = + (internal ? -backlash : backlash) / pitch_radius * 180 / pi; + half_thick_angle = (360 / number_of_teeth - backlash_angle) / 4; + + // Variables controlling the rim. + rim_radius = internal ? outer_radius + rim_width : root_radius - rim_width; + + // Variables controlling the circular holes in the gear. + circle_orbit_diameter = hub_diameter / 2 + min(rim_radius, root_radius); + circle_orbit_curcumference = pi * circle_orbit_diameter; + + max_thickness = max(rim_thickness, hub_thickness, gear_thickness); + + // Limit the circle size to 90% of the gear face. + circle_diameter = + min(0.70 * circle_orbit_curcumference / circles, + (min(rim_radius, root_radius) - hub_diameter / 2) * 0.9); + + module flat_gear() + { + module _gear_shape() + { + gear_shape(number_of_teeth, + pitch_radius = pitch_radius, + root_radius = root_radius, + base_radius = base_radius, + outer_radius = outer_radius, + half_thick_angle = half_thick_angle, + involute_facets = involute_facets); + } + + module rounding_circles() + { + path_radius = internal ? outer_radius : root_radius; + circle_positions = (internal ? [0:1:number_of_teeth] + : [0.5:1:number_of_teeth - 0.5]); + + if (roundsize > 0) + for (i = circle_positions) { + rotate([ 0, 0, (i * 360 / number_of_teeth) ]) + translate([ path_radius, 0 ]) circle( + r = ((360 / number_of_teeth - half_thick_angle) / + 360) * + pi * root_radius / 2 * roundsize, + $fa = 18, + $fs = 0.5); } - } - - // render the extruded gear shape (or cutout for internal gear) - module extruded_gear () - { - lower_rim_thickness = ( - rim_thickness / 2 + - ((internal && gear_thickness == 0) ? 0.1 : 0) - ); - lower_twist = twist / rim_thickness * lower_rim_thickness; - - upper_rim_thickness = ( - rim_thickness / 2 + - ((internal) ? 0.1 : 0) - ); - upper_twist = twist / rim_thickness * upper_rim_thickness; - - if (flat) { - flat_gear (); - - } else if (herringbone) { - translate ([0, 0, rim_thickness / 2]) { - linear_extrude ( - height = upper_rim_thickness, - convexity = 10, - twist = upper_twist - ) - flat_gear (); - - mirror ([0, 0, 1]) - linear_extrude ( - height = lower_rim_thickness, - convexity = 10, - twist = lower_twist - ) - flat_gear (); - } - - } else { - linear_extrude( - height = rim_thickness + (internal ? 0.2 : 0), - convexity = 10, - twist = twist - ) - flat_gear (); - } - } - - module ensure_rim () - { - if (flat) { - children (); - - } else if (internal) { - difference () { - linear_extrude (height = rim_thickness) - circle (r = rim_radius); - - translate ([0, 0, gear_thickness]) - children (); - } - - } else if (gear_thickness > rim_thickness) { - union () { - children (); - - linear_extrude_flat_option ( - flat = flat, - height = gear_thickness - ) - circle (r = rim_radius); - } - } else { - difference () { - children (); - - translate ([0, 0, gear_thickness]) - linear_extrude_flat_option ( - flat = flat, - height = (rim_thickness - gear_thickness - + 0.1) - ) - circle (r = rim_radius); - } - } - } - - module hub () - { - if (internal) - cylinder (d=hub_diameter, h=hub_thickness); - - else if (!flat) - translate ([0, 0, gear_thickness]) - cylinder (d=hub_diameter, h=hub_thickness - gear_thickness); - } - - module _circles () - { - if (circles > 1) - for (i=[0:circles-1]) - rotate ([0, 0, i*360/circles]) - translate ([circle_orbit_diameter / 2, 0, 0]) - circle (r=circle_diameter / 2); - } - - module bore () - { - circle (d = bore_diameter); - } - - difference () { - union () { - ensure_rim () - extruded_gear (); - - hub (); - } - - linear_extrude_flat_option ( - flat = flat, - center = true, - height = (max_thickness + 0.1) * 2 - ) - union () { - _circles (); - bore (); - } - } + } + + if (internal) + union() + { + _gear_shape(); + rounding_circles(); + } + else + difference() + { + _gear_shape(); + rounding_circles(); + } + } + + // render the extruded gear shape (or cutout for internal gear) + module extruded_gear() + { + lower_rim_thickness = + (rim_thickness / 2 + ((internal && gear_thickness == 0) ? 0.1 : 0)); + lower_twist = twist / rim_thickness * lower_rim_thickness; + + upper_rim_thickness = (rim_thickness / 2 + ((internal) ? 0.1 : 0)); + upper_twist = twist / rim_thickness * upper_rim_thickness; + + if (flat) { + flat_gear(); + + } else if (herringbone) { + translate([ 0, 0, rim_thickness / 2 ]) + { + linear_extrude(height = upper_rim_thickness, + convexity = 10, + twist = upper_twist) flat_gear(); + + mirror([ 0, 0, 1 ]) linear_extrude(height = lower_rim_thickness, + convexity = 10, + twist = lower_twist) + flat_gear(); + } + + } else { + linear_extrude(height = rim_thickness + (internal ? 0.2 : 0), + convexity = 10, + twist = twist) flat_gear(); + } + } + + module ensure_rim() + { + if (flat) { + children(); + + } else if (internal) { + difference() + { + linear_extrude(height = rim_thickness) circle(r = rim_radius); + + translate([ 0, 0, gear_thickness ]) children(); + } + + } else if (gear_thickness > rim_thickness) { + union() + { + children(); + + linear_extrude_flat_option(flat = flat, height = gear_thickness) + circle(r = rim_radius); + } + } else { + difference() + { + children(); + + translate([ 0, 0, gear_thickness ]) linear_extrude_flat_option( + flat = flat, + height = (rim_thickness - gear_thickness + 0.1)) + circle(r = rim_radius); + } + } + } + + module hub() + { + if (internal) + cylinder(d = hub_diameter, h = hub_thickness); + + else if (!flat) + translate([ 0, 0, gear_thickness ]) + cylinder(d = hub_diameter, h = hub_thickness - gear_thickness); + } + + module _circles() + { + if (circles > 1) + for (i = [0:circles - 1]) + rotate([ 0, 0, i * 360 / circles ]) + translate([ circle_orbit_diameter / 2, 0, 0 ]) + circle(r = circle_diameter / 2); + } + + module bore() { circle(d = bore_diameter); } + + difference() + { + union() + { + ensure_rim() extruded_gear(); + + hub(); + } + + linear_extrude_flat_option(flat = flat, + center = true, + height = (max_thickness + 0.1) * 2) union() + { + _circles(); + bore(); + } + } } -module linear_extrude_flat_option(flat =false, height = 10, center = false, convexity = 2, twist = 0) +module linear_extrude_flat_option(flat = false, + height = 10, + center = false, + convexity = 2, + twist = 0) { - if(flat==false) - { - linear_extrude(height = height, center = center, convexity = convexity, twist= twist) - children (); - } - else - { - children (); - } - + if (flat == false) { + linear_extrude(height = height, + center = center, + convexity = convexity, + twist = twist) children(); + } else { + children(); + } } - -module gear_shape ( - number_of_teeth, - pitch_radius, - root_radius, - base_radius, - outer_radius, - half_thick_angle, - involute_facets) +module gear_shape(number_of_teeth, + pitch_radius, + root_radius, + base_radius, + outer_radius, + half_thick_angle, + involute_facets) { - - union() - { - rotate (half_thick_angle) circle ($fn=number_of_teeth*2, r=root_radius); - - for (i = [1:number_of_teeth]) - { - - rotate ([0,0,i*360/number_of_teeth]) - { - involute_gear_tooth ( - pitch_radius = pitch_radius, - root_radius = root_radius, - base_radius = base_radius, - outer_radius = outer_radius, - half_thick_angle = half_thick_angle, - involute_facets=involute_facets); - } - } - } + union() + { + rotate(half_thick_angle) + circle($fn = number_of_teeth * 2, r = root_radius); + + for (i = [1:number_of_teeth]) { + + rotate([ 0, 0, i * 360 / number_of_teeth ]) + { + involute_gear_tooth(pitch_radius = pitch_radius, + root_radius = root_radius, + base_radius = base_radius, + outer_radius = outer_radius, + half_thick_angle = half_thick_angle, + involute_facets = involute_facets); + } + } + } } - -module involute_gear_tooth ( - pitch_radius, - root_radius, - base_radius, - outer_radius, - half_thick_angle, - involute_facets) +module involute_gear_tooth(pitch_radius, + root_radius, + base_radius, + outer_radius, + half_thick_angle, + involute_facets) { - min_radius = max (base_radius,root_radius); + min_radius = max(base_radius, root_radius); - pitch_point = involute (base_radius, involute_intersect_angle (base_radius, pitch_radius)); - pitch_angle = atan2 (pitch_point[1], pitch_point[0]); - centre_angle = pitch_angle + half_thick_angle; + pitch_point = involute(base_radius, + involute_intersect_angle(base_radius, pitch_radius)); + pitch_angle = atan2(pitch_point[1], pitch_point[0]); + centre_angle = pitch_angle + half_thick_angle; - start_angle = involute_intersect_angle (base_radius, min_radius); - stop_angle = involute_intersect_angle (base_radius, outer_radius); + start_angle = involute_intersect_angle(base_radius, min_radius); + stop_angle = involute_intersect_angle(base_radius, outer_radius); - res=(involute_facets!=0)?involute_facets:($fn==0)?5:$fn/4; + res = (involute_facets != 0) ? involute_facets : ($fn == 0) ? 5 : $fn / 4; - function reverse (v) = [ - for (i = [1:len (v)]) - v[len (v) - i] - ]; + function reverse(v) = [for (i = [1:len(v)]) v[len(v) - i]]; - side1_points = [ - for (i = [0:res]) - rotate_2dvector (centre_angle, involute (base_radius, start_angle + (stop_angle - start_angle) * i / res)) - ]; + side1_points = [for (i = [0:res]) rotate_2dvector( + centre_angle, + involute(base_radius, + start_angle + (stop_angle - start_angle) * i / res))]; - side2_points = [ - for (i = reverse (side1_points)) - mirror_2dvector (i) - ]; + side2_points = [for (i = reverse(side1_points)) mirror_2dvector(i)]; - polygon (points = concat ([[0, 0]], side1_points, side2_points)); + polygon(points = concat([[ 0, 0 ]], side1_points, side2_points)); } // Mathematical Functions //=============== -// Finds the angle of the involute about the base radius at the given distance (radius) from it's center. -//source: http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html +// Finds the angle of the involute about the base radius at the given distance +// (radius) from it's center. +// source: +// http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html -function involute_intersect_angle (base_radius, radius) = sqrt (pow (radius/base_radius, 2) - 1) * 180 / pi; +function involute_intersect_angle(base_radius, radius) = + sqrt(pow(radius / base_radius, 2) - 1) * 180 / pi; // Calculate the involute position for a given base radius and involute angle. -function rotated_involute (rotate, base_radius, involute_angle) = -[ - cos (rotate) * involute (base_radius, involute_angle)[0] + sin (rotate) * involute (base_radius, involute_angle)[1], - cos (rotate) * involute (base_radius, involute_angle)[1] - sin (rotate) * involute (base_radius, involute_angle)[0] +function rotated_involute(rotate, base_radius, involute_angle) = [ + cos(rotate) * involute(base_radius, involute_angle)[0] + + sin(rotate) * involute(base_radius, involute_angle)[1], + cos(rotate) * involute(base_radius, involute_angle)[1] - + sin(rotate) * involute(base_radius, involute_angle)[0] ]; -function involute (base_radius, involute_angle) = -[ - base_radius*(cos (involute_angle) + involute_angle*pi/180*sin (involute_angle)), - base_radius*(sin (involute_angle) - involute_angle*pi/180*cos (involute_angle)) +function involute(base_radius, involute_angle) = [ + base_radius * + (cos(involute_angle) + involute_angle * pi / 180 * sin(involute_angle)), + base_radius*(sin(involute_angle) - + involute_angle * pi / 180 * cos(involute_angle)) ]; // For ease of conversion from proper circular pitch to this broken library's // values -function convertcp (circular_pitch) = circular_pitch / PI * 180; -function circumference2radius (circumference) = circumference / (2 * PI); -function gear_spacing (cp, nt1, nt2) = circumference2radius (cp * nt1) + - circumference2radius (cp * nt2); - +function convertcp(circular_pitch) = circular_pitch / PI * 180; +function circumference2radius(circumference) = circumference / (2 * PI); +function gear_spacing(cp, nt1, nt2) = circumference2radius(cp * nt1) + + circumference2radius(cp * nt2); // Test Cases //=============== -module test_gears() +module +test_gears() { - translate([17,-15]) - { - #gear (number_of_teeth=17, - circular_pitch=500, + translate([ 17, -15 ]) + { +#gear(number_of_teeth = 17, + circular_pitch=500, circles=8); - rotate ([0,0,360*4/17]) - translate ([39.088888,0,0]) - { - #gear (number_of_teeth=11, - circular_pitch=500, + rotate([ 0, 0, 360 * 4 / 17 ]) translate([ 39.088888, 0, 0 ]) + { +#gear(number_of_teeth = 11, + circular_pitch=500, hub_diameter=0, rim_width=65); - translate ([0,0,8]) - { - gear (number_of_teeth=6, - circular_pitch=300, - hub_diameter=0, - rim_width=5, - rim_thickness=6, - pressure_angle=31); - #rotate ([0,0,360*5/6]) - translate ([22.5,0,1]) - gear (number_of_teeth=21, - circular_pitch=300, - bore_diameter=2, - hub_diameter=4, - rim_width=1, - hub_thickness=4, - rim_thickness=4, - gear_thickness=3, - pressure_angle=31); - } - } - - translate ([-61.1111111,0,0]) - { - #gear (number_of_teeth=27, - circular_pitch=500, + translate([ 0, 0, 8 ]) + { + gear(number_of_teeth = 6, + circular_pitch = 300, + hub_diameter = 0, + rim_width = 5, + rim_thickness = 6, + pressure_angle = 31); +#rotate([ 0, 0, 360 * 5 / 6 ]) + translate([ 22.5, 0, 1 ]) gear(number_of_teeth = 21, + circular_pitch = 300, + bore_diameter = 2, + hub_diameter = 4, + rim_width = 1, + hub_thickness = 4, + rim_thickness = 4, + gear_thickness = 3, + pressure_angle = 31); + } + } + + translate([ -61.1111111, 0, 0 ]) + { +#gear(number_of_teeth = 27, + circular_pitch=500, circles=5, hub_diameter=2*8.88888889); - translate ([0,0,10]) - { - gear ( - number_of_teeth=14, - circular_pitch=200, - pressure_angle=5, - clearance = 0.2, - gear_thickness = 10, - rim_thickness = 10, - rim_width = 15, - bore_diameter=5, - circles=0); - translate ([13.8888888,0,1]) - #gear ( + translate([ 0, 0, 10 ]) + { + gear(number_of_teeth = 14, + circular_pitch = 200, + pressure_angle = 5, + clearance = 0.2, + gear_thickness = 10, + rim_thickness = 10, + rim_width = 15, + bore_diameter = 5, + circles = 0); + translate ([13.8888888,0,1]) +#gear( number_of_teeth=11, circular_pitch=200, pressure_angle=5, @@ -744,12 +734,12 @@ module test_gears() hub_diameter=2*7.222222, bore_diameter=5, circles=0); - } - } + } + } - rotate ([0,0,360*-5/17]) + rotate ([0,0,360*-5/17]) translate ([44.444444444,0,0]) - #gear (number_of_teeth=15, +#gear(number_of_teeth = 15, circular_pitch=500, hub_diameter=10, rim_width=5, @@ -758,117 +748,109 @@ module test_gears() hub_thickness=6, circles=9); - rotate ([0,0,360*-1/17]) + rotate ([0,0,360*-1/17]) translate ([30.5555555,0,-1]) - #gear (number_of_teeth=5, +#gear(number_of_teeth = 5, circular_pitch=500, hub_diameter=0, rim_width=5, rim_thickness=10); - } + } } -module meshing_double_helix () +module +meshing_double_helix() { - test_double_helix_gear (); + test_double_helix_gear(); - mirror ([0,1,0]) - translate ([58.33333333,0,0]) - test_double_helix_gear (teeth=13,circles=6); + mirror([ 0, 1, 0 ]) translate([ 58.33333333, 0, 0 ]) + test_double_helix_gear(teeth = 13, circles = 6); } -module test_double_helix_gear ( - teeth=17, - circles=8) +module test_double_helix_gear(teeth = 17, circles = 8) { - //double helical gear - { - twist=200; - height=20; - pressure_angle=30; - - gear (number_of_teeth=teeth, - circular_pitch=700, - pressure_angle=pressure_angle, - clearance = 0.2, - gear_thickness = height/2*0.5, - rim_thickness = height/2, - rim_width = 5, - hub_thickness = height/2*1.2, - hub_diameter=15, - bore_diameter=5, - circles=circles, - helix_angle=45, - herringbone=true); - *mirror([0,0,1]) - gear (number_of_teeth=teeth, - circular_pitch=700, - pressure_angle=pressure_angle, - clearance = 0.2, - gear_thickness = height/2, - rim_thickness = height/2, - rim_width = 5, - hub_thickness = height/2, - hub_diameter=15, - bore_diameter=5, - circles=circles, - twist=twist/teeth); - } + // double helical gear + { + twist = 200; + height = 20; + pressure_angle = 30; + + gear(number_of_teeth = teeth, + circular_pitch = 700, + pressure_angle = pressure_angle, + clearance = 0.2, + gear_thickness = height / 2 * 0.5, + rim_thickness = height / 2, + rim_width = 5, + hub_thickness = height / 2 * 1.2, + hub_diameter = 15, + bore_diameter = 5, + circles = circles, + helix_angle = 45, + herringbone = true); + *mirror([ 0, 0, 1 ]) gear(number_of_teeth = teeth, + circular_pitch = 700, + pressure_angle = pressure_angle, + clearance = 0.2, + gear_thickness = height / 2, + rim_thickness = height / 2, + rim_width = 5, + hub_thickness = height / 2, + hub_diameter = 15, + bore_diameter = 5, + circles = circles, + twist = twist / teeth); + } } -module test_backlash () +module +test_backlash() { - backlash = 2; - teeth = 15; - - translate ([-29.166666,0,0]) - { - translate ([58.3333333,0,0]) - rotate ([0,0,-360/teeth/4]) - gear ( - number_of_teeth = teeth, - circular_pitch=700, - gear_thickness = 12, - rim_thickness = 15, - rim_width = 5, - hub_thickness = 17, - hub_diameter=15, - bore_diameter=5, - backlash = 2, - circles=8); - - rotate ([0,0,360/teeth/4]) - gear ( - number_of_teeth = teeth, - circular_pitch=700, - gear_thickness = 12, - rim_thickness = 15, - rim_width = 5, - hub_thickness = 17, - hub_diameter=15, - bore_diameter=5, - backlash = 2, - circles=8); - } - - color([0,0,128,0.5]) - translate([0,0,-5]) - cylinder ($fn=20,r=backlash / 4,h=25); + backlash = 2; + teeth = 15; + + translate([ -29.166666, 0, 0 ]) + { + translate([ 58.3333333, 0, 0 ]) rotate([ 0, 0, -360 / teeth / 4 ]) + gear(number_of_teeth = teeth, + circular_pitch = 700, + gear_thickness = 12, + rim_thickness = 15, + rim_width = 5, + hub_thickness = 17, + hub_diameter = 15, + bore_diameter = 5, + backlash = 2, + circles = 8); + + rotate([ 0, 0, 360 / teeth / 4 ]) gear(number_of_teeth = teeth, + circular_pitch = 700, + gear_thickness = 12, + rim_thickness = 15, + rim_width = 5, + hub_thickness = 17, + hub_diameter = 15, + bore_diameter = 5, + backlash = 2, + , circles = 8); + } + + color([ 0, 0, 128, 0.5 ]) translate([ 0, 0, -5 ]) + cylinder($fn = 20, r = backlash / 4, h = 25); } -module test_internal_gear () +module +test_internal_gear() { - gear ( - number_of_teeth = 30, - circular_pitch = 5 * 180 / PI, - hub_thickness = 0, - rim_thickness = 10, - rim_width = 5, - gear_thickness = 0, - internal = true, - helix_angle = 45, - herringbone = true - ); + gear(number_of_teeth = 30, + circular_pitch = 5 * 180 / PI, + hub_thickness = 0, + rim_thickness = 10, + rim_width = 5, + gear_thickness = 0, + internal = true, + helix_angle = 45, + herringbone = true); } -*test_internal_gear (); +*test_internal_gear(); diff --git a/gears/rack_and_pinion.scad b/gears/rack_and_pinion.scad index 8ed01a64..04cc19d1 100644 --- a/gears/rack_and_pinion.scad +++ b/gears/rack_and_pinion.scad @@ -1,3 +1,4 @@ + // Rack and pinion gears GPL (c) SASA October 2013. // // Very simple rack and pinion gear based on GPL code. @@ -14,12 +15,12 @@ // Modular Rack by Mark "Ckaos" Moissette GNU GPL license. (Rack based on the // work of MattMoses and Fdavies // http://forums.reprap.org/read.php?1,51452,52099#msg-52099 and Forrest Higgs: -// +// // The originals have many fine additions such as helical gears which I've // dropped in favour of simplicity (as befits my needs) - it wouldn't be a big // jobs to nobble my changes backwards or their features forwards. -$fn=50; +$fn = 50; // examples of usage // include this in your code: @@ -30,171 +31,257 @@ $fn=50; // a simple pinion and translation / rotation to make it mesh the rack // translate([0,-8.5,0])rotate([0,0,360/10/2]) pinion(4,10,10,5); -include ; - - - -module rack(cp, N, width, thickness){ -// cp = circular pitch - for rack = pitch in mm/per tooth -// N = number of teeth -// width = width of rack -// thickness = thickness of support under teeth (0 for no support) - - a = 1.0*cp/const_pi; // addendum (also known as "module") - d = 1.1*cp/const_pi; // dedendum (this is set by a standard) - height=(d+a); - - // find the tangent of pressure angle once - tanPA = tan(20); - // length of bottom and top horizontal segments of tooth profile - botL = (cp/2 - 2*d*tanPA); - topL = (cp/2 - 2*a*tanPA); - - slantLng=tanPA*height; - realBase=2*slantLng+topL; - - offset=topL+botL+2*slantLng; - length=(realBase+botL)*N; - - supportSize=width; - translate([botL/2,0,0]) - rotate([90,0,0]){ - translate([0,supportSize/2,0]){ - union(){ - cube(size=[length,width,thickness],center=true); - for (i = [0:N-1]){ - translate([i*offset-length/2+realBase/2,0,thickness/2]){ - trapezoid([topL,supportSize],[realBase,supportSize],height); - } - } - } - } - } - } - -module pinion (cp, N, width, shaft_diameter, backlash=0){ -// cp= circular pitch - for pinion pitch in mm/per as measured along the ptich radius (~1/2 way up tooth) -// N= number of teeth -// width= width of the gear -// shaft_diameter= diameter of hole for shaft -// backlash - I think this is just a bodge for making things fit when printed but I never tested it - - if (cp==false && diametral_pitch==false) - echo("MCAD ERROR: pinion module needs either a diametral_pitch or cp"); - - //Convert diametrial pitch to our native circular pitch - cp = (cp!=false?cp:180/diametral_pitch); - - // Pitch diameter: Diameter of pitch circle. - pitch_diameter = N * cp / const_pi; - pitch_radius = pitch_diameter/2; - echo ("Teeth:", N, " Pitch radius:", pitch_radius); - // Base Circle - base_radius = pitch_radius*cos(20); - - // Addendum: Radial distance from pitch circle to outside circle. - addendum = cp/const_pi; - - //Outer Circle - outer_radius = pitch_radius+addendum; - - // Dedendum: Radial distance from pitch circle to root diameter - dedendum = addendum*1.1; - - // Root diameter: Diameter of bottom of tooth spaces. - root_radius = pitch_radius-dedendum; - - backlash_angle = backlash / pitch_radius * 180 / const_pi; - half_thick_angle = (360 / N - backlash_angle) / 4; - - difference(){ - linear_extrude (height=width, convexity=10, twist=0) - pinion_shape(N, pitch_radius = pitch_radius, root_radius = root_radius, - base_radius = base_radius, outer_radius = outer_radius, - half_thick_angle = half_thick_angle, involute_facets=0); - - translate([0,0,-1]) cylinder(r=shaft_diameter/2,h=2+width); - } - - echo("Root radius =",root_radius,"\nPitch radius=",pitch_radius,"\n Tip radius=",outer_radius,"\n"); - } - -module pinion_shape ( N, pitch_radius, root_radius, base_radius, outer_radius, half_thick_angle, involute_facets) { - union(){ - rotate (half_thick_angle) circle ($fn=N*2, r=root_radius); - for (i = [1:N]) { - rotate ([0,0,i*360/N]) { - involute_pinion_tooth ( - pitch_radius = pitch_radius, - root_radius = root_radius, - base_radius = base_radius, - outer_radius = outer_radius, - half_thick_angle = half_thick_angle, - involute_facets=involute_facets); - } - } - } - } - -module involute_pinion_tooth ( pitch_radius, root_radius, base_radius, outer_radius, half_thick_angle, involute_facets) { - min_radius = max (base_radius,root_radius); - - pitch_point = involute (base_radius, involute_intersect_angle (base_radius, pitch_radius)); - pitch_angle = atan2 (pitch_point[1], pitch_point[0]); - centre_angle = pitch_angle + half_thick_angle; - - start_angle = involute_intersect_angle (base_radius, min_radius); - stop_angle = involute_intersect_angle (base_radius, outer_radius); - - res=(involute_facets!=0)?involute_facets:($fn==0)?5:$fn/4; - - union () { - for (i=[1:res]) - assign ( point1=involute (base_radius,start_angle+(stop_angle - start_angle)*(i-1)/res), point2=involute (base_radius,start_angle+(stop_angle - start_angle)*i/res)) { - assign ( - side1_point1=rotate_point (centre_angle, point1), - side1_point2=rotate_point (centre_angle, point2), - side2_point1=mirror_point (rotate_point (centre_angle, point1)), - side2_point2=mirror_point (rotate_point (centre_angle, point2))) { - polygon ( points=[[0,0],side1_point1,side1_point2,side2_point2,side2_point1], paths=[[0,1,2,3,4,0]]); - } - } - } - } +include; + +module rack(cp, N, width, thickness) +{ + // cp = circular pitch - for rack = pitch in mm/per tooth + // N = number of teeth + // width = width of rack + // thickness = thickness of support under teeth (0 for no support) + + a = 1.0 * cp / const_pi; // addendum (also known as "module") + d = 1.1 * cp / const_pi; // dedendum (this is set by a standard) + height = (d + a); + + // find the tangent of pressure angle once + tanPA = tan(20); + // length of bottom and top horizontal segments of tooth profile + botL = (cp / 2 - 2 * d * tanPA); + topL = (cp / 2 - 2 * a * tanPA); + + slantLng = tanPA * height; + realBase = 2 * slantLng + topL; + + offset = topL + botL + 2 * slantLng; + length = (realBase + botL) * N; + + supportSize = width; + translate([ botL / 2, 0, 0 ]) rotate([ 90, 0, 0 ]) + { + translate([ 0, supportSize / 2, 0 ]) + { + union() + { + cube(size = [ length, width, thickness ], center = true); + for (i = [0:N - 1]) { + translate([ + i * offset - length / 2 + realBase / 2, + 0, + thickness / 2 + ]) + { + trapezoid([ topL, supportSize ], + [ realBase, supportSize ], + height); + } + } + } + } + } +} + +module pinion(cp, N, width, shaft_diameter, backlash = 0) +{ + // cp= circular pitch - for pinion pitch in mm/per as measured along the + // ptich radius (~1/2 way up tooth) N= number of teeth width= width of the + // gear shaft_diameter= diameter of hole for shaft backlash - I think this + // is just a bodge for making things fit when printed but I never tested it + + if (cp == false && diametral_pitch == false) + echo("MCAD ERROR: pinion module needs either a diametral_pitch or cp"); + + // Convert diametrial pitch to our native circular pitch + cp = (cp != false ? cp : 180 / diametral_pitch); + + // Pitch diameter: Diameter of pitch circle. + pitch_diameter = N * cp / const_pi; + pitch_radius = pitch_diameter / 2; + echo("Teeth:", N, " Pitch radius:", pitch_radius); + // Base Circle + base_radius = pitch_radius * cos(20); + + // Addendum: Radial distance from pitch circle to outside circle. + addendum = cp / const_pi; + + // Outer Circle + outer_radius = pitch_radius + addendum; + + // Dedendum: Radial distance from pitch circle to root diameter + dedendum = addendum * 1.1; + + // Root diameter: Diameter of bottom of tooth spaces. + root_radius = pitch_radius - dedendum; + + backlash_angle = backlash / pitch_radius * 180 / const_pi; + half_thick_angle = (360 / N - backlash_angle) / 4; + + difference() + { + linear_extrude(height = width, convexity = 10, twist = 0) + pinion_shape(N, + pitch_radius = pitch_radius, + root_radius = root_radius, + base_radius = base_radius, + outer_radius = outer_radius, + half_thick_angle = half_thick_angle, + involute_facets = 0); + + translate([ 0, 0, -1 ]) cylinder(r = shaft_diameter / 2, h = 2 + width); + } + + echo("Root radius =", + root_radius, + "\nPitch radius=", + pitch_radius, + "\n Tip radius=", + outer_radius, + "\n"); +} + +module pinion_shape(N, + pitch_radius, + root_radius, + base_radius, + outer_radius, + half_thick_angle, + involute_facets) +{ + union() + { + rotate(half_thick_angle) circle($fn = N * 2, r = root_radius); + for (i = [1:N]) { + rotate([ 0, 0, i * 360 / N ]) + { + involute_pinion_tooth(pitch_radius = pitch_radius, + root_radius = root_radius, + base_radius = base_radius, + outer_radius = outer_radius, + half_thick_angle = half_thick_angle, + involute_facets = involute_facets); + } + } + } +} + +module involute_pinion_tooth(pitch_radius, + root_radius, + base_radius, + outer_radius, + half_thick_angle, + involute_facets) +{ + min_radius = max(base_radius, root_radius); + + pitch_point = involute(base_radius, + involute_intersect_angle(base_radius, pitch_radius)); + pitch_angle = atan2(pitch_point[1], pitch_point[0]); + centre_angle = pitch_angle + half_thick_angle; + + start_angle = involute_intersect_angle(base_radius, min_radius); + stop_angle = involute_intersect_angle(base_radius, outer_radius); + + res = (involute_facets != 0) ? involute_facets : ($fn == 0) ? 5 : $fn / 4; + + union() + { + for (i = [1:res]) + assign(point1 = involute(base_radius, + start_angle + (stop_angle - start_angle) * + (i - 1) / res), + point2 = involute(base_radius, + start_angle + + (stop_angle - start_angle) * i / res)) + { + assign(side1_point1 = rotate_point(centre_angle, point1), + side1_point2 = rotate_point(centre_angle, point2), + side2_point1 = + mirror_point(rotate_point(centre_angle, point1)), + side2_point2 = + mirror_point(rotate_point(centre_angle, point2))) + { + polygon(points = + [ + [ 0, 0 ], + side1_point1, + side1_point2, + side2_point2, + side2_point1 + ], + paths = [[ 0, 1, 2, 3, 4, 0 ]]); + } + } + } +} // Mathematical Functions //=============== -// Finds the angle of the involute about the base radius at the given distance (radius) from it's center. -//source: http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html +// Finds the angle of the involute about the base radius at the given distance +// (radius) from it's center. +// source: +// http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html -function involute_intersect_angle (base_radius, radius) = sqrt (pow (radius/base_radius, 2) - 1) * 180 / const_pi; +function involute_intersect_angle(base_radius, radius) = + sqrt(pow(radius / base_radius, 2) - 1) * 180 / const_pi; // Calculate the involute position for a given base radius and involute angle. -function rotated_involute(rotate,base_radius,involute_angle)=[cos(rotate)*involute(base_radius, involute_angle)[0]+sin(rotate)*involute(base_radius, involute_angle)[1],cos(rotate)*involute(base_radius, involute_angle)[1]-sin(rotate)*involute(base_radius, involute_angle)[0]]; - -function mirror_point(coord)=[coord[0],-coord[1]]; - -function rotate_point(rotate,coord)=[cos(rotate)*coord[0]+sin(rotate)*coord[1],cos(rotate)*coord[1]-sin(rotate)*coord[0]]; - -function involute (base_radius, involute_angle)=[base_radius*(cos(involute_angle)+involute_angle*const_pi/180*sin(involute_angle)),base_radius*(sin(involute_angle)-involute_angle*const_pi/180*cos(involute_angle))]; - - - - -module trapezoid(top,base,height){ - //echo ("test",base[0]); - basePT1=[ -base[0]/2, base[1]/2, 0]; - basePT2=[ base[0]/2, base[1]/2, 0]; - basePT3=[ base[0]/2, -base[1]/2, 0]; - basePT4=[ -base[0]/2, -base[1]/2, 0]; - topPT1=[ -top[0]/2, top[1]/2, height]; - topPT2=[ top[0]/2, top[1]/2, height]; - topPT3=[ top[0]/2, -top[1]/2, height]; - topPT4=[ -top[0]/2, -top[1]/2, height]; - polyhedron(points=[ basePT1, basePT2, basePT3, basePT4, topPT1, topPT2, topPT3, topPT4],faces=[[0,1,2], [0,2,3],[3,7,0], [7,4,0],[1,6,2], [1,5,6],[2,6,3], [3,6,7],[5,1,0],[4,5,0],[7,5,4],[5,7,6]]); - } - - - +function rotated_involute(rotate, base_radius, involute_angle) = [ + cos(rotate) * involute(base_radius, involute_angle)[0] + + sin(rotate) * involute(base_radius, involute_angle)[1], + cos(rotate) * involute(base_radius, involute_angle)[1] - + sin(rotate) * involute(base_radius, involute_angle)[0] +]; + +function mirror_point(coord) = [ coord[0], -coord[1] ]; + +function rotate_point(rotate, coord) = [ + cos(rotate) * coord[0] + sin(rotate) * coord[1], + cos(rotate) * coord[1] - sin(rotate) * coord[0] +]; + +function involute(base_radius, involute_angle) = [ + base_radius * (cos(involute_angle) + + involute_angle * const_pi / 180 * sin(involute_angle)), + base_radius*(sin(involute_angle) - + involute_angle * const_pi / 180 * cos(involute_angle)) +]; + +module trapezoid(top, base, height) +{ + // echo ("test",base[0]); + basePT1 = [ -base[0] / 2, base[1] / 2, 0 ]; + basePT2 = [ base[0] / 2, base[1] / 2, 0 ]; + basePT3 = [ base[0] / 2, -base[1] / 2, 0 ]; + basePT4 = [ -base[0] / 2, -base[1] / 2, 0 ]; + topPT1 = [ -top[0] / 2, top[1] / 2, height ]; + topPT2 = [ top[0] / 2, top[1] / 2, height ]; + topPT3 = [ top[0] / 2, -top[1] / 2, height ]; + topPT4 = [ -top[0] / 2, -top[1] / 2, height ]; + polyhedron(points = + [ + basePT1, + basePT2, + basePT3, + basePT4, + topPT1, + topPT2, + topPT3, + topPT4 + ], + faces = [ + [ 0, 1, 2 ], + [ 0, 2, 3 ], + [ 3, 7, 0 ], + [ 7, 4, 0 ], + [ 1, 6, 2 ], + [ 1, 5, 6 ], + [ 2, 6, 3 ], + [ 3, 6, 7 ], + [ 5, 1, 0 ], + [ 4, 5, 0 ], + [ 7, 5, 4 ], + [ 5, 7, 6 ] + ]); +} diff --git a/general/constants.scad b/general/constants.scad index cb053d2a..a243009d 100644 --- a/general/constants.scad +++ b/general/constants.scad @@ -1,3 +1,4 @@ + // MIT license // Author: Elmo Mäntynen @@ -5,7 +6,7 @@ const_e = 2.71828182845904523536028747135266249775724709369995; // http://oeis.org/A000796 const_pi = 3.14159265358979323846264338327950288419716939937510; -// +// const_pi_div_180 = 0.01745329251994329576923690768489; // const_180_div_pi = 57.295779513082320876798154814105; diff --git a/general/facets.scad b/general/facets.scad index 66d2d260..7125210f 100644 --- a/general/facets.scad +++ b/general/facets.scad @@ -1,14 +1,15 @@ + /** * Calculate the number of facets to generate for radius `r`. This is intended * to mimic OpenSCAD's internal get_fragments_from_r() function. * * @param r Radius of circle */ -function get_fragments_from_r (r) = ( - ($fn > 0) ? $fn : - (r < 0.00000095367431640625) ? 3 : - ceil (max (min (360 / $fa, r * 2 * PI / $fs), 5)) -); +function get_fragments_from_r(r) = + (($fn > 0) ? $fn + : (r < 0.00000095367431640625) + ? 3 + : ceil(max(min(360 / $fa, r * 2 * PI / $fs), 5))); /** * This is a function that generates a series of values ala $t for use as facet @@ -16,19 +17,10 @@ function get_fragments_from_r (r) = ( * * @param r Radius of circle */ -function gen_facet_series (r) = [0 : 1.0 / get_fragments_from_r (r) : 1.0001]; +function gen_facet_series(r) = [0:1.0 / get_fragments_from_r(r):1.0001]; // example -translate ([0, 0, 10]) -linear_extrude (1) -circle (10, $fn = 10); +translate([ 0, 0, 10 ]) linear_extrude(1) circle(10, $fn = 10); -linear_extrude (1) -polygon ( - [ - let (r = 10) - for (t = gen_facet_series (r, $fn = 10)) - let (angle = t * 360) - [cos (angle) * r, sin (angle) * r] - ] -); +linear_extrude(1) polygon([let(r = 10) for (t = gen_facet_series(r, $fn = 10)) + let(angle = t * 360)[cos(angle) * r, sin(angle) * r]]); diff --git a/general/math.scad b/general/math.scad index 4dea9b0b..230a9457 100644 --- a/general/math.scad +++ b/general/math.scad @@ -1,13 +1,13 @@ -// MIT license - include +// MIT license -function deg(angle) = 360*angle/const_tau; +function deg(angle) = 360 * angle / const_tau; // transformations.scad // License: GNU LGPL 2.1 or later. // © 2010 by Elmo Mäntynen -module local_scale(v, reference=[0, 0, 0]) { +module local_scale(v, reference = [ 0, 0, 0 ]) +{ translate(-reference) scale(v) translate(reference) children(0); } diff --git a/general/sweep.scad b/general/sweep.scad index e7e3647e..6752ff76 100644 --- a/general/sweep.scad +++ b/general/sweep.scad @@ -1,51 +1,70 @@ -use -use -use -function rotation_from_axis(x,y,z) = [[x[0],y[0],z[0]],[x[1],y[1],z[1]],[x[2],y[2],z[2]]]; +use use + use -function rotate_from_to(a,b,_axis=[]) = - len(_axis) == 0 - ? rotate_from_to(a,b,unit(cross(a,b))) - : _axis*_axis >= 0.99 ? rotation_from_axis(unit(b),_axis,cross(_axis,unit(b))) * - transpose_3(rotation_from_axis(unit(a),_axis,cross(_axis,unit(a)))) : identity3(); + function rotation_from_axis(x, y, z) = [[x [0], y [0], z [0]], + [x [1], y [1], z [1]], + [x [2], y [2], z [2]]]; -function make_orthogonal(u,v) = unit(u - unit(v) * (unit(v) * u)); +function rotate_from_to(a, b, _axis = []) = + len(_axis) == 0 + ? rotate_from_to(a, b, unit(cross(a, b))) + : _axis * _axis >= 0.99 + ? rotation_from_axis(unit(b), _axis, cross(_axis, unit(b))) * + transpose_3(rotation_from_axis(unit(a), + _axis, + cross(_axis, unit(a)))) + : identity3(); -// Prevent creeping nonorthogonality -function coerce(m) = [unit(m[0]), make_orthogonal(m[1],m[0]), make_orthogonal(make_orthogonal(m[2],m[0]),m[1])]; +function make_orthogonal(u, v) = unit(u - unit(v) * (unit(v) * u)); -function tangent_path(path, i) = -i == 0 ? - unit(path[1] - path[0]) : - (i == len(path)-1 ? - unit(path[i] - path[i-1]) : - unit(path[i+1]-path[i-1])); +// Prevent creeping nonorthogonality +function coerce(m) = [ + unit(m[0]), + make_orthogonal(m[1], m[0]), + make_orthogonal(make_orthogonal(m[2], m[0]), m[1]) +]; -function construct_rt(r,t) = [concat(r[0],t[0]),concat(r[1],t[1]),concat(r[2],t[2]),[0,0,0,1]]; +function tangent_path(path, i) = i == 0 + ? unit(path[1] - path[0]) + : (i == len(path) - 1 + ? unit(path[i] - path[i - 1]) + : unit(path[i + 1] - path[i - 1])); -function construct_transform_path(path) = - [let (l=len(path)) - for (i=[0:l-1]) - construct_rt(rotate_from_to([0,0,1], tangent_path(path, i)), path[i])]; +function construct_rt(r, t) = [ + concat(r[0], t[0]), + concat(r[1], t[1]), + concat(r[2], t[2]), + [ 0, 0, 0, 1 ] +]; -module sweep(shape, path_transforms, closed=false) { +function construct_transform_path(path) = [let(l = len(path)) for (i = [0:l - + 1]) + construct_rt(rotate_from_to([ 0, 0, 1 ], tangent_path(path, i)), + path[i])]; + +module sweep(shape, path_transforms, closed = false) +{ pathlen = len(path_transforms); segments = pathlen + (closed ? 0 : -1); shape3d = to_3d(shape); - function sweep_points() = - flatten([for (i=[0:pathlen-1]) transform(path_transforms[i], shape3d)]); + function sweep_points() = flatten( + [for (i = [0:pathlen - 1]) transform(path_transforms[i], shape3d)]); - function loop_faces() = [let (facets=len(shape3d)) - for(s=[0:segments-1], i=[0:facets-1]) - [(s%pathlen) * facets + i, - (s%pathlen) * facets + (i + 1) % facets, - ((s + 1) % pathlen) * facets + (i + 1) % facets, - ((s + 1) % pathlen) * facets + i]]; + function loop_faces() = [let( + facets = len(shape3d)) for (s = [0:segments - 1], i = [0:facets - 1]) + [(s % pathlen) * facets + i, + (s % pathlen) * facets + (i + 1) % facets, + ((s + 1) % pathlen) * facets + (i + 1) % facets, + ((s + 1) % pathlen) * facets + i]]; - bottom_cap = closed ? [] : [[for (i=[len(shape3d)-1:-1:0]) i]]; - top_cap = closed ? [] : [[for (i=[0:len(shape3d)-1]) i+len(shape3d)*(pathlen-1)]]; - polyhedron(points = sweep_points(), faces = concat(loop_faces(), bottom_cap, top_cap), convexity=5); + bottom_cap = closed ? [] : [[for (i = [len(shape3d) - 1:-1:0]) i]]; + top_cap = closed ? [] + : [[for (i = [0:len(shape3d) - 1]) i + + len(shape3d) * (pathlen - 1)]]; + polyhedron(points = sweep_points(), + faces = concat(loop_faces(), bottom_cap, top_cap), + convexity = 5); } diff --git a/general/utilities.scad b/general/utilities.scad index 897151c7..9e7a6927 100644 --- a/general/utilities.scad +++ b/general/utilities.scad @@ -1,81 +1,76 @@ +include /* * Utility functions. * * Originally by Hans Häggström, 2010. - * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later + * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or + * later */ -include - - /******************** Disance Poins ******************************/ -function distance3D(a,b) =sqrt( (a[0] - b[0])*(a[0] - b[0]) + - (a[1] - b[1])*(a[1] - b[1]) + - (a[2] - b[2])*(a[2] - b[2]) ); -//Obsolet -function distance(a, b) = distance3D(a,b); +function distance3D(a, b) = sqrt((a[0] - b[0]) * (a[0] - b[0]) + + (a[1] - b[1]) * (a[1] - b[1]) + + (a[2] - b[2]) * (a[2] - b[2])); +// Obsolet +function distance(a, b) = distance3D(a, b); -function distance2D(a,b) = sqrt( (a[0] - b[0])*(a[0] - b[0]) + - (a[1] - b[1])*(a[1] - b[1])); - -function distance1D(a,b) = sqrt(a*a+b*b); -//Obsolet -function length2(a) = distance1D(a[0],a[1]); +function distance2D(a, b) = sqrt((a[0] - b[0]) * (a[0] - b[0]) + + (a[1] - b[1]) * (a[1] - b[1])); +function distance1D(a, b) = sqrt(a * a + b * b); +// Obsolet +function length2(a) = distance1D(a[0], a[1]); /************************ vector *************************/ -function normalized(a) = a / (max(distance3D([0,0,0], a), 0.00001)); +function normalized(a) = a / (max(distance3D([ 0, 0, 0 ], a), 0.00001)); -function normalized_axis(a) = a == "x" ? [1, 0, 0]: - a == "y" ? [0, 1, 0]: - a == "z" ? [0, 0, 1]: normalized(a); +function normalized_axis(a) = a == "x" ? [ 1, 0, 0 ] + : a == "y" ? [ 0, 1, 0 ] + : a == "z" ? [ 0, 0, 1 ] + : normalized(a); -function angleOfNormalizedVector(n) = [0, -atan2(n[2], distance1D([n[0], n[1]])), atan2(n[1], n[0]) ]; +function angleOfNormalizedVector(n) = + [ 0, -atan2(n[2], distance1D([ n[0], n[1] ])), atan2(n[1], n[0]) ]; function angle(v) = angleOfNormalizedVector(normalized(v)); -function angleBetweenTwoPoints(a, b) = angle(normalized(b-a)); +function angleBetweenTwoPoints(a, b) = angle(normalized(b - a)); -function _angleVectore2D(a) = atan2(a[0],a[1]); -function angle_betweentTwoPoints2D (a,b) = _angleVectore2D(b-a); +function _angleVectore2D(a) = atan2(a[0], a[1]); +function angle_betweentTwoPoints2D(a, b) = _angleVectore2D(b - a); -function mirror_2dvector (coord) = -[ - coord[0], - -coord[1] -]; +function mirror_2dvector(coord) = [ coord[0], -coord[1] ]; -function rotate_2dvector (rotate, coord) = -[ - cos (rotate) * coord[0] + sin (rotate) * coord[1], - cos (rotate) * coord[1] - sin (rotate) * coord[0] +function rotate_2dvector(rotate, coord) = [ + cos(rotate) * coord[0] + sin(rotate) * coord[1], + cos(rotate) * coord[1] - sin(rotate) * coord[0] ]; - - - /********************** Circel ***************************/ function circel_area(r) = const_pi * r * r; -function circel_radius3Points(a,b,c) = (distance2D(a,b) * distance2D(b,c) * distance2D(c,a)) / (4 * triangle_area3Points(a,b,c)); - -function circel_radius3lengths(a,b,c) = (a*b*c) / (4 * triangle_area3lengths(a,b,c)); +function circel_radius3Points(a, b, c) = (distance2D(a, b) * distance2D(b, c) * + distance2D(c, a)) / + (4 * triangle_area3Points(a, b, c)); +function circel_radius3lengths(a, b, c) = (a * b * c) / + (4 * triangle_area3lengths(a, b, c)); /********************** triangle **************************/ -//Satz des Heron -function triangle_area3lengths(a,b,c) = sqrt((a+b+c)*(a+b-c)*(b+c-a)*(c+a-b))/4; - -function triangle_area3Points(a,b,c) = triangle_area3lengths(distance2D(a,b),distance2D(b,c),distance2D(c,a)); - +// Satz des Heron +function triangle_area3lengths(a, b, c) = sqrt((a + b + c) * (a + b - c) * + (b + c - a) * (c + a - b)) / + 4; +function triangle_area3Points(a, b, c) = + triangle_area3lengths(distance2D(a, b), distance2D(b, c), distance2D(c, a)); /************************** coordinate systems translation ****/ //[radius,phi] <=> [x,y] -function conv2D_cartesian2polar(x) = [ distance1D(x[0],x[1]) , atan2(x[1],x[0]) ]; -function conv2D_polar2cartesian(x) = [ x[0]*cos(x[1]) , x[0]*sin(x[1]) ]; - +function conv2D_cartesian2polar(x) = + [ distance1D(x[0], x[1]), atan2(x[1], x[0]) ]; +function conv2D_polar2cartesian(x) = [ x[0] * cos(x[1]), x[0] * sin(x[1]) ]; CENTER = 0; LEFT = -0.5; @@ -83,49 +78,73 @@ RIGHT = 0.5; TOP = 0.5; BOTTOM = -0.5; -FlatCap =0; -ExtendedCap =0.5; -CutCap =-0.5; - - -module fromTo(from=[0,0,0], to=[1,0,0], size=[1, 1], align=[CENTER, CENTER], material=[0.5, 0.5, 0.5], name="", endExtras=[0,0], endCaps=[FlatCap, FlatCap], rotation=[0,0,0], printString=true) { - - angle = angleBetweenTwoPoints(from, to); - length = distance(from, to) + endCaps[0]*size[0] + endCaps[1]*size[0] + endExtras[0] + endExtras[1]; - - if (length > 0) { - if (printString) echo(str( " " ,name, " ", size[0], "mm x ", size[1], "mm, length ", length, "mm")); +FlatCap = 0; +ExtendedCap = 0.5; +CutCap = -0.5; + +module fromTo(from = [ 0, 0, 0 ], + to = [ 1, 0, 0 ], + size = [ 1, 1 ], + align = [ CENTER, CENTER ], + material = [ 0.5, 0.5, 0.5 ], + name = "", + endExtras = [ 0, 0 ], + endCaps = [ FlatCap, FlatCap ], + rotation = [ 0, 0, 0 ], + printString = true) +{ - color(material) - translate(from) - rotate(angle) - translate( [ -endCaps[0]*size[0] - endExtras[0], size[0]*(-0.5-align[0]), size[1]*(-0.5+align[1]) ] ) - rotate(rotation) - scale([length, size[0], size[1]]) child(); - } + angle = angleBetweenTwoPoints(from, to); + length = distance(from, to) + endCaps[0] * size[0] + endCaps[1] * size[0] + + endExtras[0] + endExtras[1]; + + if (length > 0) { + if (printString) + echo(str(" ", + name, + " ", + size[0], + "mm x ", + size[1], + "mm, length ", + length, + "mm")); + + color(material) translate(from) rotate(angle) translate([ + -endCaps[0] * size[0] - endExtras[0], + size[0] * (-0.5 - align[0]), + size[1] * (-0.5 + align[1]) + ]) rotate(rotation) scale([ length, size[0], size[1] ]) child(); + } } -module part(name) { - echo(""); - echo(str(name, ":")); +module part(name) +{ + echo(""); + echo(str(name, ":")); } -module mirror_duplicate (plane = [0, 0, 1]) -union () { - child (); +module mirror_duplicate(plane = [ 0, 0, 1 ]) union() +{ + child(); - mirror (plane) - child (); + mirror(plane) child(); } -module linear_extrude_if (condition, height, center = undef, convexity = undef, - twist = undef, slices = undef) +module linear_extrude_if(condition, + height, + center = undef, + convexity = undef, + twist = undef, + slices = undef) { - if (condition) - linear_extrude (height = height, center = center, convexity = convexity, - twist = twist, slices = slices) - children (); - - else - children (); + if (condition) + linear_extrude(height = height, + center = center, + convexity = convexity, + twist = twist, + slices = slices) children(); + + else + children(); } diff --git a/gridbeam.scad b/gridbeam.scad index 66366fb4..75800506 100644 --- a/gridbeam.scad +++ b/gridbeam.scad @@ -1,13 +1,15 @@ +include /********************************* -* OpenSCAD GridBeam Library * -* (c) Timothy Schmidt 2013 * -* http://www.github.com/gridbeam * -* License: LGPL 2.1 or later * -*********************************/ + * OpenSCAD GridBeam Library * + * (c) Timothy Schmidt 2013 * + * http://www.github.com/gridbeam * + * License: LGPL 2.1 or later * + *********************************/ /* Todo: - implement "dxf" mode - - implement hole cutout pattern - interference based on hole size, compatible with two sizes above and below the currently set size. + - implement hole cutout pattern - interference based on hole size, compatible + with two sizes above and below the currently set size. */ // zBeam(segments) - create a vertical gridbeam strut 'segments' long @@ -16,174 +18,218 @@ // zBolt(segments) - create a bolt 'segments' in length // xBolt(segments) // yBolt(segments) -// topShelf(width, depth, corners) - create a shelf suitable for use in gridbeam structures width and depth in 'segments', corners == 1 notches corners -// bottomShelf(width, depth, corners) - like topShelf, but aligns shelf to underside of beams -// backBoard(width, height, corners) - create a backing board suitable for use in gridbeam structures width and height in 'segments', corners == 1 notches corners -// frontBoard(width, height, corners) - like backBoard, but aligns board to front side of beams -// translateBeam([x, y, z]) - translate gridbeam struts or shelves in X, Y, or Z axes in units 'segments' +// topShelf(width, depth, corners) - create a shelf suitable for use in gridbeam +// structures width and depth in 'segments', corners == 1 notches corners +// bottomShelf(width, depth, corners) - like topShelf, but aligns shelf to +// underside of beams backBoard(width, height, corners) - create a backing board +// suitable for use in gridbeam structures width and height in 'segments', +// corners == 1 notches corners frontBoard(width, height, corners) - like +// backBoard, but aligns board to front side of beams translateBeam([x, y, z]) - +// translate gridbeam struts or shelves in X, Y, or Z axes in units 'segments' // To render the DXF file from the command line: // openscad -x connector.dxf -D'mode="dxf"' connector.scad mode = "model"; -//mode = "dxf"; - -include +// mode = "dxf"; beam_width = length_inch * 1.5; -beam_hole_diameter = length_inch * 5/16; +beam_hole_diameter = length_inch * 5 / 16; beam_hole_radius = beam_hole_diameter / 2; beam_is_hollow = 1; -beam_wall_thickness = length_inch * 1/8; -beam_shelf_thickness = length_inch * 1/4; - -module zBeam(segments) { -if (mode == "model") { - difference() { - cube([beam_width, beam_width, beam_width * segments]); - for(i = [0 : segments - 1]) { - translate([beam_width / 2, beam_width + 1, beam_width * i + beam_width / 2]) - rotate([90,0,0]) - cylinder(r=beam_hole_radius, h=beam_width + 2); - - translate([-1, beam_width / 2, beam_width * i + beam_width / 2]) - rotate([0,90,0]) - cylinder(r=beam_hole_radius, h=beam_width + 2); - } - if (beam_is_hollow == 1) { - translate([beam_wall_thickness, beam_wall_thickness, -1]) - cube([beam_width - beam_wall_thickness * 2, beam_width - beam_wall_thickness * 2, beam_width * segments + 2]); - } -} -} - -if (mode == "dxf") { - -} -} - -module xBeam(segments) { -if (mode == "model") { - translate([0,0,beam_width]) - rotate([0,90,0]) - zBeam(segments); -} - -if (mode == "dxf") { - -} -} - -module yBeam(segments) { -if (mode == "model") { - translate([0,0,beam_width]) - rotate([-90,0,0]) - zBeam(segments); -} - -if (mode == "dxf") { - -} -} - -module zBolt(segments) { -if (mode == "model") { - -} - -if (mode == "dxf") { - -} -} - -module xBolt(segments) { -if (mode == "model") { -} - -if (mode == "dxf") { - -} -} - -module yBolt(segments) { -if (mode == "model") { -} - -if (mode == "dxf") { - -} -} - -module translateBeam(v) { - for (i = [0 : $children - 1]) { - translate(v * beam_width) child(i); - } -} - -module topShelf(width, depth, corners) { -if (mode == "model") { - difference() { - cube([width * beam_width, depth * beam_width, beam_shelf_thickness]); - - if (corners == 1) { - translate([-1, -1, -1]) - cube([beam_width + 2, beam_width + 2, beam_shelf_thickness + 2]); - translate([-1, (depth - 1) * beam_width, -1]) - cube([beam_width + 2, beam_width + 2, beam_shelf_thickness + 2]); - translate([(width - 1) * beam_width, -1, -1]) - cube([beam_width + 2, beam_width + 2, beam_shelf_thickness + 2]); - translate([(width - 1) * beam_width, (depth - 1) * beam_width, -1]) - cube([beam_width + 2, beam_width + 2, beam_shelf_thickness + 2]); - } - } -} - -if (mode == "dxf") { - -} -} - -module bottomShelf(width, depth, corners) { -if (mode == "model") { - translate([0,0,-beam_shelf_thickness]) - topShelf(width, depth, corners); -} - -if (mode == "dxf") { - -} -} - -module backBoard(width, height, corners) { -if (mode == "model") { - translate([beam_width, 0, 0]) - difference() { - cube([beam_shelf_thickness, width * beam_width, height * beam_width]); - - if (corners == 1) { - translate([-1, -1, -1]) - cube([beam_shelf_thickness + 2, beam_width + 2, beam_width + 2]); - translate([-1, -1, (height - 1) * beam_width]) - cube([beam_shelf_thickness + 2, beam_width + 2, beam_width + 2]); - translate([-1, (width - 1) * beam_width, -1]) - cube([beam_shelf_thickness + 2, beam_width + 2, beam_width + 2]); - translate([-1, (width - 1) * beam_width, (height - 1) * beam_width]) - cube([beam_shelf_thickness + 2, beam_width + 2, beam_width + 2]); - } - } -} - -if (mode == "dxf") { - -} -} - -module frontBoard(width, height, corners) { -if (mode == "model") { - translate([-beam_width - beam_shelf_thickness, 0, 0]) - backBoard(width, height, corners); -} - -if (mode == "dxf") { - -} +beam_wall_thickness = length_inch * 1 / 8; +beam_shelf_thickness = length_inch * 1 / 4; + +module zBeam(segments) +{ + if (mode == "model") { + difference() + { + cube([ beam_width, beam_width, beam_width * segments ]); + for (i = [0:segments - 1]) { + translate([ + beam_width / 2, + beam_width + 1, + beam_width * i + beam_width / 2 + ]) rotate([ 90, 0, 0 ]) + cylinder(r = beam_hole_radius, h = beam_width + 2); + + translate( + [ -1, beam_width / 2, beam_width * i + beam_width / 2 ]) + rotate([ 0, 90, 0 ]) + cylinder(r = beam_hole_radius, h = beam_width + 2); + } + if (beam_is_hollow == 1) { + translate([ beam_wall_thickness, beam_wall_thickness, -1 ]) + cube([ + beam_width - beam_wall_thickness * 2, + beam_width - beam_wall_thickness * 2, + beam_width * segments + 2 + ]); + } + } + } + + if (mode == "dxf") { + } +} + +module xBeam(segments) +{ + if (mode == "model") { + translate([ 0, 0, beam_width ]) rotate([ 0, 90, 0 ]) zBeam(segments); + } + + if (mode == "dxf") { + } +} + +module yBeam(segments) +{ + if (mode == "model") { + translate([ 0, 0, beam_width ]) rotate([ -90, 0, 0 ]) zBeam(segments); + } + + if (mode == "dxf") { + } +} + +module zBolt(segments) +{ + if (mode == "model") { + } + + if (mode == "dxf") { + } +} + +module xBolt(segments) +{ + if (mode == "model") { + } + + if (mode == "dxf") { + } +} + +module yBolt(segments) +{ + if (mode == "model") { + } + + if (mode == "dxf") { + } +} + +module translateBeam(v) +{ + for (i = [0:$children - 1]) { + translate(v * beam_width) child(i); + } +} + +module topShelf(width, depth, corners) +{ + if (mode == "model") { + difference() + { + cube([ + width * beam_width, + depth * beam_width, + beam_shelf_thickness + ]); + + if (corners == 1) { + translate([ -1, -1, -1 ]) cube([ + beam_width + 2, + beam_width + 2, + beam_shelf_thickness + 2 + ]); + translate([ -1, (depth - 1) * beam_width, -1 ]) cube([ + beam_width + 2, + beam_width + 2, + beam_shelf_thickness + 2 + ]); + translate([ (width - 1) * beam_width, -1, -1 ]) cube([ + beam_width + 2, + beam_width + 2, + beam_shelf_thickness + 2 + ]); + translate( + [ (width - 1) * beam_width, (depth - 1) * beam_width, -1 ]) + cube([ + beam_width + 2, + beam_width + 2, + beam_shelf_thickness + 2 + ]); + } + } + } + + if (mode == "dxf") { + } +} + +module bottomShelf(width, depth, corners) +{ + if (mode == "model") { + translate([ 0, 0, -beam_shelf_thickness ]) + topShelf(width, depth, corners); + } + + if (mode == "dxf") { + } +} + +module backBoard(width, height, corners) +{ + if (mode == "model") { + translate([ beam_width, 0, 0 ]) difference() + { + cube([ + beam_shelf_thickness, + width * beam_width, + height * + beam_width + ]); + + if (corners == 1) { + translate([ -1, -1, -1 ]) cube([ + beam_shelf_thickness + 2, + beam_width + 2, + beam_width + 2 + ]); + translate([ -1, -1, (height - 1) * beam_width ]) cube([ + beam_shelf_thickness + 2, + beam_width + 2, + beam_width + 2 + ]); + translate([ -1, (width - 1) * beam_width, -1 ]) cube([ + beam_shelf_thickness + 2, + beam_width + 2, + beam_width + 2 + ]); + translate( + [ -1, (width - 1) * beam_width, (height - 1) * beam_width ]) + cube([ + beam_shelf_thickness + 2, + beam_width + 2, + beam_width + 2 + ]); + } + } + } + + if (mode == "dxf") { + } +} + +module frontBoard(width, height, corners) +{ + if (mode == "model") { + translate([ -beam_width - beam_shelf_thickness, 0, 0 ]) + backBoard(width, height, corners); + } + + if (mode == "dxf") { + } } diff --git a/hardware/bearing.scad b/hardware/bearing.scad index 2d9019de..5e223c1e 100644 --- a/hardware/bearing.scad +++ b/hardware/bearing.scad @@ -1,18 +1,18 @@ +include +include /* * Bearing model. * * Originally by Hans Häggström, 2010. - * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later + * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or + * later */ /* change list 13/6/2013 - added ,604,606,607,628,629,6200,6201,6202,6203,6205,6206 bearing sizes + added ,604,606,607,628,629,6200,6201,6202,6203,6205,6206 bearing sizes */ -include -include - BEARING_INNER_DIAMETER = 0; BEARING_OUTER_DIAMETER = 1; BEARING_WIDTH = 2; @@ -23,7 +23,8 @@ SkateBearing = 608; // Bearing dimensions // model == XXX ? [inner dia, outer dia, width]: // http://www.gizmology.net/bearings.htm has some valuable information on that -// https://www.bearingworks.com/bearing-sizes has a very exhaustive table of dimensions +// https://www.bearingworks.com/bearing-sizes has a very exhaustive table of +// dimensions function bearingDimensions(model) = model == 603 ? [3*mm, 9*mm, 5*mm]: model == 604 ? [4*mm, 12*mm, 4*mm]: @@ -83,54 +84,68 @@ function bearingDimensions(model) = [8*length_mm, 22*length_mm, 7*length_mm]; // this is the default - function bearingWidth(model) = bearingDimensions(model)[BEARING_WIDTH]; -function bearingInnerDiameter(model) = bearingDimensions(model)[BEARING_INNER_DIAMETER]; -function bearingOuterDiameter(model) = bearingDimensions(model)[BEARING_OUTER_DIAMETER]; - -module bearing(pos=[0,0,0], angle=[0,0,0], model=SkateBearing, outline=false, - material=Steel, sideMaterial=Brass, center=false) { - // Common bearing names - model = - model == "Skate" ? 608 : - model; - - w = bearingWidth(model); - innerD = outline==false ? bearingInnerDiameter(model) : 0; - outerD = bearingOuterDiameter(model); - - innerRim = innerD + (outerD - innerD) * 0.2; - outerRim = outerD - (outerD - innerD) * 0.2; - midSink = w * 0.1; - - centering_pos = (center) ? [0, 0, -w/2] : [0, 0, 0]; - - translate(pos) rotate(angle) translate (centering_pos) union() { - color(material) - difference() { - // Basic ring - Ring([0,0,0], outerD, innerD, w, material, material); - - if (outline==false) { - // Side shields - Ring([0,0,-epsilon], outerRim, innerRim, epsilon+midSink, sideMaterial, material); - Ring([0,0,w-midSink], outerRim, innerRim, epsilon+midSink, sideMaterial, material); - } - } - } - - module Ring(pos, od, id, h, material, holeMaterial) { - color(material) { - translate(pos) - difference() { - cylinder(r=od/2, h=h, $fs = 0.01); - color(holeMaterial) - translate([0,0,-10*epsilon]) - cylinder(r=(id/2)+epsilon, h=h+20*epsilon, $fs = 0.01); +function bearingInnerDiameter(model) = + bearingDimensions(model)[BEARING_INNER_DIAMETER]; +function bearingOuterDiameter(model) = + bearingDimensions(model)[BEARING_OUTER_DIAMETER]; + +module bearing(pos = [ 0, 0, 0 ], + angle = [ 0, 0, 0 ], + model = SkateBearing, + outline = false, + material = Steel, + sideMaterial = Brass, + center = false) +{ + // Common bearing names + model = model == "Skate" ? 608 : model; + + w = bearingWidth(model); + innerD = outline == false ? bearingInnerDiameter(model) : 0; + outerD = bearingOuterDiameter(model); + + innerRim = innerD + (outerD - innerD) * 0.2; + outerRim = outerD - (outerD - innerD) * 0.2; + midSink = w * 0.1; + + centering_pos = (center) ? [ 0, 0, -w / 2 ] : [ 0, 0, 0 ]; + + translate(pos) rotate(angle) translate(centering_pos) union() + { + color(material) difference() + { + // Basic ring + Ring([ 0, 0, 0 ], outerD, innerD, w, material, material); + + if (outline == false) { + // Side shields + Ring([ 0, 0, -epsilon ], + outerRim, + innerRim, + epsilon + midSink, + sideMaterial, + material); + Ring([ 0, 0, w - midSink ], + outerRim, + innerRim, + epsilon + midSink, + sideMaterial, + material); + } } } - } + module Ring(pos, od, id, h, material, holeMaterial) + { + color(material) + { + translate(pos) difference() + { + cylinder(r = od / 2, h = h, $fs = 0.01); + color(holeMaterial) translate([ 0, 0, -10 * epsilon ]) cylinder( + r = (id / 2) + epsilon, h = h + 20 * epsilon, $fs = 0.01); + } + } + } } - - diff --git a/hardware/hardware.scad b/hardware/hardware.scad index aeda29a2..eb2b5f1a 100644 --- a/hardware/hardware.scad +++ b/hardware/hardware.scad @@ -1,14 +1,13 @@ -// License: LGPL 2.1 - -rodsize = 6; //threaded/smooth rod diameter in mm -xaxis = 182.5; //width of base in mm -yaxis = 266.5; //length of base in mm +// License: LGPL 2.1 -screwsize = 3; //bearing bore/screw diameter in mm -bearingsize = 10; //outer diameter of bearings in mm -bearingwidth = 4; //width of bearings in mm +rodsize = 6; // threaded/smooth rod diameter in mm +xaxis = 182.5; // width of base in mm +yaxis = 266.5; // length of base in mm +screwsize = 3; // bearing bore/screw diameter in mm +bearingsize = 10; // outer diameter of bearings in mm +bearingwidth = 4; // width of bearings in mm rodpitch = rodsize / 6; rodnutsize = 0.8 * rodsize; @@ -23,90 +22,130 @@ washerdiameter = 2 * screwsize; partthick = 2 * rodsize; vertexrodspace = 2 * rodsize; - -c = [0.3, 0.3, 0.3]; +c = [ 0.3, 0.3, 0.3 ]; rodendoffset = rodnutsize + rodwashersize * 2 + partthick / 2; vertexoffset = vertexrodspace + rodendoffset; - renderrodthreads = false; renderscrewthreads = false; fn = 36; - - -module rod(length, threaded) if (threaded && renderrodthreads) { - linear_extrude(height = length, center = true, convexity = 10, twist = -360 * length / rodpitch, $fn = fn) - translate([rodsize * 0.1 / 2, 0, 0]) - circle(r = rodsize * 0.9 / 2, $fn = fn); -} else cylinder(h = length, r = rodsize / 2, center = true, $fn = fn); - - -module screw(length, nutpos, washer, bearingpos = -1) union(){ - translate([0, 0, -length / 2]) if (renderscrewthreads) { - linear_extrude(height = length, center = true, convexity = 10, twist = -360 * length / screwpitch, $fn = fn) - translate([screwsize * 0.1 / 2, 0, 0]) - circle(r = screwsize * 0.9 / 2, $fn = fn); - } else cylinder(h = length, r = screwsize / 2, center = true, $fn = fn); - render() difference() { - translate([0, 0, screwsize / 2]) cylinder(h = screwsize, r = screwsize, center = true, $fn = fn); - translate([0, 0, screwsize]) cylinder(h = screwsize, r = screwsize / 2, center = true, $fn = 6); - } - if (washer > 0 && nutpos > 0) { - washer(nutpos); - nut(nutpos + washersize); - } else if (nutpos > 0) nut(nutpos); - if (bearingpos >= 0) bearing(bearingpos); +module rod(length, threaded) if (threaded && renderrodthreads) +{ + linear_extrude(height = length, + center = true, + convexity = 10, + twist = -360 * length / rodpitch, + $fn = fn) translate([ rodsize * 0.1 / 2, 0, 0 ]) + circle(r = rodsize * 0.9 / 2, $fn = fn); } - - -module bearing(position) render() translate([0, 0, -position - bearingwidth / 2]) union() { - difference() { - cylinder(h = bearingwidth, r = bearingsize / 2, center = true, $fn = fn); - cylinder(h = bearingwidth * 2, r = bearingsize / 2 - 1, center = true, $fn = fn); - } - difference() { - cylinder(h = bearingwidth - 0.5, r = bearingsize / 2 - 0.5, center = true, $fn = fn); - cylinder(h = bearingwidth * 2, r = screwsize / 2 + 0.5, center = true, $fn = fn); - } - difference() { - cylinder(h = bearingwidth, r = screwsize / 2 + 1, center = true, $fn = fn); - cylinder(h = bearingwidth + 0.1, r = screwsize / 2, center = true, $fn = fn); - } +else cylinder(h = length, r = rodsize / 2, center = true, $fn = fn); + +module screw(length, nutpos, washer, bearingpos = -1) union() +{ + translate([ 0, 0, -length / 2 ]) if (renderscrewthreads) + { + linear_extrude(height = length, + center = true, + convexity = 10, + twist = -360 * length / screwpitch, + $fn = fn) translate([ screwsize * 0.1 / 2, 0, 0 ]) + circle(r = screwsize * 0.9 / 2, $fn = fn); + } + else cylinder(h = length, r = screwsize / 2, center = true, $fn = fn); + render() difference() + { + translate([ 0, 0, screwsize / 2 ]) + cylinder(h = screwsize, r = screwsize, center = true, $fn = fn); + translate([ 0, 0, screwsize ]) + cylinder(h = screwsize, r = screwsize / 2, center = true, $fn = 6); + } + if (washer > 0 && nutpos > 0) { + washer(nutpos); + nut(nutpos + washersize); + } else if (nutpos > 0) + nut(nutpos); + if (bearingpos >= 0) + bearing(bearingpos); } - -module nut(position, washer) render() translate([0, 0, -position - nutsize / 2]) { - intersection() { - scale([1, 1, 0.5]) sphere(r = 1.05 * screwsize, center = true); - difference() { - cylinder (h = nutsize, r = nutdiameter / 2, center = true, $fn = 6); - cylinder(r = screwsize / 2, h = nutsize + 0.1, center = true, $fn = fn); - } - } - if (washer > 0) washer(0); +module bearing(position) render() + translate([ 0, 0, -position - bearingwidth / 2 ]) union() +{ + difference() + { + cylinder( + h = bearingwidth, r = bearingsize / 2, center = true, $fn = fn); + cylinder(h = bearingwidth * 2, + r = bearingsize / 2 - 1, + center = true, + $fn = fn); + } + difference() + { + cylinder(h = bearingwidth - 0.5, + r = bearingsize / 2 - 0.5, + center = true, + $fn = fn); + cylinder(h = bearingwidth * 2, + r = screwsize / 2 + 0.5, + center = true, + $fn = fn); + } + difference() + { + cylinder( + h = bearingwidth, r = screwsize / 2 + 1, center = true, $fn = fn); + cylinder( + h = bearingwidth + 0.1, r = screwsize / 2, center = true, $fn = fn); + } } - -module washer(position) render() translate ([0, 0, -position - washersize / 2]) difference() { - cylinder(r = washerdiameter / 2, h = washersize, center = true, $fn = fn); - cylinder(r = screwsize / 2, h = washersize + 0.1, center = true, $fn = fn); +module nut(position, washer) render() + translate([ 0, 0, -position - nutsize / 2 ]) +{ + intersection() + { + scale([ 1, 1, 0.5 ]) sphere(r = 1.05 * screwsize, center = true); + difference() + { + cylinder(h = nutsize, r = nutdiameter / 2, center = true, $fn = 6); + cylinder( + r = screwsize / 2, h = nutsize + 0.1, center = true, $fn = fn); + } + } + if (washer > 0) + washer(0); } -module rodnut(position, washer) render() translate([0, 0, position]) { - intersection() { - scale([1, 1, 0.5]) sphere(r = 1.05 * rodsize, center = true); - difference() { - cylinder (h = rodnutsize, r = rodnutdiameter / 2, center = true, $fn = 6); - rod(rodnutsize + 0.1); - } - } - if (washer == 1 || washer == 4) rodwasher(((position > 0) ? -1 : 1) * (rodnutsize + rodwashersize) / 2); - if (washer == 2 || washer == 4) rodwasher(((position > 0) ? 1 : -1) * (rodnutsize + rodwashersize) / 2); +module washer(position) render() translate([ 0, 0, -position - washersize / 2 ]) + difference() +{ + cylinder(r = washerdiameter / 2, h = washersize, center = true, $fn = fn); + cylinder(r = screwsize / 2, h = washersize + 0.1, center = true, $fn = fn); } +module rodnut(position, washer) render() translate([ 0, 0, position ]) +{ + intersection() + { + scale([ 1, 1, 0.5 ]) sphere(r = 1.05 * rodsize, center = true); + difference() + { + cylinder( + h = rodnutsize, r = rodnutdiameter / 2, center = true, $fn = 6); + rod(rodnutsize + 0.1); + } + } + if (washer == 1 || washer == 4) + rodwasher(((position > 0) ? -1 : 1) * (rodnutsize + rodwashersize) / 2); + if (washer == 2 || washer == 4) + rodwasher(((position > 0) ? 1 : -1) * (rodnutsize + rodwashersize) / 2); +} -module rodwasher(position) render() translate ([0, 0, position]) difference() { - cylinder(r = rodwasherdiameter / 2, h = rodwashersize, center = true, $fn = fn); - rod(rodwashersize + 0.1); +module rodwasher(position) render() translate([ 0, 0, position ]) difference() +{ + cylinder( + r = rodwasherdiameter / 2, h = rodwashersize, center = true, $fn = fn); + rod(rodwashersize + 0.1); } diff --git a/hardware/linear_bearing.scad b/hardware/linear_bearing.scad index aa88c915..4eae3d7e 100644 --- a/hardware/linear_bearing.scad +++ b/hardware/linear_bearing.scad @@ -1,16 +1,17 @@ -//By Glen Chung, 2013. -//Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later -include ; -include ; +// By Glen Chung, 2013. +// Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or +// later -LINEAR_BEARING_dr = 0; //Inscribed circle -LINEAR_BEARING_D = 1; //Outer diameter -LINEAR_BEARING_L = 2; //Length -LINEAR_BEARING_B = 3; //Outer locking groove B -LINEAR_BEARING_D1 = 4; //Outer locking groove D1 -LINEAR_BEARING_W = 5; //W +include; +include; +LINEAR_BEARING_dr = 0; // Inscribed circle +LINEAR_BEARING_D = 1; // Outer diameter +LINEAR_BEARING_L = 2; // Length +LINEAR_BEARING_B = 3; // Outer locking groove B +LINEAR_BEARING_D1 = 4; // Outer locking groove D1 +LINEAR_BEARING_W = 5; // W // Common bearing names LinearBearing = "LM8UU"; @@ -38,57 +39,91 @@ model == "LM80UU" ? [ 80*length_mm, 120*length_mm, 140*length_mm, 105.5*lengt model == "LM100UU" ? [100*length_mm, 150*length_mm, 150*length_mm, 125.5*length_mm, 145.0*length_mm, 4.15*length_mm]: /*model == "LM8UU" ?*/ [ 8*length_mm, 15*length_mm, 24*length_mm, 17.5*length_mm, 14.3*length_mm, 1.10*length_mm]; +function linearBearing_dr(model) = + linearBearingDimensions(model)[LINEAR_BEARING_dr]; +function linearBearing_D(model) = + linearBearingDimensions(model)[LINEAR_BEARING_D]; +function linearBearing_L(model) = + linearBearingDimensions(model)[LINEAR_BEARING_L]; +function linearBearing_B(model) = + linearBearingDimensions(model)[LINEAR_BEARING_B]; +function linearBearing_D1(model) = + linearBearingDimensions(model)[LINEAR_BEARING_D1]; +function linearBearing_W(model) = + linearBearingDimensions(model)[LINEAR_BEARING_W]; -function linearBearing_dr(model) = linearBearingDimensions(model)[LINEAR_BEARING_dr]; -function linearBearing_D(model) = linearBearingDimensions(model)[LINEAR_BEARING_D]; -function linearBearing_L(model) = linearBearingDimensions(model)[LINEAR_BEARING_L]; -function linearBearing_B(model) = linearBearingDimensions(model)[LINEAR_BEARING_B]; -function linearBearing_D1(model) = linearBearingDimensions(model)[LINEAR_BEARING_D1]; -function linearBearing_W(model) = linearBearingDimensions(model)[LINEAR_BEARING_W]; +module linearBearing(pos = [ 0, 0, 0 ], + angle = [ 0, 0, 0 ], + model = LinearBearing, + material = Steel, + sideMaterial = BlackPaint) +{ + dr = linearBearing_dr(model); + D = linearBearing_D(model); + L = linearBearing_L(model); + B = linearBearing_B(model); + D1 = linearBearing_D1(model); + W = linearBearing_W(model); -module linearBearing(pos=[0,0,0], angle=[0,0,0], model=LinearBearing, - material=Steel, sideMaterial=BlackPaint) { - dr = linearBearing_dr(model); - D = linearBearing_D(model); - L = linearBearing_L(model); - B = linearBearing_B(model); - D1 = linearBearing_D1(model); - W = linearBearing_W(model); + innerRim = dr + (D - dr) * 0.2; + outerRim = D - (D - dr) * 0.2; + midSink = W / 4; - innerRim = dr + (D - dr) * 0.2; - outerRim = D - (D - dr) * 0.2; - midSink = W/4; + translate(pos) rotate(angle) union() + { + color(material) difference() + { + // Basic ring + Ring([ 0, 0, 0 ], D, dr, L, material, material); - translate(pos) rotate(angle) union() { - color(material) - difference() { - // Basic ring - Ring([0,0,0], D, dr, L, material, material); - - if(W) { - // Side shields - Ring([0,0,-epsilon], outerRim, innerRim, L*epsilon+midSink, sideMaterial, material); - Ring([0,0,L-midSink-epsilon], outerRim, innerRim, L*epsilon+midSink, sideMaterial, material); - //Outer locking groove - Ring([0,0,(L-B)/2], D+epsilon, outerRim+W/2, W, material, material); - Ring([0,0,L-(L-B)/2], D+epsilon, outerRim+W/2, W, material, material); - } - } - if(W) - Ring([0,0,midSink], D-L*epsilon, dr+L*epsilon, L-midSink*2, sideMaterial, sideMaterial); - } - - module Ring(pos, od, id, h, material, holeMaterial) { - color(material) { - translate(pos) - difference() { - cylinder(r=od/2, h=h, $fn = 100); - color(holeMaterial) - translate([0,0,-10*epsilon]) - cylinder(r=id/2, h=h+20*epsilon, $fn = 100); - } - } - } + if (W) { + // Side shields + Ring([ 0, 0, -epsilon ], + outerRim, + innerRim, + L * epsilon + midSink, + sideMaterial, + material); + Ring([ 0, 0, L - midSink - epsilon ], + outerRim, + innerRim, + L * epsilon + midSink, + sideMaterial, + material); + // Outer locking groove + Ring([ 0, 0, (L - B) / 2 ], + D + epsilon, + outerRim + W / 2, + W, + material, + material); + Ring([ 0, 0, L - (L - B) / 2 ], + D + epsilon, + outerRim + W / 2, + W, + material, + material); + } + } + if (W) + Ring([ 0, 0, midSink ], + D - L * epsilon, + dr + L * epsilon, + L - midSink * 2, + sideMaterial, + sideMaterial); + } + module Ring(pos, od, id, h, material, holeMaterial) + { + color(material) + { + translate(pos) difference() + { + cylinder(r = od / 2, h = h, $fn = 100); + color(holeMaterial) translate([ 0, 0, -10 * epsilon ]) + cylinder(r = id / 2, h = h + 20 * epsilon, $fn = 100); + } + } + } } - diff --git a/layout/linear.scad b/layout/linear.scad index 53795705..6c37dfb2 100644 --- a/layout/linear.scad +++ b/layout/linear.scad @@ -1,3 +1,4 @@ + /* * OpenSCAD Layout Library (www.openscad.org) * Copyright (C) 2012 Peter Uithoven @@ -7,16 +8,16 @@ module array_linear(iHeight) { - for (i = [0 : $children-1]) - translate([0,i*iHeight]) children(i); + for (i = [0:$children - 1]) + translate([ 0, i * iHeight ]) children(i); } -module array_linear_grid(iWidth,iHeight,inYDir = true,limit=3) +module array_linear_grid(iWidth, iHeight, inYDir = true, limit = 3) { - for (i = [0 : $children-1]) - { - translate([(inYDir)? (iWidth)*(i%limit) : (iWidth)*floor(i/limit), - (inYDir)? (iHeight)*floor(i/limit) : (iHeight)*(i%limit)]) - children(i); - } + for (i = [0:$children - 1]) { + translate([ + (inYDir) ? (iWidth) * (i % limit) : (iWidth)*floor(i / limit), + (inYDir) ? (iHeight)*floor(i / limit) : (iHeight) * (i % limit) + ]) children(i); + } } diff --git a/lego_compatibility.scad b/lego_compatibility.scad index 4e402d9b..9436cc27 100644 --- a/lego_compatibility.scad +++ b/lego_compatibility.scad @@ -1,3 +1,4 @@ + // This file is placed under the public domain // from: http://www.thingiverse.com/thing:9512 @@ -15,143 +16,261 @@ // standard LEGO 2x1x5 brick has no pin and has hollow knobs // block(1,2,5,reinforcement=false,hollow_knob=true); - -knob_diameter=4.8; //knobs on top of blocks -knob_height=2; -knob_spacing=8.0; -wall_thickness=1.45; -roof_thickness=1.05; -block_height=9.5; -pin_diameter=3; //pin for bottom blocks with width or length of 1 -post_diameter=6.5; -reinforcing_width=1.5; -axle_spline_width=2.0; -axle_diameter=5; -cylinder_precision=0.5; +knob_diameter = 4.8; // knobs on top of blocks +knob_height = 2; +knob_spacing = 8.0; +wall_thickness = 1.45; +roof_thickness = 1.05; +block_height = 9.5; +pin_diameter = 3; // pin for bottom blocks with width or length of 1 +post_diameter = 6.5; +reinforcing_width = 1.5; +axle_spline_width = 2.0; +axle_diameter = 5; +cylinder_precision = 0.5; /* EXAMPLES: block(2,1,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true); translate([50,-10,0]) - block(1,2,1/3,axle_hole=false,circular_hole=true,reinforcement=false,hollow_knob=true,flat_top=true); + block(1,2,1/3,axle_hole=false,circular_hole=true,reinforcement=false,hollow_knob=true,flat_top=true); translate([10,0,0]) - block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true); + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true); translate([30,0,0]) - block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=false,flat_top=false); + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=false,flat_top=false); translate([50,0,0]) - block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false); + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false); translate([0,20,0]) - block(3,2,2/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false); + block(3,2,2/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false); translate([20,20,0]) - block(3,2,1,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false); + block(3,2,1,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false); translate([40,20,0]) - block(3,2,1/3,axle_hole=false,circular_hole=false,reinforcement=false,hollow_knob=false,flat_top=false); + block(3,2,1/3,axle_hole=false,circular_hole=false,reinforcement=false,hollow_knob=false,flat_top=false); translate([0,-10,0]) - block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false); + block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false); translate([0,-20,0]) - block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=false); + block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=false); translate([0,-30,0]) - block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=true); + block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=true); //*/ -module block(width,length,height,axle_hole=false,reinforcement=false, hollow_knob=false, flat_top=false, circular_hole=false, solid_bottom=true, center=false) { - overall_length=(length-1)*knob_spacing+knob_diameter+wall_thickness*2; - overall_width=(width-1)*knob_spacing+knob_diameter+wall_thickness*2; - center= center==true ? 1 : 0; - translate(center*[-overall_length/2, -overall_width/2, 0]) - union() { - difference() { - union() { - // body: - cube([overall_length,overall_width,height*block_height]); - // knobs: - if (flat_top != true) - translate([knob_diameter/2+wall_thickness,knob_diameter/2+wall_thickness,0]) - for (ycount=[0:width-1]) - for (xcount=[0:length-1]) { - translate([xcount*knob_spacing,ycount*knob_spacing,0]) - difference() { - cylinder(r=knob_diameter/2,h=block_height*height+knob_height,$fs=cylinder_precision); - if (hollow_knob==true) - translate([0,0,-roof_thickness]) - cylinder(r=pin_diameter/2,h=block_height*height+knob_height+2*roof_thickness,$fs=cylinder_precision); - } - } - } - // hollow bottom: - if (solid_bottom == false) - translate([wall_thickness,wall_thickness,-roof_thickness]) cube([overall_length-wall_thickness*2,overall_width-wall_thickness*2,block_height*height]); - // flat_top -> groove around bottom - if (flat_top == true) { - translate([-wall_thickness/2,-wall_thickness*2/3,-wall_thickness/2]) - cube([overall_length+wall_thickness,wall_thickness,wall_thickness]); - translate([-wall_thickness/2,overall_width-wall_thickness/3,-wall_thickness/2]) - cube([overall_length+wall_thickness,wall_thickness,wall_thickness]); - - translate([-wall_thickness*2/3,-wall_thickness/2,-wall_thickness/2]) - cube([wall_thickness,overall_width+wall_thickness,wall_thickness]); - translate([overall_length-wall_thickness/3,0,-wall_thickness/2]) - cube([wall_thickness,overall_width+wall_thickness,wall_thickness]); - } - if (axle_hole==true) - if (width>1 && length>1) for (ycount=[1:width-1]) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,ycount*knob_spacing,roof_thickness]) axle(height); - if (circular_hole==true) - if (width>1 && length>1) for (ycount=[1:width-1]) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,ycount*knob_spacing,roof_thickness]) - cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision); - } - - if (reinforcement==true && width>1 && length>1) - difference() { - for (ycount=[1:width-1]) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,ycount*knob_spacing,0]) reinforcement(height); - for (ycount=[1:width-1]) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,ycount*knob_spacing,-roof_thickness/2]) cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness, $fs=cylinder_precision); - } - // posts: - if (solid_bottom == false) - if (width>1 && length>1) for (ycount=[1:width-1]) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,ycount*knob_spacing,0]) post(height); - - if (reinforcement == true && width==1 && length!=1) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,overall_width/2,0]) cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision); - - if (reinforcement == true && length==1 && width!=1) - for (ycount=[1:width-1]) - translate([overall_length/2,ycount*knob_spacing,0]) cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision); - } +module block(width, + length, + height, + axle_hole = false, + reinforcement = false, + hollow_knob = false, + flat_top = false, + circular_hole = false, + solid_bottom = true, + center = false) +{ + overall_length = + (length - 1) * knob_spacing + knob_diameter + wall_thickness * 2; + overall_width = + (width - 1) * knob_spacing + knob_diameter + wall_thickness * 2; + center = center == true ? 1 : 0; + translate(center * [ -overall_length / 2, -overall_width / 2, 0 ]) union() + { + difference() + { + union() + { + // body: + cube([ overall_length, overall_width, height * block_height ]); + // knobs: + if (flat_top != true) + translate([ + knob_diameter / 2 + wall_thickness, + knob_diameter / 2 + wall_thickness, + 0 + ]) for (ycount = [0:width - 1]) for (xcount = + [0:length - 1]) + { + translate( + [ xcount * knob_spacing, ycount * knob_spacing, 0 ]) + difference() + { + cylinder(r = knob_diameter / 2, + h = block_height * height + knob_height, + $fs = cylinder_precision); + if (hollow_knob == true) + translate([ 0, 0, -roof_thickness ]) cylinder( + r = pin_diameter / 2, + h = block_height * height + knob_height + + 2 * roof_thickness, + $fs = cylinder_precision); + } + } + } + // hollow bottom: + if (solid_bottom == false) + translate([ wall_thickness, wall_thickness, -roof_thickness ]) + cube([ + overall_length - wall_thickness * 2, + overall_width - wall_thickness * 2, + block_height * + height + ]); + // flat_top -> groove around bottom + if (flat_top == true) { + translate([ + -wall_thickness / 2, + -wall_thickness * 2 / 3, + -wall_thickness / 2 + ]) + cube([ + overall_length + wall_thickness, + wall_thickness, + wall_thickness + ]); + translate([ + -wall_thickness / 2, + overall_width - wall_thickness / 3, + -wall_thickness / 2 + ]) + cube([ + overall_length + wall_thickness, + wall_thickness, + wall_thickness + ]); + + translate([ + -wall_thickness * 2 / 3, + -wall_thickness / 2, + -wall_thickness / 2 + ]) + cube([ + wall_thickness, + overall_width + wall_thickness, + wall_thickness + ]); + translate([ + overall_length - wall_thickness / 3, + 0, + -wall_thickness / 2 + ]) + cube([ + wall_thickness, + overall_width + wall_thickness, + wall_thickness + ]); + } + if (axle_hole == true) + if (width > 1 && length > 1) + for (ycount = [1:width - 1]) + for (xcount = [1:length - 1]) + translate([ + xcount * knob_spacing, + ycount * knob_spacing, + roof_thickness + ]) axle(height); + if (circular_hole == true) + if (width > 1 && length > 1) + for (ycount = [1:width - 1]) + for (xcount = [1:length - 1]) + translate([ + xcount * knob_spacing, + ycount * knob_spacing, + roof_thickness + ]) cylinder(r = knob_diameter / 2, + h = height * block_height + + roof_thickness / 4, + $fs = cylinder_precision); + } + + if (reinforcement == true && width > 1 && length > 1) + difference() + { + for (ycount = [1:width - 1]) + for (xcount = [1:length - 1]) + translate( + [ xcount * knob_spacing, ycount * knob_spacing, 0 ]) + reinforcement(height); + for (ycount = [1:width - 1]) + for (xcount = [1:length - 1]) + translate([ + xcount * knob_spacing, + ycount * knob_spacing, + -roof_thickness / 2 + ]) cylinder(r = knob_diameter / 2, + h = height * block_height + roof_thickness, + $fs = cylinder_precision); + } + // posts: + if (solid_bottom == false) + if (width > 1 && length > 1) + for (ycount = [1:width - 1]) + for (xcount = [1:length - 1]) + translate( + [ xcount * knob_spacing, ycount * knob_spacing, 0 ]) + post(height); + + if (reinforcement == true && width == 1 && length != 1) + for (xcount = [1:length - 1]) + translate([ xcount * knob_spacing, overall_width / 2, 0 ]) + cylinder(r = pin_diameter / 2, + h = block_height * height, + $fs = cylinder_precision); + + if (reinforcement == true && length == 1 && width != 1) + for (ycount = [1:width - 1]) + translate([ overall_length / 2, ycount * knob_spacing, 0 ]) + cylinder(r = pin_diameter / 2, + h = block_height * height, + $fs = cylinder_precision); + } } -module post(height) { - difference() { - cylinder(r=post_diameter/2, h=height*block_height-roof_thickness/2,$fs=cylinder_precision); - translate([0,0,-roof_thickness/2]) - cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision); - } +module post(height) +{ + difference() + { + cylinder(r = post_diameter / 2, + h = height * block_height - roof_thickness / 2, + $fs = cylinder_precision); + translate([ 0, 0, -roof_thickness / 2 ]) + cylinder(r = knob_diameter / 2, + h = height * block_height + roof_thickness / 4, + $fs = cylinder_precision); + } } -module reinforcement(height) { - union() { - translate([0,0,height*block_height/2]) union() { - cube([reinforcing_width,knob_spacing+knob_diameter+wall_thickness/2,height*block_height],center=true); - rotate(v=[0,0,1],a=90) cube([reinforcing_width,knob_spacing+knob_diameter+wall_thickness/2,height*block_height], center=true); - } - } +module reinforcement(height) +{ + union() + { + translate([ 0, 0, height * block_height / 2 ]) union() + { + cube( + [ + reinforcing_width, + knob_spacing + knob_diameter + wall_thickness / 2, + height * + block_height + ], + center = true); + rotate(v = [ 0, 0, 1 ], a = 90) cube( + [ + reinforcing_width, + knob_spacing + knob_diameter + wall_thickness / 2, + height * + block_height + ], + center = true); + } + } } -module axle(height) { - translate([0,0,height*block_height/2]) union() { - cube([axle_diameter,axle_spline_width,height*block_height],center=true); - cube([axle_spline_width,axle_diameter,height*block_height],center=true); - } +module axle(height) +{ + translate([ 0, 0, height * block_height / 2 ]) union() + { + cube([ axle_diameter, axle_spline_width, height * block_height ], + center = true); + cube([ axle_spline_width, axle_diameter, height * block_height ], + center = true); + } } - diff --git a/materials/materials.scad b/materials/materials.scad index 5afc293b..8af629e9 100644 --- a/materials/materials.scad +++ b/materials/materials.scad @@ -1,19 +1,21 @@ + /* * Material colors. - * + * * Originally by Hans Häggström, 2010. - * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later + * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or + * later */ // Material colors -Oak = [0.65, 0.5, 0.4]; -Pine = [0.85, 0.7, 0.45]; -Birch = [0.9, 0.8, 0.6]; -FiberBoard = [0.7, 0.67, 0.6]; -BlackPaint = [0.2, 0.2, 0.2]; -Iron = [0.36, 0.33, 0.33]; -Steel = [0.65, 0.67, 0.72]; -Stainless = [0.45, 0.43, 0.5]; -Aluminum = [0.77, 0.77, 0.8]; -Brass = [0.88, 0.78, 0.5]; -Transparent = [1, 1, 1, 0.2]; +Oak = [ 0.65, 0.5, 0.4 ]; +Pine = [ 0.85, 0.7, 0.45 ]; +Birch = [ 0.9, 0.8, 0.6 ]; +FiberBoard = [ 0.7, 0.67, 0.6 ]; +BlackPaint = [ 0.2, 0.2, 0.2 ]; +Iron = [ 0.36, 0.33, 0.33 ]; +Steel = [ 0.65, 0.67, 0.72 ]; +Stainless = [ 0.45, 0.43, 0.5 ]; +Aluminum = [ 0.77, 0.77, 0.8 ]; +Brass = [ 0.88, 0.78, 0.5 ]; +Transparent = [ 1, 1, 1, 0.2 ]; diff --git a/materials/visibonecolors.scad b/materials/visibonecolors.scad index 701f4d41..bca5c029 100644 --- a/materials/visibonecolors.scad +++ b/materials/visibonecolors.scad @@ -1,3 +1,4 @@ + /************************************************************************** * File: visibonecolors.scad - a VisiBone-based color library for OpenSCAD * Date: 2011-02-24 @@ -12,7 +13,7 @@ * This program is free software; you can redistribute it and/or modify * it under the terms of the Creative Commons - LGPL License (cc-lgpl) as * published by the Creative Commons Corporation. - * + * * See http://creativecommons.org/licenses/LGPL/2.1/ for details. * * This program is distributed in the hope that it will be useful, @@ -21,440 +22,441 @@ **************************************************************************/ /* Visibone Colors http://www.visibone.com/colorlab/ */ -PPR = [255/255, 0/255, 102/255]; /* Pink Pink Red */ -PPM = [255/255, 0/255, 153/255]; /* Pink Pink Magenta */ -RRP = [255/255, 0/255, 51/255]; /* Red Red Pink */ -MMP = [255/255, 0/255, 204/255]; /* Magenta Magenta Pink */ -DRP = [204/255, 0/255, 51/255]; /* Dark Red Pink */ -DMP = [204/255, 0/255, 153/255]; /* Dark Magenta Pink */ -LRP = [255/255, 51/255, 102/255]; /* Light Red Pink */ -LMP = [255/255, 51/255, 204/255]; /* Light Magenta Pink */ -DPR = [153/255, 0/255, 51/255]; /* Dark Pink Red */ -DPM = [153/255, 0/255, 102/255]; /* Dark Pink Magenta */ -LPR = [255/255, 102/255, 153/255]; /* Light Pink Red */ -LPM = [255/255, 102/255, 204/255]; /* Light Pink Magenta */ -MPR = [204/255, 51/255, 102/255]; /* Medium Pink Red */ -MPM = [204/255, 51/255, 153/255]; /* Medium Pink Magenta */ -OOY = [255/255, 153/255, 0/255]; /* Orange Orange Yellow */ -OOR = [255/255, 102/255, 0/255]; /* Orange Orange Red */ -YYO = [255/255, 204/255, 0/255]; /* Yellow Yellow Orange */ -RRO = [255/255, 51/255, 0/255]; /* Red Red Orange */ -DYO = [204/255, 153/255, 0/255]; /* Dark Yellow Orange */ -DRO = [204/255, 51/255, 0/255]; /* Dark Red Orange */ -LYO = [255/255, 204/255, 51/255]; /* Light Yellow Orange */ -LRO = [255/255, 102/255, 51/255]; /* Light Red Orange */ -DOY = [153/255, 102/255, 0/255]; /* Dark Orange Yellow */ -DOR = [153/255, 51/255, 0/255]; /* Dark Orange Red */ -LOY = [255/255, 204/255, 102/255]; /* Light Orange Yellow */ -LOR = [255/255, 153/255, 102/255]; /* Light Orange Red */ -MOY = [204/255, 153/255, 51/255]; /* Medium Orange Yellow */ -MOR = [204/255, 102/255, 51/255]; /* Medium Orange Red */ -SSG = [102/255, 255/255, 0/255]; /* Spring Spring Green */ -SSY = [153/255, 255/255, 0/255]; /* Spring Spring Yellow */ -GGS = [ 51/255, 255/255, 0/255]; /* Green Green Spring */ -YYS = [204/255, 255/255, 0/255]; /* Yellow Yellow Spring */ -DGS = [ 51/255, 204/255, 0/255]; /* Dark Green Spring */ -DYS = [153/255, 204/255, 0/255]; /* Dark Yellow Spring */ -LGS = [102/255, 255/255, 51/255]; /* Light Green Spring */ -LYS = [204/255, 255/255, 51/255]; /* Light Yellow Spring */ -DSG = [ 51/255, 153/255, 0/255]; /* Dark Spring Green */ -DSY = [102/255, 153/255, 0/255]; /* Dark Spring Yellow */ -LSG = [153/255, 255/255, 102/255]; /* Light Spring Green */ -LSY = [204/255, 255/255, 102/255]; /* Light Spring Yellow */ -MSG = [102/255, 204/255, 51/255]; /* Medium Spring Green */ -MSY = [153/255, 204/255, 51/255]; /* Medium Spring Yellow */ -TTC = [ 0/255, 255/255, 153/255]; /* Teal Teal Cyan */ -TTG = [ 0/255, 255/255, 102/255]; /* Teal Teal Green */ -CCT = [ 0/255, 255/255, 204/255]; /* Cyan Cyan Teal */ -GGT = [ 0/255, 255/255, 51/255]; /* Green Green Teal */ -DCT = [ 0/255, 204/255, 153/255]; /* Dark Cyan Teal */ -DGT = [ 0/255, 204/255, 51/255]; /* Dark Green Teal */ -LCT = [ 51/255, 255/255, 204/255]; /* Light Cyan Teal */ -LGT = [ 51/255, 255/255, 102/255]; /* Light Green Teal */ -DTC = [ 0/255, 153/255, 102/255]; /* Dark Teal Cyan */ -DTG = [ 0/255, 153/255, 51/255]; /* Dark Teal Green */ -LTC = [102/255, 255/255, 204/255]; /* Light Teal Cyan */ -LTG = [102/255, 255/255, 153/255]; /* Light Teal Green */ -MTC = [ 51/255, 204/255, 153/255]; /* Medium Teal Cyan */ -MTG = [ 51/255, 204/255, 102/255]; /* Medium Teal Green */ -AAB = [ 0/255, 102/255, 255/255]; /* Azure Azure Blue */ -AAC = [ 0/255, 153/255, 255/255]; /* Azure Azure Cyan */ -BBA = [ 0/255, 51/255, 255/255]; /* Blue Blue Azure */ -CCA = [ 0/255, 204/255, 255/255]; /* Cyan Cyan Azure */ -DBA = [ 0/255, 51/255, 204/255]; /* Dark Blue Azure */ -DCA = [ 0/255, 153/255, 204/255]; /* Dark Cyan Azure */ -LBA = [ 51/255, 102/255, 255/255]; /* Light Blue Azure */ -LCA = [ 51/255, 204/255, 255/255]; /* Light Cyan Azure */ -DAB = [ 0/255, 51/255, 153/255]; /* Dark Azure Blue */ -DAC = [ 0/255, 102/255, 153/255]; /* Dark Azure Cyan */ -LAB = [102/255, 153/255, 255/255]; /* Light Azure Blue */ -LAC = [102/255, 204/255, 255/255]; /* Light Azure Cyan */ -MAB = [ 51/255, 102/255, 204/255]; /* Medium Azure Blue */ -MAC = [ 51/255, 153/255, 204/255]; /* Medium Azure Cyan */ -VVM = [153/255, 0/255, 255/255]; /* Violet Violet Magenta */ -VVB = [102/255, 0/255, 255/255]; /* Violet Violet Blue */ -MMV = [204/255, 0/255, 255/255]; /* Magenta Magenta Violet */ -BBV = [ 51/255, 0/255, 255/255]; /* Blue Blue Violet */ -DMV = [153/255, 0/255, 204/255]; /* Dark Magenta Violet */ -DBV = [ 51/255, 0/255, 204/255]; /* Dark Blue Violet */ -LMV = [204/255, 51/255, 255/255]; /* Light Magenta Violet */ -LBV = [102/255, 51/255, 255/255]; /* Light Blue Violet */ -DVM = [102/255, 0/255, 153/255]; /* Dark Violet Magenta */ -DVB = [ 51/255, 0/255, 153/255]; /* Dark Violet Blue */ -LVM = [204/255, 102/255, 255/255]; /* Light Violet Magenta */ -LVB = [153/255, 102/255, 255/255]; /* Light Violet Blue */ -MVM = [153/255, 51/255, 204/255]; /* Medium Violet Magenta */ -MVB = [102/255, 51/255, 204/255]; /* Medium Violet Blue */ -OWM = [ 51/255, 0/255, 51/255]; /* Obscure Weak Magenta */ -ODM = [102/255, 0/255, 102/255]; /* Obscure Dull Magenta */ -DFM = [153/255, 0/255, 153/255]; /* Dark Faded Magenta */ -DHM = [204/255, 0/255, 204/255]; /* Dark Hard Magenta */ -M = [255/255, 0/255, 255/255]; /* Magenta */ -DWM = [102/255, 51/255, 102/255]; /* Dark Weak Magenta */ -DDM = [153/255, 51/255, 153/255]; /* Dark Dull Magenta */ -MFM = [204/255, 51/255, 204/255]; /* Medium Faded Magenta */ -LHM = [255/255, 51/255, 255/255]; /* Light Hard Magenta */ -MWM = [153/255, 102/255, 153/255]; /* Medium Weak Magenta */ -LDM = [204/255, 102/255, 204/255]; /* Light Dull Magenta */ -LFM = [255/255, 102/255, 255/255]; /* Light Faded Magenta */ -LWM = [204/255, 153/255, 204/255]; /* Light Weak Magenta */ -PDM = [255/255, 153/255, 255/255]; /* Pale Dull Magenta */ -PWM = [255/255, 204/255, 255/255]; /* Pale Weak Magenta */ -OWR = [ 51/255, 0/255, 0/255]; /* Obscure Weak Red */ -ODR = [102/255, 0/255, 0/255]; /* Obscure Dull Red */ -DFR = [153/255, 0/255, 0/255]; /* Dark Faded Red */ -DHR = [204/255, 0/255, 0/255]; /* Dark Hard Red */ -R = [255/255, 0/255, 0/255]; /* Red */ -DWR = [102/255, 51/255, 51/255]; /* Dark Weak Red */ -DDR = [153/255, 51/255, 51/255]; /* Dark Dull Red */ -MFR = [204/255, 51/255, 51/255]; /* Medium Faded Red */ -LHR = [255/255, 51/255, 51/255]; /* Light Hard Red */ -MWR = [153/255, 102/255, 102/255]; /* Medium Weak Red */ -LDR = [204/255, 102/255, 102/255]; /* Light Dull Red */ -LFR = [255/255, 102/255, 102/255]; /* Light Faded Red */ -LWR = [204/255, 153/255, 153/255]; /* Light Weak Red */ -PDR = [255/255, 153/255, 153/255]; /* Pale Dull Red */ -PWR = [255/255, 204/255, 204/255]; /* Pale Weak Red */ -OWY = [ 51/255, 51/255, 0/255]; /* Obscure Weak Yellow */ -ODY = [102/255, 102/255, 0/255]; /* Obscure Dull Yellow */ -DFY = [153/255, 153/255, 0/255]; /* Dark Faded Yellow */ -DHY = [204/255, 204/255, 0/255]; /* Dark Hard Yellow */ -Y = [255/255, 255/255, 0/255]; /* Yellow */ -DWY = [102/255, 102/255, 51/255]; /* Dark Weak Yellow */ -DDY = [153/255, 153/255, 51/255]; /* Dark Dull Yellow */ -MFY = [204/255, 204/255, 51/255]; /* Medium Faded Yellow */ -LHY = [255/255, 255/255, 51/255]; /* Light Hard Yellow */ -MWY = [153/255, 153/255, 102/255]; /* Medium Weak Yellow */ -LDY = [204/255, 204/255, 102/255]; /* Light Dull Yellow */ -LFY = [255/255, 255/255, 102/255]; /* Light Faded Yellow */ -LWY = [204/255, 204/255, 153/255]; /* Light Weak Yellow */ -PDY = [255/255, 255/255, 153/255]; /* Pale Dull Yellow */ -PWY = [255/255, 255/255, 204/255]; /* Pale Weak Yellow */ -OWG = [ 0/255, 51/255, 0/255]; /* Obscure Weak Green */ -ODG = [ 0/255, 102/255, 0/255]; /* Obscure Dull Green */ -DFG = [ 0/255, 153/255, 0/255]; /* Dark Faded Green */ -DHG = [ 0/255, 204/255, 0/255]; /* Dark Hard Green */ -G = [ 0/255, 255/255, 0/255]; /* Green */ -DWG = [ 51/255, 102/255, 51/255]; /* Dark Weak Green */ -DDG = [ 51/255, 153/255, 51/255]; /* Dark Dull Green */ -MFG = [ 51/255, 204/255, 51/255]; /* Medium Faded Green */ -LHG = [ 51/255, 255/255, 51/255]; /* Light Hard Green */ -MWG = [102/255, 153/255, 102/255]; /* Medium Weak Green */ -LDG = [102/255, 204/255, 102/255]; /* Light Dull Green */ -LFG = [102/255, 255/255, 102/255]; /* Light Faded Green */ -LWG = [153/255, 204/255, 153/255]; /* Light Weak Green */ -PDG = [153/255, 255/255, 153/255]; /* Pale Dull Green */ -PWG = [204/255, 255/255, 204/255]; /* Pale Weak Green */ -OWC = [ 0/255, 51/255, 51/255]; /* Obscure Weak Cyan */ -ODC = [ 0/255, 102/255, 102/255]; /* Obscure Dull Cyan */ -DFC = [ 0/255, 153/255, 153/255]; /* Dark Faded Cyan */ -DHC = [ 0/255, 204/255, 204/255]; /* Dark Hard Cyan */ -C = [ 0/255, 255/255, 255/255]; /* Cyan */ -DWC = [ 51/255, 102/255, 102/255]; /* Dark Weak Cyan */ -DDC = [ 51/255, 153/255, 153/255]; /* Dark Dull Cyan */ -MFC = [ 51/255, 204/255, 204/255]; /* Medium Faded Cyan */ -LHC = [ 51/255, 255/255, 255/255]; /* Light Hard Cyan */ -MWC = [102/255, 153/255, 153/255]; /* Medium Weak Cyan */ -LDC = [102/255, 204/255, 204/255]; /* Light Dull Cyan */ -LFC = [102/255, 255/255, 255/255]; /* Light Faded Cyan */ -LWC = [153/255, 204/255, 204/255]; /* Light Weak Cyan */ -PDC = [153/255, 255/255, 255/255]; /* Pale Dull Cyan */ -PWC = [204/255, 255/255, 255/255]; /* Pale Weak Cyan */ -OWB = [ 0/255, 0/255, 51/255]; /* Obscure Weak Blue */ -ODB = [ 0/255, 0/255, 102/255]; /* Obscure Dull Blue */ -DFB = [ 0/255, 0/255, 153/255]; /* Dark Faded Blue */ -DHB = [ 0/255, 0/255, 204/255]; /* Dark Hard Blue */ -B = [ 0/255, 0/255, 255/255]; /* Blue */ -DWB = [ 51/255, 51/255, 102/255]; /* Dark Weak Blue */ -DDB = [ 51/255, 51/255, 153/255]; /* Dark Dull Blue */ -MFB = [ 51/255, 51/255, 204/255]; /* Medium Faded Blue */ -LHB = [ 51/255, 51/255, 255/255]; /* Light Hard Blue */ -MWB = [102/255, 102/255, 153/255]; /* Medium Weak Blue */ -LDB = [102/255, 102/255, 204/255]; /* Light Dull Blue */ -LFB = [102/255, 102/255, 255/255]; /* Light Faded Blue */ -LWB = [153/255, 153/255, 204/255]; /* Light Weak Blue */ -PDB = [153/255, 153/255, 255/255]; /* Pale Dull Blue */ -PWB = [204/255, 204/255, 255/255]; /* Pale Weak Blue */ -ODP = [102/255, 0/255, 51/255]; /* Obscure Dull Pink */ -DDP = [153/255, 51/255, 102/255]; /* Dark Dull Pink */ -LDP = [204/255, 102/255, 153/255]; /* Light Dull Pink */ -PDP = [255/255, 153/255, 204/255]; /* Pale Dull Pink */ -DHP = [204/255, 0/255, 102/255]; /* Dark Hard Pink */ -LHP = [255/255, 51/255, 153/255]; /* Light Hard Pink */ -ODO = [102/255, 51/255, 0/255]; /* Obscure Dull Orange */ -DDO = [153/255, 102/255, 51/255]; /* Dark Dull Orange */ -LDO = [204/255, 153/255, 102/255]; /* Light Dull Orange */ -PDO = [255/255, 204/255, 153/255]; /* Pale Dull Orange */ -DHO = [204/255, 102/255, 0/255]; /* Dark Hard Orange */ -LHO = [255/255, 153/255, 51/255]; /* Light Hard Orange */ -ODS = [ 51/255, 102/255, 0/255]; /* Obscure Dull Spring */ -DDS = [102/255, 153/255, 51/255]; /* Dark Dull Spring */ -LDS = [153/255, 204/255, 102/255]; /* Light Dull Spring */ -PDS = [204/255, 255/255, 153/255]; /* Pale Dull Spring */ -DHS = [102/255, 204/255, 0/255]; /* Dark Hard Spring */ -LHS = [153/255, 255/255, 51/255]; /* Light Hard Spring */ -ODT = [ 0/255, 102/255, 51/255]; /* Obscure Dull Teal */ -DDT = [ 51/255, 153/255, 102/255]; /* Dark Dull Teal */ -LDT = [102/255, 204/255, 153/255]; /* Light Dull Teal */ -PDT = [153/255, 255/255, 204/255]; /* Pale Dull Teal */ -DHT = [ 0/255, 204/255, 102/255]; /* Dark Hard Teal */ -LHT = [ 51/255, 255/255, 153/255]; /* Light Hard Teal */ -ODA = [ 0/255, 51/255, 102/255]; /* Obscure Dull Azure */ -DDA = [ 51/255, 102/255, 153/255]; /* Dark Dull Azure */ -LDA = [102/255, 153/255, 204/255]; /* Light Dull Azure */ -PDA = [153/255, 204/255, 255/255]; /* Pale Dull Azure */ -DHA = [ 0/255, 102/255, 204/255]; /* Dark Hard Azure */ -LHA = [ 51/255, 153/255, 255/255]; /* Light Hard Azure */ -ODV = [ 51/255, 0/255, 102/255]; /* Obscure Dull Violet */ -DDV = [102/255, 51/255, 153/255]; /* Dark Dull Violet */ -LDV = [153/255, 102/255, 204/255]; /* Light Dull Violet */ -PDV = [204/255, 153/255, 255/255]; /* Pale Dull Violet */ -DHV = [102/255, 0/255, 204/255]; /* Dark Hard Violet */ -LHV = [153/255, 51/255, 255/255]; /* Light Hard Violet */ -K = [ 0/255, 0/255, 0/255]; /* Black */ -OG = [ 51/255, 51/255, 51/255]; /* Obscure Gray */ -DG = [102/255, 102/255, 102/255]; /* Dark Gray */ -LG = [153/255, 153/255, 153/255]; /* Light Gray */ -PG = [204/255, 204/255, 204/255]; /* Pale Gray */ -W = [255/255, 255/255, 255/255]; /* White */ +PPR = [ 255 / 255, 0 / 255, 102 / 255 ]; /* Pink Pink Red */ +PPM = [ 255 / 255, 0 / 255, 153 / 255 ]; /* Pink Pink Magenta */ +RRP = [ 255 / 255, 0 / 255, 51 / 255 ]; /* Red Red Pink */ +MMP = [ 255 / 255, 0 / 255, 204 / 255 ]; /* Magenta Magenta Pink */ +DRP = [ 204 / 255, 0 / 255, 51 / 255 ]; /* Dark Red Pink */ +DMP = [ 204 / 255, 0 / 255, 153 / 255 ]; /* Dark Magenta Pink */ +LRP = [ 255 / 255, 51 / 255, 102 / 255 ]; /* Light Red Pink */ +LMP = [ 255 / 255, 51 / 255, 204 / 255 ]; /* Light Magenta Pink */ +DPR = [ 153 / 255, 0 / 255, 51 / 255 ]; /* Dark Pink Red */ +DPM = [ 153 / 255, 0 / 255, 102 / 255 ]; /* Dark Pink Magenta */ +LPR = [ 255 / 255, 102 / 255, 153 / 255 ]; /* Light Pink Red */ +LPM = [ 255 / 255, 102 / 255, 204 / 255 ]; /* Light Pink Magenta */ +MPR = [ 204 / 255, 51 / 255, 102 / 255 ]; /* Medium Pink Red */ +MPM = [ 204 / 255, 51 / 255, 153 / 255 ]; /* Medium Pink Magenta */ +OOY = [ 255 / 255, 153 / 255, 0 / 255 ]; /* Orange Orange Yellow */ +OOR = [ 255 / 255, 102 / 255, 0 / 255 ]; /* Orange Orange Red */ +YYO = [ 255 / 255, 204 / 255, 0 / 255 ]; /* Yellow Yellow Orange */ +RRO = [ 255 / 255, 51 / 255, 0 / 255 ]; /* Red Red Orange */ +DYO = [ 204 / 255, 153 / 255, 0 / 255 ]; /* Dark Yellow Orange */ +DRO = [ 204 / 255, 51 / 255, 0 / 255 ]; /* Dark Red Orange */ +LYO = [ 255 / 255, 204 / 255, 51 / 255 ]; /* Light Yellow Orange */ +LRO = [ 255 / 255, 102 / 255, 51 / 255 ]; /* Light Red Orange */ +DOY = [ 153 / 255, 102 / 255, 0 / 255 ]; /* Dark Orange Yellow */ +DOR = [ 153 / 255, 51 / 255, 0 / 255 ]; /* Dark Orange Red */ +LOY = [ 255 / 255, 204 / 255, 102 / 255 ]; /* Light Orange Yellow */ +LOR = [ 255 / 255, 153 / 255, 102 / 255 ]; /* Light Orange Red */ +MOY = [ 204 / 255, 153 / 255, 51 / 255 ]; /* Medium Orange Yellow */ +MOR = [ 204 / 255, 102 / 255, 51 / 255 ]; /* Medium Orange Red */ +SSG = [ 102 / 255, 255 / 255, 0 / 255 ]; /* Spring Spring Green */ +SSY = [ 153 / 255, 255 / 255, 0 / 255 ]; /* Spring Spring Yellow */ +GGS = [ 51 / 255, 255 / 255, 0 / 255 ]; /* Green Green Spring */ +YYS = [ 204 / 255, 255 / 255, 0 / 255 ]; /* Yellow Yellow Spring */ +DGS = [ 51 / 255, 204 / 255, 0 / 255 ]; /* Dark Green Spring */ +DYS = [ 153 / 255, 204 / 255, 0 / 255 ]; /* Dark Yellow Spring */ +LGS = [ 102 / 255, 255 / 255, 51 / 255 ]; /* Light Green Spring */ +LYS = [ 204 / 255, 255 / 255, 51 / 255 ]; /* Light Yellow Spring */ +DSG = [ 51 / 255, 153 / 255, 0 / 255 ]; /* Dark Spring Green */ +DSY = [ 102 / 255, 153 / 255, 0 / 255 ]; /* Dark Spring Yellow */ +LSG = [ 153 / 255, 255 / 255, 102 / 255 ]; /* Light Spring Green */ +LSY = [ 204 / 255, 255 / 255, 102 / 255 ]; /* Light Spring Yellow */ +MSG = [ 102 / 255, 204 / 255, 51 / 255 ]; /* Medium Spring Green */ +MSY = [ 153 / 255, 204 / 255, 51 / 255 ]; /* Medium Spring Yellow */ +TTC = [ 0 / 255, 255 / 255, 153 / 255 ]; /* Teal Teal Cyan */ +TTG = [ 0 / 255, 255 / 255, 102 / 255 ]; /* Teal Teal Green */ +CCT = [ 0 / 255, 255 / 255, 204 / 255 ]; /* Cyan Cyan Teal */ +GGT = [ 0 / 255, 255 / 255, 51 / 255 ]; /* Green Green Teal */ +DCT = [ 0 / 255, 204 / 255, 153 / 255 ]; /* Dark Cyan Teal */ +,DGT = [ 0 / 255, 204 / 255, 51 / 255 ]; /* Dark Green Teal */ +LCT = [ 51 / 255, 255 / 255, 204 / 255 ]; /* Light Cyan Teal */ +LGT = [ 51 / 255, 255 / 255, 102 / 255 ]; /* Light Green Teal */ +DTC = [ 0 / 255, 153 / 255, 102 / 255 ]; /* Dark Teal Cyan */ +DTG = [ 0 / 255, 153 / 255, 51 / 255 ]; /* Dark Teal Green */ +LTC = [ 102 / 255, 255 / 255, 204 / 255 ]; /* Light Teal Cyan */ +LTG = [ 102 / 255, 255 / 255, 153 / 255 ]; /* Light Teal Green */ +MTC = [ 51 / 255, 204 / 255, 153 / 255 ]; /* Medium Teal Cyan */ +MTG = [ 51 / 255, 204 / 255, 102 / 255 ]; /* Medium Teal Green */ +AAB = [ 0 / 255, 102 / 255, 255 / 255 ]; /* Azure Azure Blue */ +AAC = [ 0 / 255, 153 / 255, 255 / 255 ]; /* Azure Azure Cyan */ +BBA = [ 0 / 255, 51 / 255, 255 / 255 ]; /* Blue Blue Azure */ +CCA = [ 0 / 255, 204 / 255, 255 / 255 ]; /* Cyan Cyan Azure */ +DBA = [ 0 / 255, 51 / 255, 204 / 255 ]; /* Dark Blue Azure */ +DCA = [ 0 / 255, 153 / 255, 204 / 255 ]; /* Dark Cyan Azure */ +LBA = [ 51 / 255, 102 / 255, 255 / 255 ]; /* Light Blue Azure */ +LCA = [ 51 / 255, 204 / 255, 255 / 255 ]; /* Light Cyan Azure */ +DAB = [ 0 / 255, 51 / 255, 153 / 255 ]; /* Dark Azure Blue */ +DAC = [ 0 / 255, 102 / 255, 153 / 255 ]; /* Dark Azure Cyan */ +LAB = [ 102 / 255, 153 / 255, 255 / 255 ]; /* Light Azure Blue */ +LAC = [ 102 / 255, 204 / 255, 255 / 255 ]; /* Light Azure Cyan */ +MAB = [ 51 / 255, 102 / 255, 204 / 255 ]; /* Medium Azure Blue */ +MAC = [ 51 / 255, 153 / 255, 204 / 255 ]; /* Medium Azure Cyan */ +VVM = [ 153 / 255, 0 / 255, 255 / 255 ]; /* Violet Violet Magenta */ +VVB = [ 102 / 255, 0 / 255, 255 / 255 ]; /* Violet Violet Blue */ +MMV = [ 204 / 255, 0 / 255, 255 / 255 ]; /* Magenta Magenta Violet */ +BBV = [ 51 / 255, 0 / 255, 255 / 255 ]; /* Blue Blue Violet */ +DMV = [ 153 / 255, 0 / 255, 204 / 255 ]; /* Dark Magenta Violet */ +DBV = [ 51 / 255, 0 / 255, 204 / 255 ]; /* Dark Blue Violet */ +LMV = [ 204 / 255, 51 / 255, 255 / 255 ]; /* Light Magenta Violet */ +LBV = [ 102 / 255, 51 / 255, 255 / 255 ]; /* Light Blue Violet */ +DVM = [ 102 / 255, 0 / 255, 153 / 255 ]; /* Dark Violet Magenta */ +DVB = [ 51 / 255, 0 / 255, 153 / 255 ]; /* Dark Violet Blue */ +LVM = [ 204 / 255, 102 / 255, 255 / 255 ]; /* Light Violet Magenta */ +LVB = [ 153 / 255, 102 / 255, 255 / 255 ]; /* Light Violet Blue */ +MVM = [ 153 / 255, 51 / 255, 204 / 255 ]; /* Medium Violet Magenta */ +MVB = [ 102 / 255, 51 / 255, 204 / 255 ]; /* Medium Violet Blue */ +OWM = [ 51 / 255, 0 / 255, 51 / 255 ]; /* Obscure Weak Magenta */ +ODM = [ 102 / 255, 0 / 255, 102 / 255 ]; /* Obscure Dull Magenta */ +DFM = [ 153 / 255, 0 / 255, 153 / 255 ]; /* Dark Faded Magenta */ +DHM = [ 204 / 255, 0 / 255, 204 / 255 ]; /* Dark Hard Magenta */ +M = [ 255 / 255, 0 / 255, 255 / 255 ]; /* Magenta */ +DWM = [ 102 / 255, 51 / 255, 102 / 255 ]; /* Dark Weak Magenta */ +DDM = [ 153 / 255, 51 / 255, 153 / 255 ]; /* Dark Dull Magenta */ +MFM = [ 204 / 255, 51 / 255, 204 / 255 ]; /* Medium Faded Magenta */ +LHM = [ 255 / 255, 51 / 255, 255 / 255 ]; /* Light Hard Magenta */ +MWM = [ 153 / 255, 102 / 255, 153 / 255 ]; /* Medium Weak Magenta */ +LDM = [ 204 / 255, 102 / 255, 204 / 255 ]; /* Light Dull Magenta */ +LFM = [ 255 / 255, 102 / 255, 255 / 255 ]; /* Light Faded Magenta */ +LWM = [ 204 / 255, 153 / 255, 204 / 255 ]; /* Light Weak Magenta */ +PDM = [ 255 / 255, 153 / 255, 255 / 255 ]; /* Pale Dull Magenta */ +PWM = [ 255 / 255, 204 / 255, 255 / 255 ]; /* Pale Weak Magenta */ +OWR = [ 51 / 255, 0 / 255, 0 / 255 ]; /* Obscure Weak Red */ +ODR = [ 102 / 255, 0 / 255, 0 / 255 ]; /* Obscure Dull Red */ +DFR = [ 153 / 255, 0 / 255, 0 / 255 ]; /* Dark Faded Red */ +DHR = [ 204 / 255, 0 / 255, 0 / 255 ]; /* Dark Hard Red */ +R = [ 255 / 255, 0 / 255, 0 / 255 ]; /* Red */ +DWR = [ 102 / 255, 51 / 255, 51 / 255 ]; /* Dark Weak Red */ +DDR = [ 153 / 255, 51 / 255, 51 / 255 ]; /* Dark Dull Red */ +MFR = [ 204 / 255, 51 / 255, 51 / 255 ]; /* Medium Faded Red */ +LHR = [ 255 / 255, 51 / 255, 51 / 255 ]; /* Light Hard Red */ +MWR = [ 153 / 255, 102 / 255, 102 / 255 ]; /* Medium Weak Red */ +LDR = [ 204 / 255, 102 / 255, 102 / 255 ]; /* Light Dull Red */ +LFR = [ 255 / 255, 102 / 255, 102 / 255 ]; /* Light Faded Red */ +LWR = [ 204 / 255, 153 / 255, 153 / 255 ]; /* Light Weak Red */ +PDR = [ 255 / 255, 153 / 255, 153 / 255 ]; /* Pale Dull Red */ +PWR = [ 255 / 255, 204 / 255, 204 / 255 ]; /* Pale Weak Red */ +OWY = [ 51 / 255, 51 / 255, 0 / 255 ]; /* Obscure Weak Yellow */ +ODY = [ 102 / 255, 102 / 255, 0 / 255 ]; /* Obscure Dull Yellow */ +DFY = [ 153 / 255, 153 / 255, 0 / 255 ]; /* Dark Faded Yellow */ +DHY = [ 204 / 255, 204 / 255, 0 / 255 ]; /* Dark Hard Yellow */ +Y = [ 255 / 255, 255 / 255, 0 / 255 ]; /* Yellow */ +DWY = [ 102 / 255, 102 / 255, 51 / 255 ]; /* Dark Weak Yellow */ +DDY = [ 153 / 255, 153 / 255, 51 / 255 ]; /* Dark Dull Yellow */ +MFY = [ 204 / 255, 204 / 255, 51 / 255 ]; /* Medium Faded Yellow */ +LHY = [ 255 / 255, 255 / 255, 51 / 255 ]; /* Light Hard Yellow */ +MWY = [ 153 / 255, 153 / 255, 102 / 255 ]; /* Medium Weak Yellow */ +LDY = [ 204 / 255, 204 / 255, 102 / 255 ]; /* Light Dull Yellow */ +LFY = [ 255 / 255, 255 / 255, 102 / 255 ]; /* Light Faded Yellow */ +LWY = [ 204 / 255, 204 / 255, 153 / 255 ]; /* Light Weak Yellow */ +PDY = [ 255 / 255, 255 / 255, 153 / 255 ]; /* Pale Dull Yellow */ +PWY = [ 255 / 255, 255 / 255, 204 / 255 ]; /* Pale Weak Yellow */ +OWG = [ 0 / 255, 51 / 255, 0 / 255 ]; /* Obscure Weak Green */ +ODG = [ 0 / 255, 102 / 255, 0 / 255 ]; /* Obscure Dull Green */ +DFG = [ 0 / 255, 153 / 255, 0 / 255 ]; /* Dark Faded Green */ +DHG = [ 0 / 255, 204 / 255, 0 / 255 ]; /* Dark Hard Green */ +G = [ 0 / 255, 255 / 255, 0 / 255 ]; /* Green */ +DWG = [ 51 / 255, 102 / 255, 51 / 255 ]; /* Dark Weak Green */ +DDG = [ 51 / 255, 153 / 255, 51 / 255 ]; /* Dark Dull Green */ +MFG = [ 51 / 255, 204 / 255, 51 / 255 ]; /* Medium Faded Green */ +LHG = [ 51 / 255, 255 / 255, 51 / 255 ]; /* Light Hard Green */ +MWG = [ 102 / 255, 153 / 255, 102 / 255 ]; /* Medium Weak Green */ +LDG = [ 102 / 255, 204 / 255, 102 / 255 ]; /* Light Dull Green */ +LFG = [ 102 / 255, 255 / 255, 102 / 255 ]; /* Light Faded Green */ +LWG = [ 153 / 255, 204 / 255, 153 / 255 ]; /* Light Weak Green */ +PDG = [ 153 / 255, 255 / 255, 153 / 255 ]; /* Pale Dull Green */ +PWG = [ 204 / 255, 255 / 255, 204 / 255 ]; /* Pale Weak Green */ +OWC = [ 0 / 255, 51 / 255, 51 / 255 ]; /* Obscure Weak Cyan */ +ODC = [ 0 / 255, 102 / 255, 102 / 255 ]; /* Obscure Dull Cyan */ +DFC = [ 0 / 255, 153 / 255, 153 / 255 ]; /* Dark Faded Cyan */ +DHC = [ 0 / 255, 204 / 255, 204 / 255 ]; /* Dark Hard Cyan */ +C = [ 0 / 255, 255 / 255, 255 / 255 ]; /* Cyan */ +DWC = [ 51 / 255, 102 / 255, 102 / 255 ]; /* Dark Weak Cyan */ +DDC = [ 51 / 255, 153 / 255, 153 / 255 ]; /* Dark Dull Cyan */ +MFC = [ 51 / 255, 204 / 255, 204 / 255 ]; /* Medium Faded Cyan */ +LHC = [ 51 / 255, 255 / 255, 255 / 255 ]; /* Light Hard Cyan */ +MWC = [ 102 / 255, 153 / 255, 153 / 255 ]; /* Medium Weak Cyan */ +LDC = [ 102 / 255, 204 / 255, 204 / 255 ]; /* Light Dull Cyan */ +LFC = [ 102 / 255, 255 / 255, 255 / 255 ]; /* Light Faded Cyan */ +LWC = [ 153 / 255, 204 / 255, 204 / 255 ]; /* Light Weak Cyan */ +PDC = [ 153 / 255, 255 / 255, 255 / 255 ]; /* Pale Dull Cyan */ +PWC = [ 204 / 255, 255 / 255, 255 / 255 ]; /* Pale Weak Cyan */ +OWB = [ 0 / 255, 0 / 255, 51 / 255 ]; /* Obscure Weak Blue */ +ODB = [ 0 / 255, 0 / 255, 102 / 255 ]; /* Obscure Dull Blue */ +DFB = [ 0 / 255, 0 / 255, 153 / 255 ]; /* Dark Faded Blue */ +DHB = [ 0 / 255, 0 / 255, 204 / 255 ]; /* Dark Hard Blue */ +B = [ 0 / 255, 0 / 255, 255 / 255 ]; /* Blue */ +DWB = [ 51 / 255, 51 / 255, 102 / 255 ]; /* Dark Weak Blue */ +DDB = [ 51 / 255, 51 / 255, 153 / 255 ]; /* Dark Dull Blue */ +MFB = [ 51 / 255, 51 / 255, 204 / 255 ]; /* Medium Faded Blue */ +LHB = [ 51 / 255, 51 / 255, 255 / 255 ]; /* Light Hard Blue */ +MWB = [ 102 / 255, 102 / 255, 153 / 255 ]; /* Medium Weak Blue */ +LDB = [ 102 / 255, 102 / 255, 204 / 255 ]; /* Light Dull Blue */ +LFB = [ 102 / 255, 102 / 255, 255 / 255 ]; /* Light Faded Blue */ +LWB = [ 153 / 255, 153 / 255, 204 / 255 ]; /* Light Weak Blue */ +PDB = [ 153 / 255, 153 / 255, 255 / 255 ]; /* Pale Dull Blue */ +PWB = [ 204 / 255, 204 / 255, 255 / 255 ]; /* Pale Weak Blue */ +ODP = [ 102 / 255, 0 / 255, 51 / 255 ]; /* Obscure Dull Pink */ +DDP = [ 153 / 255, 51 / 255, 102 / 255 ]; /* Dark Dull Pink */ +LDP = [ 204 / 255, 102 / 255, 153 / 255 ]; /* Light Dull Pink */ +PDP = [ 255 / 255, 153 / 255, 204 / 255 ]; /* Pale Dull Pink */ +DHP = [ 204 / 255, 0 / 255, 102 / 255 ]; /* Dark Hard Pink */ +LHP = [ 255 / 255, 51 / 255, 153 / 255 ]; /* Light Hard Pink */ +ODO = [ 102 / 255, 51 / 255, 0 / 255 ]; /* Obscure Dull Orange */ +DDO = [ 153 / 255, 102 / 255, 51 / 255 ]; /* Dark Dull Orange */ +LDO = [ 204 / 255, 153 / 255, 102 / 255 ]; /* Light Dull Orange */ +PDO = [ 255 / 255, 204 / 255, 153 / 255 ]; /* Pale Dull Orange */ +DHO = [ 204 / 255, 102 / 255, 0 / 255 ]; /* Dark Hard Orange */ +LHO = [ 255 / 255, 153 / 255, 51 / 255 ]; /* Light Hard Orange */ +ODS = [ 51 / 255, 102 / 255, 0 / 255 ]; /* Obscure Dull Spring */ +DDS = [ 102 / 255, 153 / 255, 51 / 255 ]; /* Dark Dull Spring */ +LDS = [ 153 / 255, 204 / 255, 102 / 255 ]; /* Light Dull Spring */ +PDS = [ 204 / 255, 255 / 255, 153 / 255 ]; /* Pale Dull Spring */ +DHS = [ 102 / 255, 204 / 255, 0 / 255 ]; /* Dark Hard Spring */ +LHS = [ 153 / 255, 255 / 255, 51 / 255 ]; /* Light Hard Spring */ +ODT = [ 0 / 255, 102 / 255, 51 / 255 ]; /* Obscure Dull Teal */ +DDT = [ 51 / 255, 153 / 255, 102 / 255 ]; /* Dark Dull Teal */ +LDT = [ 102 / 255, 204 / 255, 153 / 255 ]; /* Light Dull Teal */ +PDT = [ 153 / 255, 255 / 255, 204 / 255 ]; /* Pale Dull Teal */ +DHT = [ 0 / 255, 204 / 255, 102 / 255 ]; /* Dark Hard Teal */ +LHT = [ 51 / 255, 255 / 255, 153 / 255 ]; /* Light Hard Teal */ +ODA = [ 0 / 255, 51 / 255, 102 / 255 ]; /* Obscure Dull Azure */ +DDA = [ 51 / 255, 102 / 255, 153 / 255 ]; /* Dark Dull Azure */ +LDA = [ 102 / 255, 153 / 255, 204 / 255 ]; /* Light Dull Azure */ +PDA = [ 153 / 255, 204 / 255, 255 / 255 ]; /* Pale Dull Azure */ +DHA = [ 0 / 255, 102 / 255, 204 / 255 ]; /* Dark Hard Azure */ +LHA = [ 51 / 255, 153 / 255, 255 / 255 ]; /* Light Hard Azure */ +ODV = [ 51 / 255, 0 / 255, 102 / 255 ]; /* Obscure Dull Violet */ +DDV = [ 102 / 255, 51 / 255, 153 / 255 ]; /* Dark Dull Violet */ +LDV = [ 153 / 255, 102 / 255, 204 / 255 ]; /* Light Dull Violet */ +PDV = [ 204 / 255, 153 / 255, 255 / 255 ]; /* Pale Dull Violet */ +DHV = [ 102 / 255, 0 / 255, 204 / 255 ]; /* Dark Hard Violet */ +LHV = [ 153 / 255, 51 / 255, 255 / 255 ]; /* Light Hard Violet */ +K = [ 0 / 255, 0 / 255, 0 / 255 ]; /* Black */ +OG = [ 51 / 255, 51 / 255, 51 / 255 ]; /* Obscure Gray */ +DG = [ 102 / 255, 102 / 255, 102 / 255 ]; /* Dark Gray */ +LG = [ 153 / 255, 153 / 255, 153 / 255 ]; /* Light Gray */ +PG = [ 204 / 255, 204 / 255, 204 / 255 ]; /* Pale Gray */ +W = [ 255 / 255, 255 / 255, 255 / 255 ]; /* White */ -module colorshelp() +module +colorshelp() { - echo("--- visibonecolorshelp ---"); - echo("color(PPR); /* Pink Pink Red */"); - echo("color(PPM); /* Pink Pink Magenta */"); - echo("color(RRP); /* Red Red Pink */"); - echo("color(MMP); /* Magenta Magenta Pink */"); - echo("color(DRP); /* Dark Red Pink */"); - echo("color(DMP); /* Dark Magenta Pink */"); - echo("color(LRP); /* Light Red Pink */"); - echo("color(LMP); /* Light Magenta Pink */"); - echo("color(DPR); /* Dark Pink Red */"); - echo("color(DPM); /* Dark Pink Magenta */"); - echo("color(LPR); /* Light Pink Red */"); - echo("color(LPM); /* Light Pink Magenta */"); - echo("color(MPR); /* Medium Pink Red */"); - echo("color(MPM); /* Medium Pink Magenta */"); - echo("color(OOY); /* Orange Orange Yellow */"); - echo("color(OOR); /* Orange Orange Red */"); - echo("color(YYO); /* Yellow Yellow Orange */"); - echo("color(RRO); /* Red Red Orange */"); - echo("color(DYO); /* Dark Yellow Orange */"); - echo("color(DRO); /* Dark Red Orange */"); - echo("color(LYO); /* Light Yellow Orange */"); - echo("color(LRO); /* Light Red Orange */"); - echo("color(DOY); /* Dark Orange Yellow */"); - echo("color(DOR); /* Dark Orange Red */"); - echo("color(LOY); /* Light Orange Yellow */"); - echo("color(LOR); /* Light Orange Red */"); - echo("color(MOY); /* Medium Orange Yellow */"); - echo("color(MOR); /* Medium Orange Red */"); - echo("color(SSG); /* Spring Spring Green */"); - echo("color(SSY); /* Spring Spring Yellow */"); - echo("color(GGS); /* Green Green Spring */"); - echo("color(YYS); /* Yellow Yellow Spring */"); - echo("color(DGS); /* Dark Green Spring */"); - echo("color(DYS); /* Dark Yellow Spring */"); - echo("color(LGS); /* Light Green Spring */"); - echo("color(LYS); /* Light Yellow Spring */"); - echo("color(DSG); /* Dark Spring Green */"); - echo("color(DSY); /* Dark Spring Yellow */"); - echo("color(LSG); /* Light Spring Green */"); - echo("color(LSY); /* Light Spring Yellow */"); - echo("color(MSG); /* Medium Spring Green */"); - echo("color(MSY); /* Medium Spring Yellow */"); - echo("color(TTC); /* Teal Teal Cyan */"); - echo("color(TTG); /* Teal Teal Green */"); - echo("color(CCT); /* Cyan Cyan Teal */"); - echo("color(GGT); /* Green Green Teal */"); - echo("color(DCT); /* Dark Cyan Teal */"); - echo("color(DGT); /* Dark Green Teal */"); - echo("color(LCT); /* Light Cyan Teal */"); - echo("color(LGT); /* Light Green Teal */"); - echo("color(DTC); /* Dark Teal Cyan */"); - echo("color(DTG); /* Dark Teal Green */"); - echo("color(LTC); /* Light Teal Cyan */"); - echo("color(LTG); /* Light Teal Green */"); - echo("color(MTC); /* Medium Teal Cyan */"); - echo("color(MTG); /* Medium Teal Green */"); - echo("color(AAB); /* Azure Azure Blue */"); - echo("color(AAC); /* Azure Azure Cyan */"); - echo("color(BBA); /* Blue Blue Azure */"); - echo("color(CCA); /* Cyan Cyan Azure */"); - echo("color(DBA); /* Dark Blue Azure */"); - echo("color(DCA); /* Dark Cyan Azure */"); - echo("color(LBA); /* Light Blue Azure */"); - echo("color(LCA); /* Light Cyan Azure */"); - echo("color(DAB); /* Dark Azure Blue */"); - echo("color(DAC); /* Dark Azure Cyan */"); - echo("color(LAB); /* Light Azure Blue */"); - echo("color(LAC); /* Light Azure Cyan */"); - echo("color(MAB); /* Medium Azure Blue */"); - echo("color(MAC); /* Medium Azure Cyan */"); - echo("color(VVM); /* Violet Violet Magenta */"); - echo("color(VVB); /* Violet Violet Blue */"); - echo("color(MMV); /* Magenta Magenta Violet */"); - echo("color(BBV); /* Blue Blue Violet */"); - echo("color(DMV); /* Dark Magenta Violet */"); - echo("color(DBV); /* Dark Blue Violet */"); - echo("color(LMV); /* Light Magenta Violet */"); - echo("color(LBV); /* Light Blue Violet */"); - echo("color(DVM); /* Dark Violet Magenta */"); - echo("color(DVB); /* Dark Violet Blue */"); - echo("color(LVM); /* Light Violet Magenta */"); - echo("color(LVB); /* Light Violet Blue */"); - echo("color(MVM); /* Medium Violet Magenta */"); - echo("color(MVB); /* Medium Violet Blue */"); - echo("color(OWM); /* Obscure Weak Magenta */"); - echo("color(ODM); /* Obscure Dull Magenta */"); - echo("color(DFM); /* Dark Faded Magenta */"); - echo("color(DHM); /* Dark Hard Magenta */"); - echo("color(M); /* Magenta */"); - echo("color(DWM); /* Dark Weak Magenta */"); - echo("color(DDM); /* Dark Dull Magenta */"); - echo("color(MFM); /* Medium Faded Magenta */"); - echo("color(LHM); /* Light Hard Magenta */"); - echo("color(MWM); /* Medium Weak Magenta */"); - echo("color(LDM); /* Light Dull Magenta */"); - echo("color(LFM); /* Light Faded Magenta */"); - echo("color(LWM); /* Light Weak Magenta */"); - echo("color(PDM); /* Pale Dull Magenta */"); - echo("color(PWM); /* Pale Weak Magenta */"); - echo("color(OWR); /* Obscure Weak Red */"); - echo("color(ODR); /* Obscure Dull Red */"); - echo("color(DFR); /* Dark Faded Red */"); - echo("color(DHR); /* Dark Hard Red */"); - echo("color(R); /* Red */"); - echo("color(DWR); /* Dark Weak Red */"); - echo("color(DDR); /* Dark Dull Red */"); - echo("color(MFR); /* Medium Faded Red */"); - echo("color(LHR); /* Light Hard Red */"); - echo("color(MWR); /* Medium Weak Red */"); - echo("color(LDR); /* Light Dull Red */"); - echo("color(LFR); /* Light Faded Red */"); - echo("color(LWR); /* Light Weak Red */"); - echo("color(PDR); /* Pale Dull Red */"); - echo("color(PWR); /* Pale Weak Red */"); - echo("color(OWY); /* Obscure Weak Yellow */"); - echo("color(ODY); /* Obscure Dull Yellow */"); - echo("color(DFY); /* Dark Faded Yellow */"); - echo("color(DHY); /* Dark Hard Yellow */"); - echo("color(Y); /* Yellow */"); - echo("color(DWY); /* Dark Weak Yellow */"); - echo("color(DDY); /* Dark Dull Yellow */"); - echo("color(MFY); /* Medium Faded Yellow */"); - echo("color(LHY); /* Light Hard Yellow */"); - echo("color(MWY); /* Medium Weak Yellow */"); - echo("color(LDY); /* Light Dull Yellow */"); - echo("color(LFY); /* Light Faded Yellow */"); - echo("color(LWY); /* Light Weak Yellow */"); - echo("color(PDY); /* Pale Dull Yellow */"); - echo("color(PWY); /* Pale Weak Yellow */"); - echo("color(OWG); /* Obscure Weak Green */"); - echo("color(ODG); /* Obscure Dull Green */"); - echo("color(DFG); /* Dark Faded Green */"); - echo("color(DHG); /* Dark Hard Green */"); - echo("color(G); /* Green */"); - echo("color(DWG); /* Dark Weak Green */"); - echo("color(DDG); /* Dark Dull Green */"); - echo("color(MFG); /* Medium Faded Green */"); - echo("color(LHG); /* Light Hard Green */"); - echo("color(MWG); /* Medium Weak Green */"); - echo("color(LDG); /* Light Dull Green */"); - echo("color(LFG); /* Light Faded Green */"); - echo("color(LWG); /* Light Weak Green */"); - echo("color(PDG); /* Pale Dull Green */"); - echo("color(PWG); /* Pale Weak Green */"); - echo("color(OWC); /* Obscure Weak Cyan */"); - echo("color(ODC); /* Obscure Dull Cyan */"); - echo("color(DFC); /* Dark Faded Cyan */"); - echo("color(DHC); /* Dark Hard Cyan */"); - echo("color(C); /* Cyan */"); - echo("color(DWC); /* Dark Weak Cyan */"); - echo("color(DDC); /* Dark Dull Cyan */"); - echo("color(MFC); /* Medium Faded Cyan */"); - echo("color(LHC); /* Light Hard Cyan */"); - echo("color(MWC); /* Medium Weak Cyan */"); - echo("color(LDC); /* Light Dull Cyan */"); - echo("color(LFC); /* Light Faded Cyan */"); - echo("color(LWC); /* Light Weak Cyan */"); - echo("color(PDC); /* Pale Dull Cyan */"); - echo("color(PWC); /* Pale Weak Cyan */"); - echo("color(OWB); /* Obscure Weak Blue */"); - echo("color(ODB); /* Obscure Dull Blue */"); - echo("color(DFB); /* Dark Faded Blue */"); - echo("color(DHB); /* Dark Hard Blue */"); - echo("color(B); /* Blue */"); - echo("color(DWB); /* Dark Weak Blue */"); - echo("color(DDB); /* Dark Dull Blue */"); - echo("color(MFB); /* Medium Faded Blue */"); - echo("color(LHB); /* Light Hard Blue */"); - echo("color(MWB); /* Medium Weak Blue */"); - echo("color(LDB); /* Light Dull Blue */"); - echo("color(LFB); /* Light Faded Blue */"); - echo("color(LWB); /* Light Weak Blue */"); - echo("color(PDB); /* Pale Dull Blue */"); - echo("color(PWB); /* Pale Weak Blue */"); - echo("color(ODP); /* Obscure Dull Pink */"); - echo("color(DDP); /* Dark Dull Pink */"); - echo("color(LDP); /* Light Dull Pink */"); - echo("color(PDP); /* Pale Dull Pink */"); - echo("color(DHP); /* Dark Hard Pink */"); - echo("color(LHP); /* Light Hard Pink */"); - echo("color(ODO); /* Obscure Dull Orange */"); - echo("color(DDO); /* Dark Dull Orange */"); - echo("color(LDO); /* Light Dull Orange */"); - echo("color(PDO); /* Pale Dull Orange */"); - echo("color(DHO); /* Dark Hard Orange */"); - echo("color(LHO); /* Light Hard Orange */"); - echo("color(ODS); /* Obscure Dull Spring */"); - echo("color(DDS); /* Dark Dull Spring */"); - echo("color(LDS); /* Light Dull Spring */"); - echo("color(PDS); /* Pale Dull Spring */"); - echo("color(DHS); /* Dark Hard Spring */"); - echo("color(LHS); /* Light Hard Spring */"); - echo("color(ODT); /* Obscure Dull Teal */"); - echo("color(DDT); /* Dark Dull Teal */"); - echo("color(LDT); /* Light Dull Teal */"); - echo("color(PDT); /* Pale Dull Teal */"); - echo("color(DHT); /* Dark Hard Teal */"); - echo("color(LHT); /* Light Hard Teal */"); - echo("color(ODA); /* Obscure Dull Azure */"); - echo("color(DDA); /* Dark Dull Azure */"); - echo("color(LDA); /* Light Dull Azure */"); - echo("color(PDA); /* Pale Dull Azure */"); - echo("color(DHA); /* Dark Hard Azure */"); - echo("color(LHA); /* Light Hard Azure */"); - echo("color(ODV); /* Obscure Dull Violet */"); - echo("color(DDV); /* Dark Dull Violet */"); - echo("color(LDV); /* Light Dull Violet */"); - echo("color(PDV); /* Pale Dull Violet */"); - echo("color(DHV); /* Dark Hard Violet */"); - echo("color(LHV); /* Light Hard Violet */"); - echo("color(K); /* Black */"); - echo("color(OG); /* Obscure Gray */"); - echo("color(DG); /* Dark Gray */"); - echo("color(LG); /* Light Gray */"); - echo("color(PG); /* Pale Gray */"); - echo("color(W); /* White */"); + echo("--- visibonecolorshelp ---"); + echo("color(PPR); /* Pink Pink Red */"); + echo("color(PPM); /* Pink Pink Magenta */"); + echo("color(RRP); /* Red Red Pink */"); + echo("color(MMP); /* Magenta Magenta Pink */"); + echo("color(DRP); /* Dark Red Pink */"); + echo("color(DMP); /* Dark Magenta Pink */"); + echo("color(LRP); /* Light Red Pink */"); + echo("color(LMP); /* Light Magenta Pink */"); + echo("color(DPR); /* Dark Pink Red */"); + echo("color(DPM); /* Dark Pink Magenta */"); + echo("color(LPR); /* Light Pink Red */"); + echo("color(LPM); /* Light Pink Magenta */"); + echo("color(MPR); /* Medium Pink Red */"); + echo("color(MPM); /* Medium Pink Magenta */"); + echo("color(OOY); /* Orange Orange Yellow */"); + echo("color(OOR); /* Orange Orange Red */"); + echo("color(YYO); /* Yellow Yellow Orange */"); + echo("color(RRO); /* Red Red Orange */"); + echo("color(DYO); /* Dark Yellow Orange */"); + echo("color(DRO); /* Dark Red Orange */"); + echo("color(LYO); /* Light Yellow Orange */"); + echo("color(LRO); /* Light Red Orange */"); + echo("color(DOY); /* Dark Orange Yellow */"); + echo("color(DOR); /* Dark Orange Red */"); + echo("color(LOY); /* Light Orange Yellow */"); + echo("color(LOR); /* Light Orange Red */"); + echo("color(MOY); /* Medium Orange Yellow */"); + echo("color(MOR); /* Medium Orange Red */"); + echo("color(SSG); /* Spring Spring Green */"); + echo("color(SSY); /* Spring Spring Yellow */"); + echo("color(GGS); /* Green Green Spring */"); + echo("color(YYS); /* Yellow Yellow Spring */"); + echo("color(DGS); /* Dark Green Spring */"); + echo("color(DYS); /* Dark Yellow Spring */"); + echo("color(LGS); /* Light Green Spring */"); + echo("color(LYS); /* Light Yellow Spring */"); + echo("color(DSG); /* Dark Spring Green */"); + echo("color(DSY); /* Dark Spring Yellow */"); + echo("color(LSG); /* Light Spring Green */"); + echo("color(LSY); /* Light Spring Yellow */"); + echo("color(MSG); /* Medium Spring Green */"); + echo("color(MSY); /* Medium Spring Yellow */"); + echo("color(TTC); /* Teal Teal Cyan */"); + echo("color(TTG); /* Teal Teal Green */"); + echo("color(CCT); /* Cyan Cyan Teal */"); + echo("color(GGT); /* Green Green Teal */"); + echo("color(DCT); /* Dark Cyan Teal */"); + echo("color(DGT); /* Dark Green Teal */"); + echo("color(LCT); /* Light Cyan Teal */"); + echo("color(LGT); /* Light Green Teal */"); + echo("color(DTC); /* Dark Teal Cyan */"); + echo("color(DTG); /* Dark Teal Green */"); + echo("color(LTC); /* Light Teal Cyan */"); + echo("color(LTG); /* Light Teal Green */"); + echo("color(MTC); /* Medium Teal Cyan */"); + echo("color(MTG); /* Medium Teal Green */"); + echo("color(AAB); /* Azure Azure Blue */"); + echo("color(AAC); /* Azure Azure Cyan */"); + echo("color(BBA); /* Blue Blue Azure */"); + echo("color(CCA); /* Cyan Cyan Azure */"); + echo("color(DBA); /* Dark Blue Azure */"); + echo("color(DCA); /* Dark Cyan Azure */"); + echo("color(LBA); /* Light Blue Azure */"); + echo("color(LCA); /* Light Cyan Azure */"); + echo("color(DAB); /* Dark Azure Blue */"); + echo("color(DAC); /* Dark Azure Cyan */"); + echo("color(LAB); /* Light Azure Blue */"); + echo("color(LAC); /* Light Azure Cyan */"); + echo("color(MAB); /* Medium Azure Blue */"); + echo("color(MAC); /* Medium Azure Cyan */"); + echo("color(VVM); /* Violet Violet Magenta */"); + echo("color(VVB); /* Violet Violet Blue */"); + echo("color(MMV); /* Magenta Magenta Violet */"); + echo("color(BBV); /* Blue Blue Violet */"); + echo("color(DMV); /* Dark Magenta Violet */"); + echo("color(DBV); /* Dark Blue Violet */"); + echo("color(LMV); /* Light Magenta Violet */"); + echo("color(LBV); /* Light Blue Violet */"); + echo("color(DVM); /* Dark Violet Magenta */"); + echo("color(DVB); /* Dark Violet Blue */"); + echo("color(LVM); /* Light Violet Magenta */"); + echo("color(LVB); /* Light Violet Blue */"); + echo("color(MVM); /* Medium Violet Magenta */"); + echo("color(MVB); /* Medium Violet Blue */"); + echo("color(OWM); /* Obscure Weak Magenta */"); + echo("color(ODM); /* Obscure Dull Magenta */"); + echo("color(DFM); /* Dark Faded Magenta */"); + echo("color(DHM); /* Dark Hard Magenta */"); + echo("color(M); /* Magenta */"); + echo("color(DWM); /* Dark Weak Magenta */"); + echo("color(DDM); /* Dark Dull Magenta */"); + echo("color(MFM); /* Medium Faded Magenta */"); + echo("color(LHM); /* Light Hard Magenta */"); + echo("color(MWM); /* Medium Weak Magenta */"); + echo("color(LDM); /* Light Dull Magenta */"); + echo("color(LFM); /* Light Faded Magenta */"); + echo("color(LWM); /* Light Weak Magenta */"); + echo("color(PDM); /* Pale Dull Magenta */"); + echo("color(PWM); /* Pale Weak Magenta */"); + echo("color(OWR); /* Obscure Weak Red */"); + echo("color(ODR); /* Obscure Dull Red */"); + echo("color(DFR); /* Dark Faded Red */"); + echo("color(DHR); /* Dark Hard Red */"); + echo("color(R); /* Red */"); + echo("color(DWR); /* Dark Weak Red */"); + echo("color(DDR); /* Dark Dull Red */"); + echo("color(MFR); /* Medium Faded Red */"); + echo("color(LHR); /* Light Hard Red */"); + echo("color(MWR); /* Medium Weak Red */"); + echo("color(LDR); /* Light Dull Red */"); + echo("color(LFR); /* Light Faded Red */"); + echo("color(LWR); /* Light Weak Red */"); + echo("color(PDR); /* Pale Dull Red */"); + echo("color(PWR); /* Pale Weak Red */"); + echo("color(OWY); /* Obscure Weak Yellow */"); + echo("color(ODY); /* Obscure Dull Yellow */"); + echo("color(DFY); /* Dark Faded Yellow */"); + echo("color(DHY); /* Dark Hard Yellow */"); + echo("color(Y); /* Yellow */"); + echo("color(DWY); /* Dark Weak Yellow */"); + echo("color(DDY); /* Dark Dull Yellow */"); + echo("color(MFY); /* Medium Faded Yellow */"); + echo("color(LHY); /* Light Hard Yellow */"); + echo("color(MWY); /* Medium Weak Yellow */"); + echo("color(LDY); /* Light Dull Yellow */"); + echo("color(LFY); /* Light Faded Yellow */"); + echo("color(LWY); /* Light Weak Yellow */"); + echo("color(PDY); /* Pale Dull Yellow */"); + echo("color(PWY); /* Pale Weak Yellow */"); + echo("color(OWG); /* Obscure Weak Green */"); + echo("color(ODG); /* Obscure Dull Green */"); + echo("color(DFG); /* Dark Faded Green */"); + echo("color(DHG); /* Dark Hard Green */"); + echo("color(G); /* Green */"); + echo("color(DWG); /* Dark Weak Green */"); + echo("color(DDG); /* Dark Dull Green */"); + echo("color(MFG); /* Medium Faded Green */"); + echo("color(LHG); /* Light Hard Green */"); + echo("color(MWG); /* Medium Weak Green */"); + echo("color(LDG); /* Light Dull Green */"); + echo("color(LFG); /* Light Faded Green */"); + echo("color(LWG); /* Light Weak Green */"); + echo("color(PDG); /* Pale Dull Green */"); + echo("color(PWG); /* Pale Weak Green */"); + echo("color(OWC); /* Obscure Weak Cyan */"); + echo("color(ODC); /* Obscure Dull Cyan */"); + echo("color(DFC); /* Dark Faded Cyan */"); + echo("color(DHC); /* Dark Hard Cyan */"); + echo("color(C); /* Cyan */"); + echo("color(DWC); /* Dark Weak Cyan */"); + echo("color(DDC); /* Dark Dull Cyan */"); + echo("color(MFC); /* Medium Faded Cyan */"); + echo("color(LHC); /* Light Hard Cyan */"); + echo("color(MWC); /* Medium Weak Cyan */"); + echo("color(LDC); /* Light Dull Cyan */"); + echo("color(LFC); /* Light Faded Cyan */"); + echo("color(LWC); /* Light Weak Cyan */"); + echo("color(PDC); /* Pale Dull Cyan */"); + echo("color(PWC); /* Pale Weak Cyan */"); + echo("color(OWB); /* Obscure Weak Blue */"); + echo("color(ODB); /* Obscure Dull Blue */"); + echo("color(DFB); /* Dark Faded Blue */"); + echo("color(DHB); /* Dark Hard Blue */"); + echo("color(B); /* Blue */"); + echo("color(DWB); /* Dark Weak Blue */"); + echo("color(DDB); /* Dark Dull Blue */"); + echo("color(MFB); /* Medium Faded Blue */"); + echo("color(LHB); /* Light Hard Blue */"); + echo("color(MWB); /* Medium Weak Blue */"); + echo("color(LDB); /* Light Dull Blue */"); + echo("color(LFB); /* Light Faded Blue */"); + echo("color(LWB); /* Light Weak Blue */"); + echo("color(PDB); /* Pale Dull Blue */"); + echo("color(PWB); /* Pale Weak Blue */"); + echo("color(ODP); /* Obscure Dull Pink */"); + echo("color(DDP); /* Dark Dull Pink */"); + echo("color(LDP); /* Light Dull Pink */"); + echo("color(PDP); /* Pale Dull Pink */"); + echo("color(DHP); /* Dark Hard Pink */"); + echo("color(LHP); /* Light Hard Pink */"); + echo("color(ODO); /* Obscure Dull Orange */"); + echo("color(DDO); /* Dark Dull Orange */"); + echo("color(LDO); /* Light Dull Orange */"); + echo("color(PDO); /* Pale Dull Orange */"); + echo("color(DHO); /* Dark Hard Orange */"); + echo("color(LHO); /* Light Hard Orange */"); + echo("color(ODS); /* Obscure Dull Spring */"); + echo("color(DDS); /* Dark Dull Spring */"); + echo("color(LDS); /* Light Dull Spring */"); + echo("color(PDS); /* Pale Dull Spring */"); + echo("color(DHS); /* Dark Hard Spring */"); + echo("color(LHS); /* Light Hard Spring */"); + echo("color(ODT); /* Obscure Dull Teal */"); + echo("color(DDT); /* Dark Dull Teal */"); + echo("color(LDT); ,/* Light Dull Teal */"); + echo("color(PDT); /* Pale Dull Teal */"); + echo("color(DHT); /* Dark Hard Teal */"); + echo("color(LHT); /* Light Hard Teal */"); + echo("color(ODA); /* Obscure Dull Azure */"); + echo("color(DDA); /* Dark Dull Azure */"); + echo("color(LDA); /* Light Dull Azure */"); + echo("color(PDA); /* Pale Dull Azure */"); + echo("color(DHA); /* Dark Hard Azure */"); + echo("color(LHA); /* Light Hard Azure */"); + echo("color(ODV); /* Obscure Dull Violet */"); + echo("color(DDV); /* Dark Dull Violet */"); + echo("color(LDV); /* Light Dull Violet */"); + echo("color(PDV); /* Pale Dull Violet */"); + echo("color(DHV); /* Dark Hard Violet */"); + echo("color(LHV); /* Light Hard Violet */"); + echo("color(K); /* Black */"); + echo("color(OG); /* Obscure Gray */"); + echo("color(DG); /* Dark Gray */"); + echo("color(LG); /* Light Gray */"); + echo("color(PG); /* Pale Gray */"); + echo("color(W); /* White */"); } diff --git a/motors/motors.scad b/motors/motors.scad index bff35023..5f4f97ec 100644 --- a/motors/motors.scad +++ b/motors/motors.scad @@ -1,96 +1,109 @@ -// Copyright 2010 D1plo1d - -// This library is dual licensed under the GPL 3.0 and the GNU Lesser General Public License as per http://creativecommons.org/licenses/LGPL/2.1/ . - include include include +// Copyright 2010 D1plo1d -//generates a motor mount for the specified nema standard #. -module stepper_motor_mount(nema_standard,slide_distance=0, mochup=true, tolerance=0) { - //dimensions from: - // http://www.numberfactory.com/NEMA%20Motor%20Dimensions.htm - if (nema_standard == 17) - { - _stepper_motor_mount( - motor_shaft_diameter = 0.1968*length_in, - motor_shaft_length = 0.945*length_in, - pilot_diameter = 0.866*length_in, - pilot_length = 0.80*length_in, - mounting_bolt_circle = 1.725*length_in, - bolt_hole_size = 3.5, - bolt_hole_distance = 1.220*length_in, - slide_distance = slide_distance, - mochup = mochup, - tolerance=tolerance); - } - if (nema_standard == 23) - { - _stepper_motor_mount( - motor_shaft_diameter = 0.250*length_in, - motor_shaft_length = 0.81*length_in, - pilot_diameter = 1.500*length_in, - pilot_length = 0.062*length_in, - mounting_bolt_circle = 2.625*length_in, - bolt_hole_size = 0.195*length_in, - bolt_hole_distance = 1.856*length_in, - slide_distance = slide_distance, - mochup = mochup, - tolerance=tolerance); - } - -} +// This library is dual licensed under the GPL 3.0 and the GNU Lesser General +// Public License as per http://creativecommons.org/licenses/LGPL/2.1/ . +// generates a motor mount for the specified nema standard #. +module stepper_motor_mount(nema_standard, + slide_distance = 0, + mochup = true, + tolerance = 0) +{ + // dimensions from: + // http://www.numberfactory.com/NEMA%20Motor%20Dimensions.htm + if (nema_standard == 17) { + _stepper_motor_mount(motor_shaft_diameter = 0.1968 * length_in, + motor_shaft_length = 0.945 * length_in, + pilot_diameter = 0.866 * length_in, + pilot_length = 0.80 * length_in, + mounting_bolt_circle = 1.725 * length_in, + bolt_hole_size = 3.5, + bolt_hole_distance = 1.220 * length_in, + slide_distance = slide_distance, + mochup = mochup, + tolerance = tolerance); + } + if (nema_standard == 23) { + _stepper_motor_mount(motor_shaft_diameter = 0.250 * length_in, + motor_shaft_length = 0.81 * length_in, + pilot_diameter = 1.500 * length_in, + pilot_length = 0.062 * length_in, + mounting_bolt_circle = 2.625 * length_in, + bolt_hole_size = 0.195 * length_in, + bolt_hole_distance = 1.856 * length_in, + slide_distance = slide_distance, + mochup = mochup, + tolerance = tolerance); + } +} -//inner mehod for creating a stepper motor mount of any dimensions -module _stepper_motor_mount( - motor_shaft_diameter, - motor_shaft_length, - pilot_diameter, - pilot_length, - mounting_bolt_circle, - bolt_hole_size, - bolt_hole_distance, - slide_distance = 0, - motor_length = 40, //arbitray - not standardized - mochup, - tolerance = 0 -) +// inner mehod for creating a stepper motor mount of any dimensions +module _stepper_motor_mount(motor_shaft_diameter, + motor_shaft_length, + pilot_diameter, + pilot_length, + mounting_bolt_circle, + bolt_hole_size, + bolt_hole_distance, + slide_distance = 0, + motor_length = 40, // arbitray - not standardized + mochup, + tolerance = 0) { - union() - { - // == centered mount points == - //mounting circle inset - translate([0,slide_distance/2,0]) circle(r = pilot_diameter/2 + tolerance); - square([pilot_diameter,slide_distance],center=true); - translate([0,-slide_distance/2,0]) circle(r = pilot_diameter/2 + tolerance); + union() + { + // == centered mount points == + // mounting circle inset + translate([ 0, slide_distance / 2, 0 ]) + circle(r = pilot_diameter / 2 + tolerance); + square([ pilot_diameter, slide_distance ], center = true); + translate([ 0, -slide_distance / 2, 0 ]) + circle(r = pilot_diameter / 2 + tolerance); + + // todo: motor shaft hole - //todo: motor shaft hole - - //mounting screw holes - for (x = [-1,1]) for (y = [-1,1]) - { - translate([x*bolt_hole_distance/2,y*bolt_hole_distance/2,0]) - { - translate([0,slide_distance/2,0]) circle(bolt_hole_size/2 + tolerance); - translate([0,-slide_distance/2,0]) circle(bolt_hole_size/2 + tolerance); - square([bolt_hole_size+2*tolerance,slide_distance],center=true); - } - } - // == motor mock-up == - //motor box - if (mochup == true) - { - %translate([0,0,-5]) cylinder(h = 5, r = pilot_diameter/2); - %translate(v=[0,0,-motor_length/2]) - { - cube(size=[bolt_hole_distance+bolt_hole_size+5,bolt_hole_distance+bolt_hole_size+5,motor_length], center = true); - } - //shaft - %translate(v=[0,0,-(motor_length-motor_shaft_length-2)/2]) - { - %cylinder(r=motor_shaft_diameter/2,h=motor_length+motor_shaft_length--1, center = true); - } - } - } + // mounting screw holes + for (x = [ -1, 1 ]) + for (y = [ -1, 1 ]) { + translate([ + x * bolt_hole_distance / 2, + y * bolt_hole_distance / 2, + 0 + ]) + { + translate([ 0, slide_distance / 2, 0 ]) + circle(bolt_hole_size / 2 + tolerance); + translate([ 0, -slide_distance / 2, 0 ]) + circle(bolt_hole_size / 2 + tolerance); + square([ bolt_hole_size + 2 * tolerance, slide_distance ], + center = true); + } + } + // == motor mock-up == + // motor box + if (mochup == true) { + % translate([ 0, 0, -5 ]) cylinder(h = 5, r = pilot_diameter / 2); + % translate(v = [ 0, 0, -motor_length / 2 ]) + { + cube(size = + [ + bolt_hole_distance + bolt_hole_size + 5, + bolt_hole_distance + bolt_hole_size + 5, + motor_length + ], + center = true); + } + // shaft + % translate( + v = [ 0, 0, -(motor_length - motor_shaft_length - 2) / 2 ]) + { + % cylinder(r = motor_shaft_diameter / 2, + h = motor_length + motor_shaft_length-- 1, + center = true); + } + } + } } diff --git a/motors/servos.scad b/motors/servos.scad index 0f3f39c2..6b946dca 100644 --- a/motors/servos.scad +++ b/motors/servos.scad @@ -1,3 +1,4 @@ +use /** * Servo outline library * @@ -7,101 +8,86 @@ * License: LGPL 2.1 */ -use - /** * Align DS420 digital servo * * @param vector position The position vector * @param vector rotation The rotation vector - * @param boolean screws If defined then "screws" will be added and when the module is differenced() from something if will have holes for the screws - * @param number axle_lenght If defined this will draw "backgound" indicator for the main axle + * @param boolean screws If defined then "screws" will be added and when the + * module is differenced() from something if will have holes for the screws + * @param number axle_lenght If defined this will draw "backgound" indicator for + * the main axle */ module alignds420(position, rotation, screws = 0, axle_lenght = 0) { - translate(position) - { - rotate(rotation) - { - union() - { - // Main axle - translate([0,0,17]) - { - cylinder(r=6, h=8, $fn=30); - cylinder(r=2.5, h=10.5, $fn=20); - } - // Box and ears - translate([-6,-6,0]) - { - cube([12, 22.8,19.5], false); - translate([0,-5, 17]) - { - cube([12, 7, 2.5]); - } - translate([0, 20.8, 17]) - { - cube([12, 7, 2.5]); - } - } - if (screws > 0) - { - translate([0,(-10.2 + 1.8),11.5]) - { - # cylinder(r=1.8/2, h=6, $fn=6); - } - translate([0,(21.0 - 1.8),11.5]) - { - # cylinder(r=1.8/2, h=6, $fn=6); - } - - } - // The large slope - translate([-6,0,19]) - { - rotate([90,0,90]) - { - triangle(4, 18, 12); - } - } + translate(position) + { + rotate(rotation) + { + union() + { + // Main axle + translate([ 0, 0, 17 ]) + { + cylinder(r = 6, h = 8, $fn = 30); + cylinder(r = 2.5, h = 10.5, $fn = 20); + } + // Box and ears + translate([ -6, -6, 0 ]) + { + cube([ 12, 22.8, 19.5 ], false); + translate([ 0, -5, 17 ]) { cube([ 12, 7, 2.5 ]); } + translate([ 0, 20.8, 17 ]) { cube([ 12, 7, 2.5 ]); } + } + if (screws > 0) { + translate([ 0, (-10.2 + 1.8), 11.5 ]) + { +#cylinder(r = 1.8 / 2, h = 6, $fn = 6); + } + translate([ 0, (21.0 - 1.8), 11.5 ]) + { +#cylinder(r = 1.8 / 2, h = 6, $fn = 6); + } + } + // The large slope + translate([ -6, 0, 19 ]) + { + rotate([ 90, 0, 90 ]) { triangle(4, 18, 12); } + } - /** - * This seems to get too complex fast - // Small additional axes - translate([0,6,17]) - { - cylinder(r=2.5, h=6, $fn=10); - cylinder(r=1.25, h=8, $fn=10); - } - // Small slope - difference() - { - translate([-6,-6,19.0]) - { - cube([12,6.5,4]); - } - translate([7,-7,24.0]) - { - rotate([-90,0,90]) - { - triangle(3, 8, 14); - } - } + /** + * This seems to get too complex fast + // Small additional axes + translate([0,6,17]) + { + cylinder(r=2.5, h=6, $fn=10); + cylinder(r=1.25, h=8, $fn=10); + } + // Small slope + difference() + { + translate([-6,-6,19.0]) + { + cube([12,6.5,4]); + } + translate([7,-7,24.0]) + { + rotate([-90,0,90]) + { + triangle(3, 8, 14); + } + } - } - */ - // So we render a cube instead of the small slope on a cube - translate([-6,-6,19.0]) - { - cube([12,6.5,4]); - } - } - if (axle_lenght > 0) - { - % cylinder(r=0.9, h=axle_lenght, center=true, $fn=8); - } - } - } + } + */ + // So we render a cube instead of the small slope on a cube + translate([ -6, -6, 19.0 ]) { cube([ 12, 6.5, 4 ]); } + } + if (axle_lenght > 0) { + % cylinder(r = 0.9, h = axle_lenght, center = true, $fn = 8); + } + } + } } /** @@ -112,45 +98,51 @@ module alignds420(position, rotation, screws = 0, axle_lenght = 0) */ module futabas3003(position, rotation) { - translate(position) - { - rotate(rotation) - { - union() - { - // Box and ears - translate([0,0,0]) - { - cube([20.1, 39.9, 36.1], false); - translate([1.1, -7.6, 26.6]) - { - difference() { - cube([18, 7.6, 2.5]); - translate([4, 3.5, 0]) cylinder(100, 2); - translate([14, 3.5, 0]) cylinder(100, 2); + translate(position) + { + rotate(rotation) + { + union() + { + // Box and ears + translate([ 0, 0, 0 ]) + { + cube([ 20.1, 39.9, 36.1 ], false); + translate([ 1.1, -7.6, 26.6 ]) + { + difference() + { + cube([ 18, 7.6, 2.5 ]); + translate([ 4, 3.5, 0 ]) cylinder(100, 2); + translate([ 14, 3.5, 0 ]) cylinder(100, 2); } - } + } - translate([1.1, 39.9, 26.6]) - { - difference() { - cube([18, 7.6, 2.5]); - translate([4, 4.5, 0]) cylinder(100, 2); - translate([14, 4.5, 0]) cylinder(100, 2); + translate([ 1.1, 39.9, 26.6 ]) + { + difference() + { + cube([ 18, 7.6, 2.5 ]); + translate([ 4, 4.5, 0 ]) cylinder(100, 2); + translate([ 14, 4.5, 0 ]) cylinder(100, 2); } } - } + } - // Main axle - translate([10, 30, 36.1]) - { - cylinder(r=6, h=0.4, $fn=30); - cylinder(r=2.5, h=4.9, $fn=20); - } - } - } - } + // Main axle + translate([ 10, 30, 36.1 ]) + { + cylinder(r = 6, h = 0.4, $fn = 30); + cylinder(r = 2.5, h = 4.9, $fn = 20); + } + } + } + } } // Tests: -module test_alignds420(){alignds420(screws=1);} +module +test_alignds420() +{ + alignds420(screws = 1); +} diff --git a/motors/stepper.scad b/motors/stepper.scad index 1c8e5856..291e18d0 100644 --- a/motors/stepper.scad +++ b/motors/stepper.scad @@ -1,15 +1,15 @@ +include +include +include /* * A nema standard stepper motor module. - * + * * Originally by Hans Häggström, 2010. - * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later + * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or + * later */ -include -include -include - -// Parameters: +// Parameters: NemaModel = 0; NemaLengthShort = 1; NemaLengthMedium = 2; @@ -38,138 +38,127 @@ NemaShort = NemaA; NemaMedium = NemaB; NemaLong = NemaC; -// TODO: The small motors seem to be a bit too long, I picked the size specs from all over the place, is there some canonical reference? -Nema08 = [ - [NemaModel, 8], - [NemaLengthShort, 33*length_mm], - [NemaLengthMedium, 43*length_mm], - [NemaLengthLong, 43*length_mm], - [NemaSideSize, 20*length_mm], - [NemaDistanceBetweenMountingHoles, 15.4*length_mm], - [NemaMountingHoleDiameter, 2*length_mm], - [NemaMountingHoleDepth, 1.75*length_mm], - [NemaMountingHoleLip, -1*length_mm], - [NemaMountingHoleCutoutRadius, 0*length_mm], - [NemaEdgeRoundingRadius, 2*length_mm], - [NemaRoundExtrusionDiameter, 16*length_mm], - [NemaRoundExtrusionHeight, 1.5*length_mm], - [NemaAxleDiameter, 4*length_mm], - [NemaFrontAxleLength, 13.5*length_mm], - [NemaBackAxleLength, 9.9*length_mm], - [NemaAxleFlatDepth, -1*length_mm], - [NemaAxleFlatLengthFront, 0*length_mm], - [NemaAxleFlatLengthBack, 0*length_mm] - ]; - -Nema11 = [ - [NemaModel, 11], - [NemaLengthShort, 32*length_mm], - [NemaLengthMedium, 40*length_mm], - [NemaLengthLong, 52*length_mm], - [NemaSideSize, 28*length_mm], - [NemaDistanceBetweenMountingHoles, 23*length_mm], - [NemaMountingHoleDiameter, 2.5*length_mm], - [NemaMountingHoleDepth, 2*length_mm], - [NemaMountingHoleLip, -1*length_mm], - [NemaMountingHoleCutoutRadius, 0*length_mm], - [NemaEdgeRoundingRadius, 2.5*length_mm], - [NemaRoundExtrusionDiameter, 22*length_mm], - [NemaRoundExtrusionHeight, 1.8*length_mm], - [NemaAxleDiameter, 5*length_mm], - [NemaFrontAxleLength, 13.7*length_mm], - [NemaBackAxleLength, 10*length_mm], - [NemaAxleFlatDepth, 0.5*length_mm], - [NemaAxleFlatLengthFront, 10*length_mm], - [NemaAxleFlatLengthBack, 9*length_mm] - ]; - -Nema14 = [ - [NemaModel, 14], - [NemaLengthShort, 26*length_mm], - [NemaLengthMedium, 28*length_mm], - [NemaLengthLong, 34*length_mm], - [NemaSideSize, 35.3*length_mm], - [NemaDistanceBetweenMountingHoles, 26*length_mm], - [NemaMountingHoleDiameter, 3*length_mm], - [NemaMountingHoleDepth, 3.5*length_mm], - [NemaMountingHoleLip, -1*length_mm], - [NemaMountingHoleCutoutRadius, 0*length_mm], - [NemaEdgeRoundingRadius, 5*length_mm], - [NemaRoundExtrusionDiameter, 22*length_mm], - [NemaRoundExtrusionHeight, 1.9*length_mm], - [NemaAxleDiameter, 5*length_mm], - [NemaFrontAxleLength, 18*length_mm], - [NemaBackAxleLength, 10*length_mm], - [NemaAxleFlatDepth, 0.5*length_mm], - [NemaAxleFlatLengthFront, 15*length_mm], - [NemaAxleFlatLengthBack, 9*length_mm] - ]; - -Nema17 = [ - [NemaModel, 17], - [NemaLengthShort, 33*length_mm], - [NemaLengthMedium, 39*length_mm], - [NemaLengthLong, 47*length_mm], - [NemaSideSize, 42.20*length_mm], - [NemaDistanceBetweenMountingHoles, 31.04*length_mm], - [NemaMountingHoleDiameter, 4*length_mm], - [NemaMountingHoleDepth, 4.5*length_mm], - [NemaMountingHoleLip, -1*length_mm], - [NemaMountingHoleCutoutRadius, 0*length_mm], - [NemaEdgeRoundingRadius, 7*length_mm], - [NemaRoundExtrusionDiameter, 22*length_mm], - [NemaRoundExtrusionHeight, 1.9*length_mm], - [NemaAxleDiameter, 5*length_mm], - [NemaFrontAxleLength, 21*length_mm], - [NemaBackAxleLength, 15*length_mm], - [NemaAxleFlatDepth, 0.5*length_mm], - [NemaAxleFlatLengthFront, 15*length_mm], - [NemaAxleFlatLengthBack, 14*length_mm] - ]; - -Nema23 = [ - [NemaModel, 23], - [NemaLengthShort, 39*length_mm], - [NemaLengthMedium, 54*length_mm], - [NemaLengthLong, 76*length_mm], - [NemaSideSize, 56.4*length_mm], - [NemaDistanceBetweenMountingHoles, 47.14*length_mm], - [NemaMountingHoleDiameter, 4.75*length_mm], - [NemaMountingHoleDepth, 5*length_mm], - [NemaMountingHoleLip, 4.95*length_mm], - [NemaMountingHoleCutoutRadius, 9.5*length_mm], - [NemaEdgeRoundingRadius, 2.5*length_mm], - [NemaRoundExtrusionDiameter, 38.10*length_mm], - [NemaRoundExtrusionHeight, 1.52*length_mm], - [NemaAxleDiameter, 6.36*length_mm], - [NemaFrontAxleLength, 18.80*length_mm], - [NemaBackAxleLength, 15.60*length_mm], - [NemaAxleFlatDepth, 0.5*length_mm], - [NemaAxleFlatLengthFront, 16*length_mm], - [NemaAxleFlatLengthBack, 14*length_mm] - ]; - -Nema34 = [ - [NemaModel, 34], - [NemaLengthShort, 66*length_mm], - [NemaLengthMedium, 96*length_mm], - [NemaLengthLong, 126*length_mm], - [NemaSideSize, 85*length_mm], - [NemaDistanceBetweenMountingHoles, 69.58*length_mm], - [NemaMountingHoleDiameter, 6.5*length_mm], - [NemaMountingHoleDepth, 5.5*length_mm], - [NemaMountingHoleLip, 5*length_mm], - [NemaMountingHoleCutoutRadius, 17*length_mm], - [NemaEdgeRoundingRadius, 3*length_mm], - [NemaRoundExtrusionDiameter, 73.03*length_mm], - [NemaRoundExtrusionHeight, 1.9*length_mm], - [NemaAxleDiameter, 0.5*length_inch], - [NemaFrontAxleLength, 37*length_mm], - [NemaBackAxleLength, 34*length_mm], - [NemaAxleFlatDepth, 1.20*length_mm], - [NemaAxleFlatLengthFront, 25*length_mm], - [NemaAxleFlatLengthBack, 25*length_mm] - ]; +// TODO: The small motors seem to be a bit too long, I picked the size specs +// from all over the place, is there some canonical reference? +Nema08 = [[NemaModel, 8], + [NemaLengthShort, 33 * length_mm], + [NemaLengthMedium, 43 * length_mm], + [NemaLengthLong, 43 * length_mm], + [NemaSideSize, 20 * length_mm], + [NemaDistanceBetweenMountingHoles, 15.4 * length_mm], + [NemaMountingHoleDiameter, 2 * length_mm], + [NemaMountingHoleDepth, 1.75 * length_mm], + [NemaMountingHoleLip, -1 * length_mm], + [NemaMountingHoleCutoutRadius, 0 * length_mm], + [NemaEdgeRoundingRadius, 2 * length_mm], + [NemaRoundExtrusionDiameter, 16 * length_mm], + [NemaRoundExtrusionHeight, 1.5 * length_mm], + [NemaAxleDiameter, 4 * length_mm], + [NemaFrontAxleLength, 13.5 * length_mm], + [NemaBackAxleLength, 9.9 * length_mm], + [NemaAxleFlatDepth, -1 * length_mm], + [NemaAxleFlatLengthFront, 0 * length_mm], + [NemaAxleFlatLengthBack, 0 * length_mm]]; + +Nema11 = [[NemaModel, 11], + [NemaLengthShort, 32 * length_mm], + [NemaLengthMedium, 40 * length_mm], + [NemaLengthLong, 52 * length_mm], + [NemaSideSize, 28 * length_mm], + [NemaDistanceBetweenMountingHoles, 23 * length_mm], + [NemaMountingHoleDiameter, 2.5 * length_mm], + [NemaMountingHoleDepth, 2 * length_mm], + [NemaMountingHoleLip, -1 * length_mm], + [NemaMountingHoleCutoutRadius, 0 * length_mm], + [NemaEdgeRoundingRadius, 2.5 * length_mm], + [NemaRoundExtrusionDiameter, 22 * length_mm], + [NemaRoundExtrusionHeight, 1.8 * length_mm], + [NemaAxleDiameter, 5 * length_mm], + [NemaFrontAxleLength, 13.7 * length_mm], + [NemaBackAxleLength, 10 * length_mm], + [NemaAxleFlatDepth, 0.5 * length_mm], + [NemaAxleFlatLengthFront, 10 * length_mm], + [NemaAxleFlatLengthBack, 9 * length_mm]]; + +Nema14 = [[NemaModel, 14], + [NemaLengthShort, 26 * length_mm], + [NemaLengthMedium, 28 * length_mm], + [NemaLengthLong, 34 * length_mm], + [NemaSideSize, 35.3 * length_mm], + [NemaDistanceBetweenMountingHoles, 26 * length_mm], + [NemaMountingHoleDiameter, 3 * length_mm], + [NemaMountingHoleDepth, 3.5 * length_mm], + [NemaMountingHoleLip, -1 * length_mm], + [NemaMountingHoleCutoutRadius, 0 * length_mm], + [NemaEdgeRoundingRadius, 5 * length_mm], + [NemaRoundExtrusionDiameter, 22 * length_mm], + [NemaRoundExtrusionHeight, 1.9 * length_mm], + [NemaAxleDiameter, 5 * length_mm], + [NemaFrontAxleLength, 18 * length_mm], + [NemaBackAxleLength, 10 * length_mm], + [NemaAxleFlatDepth, 0.5 * length_mm], + [NemaAxleFlatLengthFront, 15 * length_mm], + [NemaAxleFlatLengthBack, 9 * length_mm]]; + +Nema17 = [[NemaModel, 17], + [NemaLengthShort, 33 * length_mm], + [NemaLengthMedium, 39 * length_mm], + [NemaLengthLong, 47 * length_mm], + [NemaSideSize, 42.20 * length_mm], + [NemaDistanceBetweenMountingHoles, 31.04 * length_mm], + [NemaMountingHoleDiameter, 4 * length_mm], + [NemaMountingHoleDepth, 4.5 * length_mm], + [NemaMountingHoleLip, -1 * length_mm], + [NemaMountingHoleCutoutRadius, 0 * length_mm], + [NemaEdgeRoundingRadius, 7 * length_mm], + [NemaRoundExtrusionDiameter, 22 * length_mm], + [NemaRoundExtrusionHeight, 1.9 * length_mm], + [NemaAxleDiameter, 5 * length_mm], + [NemaFrontAxleLength, 21 * length_mm], + [NemaBackAxleLength, 15 * length_mm], + [NemaAxleFlatDepth, 0.5 * length_mm], + [NemaAxleFlatLengthFront, 15 * length_mm], + [NemaAxleFlatLengthBack, 14 * length_mm]]; + +Nema23 = [[NemaModel, 23], + [NemaLengthShort, 39 * length_mm], + [NemaLengthMedium, 54 * length_mm], + [NemaLengthLong, 76 * length_mm], + [NemaSideSize, 56.4 * length_mm], + [NemaDistanceBetweenMountingHoles, 47.14 * length_mm], + [NemaMountingHoleDiameter, 4.75 * length_mm], + [NemaMountingHoleDepth, 5 * length_mm], + [NemaMountingHoleLip, 4.95 * length_mm], + [NemaMountingHoleCutoutRadius, 9.5 * length_mm], + [NemaEdgeRoundingRadius, 2.5 * length_mm], + [NemaRoundExtrusionDiameter, 38.10 * length_mm], + [NemaRoundExtrusionHeight, 1.52 * length_mm], + [NemaAxleDiameter, 6.36 * length_mm], + [NemaFrontAxleLength, 18.80 * length_mm], + [NemaBackAxleLength, 15.60 * length_mm], + [NemaAxleFlatDepth, 0.5 * length_mm], + [NemaAxleFlatLengthFront, 16 * length_mm], + [NemaAxleFlatLengthBack, 14 * length_mm]]; + +Nema34 = [[NemaModel, 34], + [NemaLengthShort, 66 * length_mm], + [NemaLengthMedium, 96 * length_mm], + [NemaLengthLong, 126 * length_mm], + [NemaSideSize, 85 * length_mm], + [NemaDistanceBetweenMountingHoles, 69.58 * length_mm], + [NemaMountingHoleDiameter, 6.5 * length_mm], + [NemaMountingHoleDepth, 5.5 * length_mm], + [NemaMountingHoleLip, 5 * length_mm], + [NemaMountingHoleCutoutRadius, 17 * length_mm], + [NemaEdgeRoundingRadius, 3 * length_mm], + [NemaRoundExtrusionDiameter, 73.03 * length_mm], + [NemaRoundExtrusionHeight, 1.9 * length_mm], + [NemaAxleDiameter, 0.5 * length_inch], + [NemaFrontAxleLength, 37 * length_mm], + [NemaBackAxleLength, 34 * length_mm], + [NemaAxleFlatDepth, 1.20 * length_mm], + [NemaAxleFlatLengthFront, 25 * length_mm], + [NemaAxleFlatLengthBack, 25 * length_mm]]; NemaDefinitions = [ -1, @@ -209,128 +198,196 @@ NemaDefinitions = [ Nema34 ]; - -function motorWidth(model=Nema23) = lookup(NemaSideSize, model); -function motorLength(model=Nema23, size=NemaMedium) = lookup(size, model); -function motorScrewSpacing(model=Nema23) = lookup(NemaDistanceBetweenMountingHoles, model); +function motorWidth(model = Nema23) = lookup(NemaSideSize, model); +function motorLength(model = Nema23, size = NemaMedium) = lookup(size, model); +function motorScrewSpacing(model = Nema23) = + lookup(NemaDistanceBetweenMountingHoles, model); function Nema(number) = NemaDefinitions[number]; -module motor(model=Nema23, size=NemaMedium, dualAxis=false, pos=[0,0,0], orientation = [0,0,0]) { - - //motorDef = NemaDefinitions[model]; - //echo(model); - motorDef = model; - echo(motorDef); - length = lookup(size, motorDef); - - echo(str(" Motor: Nema",lookup(NemaModel, motorDef),", length= ",length,"mm, dual axis=",dualAxis)); - - stepperBlack = BlackPaint; - stepperAluminum = Aluminum; - - side = lookup(NemaSideSize, motorDef); - - cutR = lookup(NemaMountingHoleCutoutRadius, motorDef); - lip = lookup(NemaMountingHoleLip, motorDef); - holeDepth = lookup(NemaMountingHoleDepth, motorDef); - - axleLengthFront = lookup(NemaFrontAxleLength, motorDef); - axleLengthBack = lookup(NemaBackAxleLength, motorDef); - axleRadius = lookup(NemaAxleDiameter, motorDef) * 0.5; - - extrSize = lookup(NemaRoundExtrusionHeight, motorDef); - extrRad = lookup(NemaRoundExtrusionDiameter, motorDef) * 0.5; - - holeDist = lookup(NemaDistanceBetweenMountingHoles, motorDef) * 0.5; - holeRadius = lookup(NemaMountingHoleDiameter, motorDef) * 0.5; - - mid = side / 2; - - roundR = lookup(NemaEdgeRoundingRadius, motorDef); - - axleFlatDepth = lookup(NemaAxleFlatDepth, motorDef); - axleFlatLengthFront = lookup(NemaAxleFlatLengthFront, motorDef); - axleFlatLengthBack = lookup(NemaAxleFlatLengthBack, motorDef); - - color(stepperBlack){ - translate(pos) rotate(orientation) { - translate([-mid, -mid, 0]) - difference() { - cube(size=[side, side, length + extrSize]); - - // Corner cutouts - if (lip > 0) { - translate([0, 0, lip]) cylinder(h=length, r=cutR); - translate([side, 0, lip]) cylinder(h=length, r=cutR); - translate([0, side, lip]) cylinder(h=length, r=cutR); - translate([side, side, lip]) cylinder(h=length, r=cutR); - - } - - // Rounded edges - if (roundR > 0) { - translate([mid+mid, mid+mid, length/2]) - rotate([0,0,45]) - cube(size=[roundR, roundR*2, 4+length + extrSize+2], center=true); - translate([mid-(mid), mid+(mid), length/2]) - rotate([0,0,45]) - cube(size=[roundR*2, roundR, 4+length + extrSize+2], center=true); - translate([mid+mid, mid-mid, length/2]) - rotate([0,0,45]) - cube(size=[roundR*2, roundR, 4+length + extrSize+2], center=true); - translate([mid-mid, mid-mid, length/2]) - rotate([0,0,45]) - cube(size=[roundR, roundR*2, 4+length + extrSize+2], center=true); - - } - - // Bolt holes - color(stepperAluminum, $fs=holeRadius/8) { - translate([mid+holeDist,mid+holeDist]) cylinder(h=holeDepth+1*length_mm, r=holeRadius); - translate([mid-holeDist,mid+holeDist]) cylinder(h=holeDepth+1*length_mm, r=holeRadius); - translate([mid+holeDist,mid-holeDist]) cylinder(h=holeDepth+1*length_mm, r=holeRadius); - translate([mid-holeDist,mid-holeDist]) cylinder(h=holeDepth+1*length_mm, r=holeRadius); - - } - - // Grinded flat - color(stepperAluminum) { - difference() { - translate([-1*length_mm, -1*length_mm, -1*length_mm]) - cube(size=[side+2*length_mm, side+2*length_mm, extrSize + 1*length_mm]); - translate([side/2, side/2, -1.1*length_mm]) - cylinder(h=4*length_mm, r=extrRad); +module motor(model = Nema23, + size = NemaMedium, + dualAxis = false, + pos = [ 0, 0, 0 ], + orientation = [ 0, 0, 0 ]) +{ + + // motorDef = NemaDefinitions[model]; + // echo(model); + motorDef = model; + echo(motorDef); + length = lookup(size, motorDef); + + echo(str(" Motor: Nema", + lookup(NemaModel, motorDef), + ", length= ", + length, + "mm, dual axis=", + dualAxis)); + + stepperBlack = BlackPaint; + stepperAluminum = Aluminum; + + side = lookup(NemaSideSize, motorDef); + + cutR = lookup(NemaMountingHoleCutoutRadius, motorDef); + lip = lookup(NemaMountingHoleLip, motorDef); + holeDepth = lookup(NemaMountingHoleDepth, motorDef); + + axleLengthFront = lookup(NemaFrontAxleLength, motorDef); + axleLengthBack = lookup(NemaBackAxleLength, motorDef); + axleRadius = lookup(NemaAxleDiameter, motorDef) * 0.5; + + extrSize = lookup(NemaRoundExtrusionHeight, motorDef); + extrRad = lookup(NemaRoundExtrusionDiameter, motorDef) * 0.5; + + holeDist = lookup(NemaDistanceBetweenMountingHoles, motorDef) * 0.5; + holeRadius = lookup(NemaMountingHoleDiameter, motorDef) * 0.5; + + mid = side / 2; + + roundR = lookup(NemaEdgeRoundingRadius, motorDef); + + axleFlatDepth = lookup(NemaAxleFlatDepth, motorDef); + axleFlatLengthFront = lookup(NemaAxleFlatLengthFront, motorDef); + axleFlatLengthBack = lookup(NemaAxleFlatLengthBack, motorDef); + + color(stepperBlack) + { + translate(pos) rotate(orientation) + { + translate([ -mid, -mid, 0 ]) difference() + { + cube(size = [ side, side, length + extrSize ]); + + // Corner cutouts + if (lip > 0) { + translate([ 0, 0, lip ]) cylinder(h = length, r = cutR); + translate([ side, 0, lip ]) cylinder(h = length, r = cutR); + translate([ 0, side, lip ]) cylinder(h = length, r = cutR); + translate([ side, side, lip ]) + cylinder(h = length, r = cutR); + } + + // Rounded edges + if (roundR > 0) { + translate([ mid + mid, mid + mid, length / 2 ]) + rotate([ 0, 0, 45 ]) + cube(size = + [ + roundR, + roundR * 2, + 4 + length + extrSize + 2 + ], + center = true); + translate([ mid - (mid), mid + (mid), length / 2 ]) + rotate([ 0, 0, 45 ]) + cube(size = + [ + roundR * 2, + roundR, + 4 + length + extrSize + 2 + ], + center = true); + translate([ mid + mid, mid - mid, length / 2 ]) + rotate([ 0, 0, 45 ]) + cube(size = + [ + roundR * 2, + roundR, + 4 + length + extrSize + 2 + ], + center = true); + translate([ mid - mid, mid - mid, length / 2 ]) + rotate([ 0, 0, 45 ]) + cube(size = + [ + roundR, + roundR * 2, + 4 + length + extrSize + 2 + ], + center = true); + } + + // Bolt holes + color(stepperAluminum, $fs = holeRadius / 8) + { + translate([ mid + holeDist, mid + holeDist ]) + cylinder(h = holeDepth + 1 * length_mm, r = holeRadius); + translate([ mid - holeDist, mid + holeDist ]) + cylinder(h = holeDepth + 1 * length_mm, r = holeRadius); + translate([ mid + holeDist, mid - holeDist ]) + cylinder(h = holeDepth + 1 * length_mm, r = holeRadius); + translate([ mid - holeDist, mid - holeDist ]) + cylinder(h = holeDepth + 1 * length_mm, r = holeRadius); + } + + // Grinded flat + color(stepperAluminum) + { + difference() + { + translate( + [ -1 * length_mm, -1 * length_mm, -1 * length_mm ]) + cube(size = [ + side + 2 * length_mm, + side + 2 * length_mm, + extrSize + 1 * + length_mm + ]); + translate([ side / 2, side / 2, -1.1 * length_mm ]) + cylinder(h = 4 * length_mm, r = extrRad); + } + } } - } - - } - - // Axle - translate([0, 0, extrSize-axleLengthFront]) color(stepperAluminum) - difference() { - - cylinder(h=axleLengthFront + 1*length_mm , r=axleRadius, $fs=axleRadius/10); - - // Flat - if (axleFlatDepth > 0) - translate([axleRadius - axleFlatDepth,-5*length_mm,-extrSize*length_mm -(axleLengthFront-axleFlatLengthFront)] ) cube(size=[5*length_mm, 10*length_mm, axleLengthFront]); - } - - if (dualAxis) { - translate([0, 0, length+extrSize]) color(stepperAluminum) - difference() { - - cylinder(h=axleLengthBack + 0*length_mm, r=axleRadius, $fs=axleRadius/10); - // Flat - if (axleFlatDepth > 0) - translate([axleRadius - axleFlatDepth,-5*length_mm,(axleLengthBack-axleFlatLengthBack)]) cube(size=[5*length_mm, 10*length_mm, axleLengthBack]); - } + // Axle + translate([ 0, 0, extrSize - axleLengthFront ]) + color(stepperAluminum) difference() + { + + cylinder(h = axleLengthFront + 1 * length_mm, + r = axleRadius, + $fs = axleRadius / 10); + + // Flat + if (axleFlatDepth > 0) + translate([ + axleRadius - axleFlatDepth, + -5 * length_mm, + -extrSize * length_mm - + (axleLengthFront - axleFlatLengthFront) + ]) + cube(size = [ + 5 * length_mm, + 10 * length_mm, + axleLengthFront + ]); + } + if (dualAxis) { + translate([ 0, 0, length + extrSize ]) color(stepperAluminum) + difference() + { + + cylinder(h = axleLengthBack + 0 * length_mm, + r = axleRadius, + $fs = axleRadius / 10); + + // Flat + if (axleFlatDepth > 0) + translate([ + axleRadius - axleFlatDepth, + -5 * length_mm, + (axleLengthBack - axleFlatLengthBack) + ]) + cube(size = [ + 5 * length_mm, + 10 * length_mm, + axleLengthBack + ]); + } + } } - } - } } - diff --git a/motors/stepper_mount.scad b/motors/stepper_mount.scad index 419c111e..fbd82499 100644 --- a/motors/stepper_mount.scad +++ b/motors/stepper_mount.scad @@ -1,4 +1,5 @@ -// stepper twist mount + +// stepper twist mount // tigger@interthingy.com // 201029061241 @@ -11,11 +12,10 @@ // 3 - interference check // 4 - single stl -mode = 4; +mode = 4; // variables -nema = 17; - +nema = 17; bolt = 3; size = 42; @@ -29,245 +29,257 @@ clip_depth = 15; clip_thickness = 4; slot_height = 15; -clip_count = 6; - -//extras +clip_count = 6; +// extras overlap = 0.1; clearance = 0.1; -inc = 360/clip_count; +inc = 360 / clip_count; splitter = 150; -module pip() +module +pip() { - inc = 360/(2*clip_count); - clip_rad = boss_radius+clip_thickness/2-clip_thickness/2; - difference() - { - translate([boss_radius+clip_thickness/2,0,clearance]) - cylinder(h=slot_height-2*clearance,r=clip_thickness/2-clearance/2); - translate([0,0,-boss_radius-clip_thickness+slot_height-clearance]) - cylinder(h=boss_radius+clip_thickness+overlap,r1=0,r2=boss_radius+clip_thickness); - translate([0,0,clearance]) - cylinder(h=boss_radius+clip_thickness+overlap*2,r2=0,r1=boss_radius+clip_thickness); - } + inc = 360 / (2 * clip_count); + clip_rad = boss_radius + clip_thickness / 2 - clip_thickness / 2; + difference() + { + translate([ boss_radius + clip_thickness / 2, 0, clearance ]) + cylinder(h = slot_height - 2 * clearance, + r = clip_thickness / 2 - clearance / 2); + translate( + [ 0, 0, -boss_radius - clip_thickness + slot_height - clearance ]) + cylinder(h = boss_radius + clip_thickness + overlap, + r1 = 0, + r2 = boss_radius + clip_thickness); + translate([ 0, 0, clearance ]) + cylinder(h = boss_radius + clip_thickness + overlap * 2, + r2 = 0, + r1 = boss_radius + clip_thickness); + } } -module slot() +module +slot() { - inc = 360/(2*clip_count); - clip_rad = boss_radius+clip_thickness/2-clip_thickness/2; - difference() - { - rotate([0,0,inc]) - translate([boss_radius+clip_thickness/2,0,0]) - cylinder(h=slot_height-overlap,r=clip_thickness/2); - union() - { - translate([0,0,-boss_radius-clip_thickness+slot_height+overlap]) - cylinder(h=boss_radius+clip_thickness,r1=0,r2=boss_radius+clip_thickness); - translate([0,0,-overlap]) - cylinder(h=boss_radius+clip_thickness+overlap*2,r2=0,r1=boss_radius+clip_thickness); - } - } - difference() - { - union() - { - translate([boss_radius+clip_thickness/2,0,0]) - cylinder(h=clip_depth+overlap,r=clip_thickness/2); - intersection() - { - intersection() - { - rotate(-90,[0,0,1]) - rotate(inc,[0,0,1]) - cube(size=boss_radius*4); - cube(size=boss_radius*4); - - } - difference() - { - cylinder(h=slot_height,r=boss_radius+clip_thickness+overlap); - translate([0,0,-overlap]) - cylinder(h=slot_height+overlap*2, r=clip_rad); - translate([0,0,-boss_radius-clip_thickness+slot_height+overlap]) - cylinder(h=boss_radius+clip_thickness,r1=0,r2=boss_radius+clip_thickness); - } - } - } - translate([0,0,-overlap]) - cylinder(h=boss_radius+clip_thickness+overlap*2,r2=0,r1=boss_radius+clip_thickness); - } + inc = 360 / (2 * clip_count); + clip_rad = boss_radius + clip_thickness / 2 - clip_thickness / 2; + difference() + { + rotate([ 0, 0, inc ]) + translate([ boss_radius + clip_thickness / 2, 0, 0 ]) + cylinder(h = slot_height - overlap, r = clip_thickness / 2); + union() + { + translate( + [ 0, 0, -boss_radius - clip_thickness + slot_height + overlap ]) + cylinder(h = boss_radius + clip_thickness, + r1 = 0, + r2 = boss_radius + clip_thickness); + translate([ 0, 0, -overlap ]) + cylinder(h = boss_radius + clip_thickness + overlap * 2, + r2 = 0, + r1 = boss_radius + clip_thickness); + } + } + difference() + { + union() + { + translate([ boss_radius + clip_thickness / 2, 0, 0 ]) + cylinder(h = clip_depth + overlap, r = clip_thickness / 2); + intersection() + { + intersection() + { + rotate(-90, [ 0, 0, 1 ]) rotate(inc, [ 0, 0, 1 ]) + cube(size = boss_radius * 4); + cube(size = boss_radius * 4); + } + difference() + { + cylinder(h = slot_height, + r = boss_radius + clip_thickness + overlap); + translate([ 0, 0, -overlap ]) + cylinder(h = slot_height + overlap * 2, r = clip_rad); + translate([ + 0, + 0, + -boss_radius - clip_thickness + slot_height + + overlap + ]) cylinder(h = boss_radius + clip_thickness, + r1 = 0, + r2 = boss_radius + clip_thickness); + } + } + } + translate([ 0, 0, -overlap ]) + cylinder(h = boss_radius + clip_thickness + overlap * 2, + r2 = 0, + r1 = boss_radius + clip_thickness); + } } -module pips() +module +pips() { - inc = 360/clip_count; - for ( z = [1:clip_count]) - { - rotate(z*inc,[0,0,1]) - pip(); - } + inc = 360 / clip_count; + for (z = [1:clip_count]) { + rotate(z * inc, [ 0, 0, 1 ]) pip(); + } } -module slots() +module +slots() { - inc = 360/clip_count; - for ( z = [1:clip_count]) - { - rotate(z*inc,[0,0,1]) - slot(); - } + inc = 360 / clip_count; + for (z = [1:clip_count]) { + rotate(z * inc, [ 0, 0, 1 ]) slot(); + } } -module bolt_hole() +module +bolt_hole() { - union() - { - cylinder(h=base_thickness*10,r=bolt/2,center=true); -// translate([0,0,base_thickness*2]) -// cylinder(h=base_thickness*10,r=bolt,center=false); - } + union() + { + cylinder(h = base_thickness * 10, r = bolt / 2, center = true); + // translate([0,0,base_thickness*2]) + // cylinder(h=base_thickness*10,r=bolt,center=false); + } } -module holes() +module +holes() { - union() - { - // bolt holes - translate([hole_size/2,hole_size/2,-2*base_thickness]) - bolt_hole(); - translate([hole_size/2,-hole_size/2,-2*base_thickness]) - bolt_hole(); - translate([-hole_size/2,-hole_size/2,-2*base_thickness]) - bolt_hole(); - translate([-hole_size/2,hole_size/2,-2*base_thickness]) - bolt_hole(); - - // center hole - cylinder(h = base_thickness+3*mount_height , r = inner_hole_radius, center=true); - } + union() + { + // bolt holes + translate([ hole_size / 2, hole_size / 2, -2 * base_thickness ]) + bolt_hole(); + translate([ hole_size / 2, -hole_size / 2, -2 * base_thickness ]) + bolt_hole(); + translate([ -hole_size / 2, -hole_size / 2, -2 * base_thickness ]) + bolt_hole(); + translate([ -hole_size / 2, hole_size / 2, -2 * base_thickness ]) + bolt_hole(); + + // center hole + cylinder(h = base_thickness + 3 * mount_height, + r = inner_hole_radius, + center = true); + } } -module socket_base() +module +socket_base() { - union() - { - difference() - { - cylinder(h=mount_height-clearance,r=boss_radius+clip_thickness); - cylinder(h=mount_height-clearance,r=boss_radius+clip_thickness/2+clearance/2); - } - translate([0,0,(clip_depth-slot_height)]) - rotate([0,0,inc/2]) - pips(); - } + union() + { + difference() + { + cylinder(h = mount_height - clearance, + r = boss_radius + clip_thickness); + cylinder(h = mount_height - clearance, + r = boss_radius + clip_thickness / 2 + clearance / 2); + } + translate([ 0, 0, (clip_depth - slot_height) ]) + rotate([ 0, 0, inc / 2 ]) pips(); + } } -module twist_base() +module +twist_base() { - union() - { - difference() - { - translate([0,0,-overlap]) - cylinder(h=mount_height+overlap,r=boss_radius+clip_thickness/2); - union() - { - translate([0,0,mount_height-clip_depth]) - slots(); - } - } - } + union() + { + difference() + { + translate([ 0, 0, -overlap ]) + cylinder(h = mount_height + overlap, + r = boss_radius + clip_thickness / 2); + union() { translate([ 0, 0, mount_height - clip_depth ]) slots(); } + } + } } -module base() +module +base() { - - difference() - { - union() - { - translate([0,0,base_thickness/2]) - cube( size = [size,size,base_thickness] , center = true); - translate([0,0,base_thickness]) - twist_base(); - } - holes(); - } + + difference() + { + union() + { + translate([ 0, 0, base_thickness / 2 ]) + cube(size = [ size, size, base_thickness ], center = true); + translate([ 0, 0, base_thickness ]) twist_base(); + } + holes(); + } } -module socket() +module +socket() { - difference() - { - union() - { - translate([0,0,base_thickness/2]) - cube( size = [size,size,base_thickness] , center = true); - translate([0,0,base_thickness]) - socket_base(); - } - holes(); - } + difference() + { + union() + { + translate([ 0, 0, base_thickness / 2 ]) + cube(size = [ size, size, base_thickness ], center = true); + translate([ 0, 0, base_thickness ]) socket_base(); + } + holes(); + } } -module placed_socket() +module +placed_socket() { - translate([0,0,2*base_thickness+mount_height]) - rotate([0,180,0]) + translate([ 0, 0, 2 * base_thickness + mount_height ]) rotate([ 0, 180, 0 ]) - socket(); + socket(); } -module splitter() +module +splitter() { - // for checking internal layout - translate([0,-splitter/2,-splitter/2]) - cube(splitter); + // for checking internal layout + translate([ 0, -splitter / 2, -splitter / 2 ]) cube(splitter); } -// modal display +// modal display -if ( mode == 0) -{ - base(); +if (mode == 0) { + base(); } -if (mode == 1) -{ - socket(); +if (mode == 1) { + socket(); } -if ( mode == 2) -{ - rotate([0,0,inc/2]) - difference() - { - placed_socket(); - //socket(); - rotate([0,0,inc/2]) - splitter(); - } - base(); +if (mode == 2) { + rotate([ 0, 0, inc / 2 ]) difference() + { + placed_socket(); + // socket(); + rotate([ 0, 0, inc / 2 ]) splitter(); + } + base(); } -if (mode == 3) -{ - intersection() - { - placed_socket(); - base(); - } +if (mode == 3) { + intersection() + { + placed_socket(); + base(); + } } -if( mode == 4) -{ - translate([size/2+5,0,0]) - socket(); - translate([-size/2-5,0,0]) - base(); +if (mode == 4) { + translate([ size / 2 + 5, 0, 0 ]) socket(); + translate([ -size / 2 - 5, 0, 0 ]) base(); } \ No newline at end of file diff --git a/multiply.scad b/multiply.scad index 8c214f4a..991e0709 100644 --- a/multiply.scad +++ b/multiply.scad @@ -1,25 +1,22 @@ -include use - +include /** * @deprecated * Evenly place children `no` number of times around `axis` for `angle / 360` * turns, */ -module spin (no, angle = 360, axis = Z) +module spin(no, angle = 360, axis = Z) { - mcad_rotate_multiply (no, angle / no, axis) - children (); + mcad_rotate_multiply(no, angle / no, axis) children(); } /** * @deprecated * Duplicate by rotating a copy 180° around `axis` */ -module duplicate (axis = Z) +module duplicate(axis = Z) { - mcad_duplicate (axis = axis) - children (); + mcad_duplicate(axis = axis) children(); } /** @@ -27,8 +24,8 @@ module duplicate (axis = Z) * Evenly multiply children `no` times by translating by `separation` distance * along `axis`. */ -module linear_multiply (no, separation, axis = Z) +module linear_multiply(no, separation, axis = Z) { - mcad_linear_multiply (no = no, separation = separation, axis = axis) - children (); + mcad_linear_multiply(no = no, separation = separation, axis = axis) + children(); } diff --git a/nuts_and_bolts.scad b/nuts_and_bolts.scad index 6612289e..027fc0d0 100644 --- a/nuts_and_bolts.scad +++ b/nuts_and_bolts.scad @@ -1,22 +1,22 @@ -// THIS IS A BACKWARD COMPATIBILITY SHIM - include +// THIS IS A BACKWARD COMPATIBILITY SHIM // @deprecated -module SKIPtestNutsAndBolts () +module +SKIPtestNutsAndBolts() { - mcad_test_nuts_and_bolts_1 (); + mcad_test_nuts_and_bolts_1(); } // @deprecated -module nutHole (size, units = MM, tolerance = +0.0001, proj = -1) +module nutHole(size, units = MM, tolerance = +0.0001, proj = -1) { - mcad_nut_hole (size = size, tolerance = tolerance, proj = proj); + mcad_nut_hole(size = size, tolerance = tolerance, proj = proj); } // @deprecated -module boltHole (size, units = MM, length, tolerance = +0.0001, proj = -1) +module boltHole(size, units = MM, length, tolerance = +0.0001, proj = -1) { - mcad_bolt_hole (size = size, length = length, tolerance = tolerance, - proj = proj); + mcad_bolt_hole( + size = size, length = length, tolerance = tolerance, proj = proj); } diff --git a/oshw.scad b/oshw.scad index c906f682..cbbcd619 100644 --- a/oshw.scad +++ b/oshw.scad @@ -1,3 +1,4 @@ + // OSHW Logo Generator // Open Source Hardware Logo : http://oshwlogo.com/ // ------------------------------------------------- @@ -11,31 +12,39 @@ // // cc-by-sa, pierre-alain dorange, july 2012 -module gear_tooth_2d(d) { - polygon( points=[ - [0.0,10.0*d/72.0], [0.5*d,d/15.0], - [0.5*d,-d/15.0], [0.0,-10.0*d/72.0] ] ); +module gear_tooth_2d(d) +{ + polygon(points = [ + [ 0.0, 10.0 * d / 72.0 ], + [ 0.5 * d, d / 15.0 ], + [ 0.5 * d, -d / 15.0 ], + [ 0.0, -10.0 * d / 72.0 ] + ]); } -module oshw_logo_2d(d=10.0) { - rotate(-135) { - difference() { - union() { - circle(r=14.0*d/36.0,$fn=20); - for(i=[1:7]) assign(rotAngle=45*i+45) - rotate(rotAngle) gear_tooth_2d(d); - } - circle(r=10.0*d/72.0,$fn=20); - intersection() { - rotate(-20) square(size=[10.0*d/18.0,10.0*d/18.0]); - rotate(20) square(size=[10.0*d/18.0,10.0*d/18.0]); - } - } - } +module oshw_logo_2d(d = 10.0) +{ + rotate(-135) + { + difference() + { + union() + { + circle(r = 14.0 * d / 36.0, $fn = 20); + for (i = [1:7]) + assign(rotAngle = 45 * i + 45) rotate(rotAngle) + gear_tooth_2d(d); + } + circle(r = 10.0 * d / 72.0, $fn = 20); + intersection() + { + rotate(-20) square(size = [ 10.0 * d / 18.0, 10.0 * d / 18.0 ]); + rotate(20) square(size = [ 10.0 * d / 18.0, 10.0 * d / 18.0 ]); + } + } + } } // usage : oshw_logo_2d(diameter) -linear_extrude(height=2) - oshw_logo_2d(25); - +linear_extrude(height = 2) oshw_logo_2d(25); diff --git a/polyhole.scad b/polyhole.scad index 60029ac7..dec22e4f 100644 --- a/polyhole.scad +++ b/polyhole.scad @@ -1,5 +1,3 @@ use - // @deprecated -module polyhole (h, d) -mcad_polyhole (d, (h < 0) ? undef : h); +module polyhole(h, d) mcad_polyhole(d, (h < 0) ? undef : h); diff --git a/rounder.scad b/rounder.scad index 53304b02..7cde1b3a 100644 --- a/rounder.scad +++ b/rounder.scad @@ -1 +1 @@ -use +use \ No newline at end of file diff --git a/screw.scad b/screw.scad index eb444ec0..0e0db495 100644 --- a/screw.scad +++ b/screw.scad @@ -1,9 +1,8 @@ +include // Parametric screw-like things (ball screws, augers) // License: GNU LGPL 2.1 or later. // © 2010 by Elmo Mäntynen -include - /* common screw parameter length pitch = length/rotations: the distance between the turns of the thread @@ -11,54 +10,83 @@ outside_diameter inner_diameter: thickness of the shaft */ -//Uncomment to see examples -//test_auger(); -//test_ball_groove(); -//test_ball_groove2(); -//test_ball_screw(); +// Uncomment to see examples +// test_auger(); +// test_ball_groove(); +// test_ball_groove2(); +// test_ball_screw(); -module helix(pitch, length, slices=500){ - rotations = length/pitch; - linear_extrude(height=length, center=false, convexity=10, twist=360*rotations, slices=slices, $fn=100) - child(0); +module helix(pitch, length, slices = 500) +{ + rotations = length / pitch; + linear_extrude(height = length, + center = false, + convexity = 10, + twist = 360 * rotations, + slices = slices, + $fn = 100) child(0); } -module auger(pitch, length, outside_radius, inner_radius, taper_ratio = 0.25) { - union(){ - helix(pitch, length) - polygon(points=[[0,inner_radius],[outside_radius,(inner_radius * taper_ratio)],[outside_radius,(inner_radius * -1 * taper_ratio)],[0,(-1 * inner_radius)]], paths=[[0,1,2,3]]); - cylinder(h=length, r=inner_radius); +module auger(pitch, length, outside_radius, inner_radius, taper_ratio = 0.25) +{ + union() + { + helix(pitch, length) polygon( + points = + [ + [ 0, inner_radius ], + [ outside_radius, (inner_radius * taper_ratio) ], + [ outside_radius, (inner_radius * -1 * taper_ratio) ], + [ 0, (-1 * inner_radius) ] + ], + paths = [[ 0, 1, 2, 3 ]]); + cylinder(h = length, r = inner_radius); } } -module test_auger(){translate([50, 0, 0]) auger(40, 80, 25, 5);} - +module +test_auger() +{ + translate([ 50, 0, 0 ]) auger(40, 80, 25, 5); +} -module ball_groove(pitch, length, diameter, ball_radius=10) { - helix(pitch, length, slices=100) - translate([diameter, 0, 0]) +module ball_groove(pitch, length, diameter, ball_radius = 10) +{ + helix(pitch, length, slices = 100) translate([ diameter, 0, 0 ]) circle(r = ball_radius); } -module test_ball_groove(){ translate([0, 300, 0]) ball_groove(100, 300, 10);} +module +test_ball_groove() +{ + translate([ 0, 300, 0 ]) ball_groove(100, 300, 10); +} -module ball_groove2(pitch, length, diameter, ball_radius, slices=200){ - rotations = length/pitch; - radius=diameter/2; - offset = length/slices; - union(){ +module ball_groove2(pitch, length, diameter, ball_radius, slices = 200) +{ + rotations = length / pitch; + radius = diameter / 2; + offset = length / slices; + union() + { for (i = [0:slices]) { - assign (z = i*offset){ - translate(helix_curve(pitch, radius, z)) sphere(ball_radius, $fa=5, $fs=1); + assign(z = i * offset) + { + translate(helix_curve(pitch, radius, z)) + sphere(ball_radius, $fa = 5, $fs = 1); } } } } -module test_ball_groove2(){translate([0, 0, 0]) ball_groove2(100, 300, 100, 10);} - -module ball_screw(pitch, length, bearing_radius=2) { - +module +test_ball_groove2() +{ + translate([ 0, 0, 0 ]) ball_groove2(100, 300, 100, 10); } -module test_ball_screw(){} +module ball_screw(pitch, length, bearing_radius = 2) {} + +module +test_ball_screw() +{} diff --git a/shapes/2Dshapes.scad b/shapes/2Dshapes.scad index d7b4cdb1..32f7e83a 100644 --- a/shapes/2Dshapes.scad +++ b/shapes/2Dshapes.scad @@ -1,282 +1,322 @@ + /* * OpenSCAD 2D Shapes Library (www.openscad.org) * Copyright (C) 2012 Peter Uithoven * * License: LGPL 2.1 or later -*/ + */ // 2D Shapes -//ngon(sides, radius, center=false); -//complexRoundSquare(size,rads1=[0,0], rads2=[0,0], rads3=[0,0], rads4=[0,0], center=true) -//roundedSquare(pos=[10,10],r=2) -//csquare(size, center = false) -//trapezoid (bottom, height, top = undef, left_angle = undef, right_angle = undef) +// ngon(sides, radius, center=false); +// complexRoundSquare(size,rads1=[0,0], rads2=[0,0], rads3=[0,0], rads4=[0,0], +// center=true) roundedSquare(pos=[10,10],r=2) csquare(size, center = false) +// trapezoid (bottom, height, top = undef, left_angle = undef, right_angle = +// undef) -//ring(inside_diameter, thickness) -//ellipse(width, height) -//ellipsePart(width,height,numQuarters) -//egg_outline(width, length) +// ring(inside_diameter, thickness) +// ellipse(width, height) +// ellipsePart(width,height,numQuarters) +// egg_outline(width, length) -//donutSlice(innerSize,outerSize, start_angle, end_angle) -//pieSlice(size, start_angle, end_angle) //size in radius(es) +// donutSlice(innerSize,outerSize, start_angle, end_angle) +// pieSlice(size, start_angle, end_angle) //size in radius(es) // Examples /*use ; grid(105,105,true,4) { - // ellipse - ellipse(50,75); - - // part of ellipse (a number of quarters) - ellipsePart(50,75,3); - ellipsePart(50,75,2); - ellipsePart(50,75,1); - - // complexRoundSquare examples - complexRoundSquare([75,100],[20,10],[20,10],[20,10],[20,10]); - complexRoundSquare([75,100],[0,0],[0,0],[30,50],[20,10]); - complexRoundSquare([50,50],[10,20],[10,20],[10,20],[10,20],false); - complexRoundSquare([100,100]); - complexRoundSquare([100,100],rads1=[20,20],rads3=[20,20]); - - // pie slice - pieSlice(50,0,10); - pieSlice(50,45,190); - pieSlice([50,20],180,270); - - // donut slice - donutSlice(20,50,0,350); - donutSlice(30,50,190,270); - donutSlice([40,22],[50,30],180,270); - donutSlice([50,20],50,180,270); - donutSlice([20,30],[50,40],0,270); + // ellipse + ellipse(50,75); + + // part of ellipse (a number of quarters) + ellipsePart(50,75,3); + ellipsePart(50,75,2); + ellipsePart(50,75,1); + + // complexRoundSquare examples + complexRoundSquare([75,100],[20,10],[20,10],[20,10],[20,10]); + complexRoundSquare([75,100],[0,0],[0,0],[30,50],[20,10]); + complexRoundSquare([50,50],[10,20],[10,20],[10,20],[10,20],false); + complexRoundSquare([100,100]); + complexRoundSquare([100,100],rads1=[20,20],rads3=[20,20]); + + // pie slice + pieSlice(50,0,10); + pieSlice(50,45,190); + pieSlice([50,20],180,270); + + // donut slice + donutSlice(20,50,0,350); + donutSlice(30,50,190,270); + donutSlice([40,22],[50,30],180,270); + donutSlice([50,20],50,180,270); + donutSlice([20,30],[50,40],0,270); }*/ //---------------------- // Regular 2D shapes // The orientation might change with the implementation of circle... -module ngon(sides, radius, center=false){ - rotate([0, 0, 360/sides/2]) circle(r=radius, $fn=sides, center=center); +module ngon(sides, radius, center = false) +{ + rotate([ 0, 0, 360 / sides / 2 ]) + circle(r = radius, $fn = sides, center = center); } // 2D regular shapes -module reg_polygon(sides, radius, center=false) +module reg_polygon(sides, radius, center = false) { - function dia(r) = sqrt(pow(r*2,2)/2); //sqrt((r*2^2)/2) if only we had an exponention op - if(sides<2) square([radius,0]); - if(sides==3) triangle(radius); - if(sides==4) square([dia(radius),dia(radius)],center=true); - if(sides>4) circle(r=radius,$fn=sides,center=center); + function dia(r) = sqrt( + pow(r * 2, 2) / 2); // sqrt((r*2^2)/2) if only we had an exponention op + if (sides < 2) + square([ radius, 0 ]); + if (sides == 3) + triangle(radius); + if (sides == 4) + square([ dia(radius), dia(radius) ], center = true); + if (sides > 4) + circle(r = radius, $fn = sides, center = center); } module pentagon(radius) { - reg_polygon(5,radius); + reg_polygon(5, radius); } module hexagon(radius) { - reg_polygon(6,radius); + reg_polygon(6, radius); } module heptagon(radius) { - reg_polygon(7,radius); + reg_polygon(7, radius); } module octagon(radius) { - reg_polygon(8,radius); + reg_polygon(8, radius); } module nonagon(radius) { - reg_polygon(9,radius); + reg_polygon(9, radius); } module decagon(radius) { - reg_polygon(10,radius); + reg_polygon(10, radius); } module hendecagon(radius) { - reg_polygon(11,radius); + reg_polygon(11, radius); } module dodecagon(radius) { - reg_polygon(12,radius); + reg_polygon(12, radius); } -// size, top left radius, top right radius, bottom right radius, bottom left radius, center -module complexRoundSquare(size,rads1=[0,0], rads2=[0,0], rads3=[0,0], rads4=[0,0], center=true) +// size, top left radius, top right radius, bottom right radius, bottom left +// radius, center +module complexRoundSquare(size, + rads1 = [ 0, 0 ], + rads2 = [ 0, 0 ], + rads3 = [ 0, 0 ], + rads4 = [ 0, 0 ], + center = true) { - width = size[0]; - height = size[1]; - //%square(size=[width, height],center=true); - x1 = 0-width/2+rads1[0]; - y1 = 0-height/2+rads1[1]; - x2 = width/2-rads2[0]; - y2 = 0-height/2+rads2[1]; - x3 = width/2-rads3[0]; - y3 = height/2-rads3[1]; - x4 = 0-width/2+rads4[0]; - y4 = height/2-rads4[1]; - - scs = 0.1; //straight corner size - - x = (center)? 0: width/2; - y = (center)? 0: height/2; - - translate([x,y,0]) - { - hull() { - // top left - if(rads1[0] > 0 && rads1[1] > 0) - translate([x1,y1]) mirror([1,0]) ellipsePart(rads1[0]*2,rads1[1]*2,1); - else - translate([x1,y1]) square(size=[scs, scs]); - - // top right - if(rads2[0] > 0 && rads2[1] > 0) - translate([x2,y2]) ellipsePart(rads2[0]*2,rads2[1]*2,1); - else - translate([width/2-scs,0-height/2]) square(size=[scs, scs]); - - // bottom right - if(rads3[0] > 0 && rads3[1] > 0) - translate([x3,y3]) mirror([0,1]) ellipsePart(rads3[0]*2,rads3[1]*2,1); - else - translate([width/2-scs,height/2-scs]) square(size=[scs, scs]); - - // bottom left - if(rads4[0] > 0 && rads4[1] > 0) - translate([x4,y4]) rotate([0,0,-180]) ellipsePart(rads4[0]*2,rads4[1]*2,1); - else - #translate([x4,height/2-scs]) square(size=[scs, scs]); - } - } + width = size[0]; + height = size[1]; + //%square(size=[width, height],center=true); + x1 = 0 - width / 2 + rads1[0]; + y1 = 0 - height / 2 + rads1[1]; + x2 = width / 2 - rads2[0]; + y2 = 0 - height / 2 + rads2[1]; + x3 = width / 2 - rads3[0]; + y3 = height / 2 - rads3[1]; + x4 = 0 - width / 2 + rads4[0]; + y4 = height / 2 - rads4[1]; + + scs = 0.1; // straight corner size + + x = (center) ? 0 : width / 2; + y = (center) ? 0 : height / 2; + + translate([ x, y, 0 ]) + { + hull() + { + // top left + if (rads1[0] > 0 && rads1[1] > 0) + translate([ x1, y1 ]) mirror([ 1, 0 ]) + ellipsePart(rads1[0] * 2, rads1[1] * 2, 1); + else + translate([ x1, y1 ]) square(size = [ scs, scs ]); + + // top right + if (rads2[0] > 0 && rads2[1] > 0) + translate([ x2, y2 ]) + ellipsePart(rads2[0] * 2, rads2[1] * 2, 1); + else + translate([ width / 2 - scs, 0 - height / 2 ]) + square(size = [ scs, scs ]); + + // bottom right + if (rads3[0] > 0 && rads3[1] > 0) + translate([ x3, y3 ]) mirror([ 0, 1 ]) + ellipsePart(rads3[0] * 2, rads3[1] * 2, 1); + else + translate([ width / 2 - scs, height / 2 - scs ]) + square(size = [ scs, scs ]); + + // bottom left + if (rads4[0] > 0 && rads4[1] > 0) + translate([ x4, y4 ]) rotate([ 0, 0, -180 ]) + ellipsePart(rads4[0] * 2, rads4[1] * 2, 1); + else +#translate([ x4, height / 2 - scs ]) square(size = [ scs, scs ]); + } + } } -module roundedSquare(pos=[10,10],r=2) { - minkowski() { - square([pos[0]-r*2,pos[1]-r*2],center=true); - circle(r=r); - } +module roundedSquare(pos = [ 10, 10 ], r = 2) +{ + minkowski() + { + square([ pos[0] - r * 2, pos[1] - r * 2 ], center = true); + circle(r = r); + } } -module csquare (size, center = false) +module csquare(size, center = false) { - center = (len (center) == undef) ? [center, center] : center; - size = (len (size) == undef) ? [size, size] : size; + center = (len(center) == undef) ? [ center, center ] : center; + size = (len(size) == undef) ? [ size, size ] : size; - function get_offset (i) = center[i] ? - size[i] / 2 : 0; + function get_offset(i) = center[i] ? -size[i] / 2 : 0; - translate ([get_offset (0), get_offset (1)]) - square (size); + translate([ get_offset(0), get_offset(1) ]) square(size); } module triangle(radius) { - o=radius/2; //equivalent to radius*sin(30) - a=radius*sqrt(3)/2; //equivalent to radius*cos(30) - polygon(points=[[-a,-o],[0,radius],[a,-o]],paths=[[0,1,2]]); + o = radius / 2; // equivalent to radius*sin(30) + a = radius * sqrt(3) / 2; // equivalent to radius*cos(30) + polygon(points = [ [ -a, -o ], [ 0, radius ], [ a, -o ] ], + paths = [[ 0, 1, 2 ]]); } -module trapezoid (bottom, height, top = undef, - left_angle = undef, right_angle = undef) +module trapezoid(bottom, + height, + top = undef, + left_angle = undef, + right_angle = undef) { - function tan90 (angle) = (angle == 90) ? 0 : tan (angle); - - function get_trapezoid_offset (adjacent, opposite) = ( - (adjacent == undef && opposite == undef) ? (bottom - top) / 2 : - (adjacent == undef) ? bottom - tan90 (90 - opposite) * height - top : - tan90 (90 - adjacent) * height - ); - - offset_left = get_trapezoid_offset (left_angle, right_angle); - offset_right = get_trapezoid_offset (right_angle, left_angle); - - polygon ([ - [-bottom / 2, 0], - [bottom / 2, 0], - [bottom / 2 - offset_right, height], - [-bottom / 2 + offset_left, height] - ]); + function tan90(angle) = (angle == 90) ? 0 : tan(angle); + + function get_trapezoid_offset(adjacent, opposite) = + ((adjacent == undef && opposite == undef) + ? (bottom - top) / 2 + : (adjacent == undef) + ? bottom - tan90(90 - opposite) * height - top + : tan90(90 - adjacent) * height); + + offset_left = get_trapezoid_offset(left_angle, right_angle); + offset_right = get_trapezoid_offset(right_angle, left_angle); + + polygon([ + [ -bottom / 2, 0 ], + [ bottom / 2, 0 ], + [ bottom / 2 - offset_right, height ], + [ -bottom / 2 + offset_left, height ] + ]); } -module ring(inside_diameter, thickness){ - difference(){ - circle(r=(inside_diameter+thickness*2)/2); - circle(r=inside_diameter/2); - } +module ring(inside_diameter, thickness) +{ + difference() + { + circle(r = (inside_diameter + thickness * 2) / 2); + circle(r = inside_diameter / 2); + } } -module ellipse(width, height) { - scale([1, height/width, 1]) circle(r=width/2); +module ellipse(width, height) +{ + scale([ 1, height / width, 1 ]) circle(r = width / 2); } -module ellipsePart(width,height,numQuarters) +module ellipsePart(width, height, numQuarters) { - o = 1; //slight overlap to fix a bug - difference() - { - ellipse(width,height); - if(numQuarters <= 3) - translate([0-width/2-o,0-height/2-o,0]) square([width/2+o,height/2+o]); - if(numQuarters <= 2) - translate([0-width/2-o,-o,0]) square([width/2+o,height/2+o*2]); - if(numQuarters < 2) - translate([-o,0,0]) square([width/2+o*2,height/2+o]); - } + o = 1; // slight overlap to fix a bug + difference() + { + ellipse(width, height); + if (numQuarters <= 3) + translate([ 0 - width / 2 - o, 0 - height / 2 - o, 0 ]) + square([ width / 2 + o, height / 2 + o ]); + if (numQuarters <= 2) + translate([ 0 - width / 2 - o, -o, 0 ]) + square([ width / 2 + o, height / 2 + o * 2 ]); + if (numQuarters < 2) + translate([ -o, 0, 0 ]) + square([ width / 2 + o * 2, height / 2 + o ]); + } } // The ratio of length and width is about 1.39 for a real egg -module egg_outline(width, length){ - translate([0, width/2, 0]) union(){ - rotate([0, 0, 180]) difference(){ - ellipse(width, 2*length-width); - translate([-length/2, 0, 0]) square(length); +module egg_outline(width, length) +{ + translate([ 0, width / 2, 0 ]) union() + { + rotate([ 0, 0, 180 ]) difference() + { + ellipse(width, 2 * length - width); + translate([ -length / 2, 0, 0 ]) square(length); } - circle(r=width/2); + circle(r = width / 2); } } -module donutSlice(innerSize,outerSize, start_angle, end_angle) -{ +module donutSlice(innerSize, outerSize, start_angle, end_angle) +{ difference() { pieSlice(outerSize, start_angle, end_angle); - if(len(innerSize) > 1) ellipse(innerSize[0]*2,innerSize[1]*2); - else circle(innerSize); + if (len(innerSize) > 1) + ellipse(innerSize[0] * 2, innerSize[1] * 2); + else + circle(innerSize); } } -module pieSlice(size, start_angle, end_angle) //size in radius(es) -{ - rx = ((len(size) > 1)? size[0] : size); - ry = ((len(size) > 1)? size[1] : size); - trx = rx* sqrt(2) + 1; - try = ry* sqrt(2) + 1; +module pieSlice(size, start_angle, end_angle) // size in radius(es) +{ + rx = ((len(size) > 1) ? size[0] : size); + ry = ((len(size) > 1) ? size[1] : size); + trx = rx * sqrt(2) + 1; + try + = ry * sqrt(2) + 1; a0 = (4 * start_angle + 0 * end_angle) / 4; a1 = (3 * start_angle + 1 * end_angle) / 4; a2 = (2 * start_angle + 2 * end_angle) / 4; a3 = (1 * start_angle + 3 * end_angle) / 4; a4 = (0 * start_angle + 4 * end_angle) / 4; - if(end_angle > start_angle) - intersection() { - if(len(size) > 1) - ellipse(rx*2,ry*2); - else - circle(rx); - polygon([ - [0,0], - [trx * cos(a0), try * sin(a0)], - [trx * cos(a1), try * sin(a1)], - [trx * cos(a2), try * sin(a2)], - [trx * cos(a3), try * sin(a3)], - [trx * cos(a4), try * sin(a4)], - [0,0] - ]); - } + if (end_angle > start_angle) + intersection() + { + if (len(size) > 1) + ellipse(rx * 2, ry * 2); + else + circle(rx); + polygon([ + [ 0, 0 ], + [ trx * cos(a0), try * sin(a0) ], + [ trx * cos(a1), try * sin(a1) ], + [ trx * cos(a2), try * sin(a2) ], + [ trx * cos(a3), try * sin(a3) ], + [ trx * cos(a4), try * sin(a4) ], + [ 0, 0 ] + ]); + } } diff --git a/shapes/3Dshapes.scad b/shapes/3Dshapes.scad index 45d155ba..58f17c50 100644 --- a/shapes/3Dshapes.scad +++ b/shapes/3Dshapes.scad @@ -1,3 +1,4 @@ +use /* * OpenSCAD Shapes Library (www.openscad.org) * Copyright (C) 2009 Catarina Mota @@ -10,44 +11,41 @@ */ // 3D Shapes -//box(width, height, depth); -//mcad_rounded_box (size, radius, sidesonly, center=false); -//ccube (size, center = false); - -//cone(height, radius); -//ellipsoid(width, height); -//teardrop(radius, length, angle); -//flat_teardrop(radius, length, angle); - -//torus(outerRadius, innerRadius); -//torus2(r1, r2); -//oval_torus(inner_radius, thickness=[0, 0]); +// box(width, height, depth); +// mcad_rounded_box (size, radius, sidesonly, center=false); +// ccube (size, center = false); -//tube(height, radius, wall, center = false); -//tube2(height, ID, OD, center = false); -//oval_tube(width, height, depth, wall, center = false); +// cone(height, radius); +// ellipsoid(width, height); +// teardrop(radius, length, angle); +// flat_teardrop(radius, length, angle); -//hexagon(height, depth); -//octagon(height, depth); -//dodecagon(height, depth); -//hexagram(height, depth); +// torus(outerRadius, innerRadius); +// torus2(r1, r2); +// oval_torus(inner_radius, thickness=[0, 0]); -//rightTriangle(adjacent, opposite, depth); -//equiTriangle(side, depth); -//triangle_pyramid(radius); -//square_pyramid(base_x, base_y,height); +// tube(height, radius, wall, center = false); +// tube2(height, ID, OD, center = false); +// oval_tube(width, height, depth, wall, center = false); +// hexagon(height, depth); +// octagon(height, depth); +// dodecagon(height, depth); +// hexagram(height, depth); -//12ptStar(height, depth); +// rightTriangle(adjacent, opposite, depth); +// equiTriangle(side, depth); +// triangle_pyramid(radius); +// square_pyramid(base_x, base_y,height); +// 12ptStar(height, depth); //---------------------- -use - // size is a vector [w, h, d] -module box(width, height, depth) { - cube([width, height, depth], true); +module box(width, height, depth) +{ + cube([ width, height, depth ], true); } // Author: Marius Kintel @@ -60,53 +58,54 @@ module box(width, height, depth) { // mcad_rounded_box([20, 30, 40], 5, true); // size is a vector [w, h, d] -module mcad_rounded_box (size, radius, sidesonly, center=false) -{ - module place_xy () - for (x = [size[0]/2 - radius, -size[0]/2 + radius]) - for (y = [size[1]/2 - radius, -size[1]/2 + radius]) - translate ([x, y, 0]) - children (); - - translate (center ? [0, 0, 0] : size / 2) - hull () - if (sidesonly) { - place_xy () - cylinder (r = radius, h = size[2], center=true); - - } else { - for (z = [size[2]/2 - radius, -size[2]/2 + radius]) - translate ([0, 0, z]) - place_xy () - sphere (r = radius); +module mcad_rounded_box(size, radius, sidesonly, center = false) +{ + module + place_xy() for (x = [ + size[0] / 2 - radius, + -size[0] / 2 + + radius + ]) for (y = [ size[1] / 2 - radius, -size[1] / 2 + + radius ]) translate([ x, y, 0 ]) children(); + + translate(center ? [ 0, 0, 0 ] : size / 2) hull() if (sidesonly) + { + place_xy() cylinder(r = radius, h = size[2], center = true); + } + else + { + for (z = [ size[2] / 2 - radius, -size[2] / 2 + radius ]) + translate([ 0, 0, z ]) place_xy() sphere(r = radius); } } -module ccube (size, center = false) +module ccube(size, center = false) { - center = (len (center) == undef) ? [center, center, center] : center; - size = (len (size) == undef) ? [size, size, size] : size; + center = (len(center) == undef) ? [ center, center, center ] : center; + size = (len(size) == undef) ? [ size, size, size ] : size; - function get_offset (i) = center[i] ? - size[i] / 2 : 0; + function get_offset(i) = center[i] ? -size[i] / 2 : 0; - translate ([get_offset (0), get_offset (1), get_offset (2)]) - cube (size); + translate([ get_offset(0), get_offset(1), get_offset(2) ]) cube(size); } -module cone(height, radius, center = false) { - cylinder(height, radius, 0, center); +module cone(height, radius, center = false) +{ + cylinder(height, radius, 0, center); } -module ellipsoid(w, h, center = false) { - scale([1, h/w, 1]) sphere(r=w/2, center=center); +module ellipsoid(w, h, center = false) +{ + scale([ 1, h / w, 1 ]) sphere(r = w / 2, center = center); } -module egg(width, lenght){ - rotate_extrude() - difference(){ - egg_outline(width, lenght); - translate([-lenght, 0, 0]) cube(2*lenght, center=true); - } +module egg(width, lenght) +{ + rotate_extrude() difference() + { + egg_outline(width, lenght); + translate([ -lenght, 0, 0 ]) cube(2 * lenght, center = true); + } } /* From http://www.thingiverse.com/thing:3457 @@ -126,247 +125,322 @@ module egg(width, lenght){ along with this program. If not, see . */ - /* -This script generates a teardrop shape at the appropriate angle -to prevent overhangs greater than 45 degrees. The angle is in degrees, -and is a rotation around the Y axis. You can then rotate around Z -to point it in any direction. Rotation around X or Y will cause the angle to +This script generates a teardrop shape at the appropriate angle +to prevent overhangs greater than 45 degrees. The angle is in degrees, +and is a rotation around the Y axis. You can then rotate around Z +to point it in any direction. Rotation around X or Y will cause the angle to be wrong. */ -module teardrop(radius, length, angle) { - rotate([0, angle, 0]) union() { - linear_extrude(height = length, center = true, convexity = radius, twist = 0) - circle(r = radius, center = true, $fn = 30); - linear_extrude(height = length, center = true, convexity = radius, twist = 0) - projection(cut = false) rotate([0, -angle, 0]) translate([0, 0, radius * sin(45) * 1.5]) cylinder(h = radius * sin(45), r1 = radius * sin(45), r2 = 0, center = true, $fn = 30); - } - -//I worked this portion out when a bug was causing the projection -//above to take FOREVER to calculate. It works as a replacement, -//and I figured I'd leave it here just in case. -/* - #polygon(points = [[radius * cos(-angle / 2), radius * sin(-angle / 2), 0],[radius * cos(-angle / 2), radius * -sin(-angle / 2), 0],[(sin(-angle - 45) + cos(-angle - 45)) * radius, 0, 0]], paths = [[0, 1, 2]]); - #polygon(points = [[radius * -cos(-angle / 2), radius * sin(-angle / 2), 0],[radius * -cos(-angle / 2), radius * -sin(-angle / 2), 0],[(sin(-angle - 45) + cos(-angle - 45)) * radius, 0, 0]], paths = [[0, 1, 2]]); - #polygon(points = [[radius * sin(-angle / 2), radius * cos(-angle / 2), 0],[radius * sin(-angle / 2), radius * -cos(-angle / 2), 0],[(sin(-angle - 45) + cos(-angle - 45)) * radius, 0, 0]], paths = [[0, 1, 2]]); - */ +module teardrop(radius, length, angle) +{ + rotate([ 0, angle, 0 ]) union() + { + linear_extrude( + height = length, center = true, convexity = radius, twist = 0) + circle(r = radius, center = true, $fn = 30); + linear_extrude( + height = length, center = true, convexity = radius, twist = 0) + projection(cut = false) rotate([ 0, -angle, 0 ]) + translate([ 0, 0, radius * sin(45) * 1.5 ]) + cylinder(h = radius * sin(45), + r1 = radius * sin(45), + r2 = 0, + center = true, + $fn = 30); + } + + // I worked this portion out when a bug was causing the projection + // above to take FOREVER to calculate. It works as a replacement, + // and I figured I'd leave it here just in case. + /* + #polygon(points = [[radius * cos(-angle / 2), radius * sin(-angle / + 2), 0],[radius * cos(-angle / 2), radius * -sin(-angle / 2), + 0],[(sin(-angle - 45) + cos(-angle - 45)) * radius, 0, 0]], paths = [[0, + 1, 2]]); #polygon(points = [[radius * -cos(-angle / 2), radius * + sin(-angle / 2), 0],[radius * -cos(-angle / 2), radius * -sin(-angle / + 2), 0],[(sin(-angle - 45) + cos(-angle - 45)) * radius, 0, 0]], paths = + [[0, 1, 2]]); #polygon(points = [[radius * sin(-angle / 2), radius * + cos(-angle / 2), 0],[radius * sin(-angle / 2), radius * -cos(-angle / 2), + 0],[(sin(-angle - 45) + cos(-angle - 45)) * radius, 0, 0]], paths = [[0, + 1, 2]]); + */ } /* * Simple intersection method to implement a flat/truncated teardrop */ -module flat_teardrop(radius, length, angle) { - intersection() { - rotate([0, angle, 0]) { - cube(size=[radius * 2, radius * 2, length], center=true); - } - teardrop(radius, length, angle); - } +module flat_teardrop(radius, length, angle) +{ + intersection() + { + rotate([ 0, angle, 0 ]) + { + cube(size = [ radius * 2, radius * 2, length ], center = true); + } + teardrop(radius, length, angle); + } } module torus(outerRadius, innerRadius) { - r=(outerRadius-innerRadius)/2; - rotate_extrude() translate([innerRadius+r,0,0]) circle(r); + r = (outerRadius - innerRadius) / 2; + rotate_extrude() translate([ innerRadius + r, 0, 0 ]) circle(r); } module torus2(r1, r2) { - rotate_extrude() translate([r1,0,0]) circle(r2); + rotate_extrude() translate([ r1, 0, 0 ]) circle(r2); } -module oval_torus(inner_radius, thickness=[0, 0]) +module oval_torus(inner_radius, thickness = [ 0, 0 ]) { - rotate_extrude() translate([inner_radius+thickness[0]/2,0,0]) ellipse(width=thickness[0], height=thickness[1]); + rotate_extrude() translate([ inner_radius + thickness[0] / 2, 0, 0 ]) + ellipse(width = thickness[0], height = thickness[1]); } // wall is wall thickness -module tube(h, r, wall, center = false) { - linear_extrude (height=h, center=center) - difference() { - circle(r=r, center=center); - circle(r=r-wall, center=center); - } +module tube(h, r, wall, center = false) +{ + linear_extrude(height = h, center = center) difference() + { + circle(r = r, center = center); + circle(r = r - wall, center = center); + } } -module tube2(height, ID, OD, center = false) { - difference() { - cylinder(h=height, r=OD/2, center=center); - cylinder(h=height, r=ID/2, center=center); - } +module tube2(height, ID, OD, center = false) +{ + difference() + { + cylinder(h = height, r = OD / 2, center = center); + cylinder(h = height, r = ID / 2, center = center); + } } module oval_prism(height, rx, ry, center = false) { - scale([1, rx/ry, 1]) cylinder(h=height, r=ry, center=center); + scale([ 1, rx / ry, 1 ]) cylinder(h = height, r = ry, center = center); } // wall is wall thickness -module oval_tube(height, rx, ry, wall, center = false) { - difference() { - scale([1, ry/rx, 1]) cylinder(h=height, r=rx, center=center); - translate([0,0,-0.1]) - #scale([(rx-wall)/rx, (ry-wall)/rx, 1]) cylinder(h=height+0.2, r=rx, center=center); - } +module oval_tube(height, rx, ry, wall, center = false) +{ + difference() + { + scale([ 1, ry / rx, 1 ]) cylinder(h = height, r = rx, center = center); + translate([ 0, 0, -0.1 ]) +#scale([ (rx - wall) / rx, (ry - wall) / rx, 1 ]) \ + cylinder(h = height + 0.2, r = rx, center = center); + } } -//Tubifies any regular prism -module tubify(radius,wall) +// Tubifies any regular prism +module tubify(radius, wall) { - difference() - { - child(0); - translate([0, 0, -0.1]) scale([(radius-wall)/radius, (radius-wall)/radius, 2]) child(0); - } + difference() + { + child(0); + translate([ 0, 0, -0.1 ]) + scale([ (radius - wall) / radius, (radius - wall) / radius, 2 ]) + child(0); + } } module cylinder_tube(height, radius, wall, center = false) { - tubify(radius,wall) - cylinder(h=height, r=radius, center=center); + tubify(radius, wall) cylinder(h = height, r = radius, center = center); } -module triangle_prism(height,radius) +module triangle_prism(height, radius) { - linear_extrude(height=height) triangle(radius); + linear_extrude(height = height) triangle(radius); } -module triangle_tube(height,radius,wall) +module triangle_tube(height, radius, wall) { - tubify(radius,wall) triangle_prism(height,radius); + tubify(radius, wall) triangle_prism(height, radius); } -module pentagon_prism(height,radius) +module pentagon_prism(height, radius) { - linear_extrude(height=height) pentagon(radius); + linear_extrude(height = height) pentagon(radius); } -module pentagon_tube(height,radius,wall) +module pentagon_tube(height, radius, wall) { - tubify(radius,wall) pentagon_prism(height,radius); + tubify(radius, wall) pentagon_prism(height, radius); } -module hexagon_prism(height,radius) +module hexagon_prism(height, radius) { - linear_extrude(height=height) hexagon(radius); + linear_extrude(height = height) hexagon(radius); } -module hexagon_tube(height,radius,wall) +module hexagon_tube(height, radius, wall) { - tubify(radius,wall) hexagon_prism(height,radius); + tubify(radius, wall) hexagon_prism(height, radius); } -module heptagon_prism(height,radius) +module heptagon_prism(height, radius) { - linear_extrude(height=height) heptagon(radius); + linear_extrude(height = height) heptagon(radius); } -module heptagon_tube(height,radius,wall) +module heptagon_tube(height, radius, wall) { - tubify(radius,wall) heptagon_prism(height,radius); + tubify(radius, wall) heptagon_prism(height, radius); } -module octagon_prism(height,radius) +module octagon_prism(height, radius) { - linear_extrude(height=height) octagon(radius); + linear_extrude(height = height) octagon(radius); } -module octagon_tube(height,radius,wall) +module octagon_tube(height, radius, wall) { - tubify(radius,wall) octagon_prism(height,radius); + tubify(radius, wall) octagon_prism(height, radius); } -module nonagon_prism(height,radius) +module nonagon_prism(height, radius) { - linear_extrude(height=height) nonagon(radius); + linear_extrude(height = height) nonagon(radius); } -module decagon_prism(height,radius) +module decagon_prism(height, radius) { - linear_extrude(height=height) decagon(radius); + linear_extrude(height = height) decagon(radius); } -module hendecagon_prism(height,radius) +module hendecagon_prism(height, radius) { - linear_extrude(height=height) hendecagon(radius); + linear_extrude(height = height) hendecagon(radius); } -module dodecagon_prism(height,radius) +module dodecagon_prism(height, radius) { - linear_extrude(height=height) dodecagon(radius); + linear_extrude(height = height) dodecagon(radius); } -module rightTriangle(adjacent, opposite, height) { - difference() { - translate([-adjacent/2,opposite/2,0]) cube([adjacent, opposite, height], true); - translate([-adjacent,0,0]) { - rotate([0,0,atan(opposite/adjacent)]) dislocateBox(adjacent*2, opposite, height+2); +module rightTriangle(adjacent, opposite, height) +{ + difference() + { + translate([ -adjacent / 2, opposite / 2, 0 ]) + cube([ adjacent, opposite, height ], true); + translate([ -adjacent, 0, 0 ]) + { + rotate([ 0, 0, atan(opposite / adjacent) ]) + dislocateBox(adjacent * 2, opposite, height + 2); + } } - } } -module equiTriangle(side, height) { - difference() { - translate([-side/2,side/2,0]) cube([side, side, height], true); - rotate([0,0,30]) dislocateBox(side*2, side, height); - translate([-side,0,0]) { - rotate([0,0,60]) dislocateBox(side*2, side, height); +module equiTriangle(side, height) +{ + difference() + { + translate([ -side / 2, side / 2, 0 ]) + cube([ side, side, height ], true); + rotate([ 0, 0, 30 ]) dislocateBox(side * 2, side, height); + translate([ -side, 0, 0 ]) + { + rotate([ 0, 0, 60 ]) dislocateBox(side * 2, side, height); + } } - } } module triangle_pyramid(radius) { - o=radius/2; //equivalent to radius*sin(30) - a=radius*sqrt(3)/2; //equivalent to radius*cos(30) - polyhedron(points=[[-a,-o,-o],[a,-o,-o],[0,radius,-o],[0,0,radius]],triangles=[[0,1,2],[1,2,3],[0,1,3],[0,2,3]]); -} - -module square_pyramid(base_x, base_y,height) + o = radius / 2; // equivalent to radius*sin(30) + a = radius * sqrt(3) / 2; // equivalent to radius*cos(30) + polyhedron(points = + [ + [ -a, -o, -o ], + [ a, -o, -o ], + [ 0, radius, -o ], + [ 0, 0, radius ] + ], + triangles = + [ [ 0, 1, 2 ], [ 1, 2, 3 ], [ 0, 1, 3 ], [ 0, 2, 3 ] ]); +} + +module square_pyramid(base_x, base_y, height) { - w=base_x/2; - h=base_y/2; - polyhedron(points=[[-w,-h,0],[-w,h,0],[w,h,0],[w,-h,0],[0,0,height]],triangles=[[0,3,2,1], [0,1,4], [1,2,4], [2,3,4], [3,0,4]]); + w = base_x / 2; + h = base_y / 2; + polyhedron(points = + [ + [ -w, -h, 0 ], + [ -w, h, 0 ], + [ w, h, 0 ], + [ w, -h, 0 ], + [ 0, 0, height ] + ], + triangles = [ + [ 0, 3, 2, 1 ], + [ 0, 1, 4 ], + [ 1, 2, 4 ], + [ 2, 3, 4 ], + [ 3, 0, 4 ] + ]); } // Tests: -module test_square_pyramid() +module +test_square_pyramid() { square_pyramid(10, 20, 30); } - -module 12ptStar(size, height) { - starNum = 3; - starAngle = 360/starNum; - for (s = [1:starNum]) { - rotate([0, 0, s*starAngle]) cube([size, size, height], true); - } +module 12ptStar(size, height) +{ + starNum = 3; + starAngle = 360 / starNum; + for (s = [1:starNum]) { + rotate([ 0, 0, s * starAngle ]) cube([ size, size, height ], true); + } } //----------------------- -//MOVES THE ROTATION AXIS OF A BOX FROM ITS CENTER TO THE BOTTOM LEFT CORNER -module dislocateBox(w, h, d) { - translate([0,0,-d/2]) cube([w,h,d]); +// MOVES THE ROTATION AXIS OF A BOX FROM ITS CENTER TO THE BOTTOM LEFT CORNER +module dislocateBox(w, h, d) +{ + translate([ 0, 0, -d / 2 ]) cube([ w, h, d ]); } //----------------------- // Tests -//module test2D_ellipse(){ellipse(10, 5);} -module test_ellipsoid(){ellipsoid(10, 5);} +// module test2D_ellipse(){ellipse(10, 5);} +module +test_ellipsoid() +{ + ellipsoid(10, 5); +} -//module test2D_egg_outline(){egg_outline();} +// module test2D_egg_outline(){egg_outline();} // unregular_shapes.scad // Copyright 2011 Elmo Mäntynen // LGPL 2.1 -// Give a list of 4+4 points (check order) to form an 8 point polyhedron -module connect_squares(points){ - polyhedron(points=points, - triangles=[[0,1,2], [3,0,2], [7,6,5], [7,5,4], // Given polygons - [0,4,1], [4,5,1], [1,5,2], [2,5,6], // Connecting - [2,6,3], [3,6,7], [3,4,0], [3,7,4]]);// sides +// Give a list of 4+4 points (check order) to form an 8 point polyhedron +module connect_squares(points) +{ + polyhedron(points = points, triangles = [ + [ 0, 1, 2 ], + [ 3, 0, 2 ], + [ 7, 6, 5 ], + [ 7, 5, 4 ], // Given polygons + [ 0, 4, 1 ], + [ 4, 5, 1 ], + [ 1, 5, 2 ], + [ 2, 5, 6 ], // Connecting + [ 2, 6, 3 ], + [ 3, 6, 7 ], + [ 3, 4, 0 ], + [ 3, 7, 4 ] + ]); // sides } diff --git a/shapes/3d_triangle.scad b/shapes/3d_triangle.scad index f313433a..197f842c 100644 --- a/shapes/3d_triangle.scad +++ b/shapes/3d_triangle.scad @@ -1,4 +1,5 @@ -// Enhancement of OpenSCAD Primitives Solid with Trinagles + +// Enhancement of OpenSCAD Primitives Solid with Trinagles // Copyright (C) 2011 Rene BAUMANN, Switzerland // // This library is free software; you can redistribute it and/or @@ -12,16 +13,16 @@ // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public -// License along with this library; If not, see -// or write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// License along with this library; If not, see +// or write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // ================================================================ // -// File providing functions and modules to draw 3D - triangles -// created in the X-Y plane with hight h, using various triangle -// specification methods. -// Standard traingle geometrical definition is used. Vertices are named A,B,C, -// side a is opposite vertex A a.s.o. the angle at vertex A is named alpha, +// File providing functions and modules to draw 3D - triangles +// created in the X-Y plane with hight h, using various triangle +// specification methods. +// Standard traingle geometrical definition is used. Vertices are named A,B,C, +// side a is opposite vertex A a.s.o. the angle at vertex A is named alpha, // B(beta), C(gamma). // // This SW is a contribution to the Free Software Community doing a marvelous @@ -42,8 +43,8 @@ // co-ordinates. The trinagle's c-side lies on the x-axis // and A-corner in the co-ordinates center [0,0,0]. Geometry rules // required that a + b is greater then c. The traingle's vertices are -// computed such that it is located in the X-Y plane, side c is on the -// positive x-axis. +// computed such that it is located in the X-Y plane, side c is on the +// positive x-axis. // PARAMETER: // a : real length of side a // b : real length of side b @@ -53,14 +54,18 @@ // // COMMENT: // vertices = 3dtri_sides2coord (3,4,5); -// vertices[0] : Acord vertex A cordinates the like [x,y,z] -// ------------------------------------------------------------------------------------- +// vertices[0] : Acord vertex A cordinates the like [x,y,z] +// ------------------------------------------------------------------------------------- // -function 3dtri_sides2coord (a,b,c) = [ - [0,0,0], - [c,0,0], - [(pow(c,2)+pow(a,2)-pow(b,2))/(2*c),sqrt ( pow(a,2) - - pow((pow(c,2)+pow(a,2)-pow(b,2))/(2*c),2)),0]]; +function 3dtri_sides2coord(a, b, c) = [ + [ 0, 0, 0 ], + [ c, 0, 0 ], + [ + (pow(c, 2) + pow(a, 2) - pow(b, 2)) / (2 * c), + sqrt(pow(a, 2) - pow((pow(c, 2) + pow(a, 2) - pow(b, 2)) / (2 * c), 2)), + 0 + ] +]; // // // =========================================== @@ -69,7 +74,7 @@ function 3dtri_sides2coord (a,b,c) = [ // DESCRIPTION: // Enter triangle A,B,C - corner coordinates to get the // triangles Center of Gravity coordinates. It is assumed -// the triangle is parallel to the X-Y plane. The function +// the triangle is parallel to the X-Y plane. The function // returns always zero for the z-coordinate // PARAMETER: // Acord : [x,y,z] Coordinates of vertex A @@ -81,10 +86,13 @@ function 3dtri_sides2coord (a,b,c) = [ // COMMENT: // vertices = 3dtri_sides2coord (3,4,5); // cg = 3dtri_centerOfGravityCoord(vertices[0],vertices[1],vertices[2]); -// ------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------- // -function 3dtri_centerOfGravityCoord (Acord,Bcord,Ccord) = [ - (Acord[0]+Bcord[0]+Ccord[0])/3,(Acord[1]+Bcord[1]+Ccord[1])/3,0]; +function 3dtri_centerOfGravityCoord(Acord, Bcord, Ccord) = [ + (Acord[0] + Bcord[0] + Ccord[0]) / 3, + (Acord[1] + Bcord[1] + Ccord[1]) / 3, + 0 +]; // // // =========================================== @@ -93,7 +101,7 @@ function 3dtri_centerOfGravityCoord (Acord,Bcord,Ccord) = [ // DESCRIPTION: // Enter triangle A,B,C - corner coordinates to get the // circum circle coordinates. It is assumed -// the triangle is parallel to the X-Y plane. The function +// the triangle is parallel to the X-Y plane. The function // returns always zero for the z-coordinate // PARAMETER: // Acord : [x,y,z] Coordinates of vertex A @@ -105,21 +113,23 @@ function 3dtri_centerOfGravityCoord (Acord,Bcord,Ccord) = [ // COMMENT: // vertices = 3dtri_sides2coord (3,4,5); // cc = 3dtri_centerOfcircumcircle (vertices[0],vertices[1],vertices[2]); -// ------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------- +// +function 3dtri_centerOfcircumcircle(Acord, Bcord, Ccord) = [ + 0.5 * Bcord[0], + 0.5 * ((pow(Ccord[1], 2) + pow(Ccord[0], 2) - Bcord[0] * Ccord[0]) / + Ccord[1]), + 0 +]; // -function 3dtri_centerOfcircumcircle (Acord,Bcord,Ccord) = - [0.5*Bcord[0], - 0.5*((pow(Ccord[1],2)+pow(Ccord[0],2)-Bcord[0]*Ccord[0])/Ccord[1]), - 0]; // -// // // =========================================== // // FUNCTION: 3dtri_radiusOfcircumcircle // DESCRIPTION: // Provides the triangle's radius from circumcircle to the vertices. -// It is assumed the triangle is parallel to the X-Y plane. The function +// It is assumed the triangle is parallel to the X-Y plane. The function // returns always zero for the z-coordinate // PARAMETER: // Vcord : [x,y,z] Coordinates of a vertex A or B,C @@ -129,15 +139,14 @@ function 3dtri_centerOfcircumcircle (Acord,Bcord,Ccord) = // RETURNS: // cr : Circumcircle radius // -// COMMENT: Calculate circumcircle radius of trinagle with round vertices having -// radius R = 2 -// vertices = 3dtri_sides2coord (3,4,5); -// cc = 3dtri_centerOfcircumcircle (vertices[0],vertices[1],vertices[2]); -// cr = 3dtri_radiusOfcircumcircle (vertices[0],cc,2); -// ------------------------------------------------------------------------------------- +// COMMENT: Calculate circumcircle radius of trinagle with round vertices +//having radius R = 2 vertices = 3dtri_sides2coord (3,4,5); cc = +//3dtri_centerOfcircumcircle (vertices[0],vertices[1],vertices[2]); cr = +//3dtri_radiusOfcircumcircle (vertices[0],cc,2); +// ------------------------------------------------------------------------------------- // -function 3dtri_radiusOfcircumcircle (Vcord,CCcord,R) = - sqrt(pow(CCcord[0]-Vcord[0],2)+pow(CCcord[1]-Vcord[1],2))+ R; +function 3dtri_radiusOfcircumcircle(Vcord, CCcord, R) = + sqrt(pow(CCcord[0] - Vcord[0], 2) + pow(CCcord[1] - Vcord[1], 2)) + R; // // // @@ -146,27 +155,28 @@ function 3dtri_radiusOfcircumcircle (Vcord,CCcord,R) = // FUNCTION: 3dtri_radiusOfIn_circle // DESCRIPTION: // Enter triangle A,B,C - corner coordinates to get the -// in-circle radius. It is assumed the triangle is parallel to the -// X-Y plane. The function always returns zero for the z-coordinate. +// in-circle radius. It is assumed the triangle is parallel to the +// X-Y plane. The function always returns zero for the z-coordinate. // Formula used for inner circle radius: r = 2A /(a+b+c) // PARAMETER: // Acord : [x,y,z] Coordinates of vertex A // Bcord : [x,y,z] Coordinates of vertex B // Ccord : [x,y,z] Coordinates of vertex C -// +// // RETURNS: // ir : real radius of in-circle // // COMMENT: // vertices = 3dtri_sides2coord (3,4,5); // ir = 3dtri_radiusOfIn_circle (vertices[0],vertices[1],vertices[2]); -// ------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------- +// +function 3dtri_radiusOfIn_circle(Acord, Bcord, Ccord) = + Bcord[0] * Ccord[1] / + (Bcord[0] + sqrt(pow(Ccord[0] - Bcord[0], 2) + pow(Ccord[1], 2)) + + sqrt(pow(Ccord[0], 2) + pow(Ccord[1], 2))); // -function 3dtri_radiusOfIn_circle (Acord,Bcord,Ccord) = - Bcord[0]*Ccord[1]/(Bcord[0]+sqrt(pow(Ccord[0]-Bcord[0],2)+pow(Ccord[1],2))+ - sqrt(pow(Ccord[0],2)+pow(Ccord[1],2))); // -// // // =========================================== // @@ -174,7 +184,7 @@ function 3dtri_radiusOfIn_circle (Acord,Bcord,Ccord) = // DESCRIPTION: // Enter triangle A,B,C - corner coordinates to get the // in-circle coordinates. It is assumed -// the triangle is parallel to the X-Y plane. The function +// the triangle is parallel to the X-Y plane. The function // returns always zero for the z-coordinate // PARAMETER: // Acord : [x,y,z] Coordinates of vertex A @@ -188,19 +198,24 @@ function 3dtri_radiusOfIn_circle (Acord,Bcord,Ccord) = // vertices = 3dtri_sides2coord (3,4,5); // ir = 3dtri_radiusOfIn_circle (vertices[0],vertices[1],vertices[2]); // ic = 3dtri_centerOfIn_circle (vertices[0],vertices[1],vertices[2],ir); -// ------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------- // -function 3dtri_centerOfIn_circle (Acord,Bcord,Ccord,r) = - [(Bcord[0]+sqrt(pow(Ccord[0]-Bcord[0],2)+pow(Ccord[1],2))+ - sqrt(pow(Ccord[0],2)+pow(Ccord[1],2)))/2-sqrt(pow(Ccord[0]-Bcord[0],2)+pow(Ccord[1],2)),r,0]; +function 3dtri_centerOfIn_circle(Acord, Bcord, Ccord, r) = [ + (Bcord[0] + sqrt(pow(Ccord[0] - Bcord[0], 2) + pow(Ccord[1], 2)) + + sqrt(pow(Ccord[0], 2) + pow(Ccord[1], 2))) / + 2 - + sqrt(pow(Ccord[0] - Bcord[0], 2) + pow(Ccord[1], 2)), + r, + 0 +]; // // // ============================================ // // MODULE: 3dtri_draw // DESCRIPTION: -// Draw a standard solid triangle with A,B,C - vertices specified by its -// co-ordinates and height "h", as given by the input parameters. +// Draw a standard solid triangle with A,B,C - vertices specified by its +// co-ordinates and height "h", as given by the input parameters. // PARAMETER: // Acord : [x,y,z] Coordinates of vertex A // Bcord : [x,y,z] Coordinates of vertex B @@ -211,16 +226,30 @@ function 3dtri_centerOfIn_circle (Acord,Bcord,Ccord,r) = // // COMMENT: // You might use the result from function 3dtri_sides2coord -// to call module 3dtri_draw ( vertices[0],vertices[1],vertices[2], h) -// ------------------------------------------------------------------------------------- -// -module 3dtri_draw ( Acord, Bcord, Ccord, h) { -polyhedron (points=[Acord,Bcord,Ccord, - Acord+[0,0,h],Bcord+[0,0,h],Ccord+[0,0,h]], - triangles=[ [0,1,2],[0,2,3],[3,2,5], - [3,5,4],[1,5,2],[4,5,1], - [4,1,0],[0,3,4]]); - +// to call module 3dtri_draw ( vertices[0],vertices[1],vertices[2], h) +// ------------------------------------------------------------------------------------- +// +module 3dtri_draw(Acord, Bcord, Ccord, h) +{ + polyhedron(points = + [ + Acord, + Bcord, + Ccord, + Acord + [ 0, 0, h ], + Bcord + [ 0, 0, h ], + Ccord + [ 0, 0, h ] + ], + triangles = [ + [ 0, 1, 2 ], + [ 0, 2, 3 ], + [ 3, 2, 5 ], + [ 3, 5, 4 ], + [ 1, 5, 2 ], + [ 4, 5, 1 ], + [ 4, 1, 0 ], + [ 0, 3, 4 ] + ]); }; // // @@ -228,12 +257,12 @@ polyhedron (points=[Acord,Bcord,Ccord, // // MODULE: 3dtri_rnd_draw // DESCRIPTION: -// Draw a round corner triangle with A,B,C - vertices specified by its +// Draw a round corner triangle with A,B,C - vertices specified by its // co-ordinates, height h and round vertices having radius "r". // As specified by the input parameters. // Please note, the tringles side lenght gets extended by "2 * r", -// and the vertices coordinates define the centers of the -// circles with radius "r". +// and the vertices coordinates define the centers of the +// circles with radius "r". // PARAMETER: // Acord : [x,y,z] Coordinates of vertex A // Bcord : [x,y,z] Coordinates of vertex B @@ -245,72 +274,101 @@ polyhedron (points=[Acord,Bcord,Ccord, // // COMMENT: // You might use the result from function 3dtri_sides2coord -// to call module 3dtri_rnd_draw ( vertices[0],vertices[1],vertices[2], h, r) -// ------------------------------------------------------------------------------------- -// -module 3dtri_rnd_draw ( Acord, Bcord, Ccord, h, r) { -Avect=Ccord-Bcord; // vector pointing from vertex B to vertex C -p0=Acord + [0,-r,0]; -p1=Bcord + [0,-r,0]; -p2=Bcord + [r*Avect[1]/sqrt(pow(Avect[0],2)+pow(Avect[1],2)), - -r*Avect[0]/sqrt(pow(Avect[0],2)+pow(Avect[1],2)) ,0]; -p3=Ccord + [r*Avect[1]/sqrt(pow(Avect[0],2)+pow(Avect[1],2)), - -r*Avect[0]/sqrt(pow(Avect[0],2)+pow(Avect[1],2)) ,0]; -p4=Ccord +[- r*Ccord[1]/sqrt(pow(Ccord[0],2)+pow(Ccord[1],2)), - r*Ccord[0]/sqrt(pow(Ccord[0],2)+pow(Ccord[1],2)) ,0]; -p5=Acord + [- r*Ccord[1]/sqrt(pow(Ccord[0],2)+pow(Ccord[1],2)), - r*Ccord[0]/sqrt(pow(Ccord[0],2)+pow(Ccord[1],2)) ,0]; -bottom_triangles = [[0,1,2],[0,2,3],[0,3,4],[0,4,5]]; -c_side_triangles = [[7,1,0],[0,6,7]]; -a_side_triangles = [[2,8,3],[8,9,3]]; -b_side_triangles = [[4,10,5],[10,11,5]]; -A_edge_triangles = [[0,5,11],[0,11,6]]; -B_edge_triangles = [[1,7,2],[2,7,8]]; -C_edge_triangles = [[3,9,4],[9,10,4]]; -top_triangles = [[11,7,6],[11,8,7],[11,10,8],[8,10,9]]; -union () { - polyhedron (points=[p0,p1,p2,p3,p4,p5, - p0+[0,0,h],p1+[0,0,h],p2+[0,0,h],p3+[0,0,h],p4+[0,0,h],p5+[0,0,h]], - triangles=[ bottom_triangles[0],bottom_triangles[1],bottom_triangles[2],bottom_triangles[3], - A_edge_triangles[0],A_edge_triangles[1], - c_side_triangles[0],c_side_triangles[1], - B_edge_triangles[0],B_edge_triangles[1], - a_side_triangles[0],a_side_triangles[1], - C_edge_triangles[0],C_edge_triangles[1], - b_side_triangles[0],b_side_triangles[1], - top_triangles[0],top_triangles[1],top_triangles[2],top_triangles[3]]); - translate(Acord) cylinder(r1=r,r2=r,h=h,center=false); - translate(Bcord) cylinder(r1=r,r2=r,h=h,center=false); - translate(Ccord) cylinder(r1=r,r2=r,h=h,center=false); -}; +// to call module 3dtri_rnd_draw ( vertices[0],vertices[1],vertices[2], h, +//r) +// ------------------------------------------------------------------------------------- +// +module 3dtri_rnd_draw(Acord, Bcord, Ccord, h, r) +{ + Avect = Ccord - Bcord; // vector pointing from vertex B to vertex C + p0 = Acord + [ 0, -r, 0 ]; + p1 = Bcord + [ 0, -r, 0 ]; + p2 = Bcord + [ + r * Avect[1] / sqrt(pow(Avect[0], 2) + pow(Avect[1], 2)), + -r * Avect[0] / sqrt(pow(Avect[0], 2) + pow(Avect[1], 2)), + 0 + ]; + p3 = Ccord + [ + r * Avect[1] / sqrt(pow(Avect[0], 2) + pow(Avect[1], 2)), + -r * Avect[0] / sqrt(pow(Avect[0], 2) + pow(Avect[1], 2)), + 0 + ]; + p4 = Ccord + [ + -r * Ccord[1] / sqrt(pow(Ccord[0], 2) + pow(Ccord[1], 2)), + r * Ccord[0] / sqrt(pow(Ccord[0], 2) + pow(Ccord[1], 2)), + 0 + ]; + p5 = Acord + [ + -r * Ccord[1] / sqrt(pow(Ccord[0], 2) + pow(Ccord[1], 2)), + r * Ccord[0] / sqrt(pow(Ccord[0], 2) + pow(Ccord[1], 2)), + 0 + ]; + bottom_triangles = [ [ 0, 1, 2 ], [ 0, 2, 3 ], [ 0, 3, 4 ], [ 0, 4, 5 ] ]; + c_side_triangles = [ [ 7, 1, 0 ], [ 0, 6, 7 ] ]; + a_side_triangles = [ [ 2, 8, 3 ], [ 8, 9, 3 ] ]; + b_side_triangles = [ [ 4, 10, 5 ], [ 10, 11, 5 ] ]; + A_edge_triangles = [ [ 0, 5, 11 ], [ 0, 11, 6 ] ]; + B_edge_triangles = [ [ 1, 7, 2 ], [ 2, 7, 8 ] ]; + C_edge_triangles = [ [ 3, 9, 4 ], [ 9, 10, 4 ] ]; + top_triangles = [ [ 11, 7, 6 ], [ 11, 8, 7 ], [ 11, 10, 8 ], [ 8, 10, 9 ] ]; + union() + { + polyhedron( + points = + [ + p0, + p1, + p2, + p3, + p4, + p5, + p0 + [ 0, 0, h ], + p1 + [ 0, 0, h ], + p2 + [ 0, 0, h ], + p3 + [ 0, 0, h ], + p4 + [ 0, 0, h ], + p5 + [ 0, 0, h ] + ], + triangles = [ + bottom_triangles[0], bottom_triangles[1], bottom_triangles[2], + bottom_triangles[3], A_edge_triangles[0], A_edge_triangles[1], + c_side_triangles[0], c_side_triangles[1], B_edge_triangles[0], + B_edge_triangles[1], a_side_triangles[0], a_side_triangles[1], + C_edge_triangles[0], C_edge_triangles[1], b_side_triangles[0], + b_side_triangles[1], top_triangles[0], top_triangles[1], + top_triangles[2], top_triangles[3] + ]); + translate(Acord) cylinder(r1 = r, r2 = r, h = h, center = false); + translate(Bcord) cylinder(r1 = r, r2 = r, h = h, center = false); + translate(Ccord) cylinder(r1 = r, r2 = r, h = h, center = false); + }; } // // ============================================== // // Demo Application - copy into new file and uncomment or uncomment here but -// without uncommenting the use <...> statement, then press F6 - Key +// without uncommenting the use <...> statement, then press F6 - Key // // use ; //$fn=50; // h =4; // r=2; // echo ("Draws a right angle triangle with its circumcircle and in-circle"); -// echo ("The calculated co-ordinates and radius are show in this console window"); -// echo ("Geometry rules for a right angle triangle say, that the circumcircle is the"); -// echo ("Thales Circle which center must be in the middle of the triangle's c - side"); -// echo ("==========================================="); -// vertices = 3dtri_sides2coord (30,40,50); -// echo("A = ",vertices[0]," B = ",vertices[1]," C = ",vertices[2]); -// cg = 3dtri_centerOfGravityCoord (vertices[0],vertices[1],vertices[2]); -// echo (" Center of gravity = ",cg); -// cc = 3dtri_centerOfcircumcircle (vertices[0],vertices[1],vertices[2]); -// echo (" Center of circumcircle = ",cc); -// cr = 3dtri_radiusOfcircumcircle (vertices[0],cc,r); -// echo(" Radius of circumcircle ",cr); -// ir = 3dtri_radiusOfIn_circle (vertices[0],vertices[1],vertices[2]); -// echo (" Radius of in-circle = ",ir); -// ic = 3dtri_centerOfIn_circle (vertices[0],vertices[1],vertices[2],ir); -// echo (" Center of in-circle = ",ic); +// echo ("The calculated co-ordinates and radius are show in this console +// window"); echo ("Geometry rules for a right angle triangle say, that the +// circumcircle is the"); echo ("Thales Circle which center must be in the +// middle of the triangle's c - side"); echo +// ("==========================================="); vertices = +// 3dtri_sides2coord (30,40,50); echo("A = ",vertices[0]," B = ",vertices[1]," +// C = ",vertices[2]); cg = 3dtri_centerOfGravityCoord +// (vertices[0],vertices[1],vertices[2]); echo (" Center of gravity = ",cg); cc +// = 3dtri_centerOfcircumcircle (vertices[0],vertices[1],vertices[2]); echo (" +// Center of circumcircle = ",cc); cr = 3dtri_radiusOfcircumcircle +// (vertices[0],cc,r); echo(" Radius of circumcircle ",cr); ir = +// 3dtri_radiusOfIn_circle (vertices[0],vertices[1],vertices[2]); echo (" +// Radius of in-circle = ",ir); ic = 3dtri_centerOfIn_circle +// (vertices[0],vertices[1],vertices[2],ir); echo (" Center of in-circle = +// ",ic); // translate(cc+[0,0,5*h/2]) difference () { // cylinder (h=5*h,r1=cr+4,r2=cr+4,center=true); // cylinder (h=6*h,r1=cr,r2=cr,center=true);} @@ -318,10 +376,12 @@ union () { // union () { // difference () { // 3dtri_rnd_draw (vertices[0], vertices[1], vertices[2],5*h,r); -// scale([0.8,0.8,1]) translate([6,2,4*h]) 3dtri_rnd_draw (vertices[0], vertices[1], vertices[2],5*h,r); +// scale([0.8,0.8,1]) translate([6,2,4*h]) 3dtri_rnd_draw +// (vertices[0], vertices[1], vertices[2],5*h,r); // } -// translate (ic+[0,0,5*h]) cylinder(h=10*h,r1=ir+r,r2=ir+r,center=true); +// translate (ic+[0,0,5*h]) +// cylinder(h=10*h,r1=ir+r,r2=ir+r,center=true); // } -// translate (ic+[0,0,5*h]) cylinder(h=12*h,r1=0.5*ir,r2=0.5*ir,center=true); +// translate (ic+[0,0,5*h]) +// cylinder(h=12*h,r1=0.5*ir,r2=0.5*ir,center=true); // } - diff --git a/shapes/cylinder.scad b/shapes/cylinder.scad index 438fe124..bb70ef27 100644 --- a/shapes/cylinder.scad +++ b/shapes/cylinder.scad @@ -1,107 +1,95 @@ -include -use use - -module mcad_rounded_cylinder ( +use +include +module mcad_rounded_cylinder( // same options as cylinder() - r = undef, h = undef, d = undef, - r1 = undef, r2 = undef, - d1 = undef, d2 = undef, + r = undef, + h = undef, + d = undef, + r1 = undef, + r2 = undef, + d1 = undef, + d2 = undef, center = false, // rounding radius round_r = 0, - round_r1 = 0, round_r2 = 0, - slices = 0 -) + round_r1 = 0, + round_r2 = 0, + slices = 0) { // First resolve all the required values from arguments... r = (r == undef && d != undef) ? d / 2 : r; - function resolve_numbered_radius (rN, dN) = ( - (rN == undef) ? ( - (dN != undef) ? dN / 2 : - r - ) : rN - ); + function resolve_numbered_radius(rN, dN) = + ((rN == undef) ? ((dN != undef) ? dN / 2 : r) : rN); - r1 = resolve_numbered_radius (r1, d1); - r2 = resolve_numbered_radius (r2, d2); + r1 = resolve_numbered_radius(r1, d1); + r2 = resolve_numbered_radius(r2, d2); round_r1 = (round_r1 == 0) ? round_r : round_r1; round_r2 = (round_r2 == 0) ? round_r : round_r2; inv_gradient = (r2 - r1) / h; - module trapezoid (top, bottom, h) + module trapezoid(top, bottom, h) { - polygon ([ - [0, 0], - [0, h], - [top, h], - [bottom, 0] - ]); + polygon([ [ 0, 0 ], [ 0, h ], [ top, h ], [ bottom, 0 ] ]); } - module basic_section () - { - trapezoid (top = r2, bottom = r1, h = h); - } + module basic_section() { trapezoid(top = r2, bottom = r1, h = h); } - module scale_at (factor, pos = [0, 0, 0]) + module scale_at(factor, pos = [ 0, 0, 0 ]) { - translate (pos) - scale (factor) - translate (pos * -1) - children (); + translate(pos) scale(factor) translate(pos * -1) children(); } - module round_corner (r, pos) + module round_corner(r, pos) { - offset (r = r, $fn = slices) - offset (r = -r) - scale_at (10, pos = pos) - children (); + offset(r = r, $fn = slices) offset(r = -r) scale_at(10, pos = pos) + children(); } - translate ([0, 0, center ? -h / 2 : 0]) - rotate_extrude () - hull () { - intersection () { - union () { - difference () { - round_corner (round_r2, [r2, h]) - basic_section (); - - translate ([-epsilon, -epsilon]) - square ([max (r1, r2) + epsilon * 2, - max (epsilon, round_r1 + epsilon)]); + translate([ 0, 0, center ? -h / 2 : 0 ]) rotate_extrude() hull() + { + intersection() + { + union() + { + difference() + { + round_corner(round_r2, [ r2, h ]) basic_section(); + + translate([ -epsilon, -epsilon ]) square([ + max(r1, r2) + epsilon * 2, + max(epsilon, round_r1 + epsilon) + ]); } - difference () { - round_corner (round_r1, [r1, 0]) - basic_section (); + difference() + { + round_corner(round_r1, [ r1, 0 ]) basic_section(); - translate ([-epsilon, h + epsilon]) - mirror (Y) - square ([max (r1, r2) + epsilon * 2, round_r2]); + translate([ -epsilon, h + epsilon ]) mirror(Y) + square([ max(r1, r2) + epsilon * 2, round_r2 ]); } } - basic_section (); + basic_section(); } } } -module mcad_tube (od, id, h = undef) -{ - linear_extrude_if (h != undef, height = h) - difference () { - circle (d = od); - mcad_polyhole (d = id); - } +module mcad_tube(od, id, h = undef){ linear_extrude_if(h != undef, height = h) + difference(){ circle(d = od); +mcad_polyhole(d = id); +} } -*mcad_rounded_cylinder (r1 = 3, r2 = 10, h = 40, round_r1 = 3, round_r2 = 10, - slices = 100); -*mcad_rounded_cylinder (r = 3, h = 40, round_r1 = 3, slices = 100); +*mcad_rounded_cylinder(r1 = 3, + r2 = 10, + h = 40, + round_r1 = 3, + round_r2 = 10, + slices = 100); +*mcad_rounded_cylinder(r = 3, h = 40, round_r1 = 3, slices = 100); diff --git a/shapes/polyhole.scad b/shapes/polyhole.scad index 16d4654b..7251fcb0 100644 --- a/shapes/polyhole.scad +++ b/shapes/polyhole.scad @@ -1,20 +1,15 @@ + // Copyright 2011 Nophead (of RepRap fame) -// This file is licensed under the terms of Creative Commons Attribution 3.0 Unported. +// This file is licensed under the terms of Creative Commons Attribution 3.0 +// Unported. // Using this holes should come out approximately right when printed -module mcad_polyhole(d, h = undef, center = false) { - n = max (round (2 * d), 3); +module mcad_polyhole(d, h = undef, center = false) +{ + n = max(round(2 * d), 3); flat = (h == undef); - rotate([0,0,180]) - if (flat) - circle (r = (d / 2) / cos (180 / n), $fn = n); - else - cylinder ( - h = h, - r = (d / 2) / cos (180 / n), - center = center, - $fn = n - ); + rotate([ 0, 0, 180 ]) if (flat) circle(r = (d / 2) / cos(180 / n), $fn = n); + else cylinder(h = h, r = (d / 2) / cos(180 / n), center = center, $fn = n); } diff --git a/shapes/standard_shapes.scad b/shapes/standard_shapes.scad index fcf99f12..b039e8e1 100644 --- a/shapes/standard_shapes.scad +++ b/shapes/standard_shapes.scad @@ -1,3 +1,4 @@ + /* * Copyright (C) 2012 Krallinger Sebastian * @@ -15,38 +16,43 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -*/ + */ -include ; -include ; +include; +include; -module cylinderSegment_angle(r,h,Phi,center = false){ - a = Phi/2; - if(center == false ){ - translate([0, 0, h/2]){ - _halfCircelSegment(radius=r,height=h,angle=abs(a)); - rotate(a = 180, v = X) - _halfCircelSegment(radius=r,height=h,angle=abs(a)); - } - }else{ - _halfCircelSegment(radius=r,height=h,angle=abs(a)); - rotate(a = 180, v = X) - _halfCircelSegment(radius=r,height=h,angle=abs(a)); - } +module cylinderSegment_angle(r, h, Phi, center = false) +{ + a = Phi / 2; + if (center == false) { + translate([ 0, 0, h / 2 ]) + { + _halfCircelSegment(radius = r, height = h, angle = abs(a)); + rotate(a = 180, v = X) + _halfCircelSegment(radius = r, height = h, angle = abs(a)); + } + } else { + _halfCircelSegment(radius = r, height = h, angle = abs(a)); + rotate(a = 180, v = X) + _halfCircelSegment(radius = r, height = h, angle = abs(a)); + } } -//cylinderSegment_angle(radius=10,height=1,Phi=360); +// cylinderSegment_angle(radius=10,height=1,Phi=360); -module _halfCircelSegment(radius,height,angle){ - difference(){ - union(){ - cylinder(h = height, r = radius, center = true); - } - union(){ - translate([0, -radius/2-OS, 0]) - cube ([(radius+OS)*2,radius+OS,height+2*OS],center =true); - rotate(a = angle, v = Z) translate([0, -radius/2, 0]) - cube ([(radius+OS)*2,radius+OS,height+2*OS],center =true); - } - } +module _halfCircelSegment(radius, height, angle) +{ + difference() + { + union() { cylinder(h = height, r = radius, center = true); } + union() + { + translate([ 0, -radius / 2 - OS, 0 ]) + cube([ (radius + OS) * 2, radius + OS, height + 2 * OS ], + center = true); + rotate(a = angle, v = Z) translate([ 0, -radius / 2, 0 ]) + cube([ (radius + OS) * 2, radius + OS, height + 2 * OS ], + center = true); + } + } } //_halfCircelSegment(10,1,111); diff --git a/shapes/triangles_pyramids.scad b/shapes/triangles_pyramids.scad index 7bbd9a31..3c9bab16 100644 --- a/shapes/triangles_pyramids.scad +++ b/shapes/triangles_pyramids.scad @@ -1,70 +1,127 @@ -/* + +/* MCAD triangles - Copyright (C) 2013 Alex Davies License: LGPL 2.1 or later -rightpyramid(rightpyramidx, rightpyramidy, rightpyramidz) -cornerpyramid(cornerpyramidx, cornerpyramidy, cornerpyramidz) -eqlpyramid(eqlpyramidx, eqlpyramidy, eqlpyramidz) +rightpyramid(rightpyramidx, rightpyramidy, rightpyramidz) +cornerpyramid(cornerpyramidx, cornerpyramidy, cornerpyramidz) +eqlpyramid(eqlpyramidx, eqlpyramidy, eqlpyramidz) rightprism(rightprismx,rightprismy,rightprismz) eqlprism(eqlprismx,eqlprismy,eqlprismz) -todo, make library work with negative lengths by adding triangles to the inside of every surface. basicaly copy and paste the current triangles set and reverse the first and last digit of every triangle. In 4 character triangles switch the middle ones around as well. Not sure if that's actually useful though. +todo, make library work with negative lengths by adding triangles to the inside +of every surface. basicaly copy and paste the current triangles set and reverse +the first and last digit of every triangle. In 4 character triangles switch the +middle ones around as well. Not sure if that's actually useful though. - Copyright Eero 'rambo' af Heurlin 2010- triangle(o_len, a_len, depth) a_triangle(tan_angle, a_len, depth) */ -module rightpyramid(rightpyramidx, rightpyramidy, rightpyramidz) { - polyhedron ( points = [[0,0,0], - [rightpyramidx, 0, 0], - [0, rightpyramidy, 0], - [rightpyramidx, rightpyramidy, 0], - [rightpyramidx/2, rightpyramidy, rightpyramidz]], - - faces = [[0,1,2],[2,1,3],[4,1,0],[3,1,4],[2,3,4],[0,2,4]]); +module rightpyramid(rightpyramidx, rightpyramidy, rightpyramidz) +{ + polyhedron(points = + [ + [ 0, 0, 0 ], + [ rightpyramidx, 0, 0 ], + [ 0, rightpyramidy, 0 ], + [ rightpyramidx, rightpyramidy, 0 ], + [ rightpyramidx / 2, rightpyramidy, rightpyramidz ] + ], + + faces = [ + [ 0, 1, 2 ], + [ 2, 1, 3 ], + [ 4, 1, 0 ], + [ 3, 1, 4 ], + [ 2, 3, 4 ], + [ 0, 2, 4 ] + ]); } -module cornerpyramid(cornerpyramidx, cornerpyramidy, cornerpyramidz) { - polyhedron ( points = [[0,0,0], - [cornerpyramidx, 0, 0], - [0, cornerpyramidy, 0], - [cornerpyramidx, cornerpyramidy, 0], - [0, cornerpyramidy, cornerpyramidz]], - - faces = [[0,1,2],[2,1,3],[4,1,0],[3,1,4],[2,3,4],[0,2,4]]); +module cornerpyramid(cornerpyramidx, cornerpyramidy, cornerpyramidz) +{ + polyhedron(points = + [ + [ 0, 0, 0 ], + [ cornerpyramidx, 0, 0 ], + [ 0, cornerpyramidy, 0 ], + [ cornerpyramidx, cornerpyramidy, 0 ], + [ 0, cornerpyramidy, cornerpyramidz ] + ], + + faces = [ + [ 0, 1, 2 ], + [ 2, 1, 3 ], + [ 4, 1, 0 ], + [ 3, 1, 4 ], + [ 2, 3, 4 ], + [ 0, 2, 4 ] + ]); } -module eqlpyramid(eqlpyramidx, eqlpyramidy, eqlpyramidz) { - polyhedron ( points = [[0,0,0], - [eqlpyramidx, 0, 0], - [0, eqlpyramidy, 0], - [eqlpyramidx, eqlpyramidy, 0], - [eqlpyramidx/2, eqlpyramidy/2, eqlpyramidz]], - - faces = [[0,1,2],[2,1,3],[4,1,0],[3,1,4],[2,3,4],[0,2,4]]); +module eqlpyramid(eqlpyramidx, eqlpyramidy, eqlpyramidz) +{ + polyhedron(points = + [ + [ 0, 0, 0 ], + [ eqlpyramidx, 0, 0 ], + [ 0, eqlpyramidy, 0 ], + [ eqlpyramidx, eqlpyramidy, 0 ], + [ eqlpyramidx / 2, eqlpyramidy / 2, eqlpyramidz ] + ], + + faces = [ + [ 0, 1, 2 ], + [ 2, 1, 3 ], + [ 4, 1, 0 ], + [ 3, 1, 4 ], + [ 2, 3, 4 ], + [ 0, 2, 4 ] + ]); } -module rightprism(rightprismx,rightprismy,rightprismz){ - polyhedron ( points = [[0,0,0], - [rightprismx,0,0], - [rightprismx,rightprismy,0], - [0,rightprismy,0], - [0,rightprismy,rightprismz], - [0,0,rightprismz]], - faces = [[0,1,2,3],[5,1,0],[5,4,2,1],[4,3,2],[0,3,4,5]]); +module rightprism(rightprismx, rightprismy, rightprismz) +{ + polyhedron(points = + [ + [ 0, 0, 0 ], + [ rightprismx, 0, 0 ], + [ rightprismx, rightprismy, 0 ], + [ 0, rightprismy, 0 ], + [ 0, rightprismy, rightprismz ], + [ 0, 0, rightprismz ] + ], + faces = [ + [ 0, 1, 2, 3 ], + [ 5, 1, 0 ], + [ 5, 4, 2, 1 ], + [ 4, 3, 2 ], + [ 0, 3, 4, 5 ] + ]); } -module eqlprism(eqlprismx,eqlprismy,eqlprismz){ - polyhedron ( points = [[0,0,0], - [eqlprismx,0,0], - [eqlprismx,eqlprismy,0], - [0,eqlprismy,0], - [eqlprismx/2,eqlprismy,eqlprismz], - [eqlprismx/2,0,eqlprismz]], - faces = [[0,1,2,3],[5,1,0],[5,4,2,1],[4,3,2],[0,3,4,5]]); +module eqlprism(eqlprismx, eqlprismy, eqlprismz) +{ + polyhedron(points = + [ + [ 0, 0, 0 ], + [ eqlprismx, 0, 0 ], + [ eqlprismx, eqlprismy, 0 ], + [ 0, eqlprismy, 0 ], + [ eqlprismx / 2, eqlprismy, eqlprismz ], + [ eqlprismx / 2, 0, eqlprismz ] + ], + faces = [ + [ 0, 1, 2, 3 ], + [ 5, 1, 0 ], + [ 5, 4, 2, 1 ], + [ 4, 3, 2 ], + [ 0, 3, 4, 5 ] + ]); } /** @@ -77,9 +134,10 @@ module eqlprism(eqlprismx,eqlprismy,eqlprismz){ */ module triangle(o_len, a_len, depth) { - linear_extrude(height=depth) + linear_extrude(height = depth) { - polygon(points=[[0,0],[a_len,0],[0,o_len]], paths=[[0,1,2]]); + polygon(points = [ [ 0, 0 ], [ a_len, 0 ], [ 0, o_len ] ], + paths = [[ 0, 1, 2 ]]); } } @@ -92,32 +150,38 @@ module triangle(o_len, a_len, depth) */ module a_triangle(tan_angle, a_len, depth) { - linear_extrude(height=depth) + linear_extrude(height = depth) { - polygon(points=[[0,0],[a_len,0],[0,tan(tan_angle) * a_len]], paths=[[0,1,2]]); + polygon(points = + [ [ 0, 0 ], [ a_len, 0 ], [ 0, tan(tan_angle) * a_len ] ], + paths = [[ 0, 1, 2 ]]); } } // Tests: -module test_triangle() { triangle(5, 5, 5); } -module test_a_triangle() { a_triangle(45, 5, 5); } -module test_triangles() +module +test_triangle() +{ + triangle(5, 5, 5); +} +module +test_a_triangle() +{ + a_triangle(45, 5, 5); +} +module +test_triangles() { // Generate a bunch of triangles by sizes - for (i = [1:10]) - { - translate([i*7, -30, i*7]) + for (i = [1:10]) { + translate([ i * 7, -30, i * 7 ]) { - triangle(i*5, sqrt(i*5+pow(i,2)), 5); + triangle(i * 5, sqrt(i * 5 + pow(i, 2)), 5); } } // Generate a bunch of triangles by angle - for (i = [1:85/5]) - { - translate([i*7, 22, i*7]) - { - a_triangle(i*5, 10, 5); - } + for (i = [1:85 / 5]) { + translate([ i * 7, 22, i * 7 ]) { a_triangle(i * 5, 10, 5); } } } diff --git a/shapes/trochoids.scad b/shapes/trochoids.scad index 99083303..c7a2e900 100644 --- a/shapes/trochoids.scad +++ b/shapes/trochoids.scad @@ -1,3 +1,4 @@ + //=========================================== // Public Domain Epi- and Hypo- trochoids in OpenSCAD // version 1.0 @@ -8,16 +9,16 @@ // applications. Attribution would be nice, but is not required. There is // no warranty of any kind, including its correctness, usefulness, or safety. // -// An EPITROCHOID is a curve traced by a point -// fixed at a distance "d" +// An EPITROCHOID is a curve traced by a point +// fixed at a distance "d" // to the center of a circle of radius "r" -// as the circle rolls +// as the circle rolls // outside another circle of radius "R". // -// An HYPOTROCHOID is a curve traced by a point -// fixed at a distance "d" +// An HYPOTROCHOID is a curve traced by a point +// fixed at a distance "d" // to the center of a circle of radius "r" -// as the circle rolls +// as the circle rolls // inside another circle of radius "R". // // An EPICYCLOID is an epitrochoid with d = r. @@ -26,7 +27,7 @@ // // See http://en.wikipedia.org/wiki/Epitrochoid // and http://en.wikipedia.org/wiki/Hypotrochoid -// +// // Beware the polar forms of the equations on Wikipedia... // They are correct, but theta is measured to the center of the small disk!! //=========================================== @@ -34,16 +35,15 @@ // There are several different methods for extruding. The best are probably // the ones using linear extrude. - //=========================================== // Demo - draws one of each, plus some little wheels and sticks. // -// Fun stuff to try: +// Fun stuff to try: // Animate, try FPS = 5 and Steps = 200 // R = 2, r = 1, d = 0.2 // R = 4, r = 1, d = 1 // R = 2, r = 1, d = 0.5 -// +// // What happens when you make d > r ?? // What happens when d < 0 ?? // What happens when r < 0 ?? @@ -58,233 +58,385 @@ r = 1; d = 1; n = 60; // number of wedge segments -alpha = 360*$t; +alpha = 360 * $t; -color([0, 0, 1]) -translate([0, 0, -0.5]) - cylinder(h = 1, r= R, center = true); +color([ 0, 0, 1 ]) translate([ 0, 0, -0.5 ]) + cylinder(h = 1, r = R, center = true); -color([0, 1, 0]) -epitrochoid(R,r,d,n,thickness); +color([ 0, 1, 0 ]) epitrochoid(R, r, d, n, thickness); -color([1, 0, 0]) -translate([ (R+r)*cos(alpha) , (R+r)*sin(alpha), -0.5]) { - rotate([0, 0, alpha + R/r*alpha]) { - cylinder(h = 1, r = r, center = true); - translate([-d, 0, 1.5]) { - cylinder(h = 2.2, r = 0.1, center = true); - } - } +color([ 1, 0, 0 ]) + translate([ (R + r) * cos(alpha), (R + r) * sin(alpha), -0.5 ]) +{ + rotate([ 0, 0, alpha + R / r * alpha ]) + { + cylinder(h = 1, r = r, center = true); + translate([ -d, 0, 1.5 ]) { cylinder(h = 2.2, r = 0.1, center = true); } + } } +translate([ 2 * (abs(R) + abs(r) + abs(d)), 0, 0 ]) +{ + color([ 0, 0, 1 ]) translate([ 0, 0, -0.5 ]) difference() + { + cylinder(h = 1, r = 1.1 * R, center = true); + cylinder(h = 1.1, r = R, center = true); + } -translate([2*(abs(R) + abs(r) + abs(d)), 0, 0]){ -color([0, 0, 1]) -translate([0, 0, -0.5]) - difference() { - cylinder(h = 1, r = 1.1*R, center = true); - cylinder(h = 1.1, r= R, center = true); - } + color([ 0, 1, 0 ]) hypotrochoid(R, r, d, n, thickness); -color([0, 1, 0]) -hypotrochoid(R,r,d,n,thickness); - -color([1, 0, 0]) -translate([ (R-r)*cos(alpha) , (R-r)*sin(alpha), -0.5]) { - rotate([0, 0, alpha - R/r*alpha]) { - cylinder(h = 1, r = r, center = true); - translate([d, 0, 1.5]) { - cylinder(h = 2.2, r = 0.1, center = true); - } - } -} + color([ 1, 0, 0 ]) + translate([ (R - r) * cos(alpha), (R - r) * sin(alpha), -0.5 ]) + { + rotate([ 0, 0, alpha - R / r * alpha ]) + { + cylinder(h = 1, r = r, center = true); + translate([ d, 0, 1.5 ]) + { + cylinder(h = 2.2, r = 0.1, center = true); + } + } + } } // This just makes a twisted hypotrochoid -translate([0,14, 0]) -hypotrochoidLinear(4, 1, 1, 40, 40, 10, 30); +translate([ 0, 14, 0 ]) hypotrochoidLinear(4, 1, 1, 40, 40, 10, 30); // End of Demo Section //=========================================== - //=========================================== // Epitrochoid // -module epitrochoid(R, r, d, n, thickness) { - dth = 360/n; - for ( i = [0:n-1] ) { - polyhedron(points = [[0,0,0], - [(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i), 0], - [(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1)), 0], - [0,0,thickness], - [(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i), thickness], - [(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1)), thickness]], - triangles = [[0, 2, 1], - [0, 1, 3], - [3, 1, 4], - [3, 4, 5], - [0, 3, 2], - [2, 3, 5], - [1, 2, 4], - [2, 5, 4]]); - } +module epitrochoid(R, r, d, n, thickness) +{ + dth = 360 / n; + for (i = [0:n - 1]) { + polyhedron( + points = + [ + [ 0, 0, 0 ], + [ + (R + r) * cos(dth * i) - d * cos((R + r) / r * dth * i), + (R + r) * sin(dth * i) - d * sin((R + r) / r * dth * i), + 0 + ], + [ + (R + r) * cos(dth * (i + 1)) - + d * cos((R + r) / r * dth * (i + 1)), + (R + r) * sin(dth * (i + 1)) - + d * sin((R + r) / r * dth * (i + 1)), + 0 + ], + [ 0, 0, thickness ], + [ + (R + r) * cos(dth * i) - d * cos((R + r) / r * dth * i), + (R + r) * sin(dth * i) - d * sin((R + r) / r * dth * i), + thickness + ], + [ + (R + r) * cos(dth * (i + 1)) - + d * cos((R + r) / r * dth * (i + 1)), + (R + r) * sin(dth * (i + 1)) - + d * sin((R + r) / r * dth * (i + 1)), + thickness + ] + ], + triangles = [ + [ 0, 2, 1 ], + [ 0, 1, 3 ], + [ 3, 1, 4 ], + [ 3, 4, 5 ], + [ 0, 3, 2 ], + [ 2, 3, 5 ], + [ 1, 2, 4 ], + [ 2, 5, 4 ] + ]); + } } //=========================================== - //=========================================== // Hypotrochoid // -module hypotrochoid(R, r, d, n, thickness) { - dth = 360/n; - for ( i = [0:n-1] ) { - polyhedron(points = [[0,0,0], - [(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i), 0], - [(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1)), 0], - [0,0,thickness], - [(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i), thickness], - [(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1)), thickness]], - triangles = [[0, 2, 1], - [0, 1, 3], - [3, 1, 4], - [3, 4, 5], - [0, 3, 2], - [2, 3, 5], - [1, 2, 4], - [2, 5, 4]]); - } +module hypotrochoid(R, r, d, n, thickness) +{ + dth = 360 / n; + for (i = [0:n - 1]) { + polyhedron( + points = + [ + [ 0, 0, 0 ], + [ + (R - r) * cos(dth * i) + d * cos((R - r) / r * dth * i), + (R - r) * sin(dth * i) - d * sin((R - r) / r * dth * i), + 0 + ], + [ + (R - r) * cos(dth * (i + 1)) + + d * cos((R - r) / r * dth * (i + 1)), + (R - r) * sin(dth * (i + 1)) - + d * sin((R - r) / r * dth * (i + 1)), + 0 + ], + [ 0, 0, thickness ], + [ + (R - r) * cos(dth * i) + d * cos((R - r) / r * dth * i), + (R - r) * sin(dth * i) - d * sin((R - r) / r * dth * i), + thickness + ], + [ + (R - r) * cos(dth * (i + 1)) + + d * cos((R - r) / r * dth * (i + 1)), + (R - r) * sin(dth * (i + 1)) - + d * sin((R - r) / r * dth * (i + 1)), + thickness + ] + ], + triangles = [ + [ 0, 2, 1 ], + [ 0, 1, 3 ], + [ 3, 1, 4 ], + [ 3, 4, 5 ], + [ 0, 3, 2 ], + [ 2, 3, 5 ], + [ 1, 2, 4 ], + [ 2, 5, 4 ] + ]); + } } //=========================================== - //=========================================== // Epitrochoid Wedge with Bore // -module epitrochoidWBore(R, r, d, n, p, thickness, rb) { - dth = 360/n; - union() { - for ( i = [0:p-1] ) { - polyhedron(points = [[rb*cos(dth*i), rb*sin(dth*i),0], - [(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i), 0], - [(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1)), 0], - [rb*cos(dth*(i+1)), rb*sin(dth*(i+1)), 0], - [rb*cos(dth*i), rb*sin(dth*i), thickness], - [(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i), thickness], - [(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1)), thickness], - [rb*cos(dth*(i+1)), rb*sin(dth*(i+1)), thickness]], - triangles = [[0, 1, 4], [4, 1, 5], - [1, 2, 5], [5, 2, 6], - [2, 3, 7], [7, 6, 2], - [3, 0, 4], [4, 7, 3], - [4, 5, 7], [7, 5, 6], - [0, 3, 1], [1, 3, 2]]); - } - } +module epitrochoidWBore(R, r, d, n, p, thickness, rb) +{ + dth = 360 / n; + union() + { + for (i = [0:p - 1]) { + polyhedron( + points = + [[rb * cos(dth * i), rb * sin(dth * i), 0], + [(R + r) * cos(dth * i) - d * cos((R + r) / r * dth * i), + (R + r) * sin(dth * i) - d * sin((R + r) / r * dth * i), + 0], + [(R + r) * cos(dth * (i + 1)) - + d * cos((R + r) / r * dth * (i + 1)), + (R + r) * sin(dth * (i + 1)) - + d * sin((R + r) / r * dth * (i + 1)), + 0], + [rb * cos(dth * (i + 1)), rb * sin(dth * (i + 1)), 0], + [rb * cos(dth * i), rb * sin(dth * i), thickness], + [(R + r) * cos(dth * i) - d * cos((R + r) / r * dth * i), + (R + r) * sin(dth * i) - d * sin((R + r) / r * dth * i), + thickness], + [(R + r) * cos(dth * (i + 1)) - + d * cos((R + r) / r * dth * (i + 1)), + (R + r) * sin(dth * (i + 1)) - + d * sin((R + r) / r * dth * (i + 1)), + thickness], + [rb * cos(dth * (i + 1)), + rb * sin(dth * (i + 1)), + thickness]], + triangles = [ + [ 0, 1, 4 ], + [ 4, 1, 5 ], + [ 1, 2, 5 ], + [ 5, 2, 6 ], + [ 2, 3, 7 ], + [ 7, 6, 2 ], + [ 3, 0, 4 ], + [ 4, 7, 3 ], + [ 4, 5, 7 ], + [ 7, 5, 6 ], + [ 0, 3, 1 ], + [ 1, 3, 2 ] + ]); + } + } } //=========================================== - //=========================================== // Epitrochoid Wedge with Bore, Linear Extrude // -module epitrochoidWBoreLinear(R, r, d, n, p, thickness, rb, twist) { - dth = 360/n; - linear_extrude(height = thickness, convexity = 10, twist = twist) { - union() { - for ( i = [0:p-1] ) { - polygon(points = [[rb*cos(dth*i), rb*sin(dth*i)], - [(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i)], - [(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1))], - [rb*cos(dth*(i+1)), rb*sin(dth*(i+1))]], - paths = [[0, 1, 2, 3]], convexity = 10); - } - } - } +module epitrochoidWBoreLinear(R, r, d, n, p, thickness, rb, twist) +{ + dth = 360 / n; + linear_extrude(height = thickness, convexity = 10, twist = twist) + { + union() + { + for (i = [0:p - 1]) { + polygon(points = [ + [rb * cos(dth * i), rb * sin(dth * i)], + [(R + r) * cos(dth * i) - + d * cos((R + r) / r * dth * i), + (R + r) * sin(dth * i) - + d * sin((R + r) / r * dth * i)], + [(R + r) * cos(dth * (i + 1)) - + d * cos((R + r) / r * dth * (i + 1)), + (R + r) * sin(dth * (i + 1)) - + d * sin((R + r) / r * dth * (i + 1))], + [rb * cos(dth * (i + 1)), rb * sin(dth * (i + 1))]], + paths = [[ 0, 1, 2, 3 ]], + convexity = 10); + } + } + } } //=========================================== - //=========================================== // Epitrochoid Wedge, Linear Extrude // -module epitrochoidLinear(R, r, d, n, p, thickness, twist) { - dth = 360/n; - linear_extrude(height = thickness, convexity = 10, twist = twist) { - union() { - for ( i = [0:p-1] ) { - polygon(points = [[0, 0], - [(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i)], - [(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1))]], - paths = [[0, 1, 2]], convexity = 10); - } - } - } +module epitrochoidLinear(R, r, d, n, p, thickness, twist) +{ + dth = 360 / n; + linear_extrude(height = thickness, convexity = 10, twist = twist) + { + union() + { + for (i = [0:p - 1]) { + polygon(points = + [ + [ 0, 0 ], + [ + (R + r) * cos(dth * i) - + d * cos((R + r) / r * dth * i), + (R + r) * sin(dth * i) - + d * sin((R + r) / r * dth * i) + ], + [ + (R + r) * cos(dth * (i + 1)) - + d * cos((R + r) / r * dth * (i + 1)), + (R + r) * sin(dth * (i + 1)) - + d * sin((R + r) / r * dth * (i + 1)) + ] + ], + paths = [[ 0, 1, 2 ]], + convexity = 10); + } + } + } } //=========================================== - //=========================================== // Hypotrochoid Wedge with Bore // -module hypotrochoidWBore(R, r, d, n, p, thickness, rb) { - dth = 360/n; - union() { - for ( i = [0:p-1] ) { - polyhedron(points = [[rb*cos(dth*i), rb*sin(dth*i),0], - [(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i), 0], - [(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1)), 0], - [rb*cos(dth*(i+1)), rb*sin(dth*(i+1)), 0], - [rb*cos(dth*i), rb*sin(dth*i), thickness], - [(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i), thickness], - [(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1)), thickness], - [rb*cos(dth*(i+1)), rb*sin(dth*(i+1)), thickness]], - triangles = [[0, 1, 4], [4, 1, 5], - [1, 2, 5], [5, 2, 6], - [2, 3, 7], [7, 6, 2], - [3, 0, 4], [4, 7, 3], - [4, 5, 7], [7, 5, 6], - [0, 3, 1], [1, 3, 2]]); - } - } +module hypotrochoidWBore(R, r, d, n, p, thickness, rb) +{ + dth = 360 / n; + union() + { + for (i = [0:p - 1]) { + polyhedron( + points = + [[rb * cos(dth * i), rb * sin(dth * i), 0], + [(R - r) * cos(dth * i) + d * cos((R - r) / r * dth * i), + (R - r) * sin(dth * i) - d * sin((R - r) / r * dth * i), + 0], + [(R - r) * cos(dth * (i + 1)) + + d * cos((R - r) / r * dth * (i + 1)), + (R - r) * sin(dth * (i + 1)) - + d * sin((R - r) / r * dth * (i + 1)), + 0], + [rb * cos(dth * (i + 1)), rb * sin(dth * (i + 1)), 0], + [rb * cos(dth * i), rb * sin(dth * i), thickness], + [(R - r) * cos(dth * i) + d * cos((R - r) / r * dth * i), + (R - r) * sin(dth * i) - d * sin((R - r) / r * dth * i), + thickness], + [(R - r) * cos(dth * (i + 1)) + + d * cos((R - r) / r * dth *, (i + 1)), + (R - r) * sin(dth * (i + 1)) - + d * sin((R - r) / r * dth * (i + 1)), + thickness], + [rb * cos(dth * (i + 1)), + rb * sin(dth * (i + 1)), + thickness]], + triangles = [ + [ 0, 1, 4 ], + [ 4, 1, 5 ], + [ 1, 2, 5 ], + [ 5, 2, 6 ], + [ 2, 3, 7 ], + [ 7, 6, 2 ], + [ 3, 0, 4 ], + [ 4, 7, 3 ], + [ 4, 5, 7 ], + [ 7, 5, 6 ], + [ 0, 3, 1 ], + [ 1, 3, 2 ] + ]); + } + } } //=========================================== - //=========================================== // Hypotrochoid Wedge with Bore, Linear Extrude // -module hypotrochoidWBoreLinear(R, r, d, n, p, thickness, rb, twist) { - dth = 360/n; - linear_extrude(height = thickness, convexity = 10, twist = twist) { - union() { - for ( i = [0:p-1] ) { - polygon(points = [[rb*cos(dth*i), rb*sin(dth*i)], - [(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i)], - [(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1))], - [rb*cos(dth*(i+1)), rb*sin(dth*(i+1))]], - paths = [[0, 1, 2, 3]], convexity = 10); - } - } - } +module hypotrochoidWBoreLinear(R, r, d, n, p, thickness, rb, twist) +{ + dth = 360 / n; + linear_extrude(height = thickness, convexity = 10, twist = twist) + { + union() + { + for (i = [0:p - 1]) { + polygon(points = [ + [rb * cos(dth * i), rb * sin(dth * i)], + [(R - r) * cos(dth * i) + + d * cos((R - r) / r * dth * i), + (R - r) * sin(dth * i) - + d * sin((R - r) / r * dth * i)], + [(R - r) * cos(dth * (i + 1)) + + d * cos((R - r) / r * dth * (i + 1)), + (R - r) * sin(dth * (i + 1)) - + d * sin((R - r) / r * dth * (i + 1))], + [rb * cos(dth * (i + 1)), rb * sin(dth * (i + 1))]], + paths = [[ 0, 1, 2, 3 ]], + convexity = 10); + } + } + } } //=========================================== - //=========================================== // Hypotrochoid Wedge, Linear Extrude // -module hypotrochoidLinear(R, r, d, n, p, thickness, twist) { - dth = 360/n; - linear_extrude(height = thickness, convexity = 10, twist = twist) { - union() { - for ( i = [0:p-1] ) { - polygon(points = [[0, 0], - [(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i)], - [(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1))]], - paths = [[0, 1, 2]], convexity = 10); - } - } - } +module hypotrochoidLinear(R, r, d, n, p, thickness, twist) +{ + dth = 360 / n; + linear_extrude(height = thickness, convexity = 10, twist = twist) + { + union() + { + for (i = [0:p - 1]) { + polygon(points = + [ + [ 0, 0 ], + [ + (R - r) * cos(dth * i) + + d * cos((R - r) / r * dth * i), + (R - r) * sin(dth * i) - + d * sin((R - r) / r * dth * i) + ], + [ + (R - r) * cos(dth * (i + 1)) + + d * cos((R - r) / r * dth * (i + 1)), + (R - r) * sin(dth * (i + 1)) - + d * sin((R - r) / r * dth * (i + 1)) + ] + ], + paths = [[ 0, 1, 2 ]], + convexity = 10); + } + } + } } -//=========================================== +//=========================================== diff --git a/text/alphabet_block.scad b/text/alphabet_block.scad index ff82cba2..ef55d2e0 100644 --- a/text/alphabet_block.scad +++ b/text/alphabet_block.scad @@ -1,24 +1,21 @@ +use /* -Parametric Alphabet Block +Parametric Alphabet Block Tony Buser http://tonybuser.com http://creativecommons.org/licenses/by/3.0/ */ -use - // change to any letter letter = "A"; -union() { - difference() { - cube(size = 20); - translate(v = [2, 2, 17]) { - cube(size = [16, 16, 5]); - } - } +union() +{ + difference() + { + cube(size = 20); + translate(v = [ 2, 2, 17 ]) { cube(size = [ 16, 16, 5 ]); } + } - translate(v = [10, 10, 15]) { - 8bit_char(letter, 2, 5); - } + translate(v = [ 10, 10, 15 ]) { 8bit_char(letter, 2, 5); } } diff --git a/text/bitmap.scad b/text/bitmap.scad index 3ae5db8a..63400720 100644 --- a/text/bitmap.scad +++ b/text/bitmap.scad @@ -1,3 +1,4 @@ + /* Bitmap and 8Bit Font Module Tony Buser @@ -5,1022 +6,1039 @@ http://tonybuser.com http://creativecommons.org/licenses/by/3.0/ */ -module bitmap(bitmap, block_size, height, row_size) { - width = block_size * row_size; - bitmap_size = row_size * row_size; - - function loc_x(loc) = floor(loc / row_size) * block_size; - function loc_y(loc) = loc % row_size * block_size; - function loc_z(loc) = (bitmap[loc]*height-height)/2; +module bitmap(bitmap, block_size, height, row_size) +{ + width = block_size * row_size; + bitmap_size = row_size * row_size; - translate(v = [-width/2+block_size/2,-width/2+block_size/2,height/2]) { - for (loc = [0:bitmap_size - 1]) { - if (bitmap[loc] != 0) { - union() { - translate(v = [loc_x(loc), loc_y(loc), loc_z(loc)]) { - cube(size = [block_size, block_size, height * bitmap[loc]], center = true); - } - } - } - } - } -} + function loc_x(loc) = floor(loc / row_size) * block_size; + function loc_y(loc) = loc % row_size * block_size; + function loc_z(loc) = (bitmap[loc] * height - height) / 2; -module 8bit_char(char, block_size, height, include_base) { - if (char == "0") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,1,1,1,0, - 0,1,1,1,1,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "1") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "2") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "3") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "4") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,1,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,1,1,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "5") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,1,1,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,0,0,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "6") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "7") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "8") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "9") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,1,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "A") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "B") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "C") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "D") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,0,0,0, - 0,1,1,0,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,1,1,0,0, - 0,1,1,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "E") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,1,1,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "F") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,1,1,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "G") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,1,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,1,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "H") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "I") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "J") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,1,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "K") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,1,1,0,0, - 0,1,1,1,1,0,0,0, - 0,1,1,1,1,0,0,0, - 0,1,1,0,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "L") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "M") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,0,1,1, - 0,1,1,1,0,1,1,1, - 0,1,1,1,1,1,1,1, - 0,1,1,0,1,0,1,1, - 0,1,1,0,0,0,1,1, - 0,1,1,0,0,0,1,1, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "N") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,0,1,1,0, - 0,1,1,1,1,1,1,0, - 0,1,1,1,1,1,1,0, - 0,1,1,0,1,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "O") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "P") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "Q") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,0,0, - 0,0,1,1,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "R") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "S") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "T") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "U") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "V") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "W") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,0,1,1, - 0,1,1,0,0,0,1,1, - 0,1,1,0,1,0,1,1, - 0,1,1,1,1,1,1,1, - 0,1,1,1,0,1,1,1, - 0,1,1,0,0,0,1,1, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "X") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "Y") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "Z") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "OE") { - bitmap([ - 0,0,1,0,0,1,0,0, - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0 - ], block_size, height, 8); - } else if (char == "a") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "b") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "c") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "d") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "e") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,1,0, - 0,1,1,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "f") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,1,1,1,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,1,1,1,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "g") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,0,0,0,0,1,1,0, - 0,1,1,1,1,1,0,0 - ], block_size, height, 8); - } else if (char == "h") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "i") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "j") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,1,1,1,1,0,0 - ], block_size, height, 8); - } else if (char == "k") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,1,1,0,0, - 0,1,1,1,1,0,0,0, - 0,1,1,0,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "l") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "m") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,1,1, - 0,1,1,1,1,1,1,1, - 0,1,1,0,1,0,1,1, - 0,1,1,0,0,0,1,1, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "n") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "o") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "p") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "q") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,1,1,0 - ], block_size, height, 8); - } else if (char == "r") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "s") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,1,0, - 0,1,1,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,1,1,0, - 0,1,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "t") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "u") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "v") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "w") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,0,1,1, - 0,1,1,0,1,0,1,1, - 0,1,1,1,1,1,1,1, - 0,0,1,1,1,1,1,0, - 0,0,1,1,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "x") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "y") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,0,0,0,1,1,0,0, - 0,1,1,1,1,0,0,0 - ], block_size, height, 8); - } else if (char == "z") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "+") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,1,1,1,1,1,1,0, - 0,1,1,1,1,1,1,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "-") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == ":") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == ".") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == ",") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,0,0,0,0 - ], block_size, height, 8); - } else if (char == "?") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "=") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "*") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 1,1,1,1,1,1,1,1, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "!") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "''") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "#") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 1,1,1,1,1,1,1,1, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 1,1,1,1,1,1,1,1, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "$") { - bitmap([ - 0,0,0,1,1,0,0,0, - 0,0,1,1,1,1,1,0, - 0,1,1,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,1,1,0, - 0,1,1,1,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "%") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,1,1,0,0, - 0,0,1,1,1,0,0,0, - 0,0,1,1,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,0,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "&") { - bitmap([ - 0,0,0,1,1,1,0,0, - 0,0,1,1,0,1,1,0, - 0,0,0,1,1,1,0,0, - 0,0,1,1,1,0,0,0, - 0,1,1,0,1,1,1,1, - 0,1,1,0,1,1,1,0, - 0,0,1,1,1,0,1,1, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "@") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,1,1,1,0, - 0,1,1,0,1,1,1,0, - 0,1,1,0,0,0,0,0, - 0,0,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "'") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "(") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,1,0,0, - 0,0,1,1,1,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,1,1,1,0,0,0, - 0,0,0,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == ")") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,0,0,0, - 0,0,0,1,1,1,0,0, - 0,0,0,0,1,1,0,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,1,0,0, - 0,0,1,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "<") { - bitmap([ - 0,0,0,0,0,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,1,1,0,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == ">") { - bitmap([ - 0,1,1,0,0,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "[") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,1,1,0,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "]") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,1,1,0,0, - 0,0,0,0,1,1,0,0, - 0,0,0,0,1,1,0,0, - 0,0,0,0,1,1,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "/") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "\\") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,1,1,0,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,0,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "_") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 1,1,1,1,1,1,1,1 - ], block_size, height, 8); - } else if (char == "|") { - bitmap([ - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0 - ], block_size, height, 8); - } else { - echo("Invalid Character: ", char); - } + translate(v = [ + -width / 2 + block_size / 2, + -width / 2 + block_size / 2, + height / 2 + ]) + { + for (loc = [0:bitmap_size - 1]) { + if (bitmap[loc] != 0) { + union() + { + translate(v = [ loc_x(loc), loc_y(loc), loc_z(loc) ]) + { + cube(size = + [ + block_size, + block_size, + height * bitmap[loc] + ], + center = true); + } + } + } + } + } +} +module 8bit_char(char, block_size, height, include_base) +{ + if (char == "0") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, + 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "1") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "2") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "3") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "4") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "5") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "6") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "7") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, + 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "8") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "9") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "A") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "B") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "C") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "D") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, + 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, + 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "E") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "F") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "G") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "H") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + bloc,k_size, + height, + 8); + } else if (char == "I") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "J") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "K") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, + 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "L") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "M") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, + 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, + 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "N") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "O") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "P") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "Q") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "R") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "S") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "T") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "U") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "V") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "W") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, + 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, + 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, + 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "X") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "Y") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "Z") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "OE") { + bitmap( + [ + 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "a") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "b") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "c") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "d") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "e") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "f") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "g") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "h") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "i") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "j") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "k") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, + 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "l") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "m") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, + 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "n") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "o") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "p") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "q") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0 + ], + block_size, + height, + 8); + } else if (char == "r") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "s") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "t") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "u") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "v") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "w") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, + 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, + 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "x") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "y") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "z") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "+") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "-") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == ":") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == ".") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == ",") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "?") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "=") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "*") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "!") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "''") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "#") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "$") { + bitmap( + [ + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "%") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, + 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "&") { + bitmap( + [ + 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, + 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, + 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, + 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "@") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, + 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "'") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "(") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, + 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == ")") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_si,ze, + height, + 8); + } else if (char == "<") { + bitmap( + [ + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == ">") { + bitmap( + [ + 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "[") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, + 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "]") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "/") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "\\") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "_") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 + ], + block_size, + height, + 8); + } else if (char == "|") { + bitmap( + [ + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 + ], + block_size, + height, + 8); + } else { + echo("Invalid Character: ", char); + } } -module 8bit_str(chars, char_count, block_size, height) { - echo(str("Total Width: ", block_size * 8 * char_count, "mm")); - union() { - for (count = [0:char_count-1]) { - translate(v = [0, count * block_size * 8, 0]) { - 8bit_char(chars[count], block_size, height); - } - } - } +module 8bit_str(chars, char_count, block_size, height) +{ + echo(str("Total Width: ", block_size * 8 * char_count, "mm")); + union() + { + for (count = [0:char_count - 1]) { + translate(v = [ 0, count * block_size * 8, 0 ]) + { + 8bit_char(chars[count], block_size, height); + } + } + } } /* @@ -1030,32 +1048,32 @@ block_size = 5; height = 10; union() { - translate(v = [0,0,5]) { - 8bit_char("A", block_size, height); + translate(v = [0,0,5]) { + 8bit_char("A", block_size, height); - //bitmap([ - // 1,1,1,1,1,1,1,1, - // 1,0,0,1,1,0,0,1, - // 1,0,1,1,1,1,0,1, - // 1,1,1,0,0,1,1,1, - // 1,1,1,0,0,1,1,1, - // 1,0,1,1,1,1,0,1, - // 1,0,0,1,1,0,0,1, - // 1,1,1,1,1,1,1,1 - //], block_size, height, 8); + //bitmap([ + // 1,1,1,1,1,1,1,1, + // 1,0,0,1,1,0,0,1, + // 1,0,1,1,1,1,0,1, + // 1,1,1,0,0,1,1,1, + // 1,1,1,0,0,1,1,1, + // 1,0,1,1,1,1,0,1, + // 1,0,0,1,1,0,0,1, + // 1,1,1,1,1,1,1,1 + //], block_size, height, 8); - //bitmap([ - // 1,1,1,1, - // 1,0,0,1, - // 1,0,0,1, - // 1,1,1,1 - //], block_size, height, 4); - } - translate(v = [0,0,5/2]) { - color([0,0,1,1]) { - cube(size = [block_size * 8, block_size * 8, 5], center = true); - } - } + //bitmap([ + // 1,1,1,1, + // 1,0,0,1, + // 1,0,0,1, + // 1,1,1,1 + , //], block_size, height, 4); + } + translate(v = [0,0,5/2]) { + color([0,0,1,1]) { + cube(size = [block_size * 8, block_size * 8, 5], center = true); + } + } } @@ -1066,13 +1084,14 @@ block_size = 1; height = 5; union() { - translate(v = [0,-block_size*8*char_count/2+block_size*8/2,5]) { - 8bit_str(chars, char_count, block_size, height); - } - translate(v = [0,0,5/2]) { - color([0,0,1,1]) { - cube(size = [block_size * 8, block_size * 8 * char_count, 5], center = true); - } - } + translate(v = [0,-block_size*8*char_count/2+block_size*8/2,5]) { + 8bit_str(chars, char_count, block_size, height); + } + translate(v = [0,0,5/2]) { + color([0,0,1,1]) { + cube(size = [block_size * 8, block_size * 8 * char_count, 5], center += true); + } + } } */ diff --git a/text/fonts.scad b/text/fonts.scad index 91e2d17f..f234e119 100644 --- a/text/fonts.scad +++ b/text/fonts.scad @@ -1,71 +1,123 @@ + // Font Functions // Encoding from http://en.wikipedia.org/wiki/ASCII // Author: Andrew Plumb // License: LGPL 2.1 -module outline_2d(outline,points,paths,width=0.1,resolution=8) { - if(outline && resolution > 4) { - for(j=[0:len(paths)-1]) union() { - for(i=[1:len(paths[j])-1]) hull() { - translate(points[paths[j][i-1]]) circle($fn=resolution,r=width/2); - translate(points[paths[j][i]]) circle($fn=resolution,r=width/2); - } - hull() { - translate(points[paths[j][len(paths[j])-1]]) circle($fn=resolution,r=width/2); - translate(points[paths[j][0]]) circle($fn=resolution,r=width/2); - } +module outline_2d(outline, points, paths, width = 0.1, resolution = 8) +{ + if (outline && resolution > 4) { + for (j = [0:len(paths) - 1]) + union() + { + for (i = [1:len(paths[j]) - 1]) + hull() + { + translate(points[paths[j][i - 1]]) + circle($fn = resolution, r = width / 2); + translate(points[paths[j][i]]) + circle($fn = resolution, r = width / 2); + } + hull() + { + translate(points[paths[j][len(paths[j]) - 1]]) + circle($fn = resolution, r = width / 2); + translate(points[paths[j][0]]) + circle($fn = resolution, r = width / 2); + } + } + } else { + polygon(points = points, paths = paths); } - } else { - polygon(points=points,paths=paths); - } } -module bold_2d(bold,width=0.2,resolution=8) { - for(j=[0:$children-1]) { - if(bold) { - union() { +module bold_2d(bold, width = 0.2, resolution = 8) +{ + for (j = [0:$children - 1]) { + if (bold) { + union() + { + child(j); + for (i = [0:resolution - 1]) + assign(dx = width * cos(360 * i / resolution), + dy = width * sin(360 * i / resolution)) + translate([ dx, dy ]) child(j); + } + } else { child(j); - for(i=[0:resolution-1]) assign(dx=width*cos(360*i/resolution),dy=width*sin(360*i/resolution)) - translate([dx,dy]) child(j); - } - } else { - child(j); + } } - } } -module polytext(charstring,size,font,line=0,justify=1,align=-1 - ,bold=false,bold_width=0.2,bold_resolution=8 - ,underline=false,underline_start=[0,0],underline_width=1.0 - ,outline=false,outline_width=0.2,outline_resolution=8 - ,strike=false,strike_start=[-0.5,0],strike_width=1.0 - ) { - line_length=len(charstring)*font[0][0]; - line_shift_x=-line_length/2+justify*line_length/2; - char_width=font[0][0]; - char_height=font[0][1]; - char_shift_height=-char_height/2-align*char_height/2; - char_thickness=font[0][2]; - char_index_map=search(charstring,font[2],1,1); - for(i=[0:len(char_index_map)-1]) assign( thisCharIndex=char_index_map[i], x_pos=i*size+line_shift_x*size/char_width) { - translate([x_pos,line*size+char_shift_height*size/char_height]) scale([size/char_width,size/char_height]) { - if(char_thickness==0) - bold_2d(bold,width=bold_width,resolution=bold_resolution) - outline_2d(outline,points=font[2][thisCharIndex][6][0],paths=font[2][thisCharIndex][6][1] - ,width=outline_width,resolution=outline_resolution); - if( charstring[i] != " " ) { - if(underline) translate(underline_start) - square(size=[char_width-2*underline_start[0],underline_width],center=false); - if(strike) translate([strike_start[0],char_height/2+strike_start[1]]) - square(size=[char_width-2*strike_start[0],strike_width],center=false); - } - if(char_thickness>0) - polyhedron(points=font[2][thisCharIndex][6][0],triangles=font[2][thisCharIndex][6][1]); - } - } +module polytext(charstring, + size, + font, + line = 0, + justify = 1, + align = -1, + bold = false, + bold_width = 0.2, + bold_resolution = 8, + underline = false, + underline_start = [ 0, 0 ], + underline_width = 1.0, + outline = false, + outline_width = 0.2, + outline_resolution = 8, + strike = false, + strike_start = [ -0.5, 0 ], + strike_width = 1.0) +{ + line_length = len(charstring) * font[0][0]; + line_shift_x = -line_length / 2 + justify * line_length / 2; + char_width = font[0][0]; + char_height = font[0][1]; + char_shift_height = -char_height / 2 - align * char_height / 2; + char_thickness = font[0][2]; + char_index_map = search(charstring, font[2], 1, 1); + for (i = [0:len(char_index_map) - 1]) + assign(thisCharIndex = char_index_map[i], + x_pos = i * size + line_shift_x * size / char_width) + { + translate( + [ x_pos, line * size + char_shift_height * size / char_height ]) + scale([ size / char_width, size / char_height ]) + { + if (char_thickness == 0) + bold_2d( + bold, width = bold_width, resolution = bold_resolution) + outline_2d(outline, + points = font[2][thisCharIndex][6][0], + paths = font[2][thisCharIndex][6][1], + width = outline_width, + resolution = outline_resolution); + if (charstring[i] != " ") { + if (underline) + translate(underline_start) + square(size = + [ + char_width - 2 * underline_start[0], + underline_width + ], + center = false); + if (strike) + translate([ + strike_start[0], + char_height / 2 + strike_start[1] + ]) square(size = + [ + char_width - 2 * strike_start[0], + strike_width + ], + center = false); + } + if (char_thickness > 0) + polyhedron(points = font[2][thisCharIndex][6][0], + triangles = font[2][thisCharIndex][6][1]); + } + } } - function 8bit_polyfont(dx=0.1,dy=0.1) = [ [8,8,0,"fixed"],["Decimal Byte","Caret Notation","Character Escape Code","Abbreviation","Name","Bound Box","[points,paths]"] ,[ @@ -550,47 +602,89 @@ function 8bit_polyfont(dx=0.1,dy=0.1) = [ // From http://www.brailleauthority.org/sizespacingofbraille/ // -// Section 3.2 of Specification 800 (Braille Books and Pamphlets) February 2008 reads as follows: +// Section 3.2 of Specification 800 (Braille Books and Pamphlets) February +// 2008 reads as follows: // Size and Spacing -// 3.2.1 The nominal height of braille dots shall be 0.019 inches [0.48 mm] and shall be uniform within any given transcription. -// 3.2.2 The nominal base diameter of braille dots shall be 0.057 inches [1.44 mm]. -// 3.2.3 Cell spacing of dots shall conform to the following: -// 3.2.3.1 The nominal distance from center to center of adjacent dots (horizontally or vertically, but not diagonally) +// 3.2.1 The nominal height of braille dots shall be 0.019 inches [0.48 mm] +// and shall be uniform within any given transcription. 3.2.2 The nominal +// base diameter of braille dots shall be 0.057 inches [1.44 mm]. 3.2.3 Cell +// spacing of dots shall conform to the following: 3.2.3.1 The nominal +// distance from center to center of adjacent dots (horizontally or +// vertically, but not diagonally) // in the same cell shall be 0.092 inches [2.340 mm]. -// 3.2.3.2 The nominal distance from center to center of corresponding dots in adjacent cells shall be 0.245 inches [6.2 mm]. -// 3.2.4 The nominal line spacing of braille cells from center to center of nearest corresponding dots in adjacent lines shall +// 3.2.3.2 The nominal distance from center to center of corresponding dots +// in adjacent cells shall be 0.245 inches [6.2 mm]. 3.2.4 The nominal +// line spacing of braille cells from center to center of nearest +// corresponding dots in adjacent lines shall // be 0.400 inches [1.000 cm]. // // Additional References: // http://www.loc.gov/nls/specs/800.pdf // http://www.tiresias.org/research/reports/braille_cell.htm -module braille_ascii_spec800(inString,dot_backing=true,cell_backing=false,justify=1,align=-1,dot_h=0.48,dot_d=1.44,dot_spacing=2.340,cell_d2d_spacing=6.2, line_d2d_spacing=10.0, echo_translate=true) { - // justify: - // -1 : left side - // 0 : center - // 1 : right side (default) - // align: - // -1 : bottom braille cell edge - shift up (default) - // 0 : center braille cell - // 1 : top braille cell edge - shift down - thisFont=braille_ascii_font(dot_h=dot_h,dot_d=dot_d,dot_spacing=dot_spacing - ,cell_d2d_spacing=cell_d2d_spacing,line_d2d_spacing=line_d2d_spacing); - x_shift=thisFont[0][0]; - y_shift=thisFont[0][1]; - theseIndicies=search(inString,thisFont[2],1,1); - for( i=[0:len(theseIndicies)-1]) translate([i*x_shift-(1-justify)*x_shift*len(theseIndicies)/2,-y_shift*(align+1)/2]) - assign(dotPattern=thisFont[2][theseIndicies[i]][6]) { - if(dot_backing) translate([cell_d2d_spacing/2-dot_spacing/2-dot_d/2,line_d2d_spacing/2-dot_spacing-dot_d/2,-dot_h]) - cube(size=[dot_spacing+dot_d,2*dot_spacing+dot_d,dot_h],center=false); - if(cell_backing) translate([0,0,-dot_h]) - cube(size=[x_shift,y_shift,dot_h],center=false); - if(echo_translate) echo(str(inString[i]," maps to '",thisFont[2][theseIndicies[i]][4],"'")); - for(dotIndex=dotPattern) { - translate([cell_d2d_spacing/2-dot_spacing/2+floor((dotIndex-1)/3)*dot_spacing - , line_d2d_spacing/2-dot_spacing+(2-(dotIndex-1)%3)*dot_spacing]) - scale([dot_d,dot_d,2*dot_h]) sphere($fn=8,r=0.5); - } - } +module braille_ascii_spec800(inString, + dot_backing = true, + cell_backing = false, + justify = 1, + align = -1, + dot_h = 0.48, + dot_d = 1.44, + dot_spacing = 2.340, + cell_d2d_spacing = 6.2, + line_d2d_spacing = 10.0, + echo_translate = true) +{ + // justify: + // -1 : left side + // 0 : center + // 1 : right side (default) + // align: + // -1 : bottom braille cell edge - shift up (default) + // 0 : center braille cell + // 1 : top braille cell edge - shift down + thisFont = braille_ascii_font(dot_h = dot_h, + dot_d = dot_d, + dot_spacing = dot_spacing, + cell_d2d_spacing = cell_d2d_spacing, + line_d2d_spacing = line_d2d_spacing); + x_shift = thisFont[0][0]; + y_shift = thisFont[0][1]; + theseIndicies = search(inString, thisFont[2], 1, 1); + for (i = [0:len(theseIndicies) - 1]) + translate([ + i * x_shift - (1 - justify) * x_shift * len(theseIndicies) / 2, + -y_shift * (align + 1) / 2 + ]) assign(dotPattern = thisFont[2][theseIndicies[i]][6]) + { + if (dot_backing) + translate([ + cell_d2d_spacing / 2 - dot_spacing / 2 - dot_d / 2, + line_d2d_spacing / 2 - dot_spacing - dot_d / 2, + -dot_h + ]) cube(size = + [ + dot_spacing + dot_d, + 2 * dot_spacing + dot_d, + dot_h + ], + center = false); + if (cell_backing) + translate([ 0, 0, -dot_h ]) + cube(size = [ x_shift, y_shift, dot_h ], center = false); + if (echo_translate) + echo(str(inStrin,g[i], + " maps to '", + thisFont[2][theseIndicies[i]][4], + "'")); + for (dotIndex = dotPattern) { + translate([ + cell_d2d_spacing / 2 - dot_spacing / 2 + + floor((dotIndex - 1) / 3) * dot_spacing, + line_d2d_spacing / 2 - dot_spacing + + (2 - (dotIndex - 1) % 3) * + dot_spacing + ]) scale([ dot_d, dot_d, 2 * dot_h ]) sphere($fn = 8, r = 0.5); + } + } } // Encoding from http://en.wikipedia.org/wiki/Braille_ASCII @@ -598,141 +692,148 @@ module braille_ascii_spec800(inString,dot_backing=true,cell_backing=false,justif // 1 4 // 2 5 // 3 6 -function braille_ascii_font(dot_h=0.48,dot_d=1.44,dot_spacing=2.340,cell_d2d_spacing=6.2,line_d2d_spacing=10.0) = [ - [cell_d2d_spacing,line_d2d_spacing,0,"bump"],["Decimal Byte","Caret Notation","Character Escape Code","Abbreviation","Name","Bound Box","[bump_list]"] - ,[ - [ 0,"^@","\0","NUL","Null character",[[0,0],[2,3]],[]] - ,[ 1,"^A","", "SOH","Start of Header",[[0,0],[2,3]],[]] - ,[ 2,"^B","", "STX","Start of Text",[[0,0],[2,3]],[]] - ,[ 3,"^C","", "ETX","End of Text",[[0,0],[2,3]],[]] - ,[ 4,"^D","", "EOT","End of Transmission",[[0,0],[2,3]],[]] - ,[ 5,"^E","", "ENQ","Enquiry",[[0,0],[2,3]],[]] - ,[ 6,"^F","", "ACK","Acknowledgment",[[0,0],[2,3]],[]] - ,[ 7,"^G","\a","BEL","Bell",[[0,0],[2,3]],[]] - ,[ 8,"^H","\b","BS", "Backspace",[[0,0],[2,3]],[]] - ,[ 9,"^I","\t","HT", "Horizontal Tab",[[0,0],[2,3]],[]] - ,[ 10,"^J","\n","LF", "Line Feed",[[0,0],[2,3]],[]] - ,[ 11,"^K","\v","VT", "Vertical Tab",[[0,0],[2,3]],[]] - ,[ 12,"^L","\f","FF", "Form feed",[[0,0],[2,3]],[]] - ,[ 13,"^M","\r","CR", "Carriage return",[[0,0],[2,3]],[]] - ,[ 14,"^N","", "SO", "Shift Out",[[0,0],[2,3]],[]] - ,[ 15,"^O","", "SI", "Shift In",[[0,0],[2,3]],[]] - ,[ 16,"^P","", "DLE","Data Link Escape",[[0,0],[2,3]],[]] - ,[ 17,"^Q","", "DC1","Device Control 1",[[0,0],[2,3]],[]] - ,[ 18,"^R","", "DC2","Device Control 2",[[0,0],[2,3]],[]] - ,[ 19,"^S","", "DC3","Device Control 3",[[0,0],[2,3]],[]] - ,[ 20,"^T","", "DC4","Device Control 4",[[0,0],[2,3]],[]] - ,[ 21,"^U","", "NAK","Negative Acknowledgement",[[0,0],[2,3]],[]] - ,[ 22,"^V","", "SYN","Synchronous Idle",[[0,0],[2,3]],[]] - ,[ 23,"^W","", "ETB","End of Transmission Block",[[0,0],[2,3]],[]] - ,[ 24,"^X","", "CAN","Cancel",[[0,0],[2,3]],[]] - ,[ 25,"^Y","", "EM", "End of Medium",[[0,0],[2,3]],[]] - ,[ 26,"^Z","", "SUB","Substitute",[[0,0],[2,3]],[]] - ,[ 27,"^[","\e","ESC","Escape",[[0,0],[2,3]],[]] - ,[ 28,"^\\","", "FS", "File Separator",[[0,0],[2,3]],[]] - ,[ 29,"^]","", "GS", "Group Separator",[[0,0],[2,3]],[]] - ,[ 30,"^^","", "RS", "Record Separator",[[0,0],[2,3]],[]] - ,[ 31,"^_","", "US", "Unit Separator",[[0,0],[2,3]],[]] - ,[ 32," "," ", "", "Space",[[0,0],[2,3]],[]] - ,[ 33,"!","!", "", "the",[[0,0],[2,3]],[ 2,3,4,6 ]] - ,[ 34,"\"","\"","", "(contraction)",[[0,0],[2,3]],[ 5 ]] - ,[ 35,"#","#", "", "(number prefix)",[[0,0],[2,3]],[ 3,4,5,6 ]] - ,[ 36,"$","$", "", "ed",[[0,0],[2,3]],[ 1,2,4,6 ]] - ,[ 37,"%","%", "", "sh",[[0,0],[2,3]],[ 1,4,6 ]] - ,[ 38,"&","&", "", "and",[[0,0],[2,3]],[ 1,2,3,4,6 ]] - ,[ 39,"'","'", "", "",[[0,0],[2,3]],[ 3 ]] - ,[ 40,"(","(", "", "of",[[0,0],[2,3]],[ 1,2,3,5,6 ]] - ,[ 41,")",")", "", "with",[[0,0],[2,3]],[ 2,3,4,5,6 ]] - ,[ 42,"*","*", "", "ch",[[0,0],[2,3]],[ 1,6 ]] - ,[ 43,"+","+", "", "ing",[[0,0],[2,3]],[ 3,4,6 ]] - ,[ 44,",",",", "", "(uppercase prefix)",[[0,0],[2,3]],[ 6 ]] - ,[ 45,"-","-", "", "",[[0,0],[2,3]],[ 3,6 ]] - ,[ 46,".",".", "", "(italic prefix)",[[0,0],[2,3]],[ 4,6 ]] - ,[ 47,"/","/", "", "st",[[0,0],[2,3]],[ 3,4 ]] - ,[ 48,"0","0", "", "\"",[[0,0],[2,3]],[ 3,5,6 ]] - ,[ 49,"1","1", "", ",",[[0,0],[2,3]],[ 2 ]] - ,[ 50,"2","2", "", ";",[[0,0],[2,3]],[ 2,3 ]] - ,[ 51,"3","3", "", ":",[[0,0],[2,3]],[ 2,5 ]] - ,[ 52,"4","4", "", ".",[[0,0],[2,3]],[ 2,5,6 ]] - ,[ 53,"5","5", "", "en",[[0,0],[2,3]],[ 2,6 ]] - ,[ 54,"6","6", "", "!",[[0,0],[2,3]],[ 2,3,5 ]] - ,[ 55,"7","7", "", "( or )",[[0,0],[2,3]],[ 2,3,5,6 ]] - ,[ 56,"8","8", "", "\" or ?",[[0,0],[2,3]],[ 2,3,6 ]] - ,[ 57,"9","9", "", "in",[[0,0],[2,3]],[ 3,5 ]] - ,[ 58,":",":", "", "wh",[[0,0],[2,3]],[ 1,5,6 ]] - ,[ 59,";",";", "", "(letter prefix)",[[0,0],[2,3]],[ 5,6 ]] - ,[ 60,"<","<", "", "gh",[[0,0],[2,3]],[ 1,2,6 ]] - ,[ 61,"=","=", "", "for",[[0,0],[2,3]],[ 1,2,3,4,5,6 ]] - ,[ 62,">",">", "", "ar",[[0,0],[2,3]],[ 3,4,5 ]] - ,[ 63,"?","?", "", "th",[[0,0],[2,3]],[ 1,4,5,6 ]] - ,[ 64,"@","@", "", "(accent prefix)",[[0,0],[2,3]],[ 4 ]] - ,[ 65,"A","A", "", "a",[[0,0],[2,3]],[ 1 ]] - ,[ 66,"B","B", "", "b",[[0,0],[2,3]],[ 1,2 ]] - ,[ 67,"C","C", "", "c",[[0,0],[2,3]],[ 1,4 ]] - ,[ 68,"D","D", "", "d",[[0,0],[2,3]],[ 1,4,5 ]] - ,[ 69,"E","E", "", "e",[[0,0],[2,3]],[ 1,5 ]] - ,[ 70,"F","F", "", "f",[[0,0],[2,3]],[ 1,2,4 ]] - ,[ 71,"G","G", "", "g",[[0,0],[2,3]],[ 1,2,4,5 ]] - ,[ 72,"H","H", "", "h",[[0,0],[2,3]],[ 1,2,5 ]] - ,[ 73,"I","I", "", "i",[[0,0],[2,3]],[ 2,4 ]] - ,[ 74,"J","J", "", "j",[[0,0],[2,3]],[ 2,4,5 ]] - ,[ 75,"K","K", "", "k",[[0,0],[2,3]],[ 1,3 ]] - ,[ 76,"L","L", "", "l",[[0,0],[2,3]],[ 1,2,3 ]] - ,[ 77,"M","M", "", "m",[[0,0],[2,3]],[ 1,3,4 ]] - ,[ 78,"N","N", "", "n",[[0,0],[2,3]],[ 1,3,4,5 ]] - ,[ 79,"O","O", "", "o",[[0,0],[2,3]],[ 1,3,5 ]] - ,[ 80,"P","P", "", "p",[[0,0],[2,3]],[ 1,2,3,4 ]] - ,[ 81,"Q","Q", "", "q",[[0,0],[2,3]],[ 1,2,3,4,5 ]] - ,[ 82,"R","R", "", "r",[[0,0],[2,3]],[ 1,2,3,5 ]] - ,[ 83,"S","S", "", "s",[[0,0],[2,3]],[ 2,3,4 ]] - ,[ 84,"T","T", "", "t",[[0,0],[2,3]],[ 2,3,4,5 ]] - ,[ 85,"U","U", "", "u",[[0,0],[2,3]],[ 1,3,6 ]] - ,[ 86,"V","V", "", "v",[[0,0],[2,3]],[ 1,2,3,6 ]] - ,[ 87,"W","W", "", "w",[[0,0],[2,3]],[ 2,4,5,6 ]] - ,[ 88,"X","X", "", "x",[[0,0],[2,3]],[ 1,3,4,6 ]] - ,[ 89,"Y","Y", "", "y",[[0,0],[2,3]],[ 1,3,4,5,6 ]] - ,[ 90,"Z","Z", "", "z",[[0,0],[2,3]],[ 1,3,5,6 ]] - ,[ 91,"[","[", "", "ow",[[0,0],[2,3]],[ 2,4,6 ]] // ]] - ,[ 92,"\\","\\","", "ou",[[0,0],[2,3]],[ 1,2,5,6 ]] // [[ - ,[ 93,"]","]", "", "er",[[0,0],[2,3]],[ 1,2,4,5,6 ]] - ,[ 94,"^","^", "", "(contraction)",[[0,0],[2,3]],[ 4,5 ]] - ,[ 95,"_","_", "", "(contraction)",[[0,0],[2,3]],[ 4,5,6 ]] - ,[ 96,"`","`", "", "",[[0,0],[2,3]],[ - ]] -// Repeating upper-case patterns for lower-case letters. - ,[ 97,"a","a", "", "a",[[0,0],[2,3]],[ 1 ]] - ,[ 98,"b","b", "", "b",[[0,0],[2,3]],[ 1,2 ]] - ,[ 99,"c","c", "", "c",[[0,0],[2,3]],[ 1,4 ]] - ,[100,"d","d", "", "d",[[0,0],[2,3]],[ 1,4,5 ]] - ,[101,"e","e", "", "e",[[0,0],[2,3]],[ 1,5 ]] - ,[102,"f","f", "", "f",[[0,0],[2,3]],[ 1,2,4 ]] - ,[103,"g","g", "", "g",[[0,0],[2,3]],[ 1,2,4,5 ]] - ,[104,"h","h", "", "h",[[0,0],[2,3]],[ 1,2,5 ]] - ,[105,"i","i", "", "i",[[0,0],[2,3]],[ 2,4 ]] - ,[106,"j","j", "", "j",[[0,0],[2,3]],[ 2,4,5 ]] - ,[107,"k","k", "", "k",[[0,0],[2,3]],[ 1,3 ]] - ,[108,"l","l", "", "l",[[0,0],[2,3]],[ 1,2,3 ]] - ,[109,"m","m", "", "m",[[0,0],[2,3]],[ 1,3,4 ]] - ,[110,"n","n", "", "n",[[0,0],[2,3]],[ 1,3,4,5 ]] - ,[111,"o","o", "", "o",[[0,0],[2,3]],[ 1,3,5 ]] - ,[112,"p","p", "", "p",[[0,0],[2,3]],[ 1,2,3,4 ]] - ,[113,"q","q", "", "q",[[0,0],[2,3]],[ 1,2,3,4,5 ]] - ,[114,"r","r", "", "r",[[0,0],[2,3]],[ 1,2,3,5 ]] - ,[115,"s","s", "", "s",[[0,0],[2,3]],[ 2,3,4 ]] - ,[116,"t","t", "", "t",[[0,0],[2,3]],[ 2,3,4,5 ]] - ,[117,"u","u", "", "u",[[0,0],[2,3]],[ 1,3,6 ]] - ,[118,"v","v", "", "v",[[0,0],[2,3]],[ 1,2,3,6 ]] - ,[119,"w","w", "", "w",[[0,0],[2,3]],[ 2,4,5,6 ]] - ,[120,"x","x", "", "x",[[0,0],[2,3]],[ 1,3,4,6 ]] - ,[121,"y","y", "", "y",[[0,0],[2,3]],[ 1,3,4,5,6 ]] - ,[122,"z","z", "", "z",[[0,0],[2,3]],[ 1,3,5,6 ]] - ,[123,"{","{", "", "",[[0,0],[2,3]],[ - ]] - ,[124,"|","|", "", "",[[0,0],[2,3]],[ - ]] - ,[125,"}","}", "", "",[[0,0],[2,3]],[ - ]] - ,[126,"~","~", "", "",[[0,0],[2,3]],[ - ]] - ,[127,"^?","", "DEL","Delete",[[0,0],[2,3]],[]] - ] ]; +function braille_ascii_font(dot_h = 0.48, + dot_d = 1.44, + dot_spacing = 2.340, + cell_d2d_spacing = 6.2, + line_d2d_spacing = 10.0) = + [[cell_d2d_spacing, line_d2d_spacing, 0, "bump"], + ["Decimal Byte", + "Caret Notation", + "Character Escape Code", + "Abbreviation", + "Name", + "Bound Box", + "[bump_list]"], + [[0, "^@", "\0", "NUL", "Null character", [[0, 0], [2, 3]], []], + [1, "^A", "", "SOH", "Start of Header", [[0, 0], [2, 3]], []], + [2, "^B", "", "STX", "Start of Text", [[0, 0], [2, 3]], []], + [3, "^C", "", "ETX", "End of Text", [[0, 0], [2, 3]], []], + [4, "^D", "", "EOT", "End of Transmission", [[0, 0], [2, 3]], []], + [5, "^E", "", "ENQ", "Enquiry", [[0, 0], [2, 3]], []], + [6, "^F", "", "ACK", "Acknowledgment", [[0, 0], [2, 3]], []], + [7, "^G", "\a", "BEL", "Bell", [[0, 0], [2, 3]], []], + [8, "^H", "\b", "BS", "Backspace", [[0, 0], [2, 3]], []], + [9, "^I", "\t", "HT", "Horizontal Tab", [[0, 0], [2, 3]], []], + [10, "^J", "\n", "LF", "Line Feed", [[0, 0], [2, 3]], []], + [11, "^K", "\v", "VT", "Vertical Tab", [[0, 0], [2, 3]], []], + [12, "^L", "\f", "FF", "Form feed", [[0, 0], [2, 3]], []], + [13, "^M", "\r", "CR", "Carriage return", [[0, 0], [2, 3]], []], + [14, "^N", "", "SO", "Shift Out", [[0, 0], [2, 3]], []], + [15, "^O", "", "SI", "Shift In", [[0, 0], [2, 3]], []], + [16, "^P", "", "DLE", "Data Link Escape", [[0, 0], [2, 3]], []], + [17, "^Q", "", "DC1", "Device Control 1", [[0, 0], [2, 3]], []], + [18, "^R", "", "DC2", "Device Control 2", [[0, 0], [2, 3]], []], + [19, "^S", "", "DC3", "Device Control 3", [[0, 0], [2, 3]], []], + [20, "^T", "", "DC4", "Device Control 4", [[0, 0], [2, 3]], []], + [21, "^U", "", "NAK", "Negative Acknowledgement", [[0, 0], [2, 3]], []], + [22, "^V", "", "SYN", "Synchronous Idle", [[0, 0], [2, 3]], []], + [23, "^W", "", "ETB", "End of Transmission Block", [[0, 0], [2, 3]], []], + [24, "^X", "", "CAN", "Cancel", [[0, 0], [2, 3]], []], + [25, "^Y", "", "EM", "End of Medium", [[0, 0], [2, 3]], []], + [26, "^Z", "", "SUB", "Substitute", [[0, 0], [2, 3]], []], + [27, "^[", "\e", "ESC", "Escape", [[0, 0], [2, 3]], []], + [28, "^\\", "", "FS", "File Separator", [[0, 0], [2, 3]], []], + [29, "^]", "", "GS", "Group Separator", [[0, 0], [2, 3]], []], + [30, "^^", "", "RS", "Record Separator", [[0, 0], [2, 3]], []], + [31, "^_", "", "US", "Unit Separator", [[0, 0], [2, 3]], []], + [32, " ", " ", "", "Space", [[0, 0], [2, 3]], []], + [33, "!", "!", "", "the", [[0, 0], [2, 3]], [2, 3, 4, 6]], + [34, "\"", "\"", "", "(contraction)", [[0, 0], [2, 3]], [5]], + [35, "#", "#", "", "(number prefix)", [[0, 0], [2, 3]], [3, 4, 5, 6]], + [36, "$", "$", "", "ed", [[0, 0], [2, 3]], [1, 2, 4, 6]], + [37, "%", "%", "", "sh", [[0, 0], [2, 3]], [1, 4, 6]], + [38, "&", "&", "", "and", [[0, 0], [2, 3]], [1, 2, 3, 4, 6]], + [39, "'", "'", "", "", [[0, 0], [2, 3]], [3]], + [40, "(", "(", "", "of", [[0, 0], [2, 3]], [1, 2, 3, 5, 6]], + [41, ")", ")", "", "with", [[0, 0], [2, 3]], [2, 3, 4, 5, 6]], + [42, "*", "*", "", "ch", [[0, 0], [2, 3]], [1, 6]], + [43, "+", "+", "", "ing", [[0, 0], [2, 3]], [3, 4, 6]], + [44, ",", ",", "", "(uppercase prefix)", [[0, 0], [2, 3]], [6]], + [45, "-", "-", "", "", [[0, 0], [2, 3]], [3, 6]], + [46, ".", ".", "", "(italic prefix)", [[0, 0], [2, 3]], [4, 6]], + [47, "/", "/", "", "st", [[0, 0], [2, 3]], [3, 4]], + [48, "0", "0", "", "\"", [[0, 0], [2, 3]], [3, 5, 6]], + [49, "1", "1", "", ",", [[0, 0], [2, 3]], [2]], + [50, "2", "2", "", ";", [[0, 0], [2, 3]], [2, 3]], + [51, "3", "3", "", ":", [[0, 0], [2, 3]], [2, 5]], + [52, "4", "4", "", ".", [[0, 0], [2, 3]], [2, 5, 6]], + [53, "5", "5", "", "en", [[0, 0], [2, 3]], [2, 6]], + [54, "6", "6", "", "!", [[0, 0], [2, 3]], [2, 3, 5]], + [55, "7", "7", "", "( or )", [[0, 0], [2, 3]], [2, 3, 5, 6]], + [56, "8", "8", "", "\" or ?", [[0, 0], [2, 3]], [2, 3, 6]], + [57, "9", "9", "", "in", [[0, 0], [2, 3]], [3, 5]], + [58, ":", ":", "", "wh", [[0, 0], [2, 3]], [1, 5, 6]], + [59, ";", ";", "", "(letter prefix)", [[0, 0], [2, 3]], [5, 6]], + [60, "<", "<", "", "gh", [[0, 0], [2, 3]], [1, 2, 6]], + [61, "=", "=", "", "for", [[0, 0], [2, 3]], [1, 2, 3, 4, 5, 6]], + [62, ">", ">", "", "ar", [[0, 0], [2, 3]], [3, 4, 5]], + [63, "?", "?", "", "th", [[0, 0], [2, 3]], [1, 4, 5, 6]], + [64, "@", "@", "", "(accent prefix)", [[0, 0], [2, 3]], [4]], + [65, "A", "A", "", "a", [[0, 0], [2, 3]], [1]], + [66, "B", "B", "", "b", [[0, 0], [2, 3]], [1, 2]], + [67, "C", "C", "", "c", [[0, 0], [2, 3]], [1, 4]], + [68, "D", "D", "", "d", [[0, 0], [2, 3]], [1, 4, 5]], + [69, "E", "E", "", "e", [[0, 0], [2, 3]], [1, 5]], + [70, "F", "F", "", "f", [[0, 0], [2, 3]], [1, 2, 4]], + [71, "G", "G", "", "g", [[0, 0], [2, 3]], [1, 2, 4, 5]], + [72, "H", "H", "", "h", [[0, 0], [2, 3]], [1, 2, 5]], + [73, "I", "I", "", "i", [[0, 0], [2, 3]], [2, 4]], + [74, "J", "J", "", "j", [[0, 0], [2, 3]], [2, 4, 5]], + [75, "K", "K", "", "k", [[0, 0], [2, 3]], [1, 3]], + [76, "L", "L", "", "l", [[0, 0], [2, 3]], [1, 2, 3]], + [77, "M", "M", "", "m", [[0, 0], [2, 3]], [1, 3, 4]], + [78, "N", "N", "", "n", [[0, 0], [2, 3]], [1, 3, 4, 5]], + [79, "O", "O", "", "o", [[0, 0], [2, 3]], [1, 3, 5]], + [80, "P", "P", "", "p", [[0, 0], [2, 3]], [1, 2, 3, 4]], + [81, "Q", "Q", "", "q", [[0, 0], [2, 3]], [1, 2, 3, 4, 5]], + [82, "R", "R", "", "r", [[0, 0], [2, 3]], [1, 2, 3, 5]], + [83, "S", "S", "", "s", [[0, 0], [2, 3]], [2, 3, 4]], + [84, "T", "T", "", "t", [[0, 0], [2, 3]], [2, 3, 4, 5]], + [85, "U", "U", "", "u", [[0, 0], [2, 3]], [1, 3, 6]], + [86, "V", "V", "", "v", [[0, 0], [2, 3]], [1, 2, 3, 6]], + [87, "W", "W", "", "w", [[0, 0], [2, 3]], [2, 4, 5, 6]], + [88, "X", "X", "", "x", [[0, 0], [2, 3]], [1, 3, 4, 6]], + [89, "Y", "Y", "", "y", [[0, 0], [2, 3]], [1, 3, 4, 5, 6]], + [90, "Z", "Z", "", "z", [[0, 0], [2, 3]], [1, 3, 5, 6]], + [91, "[", "[", "", "ow", [[0, 0], [2, 3]], [2, 4, 6]] // ]] + , + [92, "\\", "\\", "", "ou", [[0, 0], [2, 3]], [1, 2, 5, 6]] // [[ + , + [93, "]", "]", "", "er", [[0, 0], [2, 3]], [1, 2, 4, 5, 6]], + [94, "^", "^", "", "(contraction)", [[0, 0], [2, 3]], [4, 5]], + [95, "_", "_", "", "(contraction)", [[0, 0], [2, 3]], [4, 5, 6]], + [96, "`", "`", "", "", [[0, 0], [2, 3]], []] + // Repeating upper-case patterns for lower-case letters. + , + [97, "a", "a", "", "a", [[0, 0], [2, 3]], [1]], + [98, "b", "b", "", "b", [[0, 0], [2, 3]], [1, 2]], + [99, "c", "c", "", "c", [[0, 0], [2, 3]], [1, 4]], + [100, "d", "d", "", "d", [[0, 0], [2, 3]], [1, 4, 5]], + [101, "e", "e", "", "e", [[0, 0], [2, 3]], [1, 5]], + [102, "f", "f", "", "f", [[0, 0], [2, 3]], [1, 2, 4]], + [103, "g", "g", "", "g", [[0, 0], [2, 3]], [1, 2, 4, 5]], + [104, "h", "h", "", "h", [[0, 0], [2, 3]], [1, 2, 5]], + [105, "i", "i", "", "i", [[0, 0], [2, 3]], [2, 4]], + [106, "j", "j", "", "j", [[0, 0], [2, 3]], [2, 4, 5]], + [107, "k", "k", "", "k", [[0, 0], [2, 3]], [1, 3]], + [108, "l", "l", "", "l", [[0, 0], [2, 3]], [1, 2, 3]], + [109, "m", "m", "", "m", [[0,, 0], [2, 3]], [1, 3, 4]], + [110, "n", "n", "", "n", [[0, 0], [2, 3]], [1, 3, 4, 5]], + [111, "o", "o", "", "o", [[0, 0], [2, 3]], [1, 3, 5]], + [112, "p", "p", "", "p", [[0, 0], [2, 3]], [1, 2, 3, 4]], + [113, "q", "q", "", "q", [[0, 0], [2, 3]], [1, 2, 3, 4, 5]], + [114, "r", "r", "", "r", [[0, 0], [2, 3]], [1, 2, 3, 5]], + [115, "s", "s", "", "s", [[0, 0], [2, 3]], [2, 3, 4]], + [116, "t", "t", "", "t", [[0, 0], [2, 3]], [2, 3, 4, 5]], + [117, "u", "u", "", "u", [[0, 0], [2, 3]], [1, 3, 6]], + [118, "v", "v", "", "v", [[0, 0], [2, 3]], [1, 2, 3, 6]], + [119, "w", "w", "", "w", [[0, 0], [2, 3]], [2, 4, 5, 6]], + [120, "x", "x", "", "x", [[0, 0], [2, 3]], [1, 3, 4, 6]], + [121, "y", "y", "", "y", [[0, 0], [2, 3]], [1, 3, 4, 5, 6]], + [122, "z", "z", "", "z", [[0, 0], [2, 3]], [1, 3, 5, 6]], + [123, "{", "{", "", "", [[0, 0], [2, 3]], []], + [124, "|", "|", "", "", [[0, 0], [2, 3]], []], + [125, "}", "}", "", "", [[0, 0], [2, 3]], []], + [126, "~", "~", "", "", [[0, 0], [2, 3]], []], + [127, "^?", "", "DEL", "Delete", [[0, 0], [2, 3]], []]]]; diff --git a/text/height_map.scad b/text/height_map.scad index 0b75f569..6e20e719 100644 --- a/text/height_map.scad +++ b/text/height_map.scad @@ -1,3 +1,4 @@ +use /* Height Map Example Tony Buser @@ -6,26 +7,19 @@ http://creativecommons.org/licenses/by/3.0/ Can also dynamically run this by passing an array on the command line: -/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD -m make -D bitmap=[2,2,2,0,1,3,2,2,2] -D row_size=3 -s height_map.stl height_map.scad +/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD -m make -D +bitmap=[2,2,2,0,1,3,2,2,2] -D row_size=3 -s height_map.stl height_map.scad */ -use - block_size = 5; height = 5; row_size = 10; // 10x10 pixels bitmap = [ - 1,1,0,0,1,1,0,0,1,1, - 1,1,1,1,1,1,1,1,1,1, - 0,1,2,2,1,1,2,2,1,0, - 0,1,2,1,1,1,1,2,1,0, - 1,1,1,1,3,3,1,1,1,1, - 1,1,1,1,3,3,1,1,1,1, - 0,1,2,1,1,1,1,2,1,0, - 0,1,2,2,1,1,2,2,1,0, - 1,1,1,1,1,1,1,1,1,1, - 1,1,0,0,1,1,0,0,1,1 + 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 2, 1, + 1, 2, 2, 1, 0, 0, 1, 2, 1, 1, 1, 1, 2, 1, 0, 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, + 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, 0, 1, 2, 1, 1, 1, 1, 2, 1, 0, 0, 1, 2, 2, 1, + 1, 2, 2, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1 ]; bitmap(bitmap, block_size, height, row_size); diff --git a/text/letter_necklace.scad b/text/letter_necklace.scad index 8d357816..e894395a 100644 --- a/text/letter_necklace.scad +++ b/text/letter_necklace.scad @@ -1,14 +1,13 @@ +use /* Parametric letters for for a necklace Elmo Mäntynen LGPL 2.1 */ -use - // change chars array and char_count // OpenSCAD has no string or length methods :( -chars = ["M","a","k","e","r","B","o","t"]; +chars = [ "M", "a", "k", "e", "r", "B", "o", "t" ]; char_count = 8; // block size 1 will result in 8mm per letter @@ -16,44 +15,65 @@ block_size = 2; // height is the Z height of each letter height = 3; -//Hole for the necklace +// Hole for the necklace hole_diameter = 5; -module 8bit_str(chars, char_count, block_size, height) { - echo(str("Total Width: ", block_size * 8 * char_count, "mm")); - union() { - for (count = [0:char_count-1]) { - translate(v = [0, count * block_size * 8, 0]) { - 8bit_char(chars[count], block_size, height); - } - } - } +module 8bit_str(chars, char_count, block_size, height) +{ + echo(str("Total Width: ", block_size * 8 * char_count, "mm")); + union() + { + for (count = [0:char_count - 1]) { + translate(v = [ 0, count * block_size * 8, 0 ]) + { + 8bit_char(chars[count], block_size, height); + } + } + } } -module letter(char, block_size, height, hole_diameter) { - union() { - translate(v = [0,0, hole_diameter*1.3]) { - 8bit_char(char, block_size, height); - } - translate(v = [0,0,(hole_diameter*1.3)/2]) { - color([0,0,1,1]) { - difference() { - cube(size = [block_size * 8, block_size * 8, hole_diameter+2], center = true); - rotate([90, 0, 0]) cylinder(h = block_size * 8 + 1, r = hole_diameter/2, center = true); - } - } - } - } +module +letter(char, block_size, height, hole_diameter) +{ + union() + { + translate(v = [ 0, 0, hole_diameter * 1.3 ]) + { + 8bit_char(char, block_size, height); + } + translate(v = [ 0, 0, (hole_diameter * 1.3) / 2 ]) + { + color([ 0, 0, 1, 1 ]) + { + difference() + { + cube(size = + [ + block_size * 8, + block_size * 8, + hole_diameter + 2 + ], + center = true); + rotate([ 90, 0, 0 ]) cylinder(h = block_size * 8 + 1, + r = hole_diameter / 2, + center = true); + } + } + } + } } -matrix = [["O", "L", "E", "N", "S"], - [ "Y", "OE", "N", "Y", "T"]]; +matrix = [ [ "O", "L", "E", "N", "S" ], [ "Y", "OE", "N", "Y", "T" ] ]; -union() { - for (column = [0:1]) { - for (row = [0:4]) { - translate(v=[column*(block_size*1.1)*8, row*(block_size*1.1)*8, 0]) - letter(matrix[column][row], block_size, height, hole_diameter); - } - } +union() +{ + for (column = [0:1]) { + for (row = [0:4]) { + translate(v = [ + column * (block_size * 1.1) * 8, + row * (block_size * 1.1) * 8, + 0 + ]) letter(matrix[column][row], block_size, height, hole_diameter); + } + } } diff --git a/text/name_tag.scad b/text/name_tag.scad index 4b392bb3..0509ac90 100644 --- a/text/name_tag.scad +++ b/text/name_tag.scad @@ -1,36 +1,47 @@ +use /* -Parametric Name Tag +Parametric Name Tag Tony Buser http://tonybuser.com http://creativecommons.org/licenses/by/3.0/ */ -use - /* chars = chars array block_size = letter size (block size 1 will result in 8mm per letter) height = the Z height of each letter in mm key_ring_hole = (boolean) Append a hole to a keyring, necklace etc. ? */ -module name_tag(chars = ["R", "E", "P", "R", "A", "P"], - block_size = 2, height = 3, key_ring_hole = true) { - char_count = len(chars); - union() { - translate(v = [0,-block_size*8*char_count/2+block_size*8/2,3]) { - 8bit_str(chars, char_count, block_size, height); - } - translate(v = [0,0,3/2]) { - color([0,0,1,1]) { - cube(size = [block_size * 8, block_size * 8 * char_count, 3], center = true); - } - } - if (key_ring_hole == true){ - translate([0, block_size * 8 * (char_count+1)/2, 3/2]) - difference(){ - cube(size = [block_size * 8, block_size * 8 , 3], center = true); - cube(size = [block_size * 4, block_size * 4 , 5], center = true); - } +module name_tag(chars = [ "R", "E", "P", "R", "A", "P" ], + block_size = 2, + height = 3, + key_ring_hole = true) +{ + char_count = len(chars); + union() + { + translate( + v = [ 0, -block_size * 8 * char_count / 2 + block_size * 8 / 2, 3 ]) + { + 8bit_str(chars, char_count, block_size, height); + } + translate(v = [ 0, 0, 3 / 2 ]) + { + color([ 0, 0, 1, 1 ]) + { + cube(size = [ block_size * 8, block_size * 8 * char_count, 3 ], + center = true); + } + } + if (key_ring_hole == true) { + translate([ 0, block_size * 8 * (char_count + 1) / 2, 3 / 2 ]) + difference() + { + cube(size = [ block_size * 8, block_size * 8, 3 ], + center = true); + cube(size = [ block_size * 4, block_size * 4, 5 ], + center = true); + } + } } - } } diff --git a/text/string.scad b/text/string.scad index 5c2292b5..b126ae8e 100644 --- a/text/string.scad +++ b/text/string.scad @@ -1,14 +1,34 @@ -function strToInt(str, base=10, i=0, nb=0) = (str[0] == "-") ? -1*_strToInt(str, base, 1) : _strToInt(str, base); -function _strToInt(str, base, i=0, nb=0) = (i == len(str)) ? nb : nb+_strToInt(str, base, i+1, search(str[i],"0123456789ABCDEF")[0]*pow(base,len(str)-i-1)); +function strToInt(str, base = 10, i = 0, nb = 0) = + (str[0] == "-") ? -1 * _strToInt(str, base, 1) : _strToInt(str, base); +function _strToInt(str, base, i = 0, nb = 0) = + (i == len(str)) ? nb + : nb + _strToInt(str, + base, + i + 1, + search(str[i], "0123456789ABCDEF")[0] * + pow(base, len(str) - i - 1)); -function strcat(v, car="") = _strcat(v, len(v)-1, car, 0); -function _strcat(v, i, car, s) = (i==s ? v[i] : str(_strcat(v, i-1, car, s), str(car,v[i]) )); +function strcat(v, car = "") = _strcat(v, len(v) - 1, car, 0); +function _strcat(v, i, car, s) = (i == s ? v[i] + : str(_strcat(v, i - 1, car, s), + str(car, v[i]))); -function substr(data, i, length=0) = (length == 0) ? _substr(data, i, len(data)) : _substr(data, i, length+i); -function _substr(str, i, j, out="") = (i==j) ? out : str(str[i], _substr(str, i+1, j, out)); +function substr(data, i, length = 0) = (length == 0) + ? _substr(data, i, len(data)) + : _substr(data, i, length + i); +function _substr(str, i, j, out = "") = (i == j) + ? out + : str(str[i], + _substr(str, i + 1, j, out)); -function fill(car, nb_occ, out="") = (nb_occ == 0) ? out : str(fill(car, nb_occ-1, out), car); +function fill(car, nb_occ, out = "") = (nb_occ == 0) + ? out + : str(fill(car, nb_occ - 1, out), + car); -function getsplit(str, index=0, char=" ") = (index==0) ? substr(str, 0, search(char, str)[0]) : getsplit( substr(str, search(" ", str)[0]+1) , index-1, char); \ No newline at end of file +function getsplit(str, index = 0, char = " ") = + (index == 0) + ? substr(str, 0, search(char, str)[0]) + : getsplit(substr(str, search(" ", str)[0] + 1), index - 1, char); \ No newline at end of file diff --git a/text/test_name_tag.scad b/text/test_name_tag.scad index 85e5c707..a7f56118 100644 --- a/text/test_name_tag.scad +++ b/text/test_name_tag.scad @@ -1,19 +1,19 @@ -include ; -translate([0,0,0]) -name_tag("name_tag"); +include; -translate([20,0,0]) // 0 + 16/2 + 16/2 + 4 -name_tag("NAME_TAG"); +translate([ 0, 0, 0 ]) name_tag("name_tag"); -translate([52,0,0]) // 20 + 16/2 + 40/2 + 4 -name_tag("name_tag", block_size=5); +translate([ 20, 0, 0 ]) // 0 + 16/2 + 16/2 + 4 + name_tag("NAME_TAG"); -translate([96,0,0]) // 52 + 40/2 + 40/2 + 4 -name_tag("NAME_TAG", block_size=5); +translate([ 52, 0, 0 ]) // 20 + 16/2 + 40/2 + 4 + name_tag("name_tag", block_size = 5); -translate([130,0,0]) // 92 + 40/2 + 16/2 + 4 -name_tag("name_tag", height=30); +translate([ 96, 0, 0 ]) // 52 + 40/2 + 40/2 + 4 + name_tag("NAME_TAG", block_size = 5); -translate([150,0,0]) // 130 + 16/2 + 16/2 + 4 -name_tag("NAME_TAG", height=30); +translate([ 130, 0, 0 ]) // 92 + 40/2 + 16/2 + 4 + name_tag("name_tag", height = 30); + +translate([ 150, 0, 0 ]) // 130 + 16/2 + 16/2 + 4 + name_tag("NAME_TAG", height = 30); diff --git a/units/default.scad b/units/default.scad index 91c03af7..51f970ff 100644 --- a/units/default.scad +++ b/units/default.scad @@ -1,3 +1,4 @@ + // Default units are mm. length_mm = 1; diff --git a/units/metric.scad b/units/metric.scad index 0a457b22..225e5211 100644 --- a/units/metric.scad +++ b/units/metric.scad @@ -1,8 +1,9 @@ +include // 1 2 3 4 5 6 7 -//3456789012345678901234567890123456789012345678901234567890123456789012 +// 3456789012345678901234567890123456789012345678901234567890123456789012 /* * Metric units. - * + * * Originally by Hans Häggström, 2010. With contributions from: * elmom (Elmo Mantynen ) * kr2 (Krallinger Sebastian ) @@ -21,8 +22,8 @@ function length_nm(quantity) = quantity * length_nm; //! Commented out until https://github.com/openscad/openscad/issues/737 //! is resolved. -//length_µm = 0.001 * length_mm; // micrometre -//function length_µm(quantity) = quantity * length_µm; +// length_µm = 0.001 * length_mm; // micrometre +// function length_µm(quantity) = quantity * length_µm; length_um = 0.001 * length_mm; // micrometre (alternate) function length_um(quantity) = quantity * length_um; @@ -60,9 +61,9 @@ function length_km(quantity) = quantity * length_km; //㎝ = length_cm; //㎞ = length_km; -X = [1, 0, 0]; -Y = [0, 1, 0]; -Z = [0, 0, 1]; +X = [ 1, 0, 0 ]; +Y = [ 0, 1, 0 ]; +Z = [ 0, 0, 1 ]; M3 = 3 * length_mm; M4 = 4 * length_mm; @@ -74,8 +75,6 @@ M8 = 8 * length_mm; // cutting, etc. //! Commented out until https://github.com/openscad/openscad/issues/737 //! is resolved. -//epsilon = 10.0 * length_µm; +// epsilon = 10.0 * length_µm; epsilon = 10.0 * length_um; -OS = epsilon; // Over size - -include +OS = epsilon; // Over size diff --git a/units/us.scad b/units/us.scad index 586a7af5..0d7e205f 100644 --- a/units/us.scad +++ b/units/us.scad @@ -1,8 +1,9 @@ +include // 1 2 3 4 5 6 7 -//3456789012345678901234567890123456789012345678901234567890123456789012 +// 3456789012345678901234567890123456789012345678901234567890123456789012 /* * United States customary units. - * + * * Originally by McNeight (Neil McNeight ) * * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and @@ -10,18 +11,19 @@ */ /* - * From http://en.wikipedia.org/wiki/United_States_customary_units#Other_names_for_U.S._customary_units - * + * From + * http://en.wikipedia.org/wiki/United_States_customary_units#Other_names_for_U.S._customary_units + * * The United States Code refers to these units as "traditional systems * of weights and measures". - * + * * Other common ways of referring to these systems in the United States * are: "Standard", "Customary", or, somewhat erroneously when considering * volume/tonnage, "Imperial", or "English", which refers to the pre-1824 * reform measures used throughout the British Empire. Another term is the * "foot-pound-second" (FPS) system (as opposed to centimeter-gram-second * (CGS) system). - * + * * Tools and fasteners with sizes measured in inches are sometimes called * "SAE bolts" or "SAE wrenches" to differentiate them from their metric * counterparts. The Society of Automotive Engineers originally developed @@ -29,8 +31,6 @@ * organization now uses metric units. */ -include - /* * Conversion to metric is defined by Roberts, R.W. (February 3, 1975). * Federal Register republished in Barbrow, L.E. and Judson, L. V. (1976) @@ -68,42 +68,59 @@ function length_thou(quantity) = quantity * length_thou; length_mil = 0.001 * length_inch; function length_mil(quantity) = quantity * length_mil; -module inch_ruler(inches) -{ - difference() - { - // Body of ruler - color("Beige") - cube(size = [length_inch(inches), length_inch(1.125), length_thou(150)]); - // Inch markings - for (i = [0:length_inch(1):length_inch(inches) + epsilon]) - { - translate([i,length_inch(0.8875),length_thou(130)]) - color("Red") - cube(size = [length_thou(20), length_inch(0.475) + epsilon, length_thou(40) + epsilon], center = true); - } - // Half inch markings - for (i = [length_inch(0.5):length_inch(1):length_inch(inches)]) - { - translate([i,length_inch(0.93125),length_thou(135)]) - color("Red") - cube(size = [length_thou(20), length_inch(0.3875) + epsilon, length_thou(30) + epsilon], center = true); - } - // Quarter inch markings - for (i = [length_inch(0.25):length_inch(0.5):length_inch(inches)]) - { - translate([i,length_inch(1.0),length_thou(140)]) - color("Red") - cube(size = [length_thou(20), length_inch(0.25) + epsilon, length_thou(20) + epsilon], center = true); - } - // Eighth inch markings - for (i = [length_inch(0.125):length_inch(0.25):length_inch(inches)]) - { - translate([i,length_inch(1.0375),length_thou(145)]) - color("Red") - cube(size = [length_thou(20), length_inch(0.175) + epsilon, length_thou(10) + epsilon], center = true); - } - } +module inch_ruler(inches){ difference(){ + // Body of ruler + color("Beige") cube( + size = [ length_inch(inches), length_inch(1.125), length_thou(150) ]); +// Inch markings +for (i = [0:length_inch(1):length_inch(inches) + epsilon]) { + translate([ i, length_inch(0.8875), length_thou(130) ]) color("Red") + cube(size = + [ + length_thou(20), + length_inch(0.475) + epsilon, + length_thou(40) + + epsilon + ], + center = true); +} +// Half inch markings +for (i = [length_inch(0.5):length_inch(1):length_inch(inches)]) { + translate([ i, length_inch(0.93125), length_thou(135) ]) color("Red") + cube(size = + [ + length_thou(20), + length_inch(0.3875) + epsilon, + length_thou(30) + + epsilon + ], + center = true); +} +// Quarter inch markings +for (i = [length_inch(0.25):length_inch(0.5):length_inch(inches)]) { + translate([ i, length_inch(1.0), length_thou(140) ]) color("Red") + cube(size = + [ + length_thou(20), + length_inch(0.25) + epsilon, + length_thou(20) + + epsilon + ], + center = true); +} +// Eighth inch markings +for (i = [length_inch(0.125):length_inch(0.25):length_inch(inches)]) { + translate([ i, length_inch(1.0375), length_thou(145) ]) color("Red") + cube(size = + [ + length_thou(20), + length_inch(0.175) + epsilon, + length_thou(10) + + epsilon + ], + center = true); +} +} } *inch_ruler(4); From fdb6ff2aa79e7ef19e2f5bd609a3d2ed3c4550cd Mon Sep 17 00:00:00 2001 From: Max O'Cull Date: Fri, 15 Mar 2019 01:41:39 -0400 Subject: [PATCH 2/3] Revert "Implement and apply openscad-format" This reverts commit 68e31e24f69d2717e7199933eb911f6b73c90a28. --- array/along_curve.scad | 14 +- array/generic-multiply.scad | 8 +- array/mirror.scad | 8 +- array/polar.scad | 66 +- array/rectangular.scad | 55 +- array/translations.scad | 75 +- boxes.scad | 5 +- curves.scad | 20 +- demos/array_along_curve_demo.scad | 33 +- demos/array_linear_demo.scad | 52 +- demos/array_polar_demo.scad | 38 +- demos/array_rectangular_demo.scad | 59 +- demos/bearing_demo.scad | 25 +- demos/constants_demo.scad | 9 +- demos/hardware_demo.scad | 17 +- demos/linear_bearing_demo.scad | 9 +- demos/materials_demo.scad | 12 +- demos/metric_demo.scad | 73 +- demos/polyhole_demo.scad | 29 +- demos/rack_and_pinion_demo.scad | 10 +- demos/stepper_demo.scad | 31 +- demos/string_demo.scad | 116 +- demos/teardrop_demo.scad | 15 +- demos/visibonecolors_demo.scad | 33 +- electronics/ATXpowerSupply.scad | 117 +- extrusions/8020.scad | 72 +- extrusions/extrusions.scad | 119 +- extrusions/makerbeam.scad | 15 +- extrusions/misumi_nfs5.scad | 59 +- extrusions/openbeam.scad | 37 +- fasteners/iso4017.scad | 243 ++-- fasteners/metric_fastners.scad | 124 +- fasteners/nuts_and_bolts.scad | 414 +++--- fasteners/threads.scad | 287 ++-- format.py | 8 - gears/gears.scad | 330 +++-- gears/involute_gears.scad | 1490 ++++++++++---------- gears/rack_and_pinion.scad | 411 +++--- general/constants.scad | 3 +- general/facets.scad | 28 +- general/math.scad | 8 +- general/sweep.scad | 89 +- general/utilities.scad | 183 ++- gridbeam.scad | 382 +++--- hardware/bearing.scad | 119 +- hardware/hardware.scad | 193 ++- hardware/linear_bearing.scad | 151 +-- layout/linear.scad | 19 +- lego_compatibility.scad | 349 ++--- materials/materials.scad | 28 +- materials/visibonecolors.scad | 872 ++++++------ motors/motors.scad | 187 ++- motors/servos.scad | 230 ++-- motors/stepper.scad | 567 ++++---- motors/stepper_mount.scad | 396 +++--- multiply.scad | 19 +- nuts_and_bolts.scad | 18 +- oshw.scad | 53 +- polyhole.scad | 4 +- rounder.scad | 2 +- screw.scad | 96 +- shapes/2Dshapes.scad | 410 +++--- shapes/3Dshapes.scad | 460 +++---- shapes/3d_triangle.scad | 310 ++--- shapes/cylinder.scad | 124 +- shapes/polyhole.scad | 21 +- shapes/standard_shapes.scad | 64 +- shapes/triangles_pyramids.scad | 188 +-- shapes/trochoids.scad | 512 +++---- text/alphabet_block.scad | 23 +- text/bitmap.scad | 2105 ++++++++++++++--------------- text/fonts.scad | 553 ++++---- text/height_map.scad | 20 +- text/letter_necklace.scad | 92 +- text/name_tag.scad | 55 +- text/string.scad | 36 +- text/test_name_tag.scad | 26 +- units/default.scad | 1 - units/metric.scad | 21 +- units/us.scad | 105 +- 80 files changed, 6276 insertions(+), 7384 deletions(-) delete mode 100755 format.py diff --git a/array/along_curve.scad b/array/along_curve.scad index c0e2d8ea..c20959a6 100644 --- a/array/along_curve.scad +++ b/array/along_curve.scad @@ -1,4 +1,3 @@ -include /* * Multiplication along certain curves * @@ -6,6 +5,8 @@ include * Licenced under LGPL2 or later */ +include + /** * Place children $no times around $axis, with the first duplicate being unmoved * from its original spot. $angle is the angle of rotation between children(n) @@ -16,13 +17,14 @@ include * rotation (default: undef) * @param axis Axis to rotate around (default: Z) */ -module mcad_rotate_multiply(no, angle = undef, axis = Z) +module mcad_rotate_multiply (no, angle = undef, axis = Z) { if (no > 0) { angle = (angle == undef) ? 360 / no : angle; for (i = [0:no - 1]) { - rotate(angle * i, axis) children(); + rotate (angle * i, axis) + children (); } } } @@ -32,7 +34,9 @@ module mcad_rotate_multiply(no, angle = undef, axis = Z) * * @param axis Axis of rotation (default: Z) */ -module mcad_duplicate(axis = Z) +module mcad_duplicate (axis = Z) { - mcad_rotate_multiply(no = 2, axis = axis) children(); + mcad_rotate_multiply (no = 2, axis = axis) + children (); } + diff --git a/array/generic-multiply.scad b/array/generic-multiply.scad index f034af04..deb32937 100644 --- a/array/generic-multiply.scad +++ b/array/generic-multiply.scad @@ -1,4 +1,3 @@ - /* * Copyright (C) 2016 Chow Loong Jin * @@ -25,11 +24,12 @@ * @param transformations List of transformations to apply to children() * @Param keep_original Whether or not to show the original child */ -module mcad_multiply(transformations, keep_original = true) +module mcad_multiply (transformations, keep_original = true) { if (keep_original) - children(); + children (); for (t = transformations) - multmatrix(t) children(); + multmatrix (t) + children (); } diff --git a/array/mirror.scad b/array/mirror.scad index 7d59aee6..42b84c82 100644 --- a/array/mirror.scad +++ b/array/mirror.scad @@ -1,12 +1,12 @@ - /** * Render an object as well as its mirror. * * @param axis Vector representing axis to mirror(). */ -module mcad_mirror_duplicate(axis) +module mcad_mirror_duplicate (axis) { - children(); + children (); - mirror(axis) children(); + mirror (axis) + children (); } diff --git a/array/polar.scad b/array/polar.scad index ce7dbb97..e02ac955 100644 --- a/array/polar.scad +++ b/array/polar.scad @@ -1,45 +1,51 @@ +include use use -include -use +use - /** - * Generate polar coordinates for polar-arrayed objects - * - * @param angle Angle increment between each coordinate (negative is - * clockwise) - * @param number Number of coordinates - * @param radius Radius of coordinates - */ - function mcad_generate_polar_coords(angle, number, radius) = (let( - total = - angle * - number)[for (i = [0:number - 1])[radius, i* total / number]]); +/** + * Generate polar coordinates for polar-arrayed objects + * + * @param angle Angle increment between each coordinate (negative is clockwise) + * @param number Number of coordinates + * @param radius Radius of coordinates + */ +function mcad_generate_polar_coords (angle, number, radius) = ( + let (total = angle * number) + [ + for (i = [0:number-1]) + [radius, i * total / number] + ] +); /** - * Polar array, i.e. place objects in a circular arc - * - * @param angle Angle between each copy (negative is clockwise) - * @param number Number of copies - * @param radius Radius of array path - */ -module mcad_array_polar(angle, number, radius, preserve_orientation = false) + * Polar array, i.e. place objects in a circular arc + * + * @param angle Angle between each copy (negative is clockwise) + * @param number Number of copies + * @param radius Radius of array path + */ +module mcad_array_polar (angle, number, radius, preserve_orientation = false) { - polar_coords = mcad_generate_polar_coords(angle, number, radius); + polar_coords = mcad_generate_polar_coords (angle, number, radius); if (preserve_orientation) - mcad_place_at([for (coord = polar_coords) - conv2D_polar2cartesian(coord)]) children(); + mcad_place_at ([for (coord = polar_coords) + conv2D_polar2cartesian (coord)]) + children (); else for (coord = polar_coords) - rotate(coord[1], Z) translate([ coord[0], 0 ]) children(); + rotate (coord[1], Z) + translate ([coord[0], 0]) + children (); } -module -test_mcad_array_polar() +module test_mcad_array_polar () { - mcad_array_polar( - angle = 30, number = 3, radius = 10, preserve_orientation = true) - cube(2, center = true); + mcad_array_polar (angle = 30, + number = 3, + radius = 10, + preserve_orientation = true) + cube (2, center = true); } diff --git a/array/rectangular.scad b/array/rectangular.scad index 27abc0f4..b43184ac 100644 --- a/array/rectangular.scad +++ b/array/rectangular.scad @@ -1,23 +1,25 @@ +/** + * Copyright (C) 2016 Chow Loong Jin + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + + use include -/** - * Copyright (C) 2016 Chow Loong Jin - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ /** * Rectangular array, i.e. place objects on a grid. @see mcad_generate_grid @@ -26,11 +28,12 @@ include * @param separation 2- or 3-vector indicating separation in respective axes * @param center Boolean or vector indicating which axes to center */ -module mcad_array_rectangular(grid_size, separation, center = true) +module mcad_array_rectangular (grid_size, separation, center = true) { - mcad_place_at(mcad_generate_grid( - grid_size = grid_size, separation = separation, center = center)) - children(); + mcad_place_at (mcad_generate_grid (grid_size = grid_size, + separation = separation, + center = center)) + children (); } /** @@ -41,10 +44,12 @@ module mcad_array_rectangular(grid_size, separation, center = true) * @param separation Separation between centers of adjacent copies * @param axis Direction to project toward */ -module mcad_linear_multiply(no, separation, axis = Z, center = false) +module mcad_linear_multiply (no, separation, axis = Z, center = false) { centering_offset = -1 * axis * (no - 1) * separation / 2; - translate(center ? centering_offset : [ 0, 0, 0 ]) for (i = [0:no - 1]) - translate(i * separation * axis) children(); + translate (center ? centering_offset : [0, 0, 0]) + for (i = [0:no - 1]) + translate (i * separation * axis) + children (); } diff --git a/array/translations.scad b/array/translations.scad index 0f8570b9..9b6ec65f 100644 --- a/array/translations.scad +++ b/array/translations.scad @@ -1,4 +1,3 @@ - /* * Copyright (C) 2016 Chow Loong Jin * @@ -18,17 +17,19 @@ * 02110-1301 USA */ -use - use +use +use - /** - * Convert vector of points to vector of translation matrices - * - * @param points Vector of points - * @returns Vector of translation matrices - **/ - function mcad_points2translations(points) = [for (point = points) - translation(point)]; +/** + * Convert vector of points to vector of translation matrices + * + * @param points Vector of points + * @returns Vector of translation matrices + **/ +function mcad_points2translations (points) = [ + for (point = points) + translation (point) +]; /** * Generate vector of points that represents grid @@ -37,42 +38,48 @@ use * @param separation 2- or 3-vector indicating separation in respective axes * @param center Boolean or vector indicating which axes to center */ -function mcad_generate_grid(grid_size, separation, center = false) = - (let(sep = len(separation) > 0 ? separation : [ 1, 1, 1 ] * separation, - g = grid_size, - center = len(center) > 0 ? center : [ center, center, center ], +function mcad_generate_grid (grid_size, separation, center = false) = ( + let ( + sep = len (separation) > 0 ? separation : [1, 1, 1] * separation, + g = grid_size, + center = len(center) > 0 ? center : [center, center, center], + + center_offset = [ + for (i = [0:len(g)]) + (center[i]) ? (g[i] - 1) * sep[i] / 2 : 0 + ] + ) - center_offset = [for (i = [0:len(g)])(center[i]) - ? (g[i] - 1) * sep[i] / 2 - : 0]) + (len (grid_size) == 2) ? [ + for (x = [0 : g[0] - 1]) + for (y = [0 : g[1] - 1]) + [x * sep[0], y * sep[1]] - center_offset + ] : + (len (grid_size) == 3) ? [ + for (x = [0 : g[0] - 1]) + for (y = [0 : g[1] - 1]) + for (z = [0 : g[2] - 1]) + [x * sep[0], y * sep[1], z * sep[2]] - center_offset + ] : [] +); - (len(grid_size) == 2) - ? [for (x = [0:g[0] - 1]) for (y = [0:g[1] - - 1])[x * sep[0], y* sep[1]] - - center_offset] - : (len(grid_size) == 3) - ? [for (x = [0:g[0] - 1]) for (y = [0:g[1] - 1]) for ( - z = [0:g[2] - 1])[x * sep[0], y* sep[1], z* sep[2]] - - center_offset] - : []); /** * Place children at points * * @param List of points. */ -module mcad_place_at(points) +module mcad_place_at (points) { - mcad_multiply(mcad_points2translations(points), keep_original = false) - children(); + mcad_multiply (mcad_points2translations (points), keep_original = false) + children (); } /** * Test mcad_place_at module */ -module -mcad_test_place_at() +module mcad_test_place_at () { - mcad_place_at(mcad_generate_grid( - [ 10, 10, 10 ], separation = $t * 10, center = true)); + mcad_place_at (mcad_generate_grid ([10, 10, 10], separation = $t * 10, + center = true)); } diff --git a/boxes.scad b/boxes.scad index 5d266449..40d2e9e9 100644 --- a/boxes.scad +++ b/boxes.scad @@ -1,4 +1,5 @@ use + // @deprecated -module roundedBox(size, radius, sidesonly, center = true) - mcad_rounded_box(size, radius, sidesonly, center); +module roundedBox (size, radius, sidesonly, center = true) +mcad_rounded_box (size, radius, sidesonly, center); diff --git a/curves.scad b/curves.scad index b439d948..0e20005f 100644 --- a/curves.scad +++ b/curves.scad @@ -1,15 +1,21 @@ -include -use // Parametric curves, to be used as paths // Licensed under the MIT license. // © 2010 by Elmo Mäntynen +use +include -/* A circular helix of radius a and pitch 2πb is described by the following -parametrisation: x(t) = a*cos(t), y(t) = a*sin(t), z(t) = b*t + + +/* A circular helix of radius a and pitch 2πb is described by the following parametrisation: +x(t) = a*cos(t), +y(t) = a*sin(t), +z(t) = b*t */ -function b(pitch) = pitch / (const_tau); -function t(pitch, z) = z / b(pitch); + +function b(pitch) = pitch/(const_tau); +function t(pitch, z) = z/b(pitch); function helix_curve(pitch, radius, z) = - [ radius * cos(deg(t(pitch, z))), radius* sin(deg(t(pitch, z))), z ]; + [radius*cos(deg(t(pitch, z))), radius*sin(deg(t(pitch, z))), z]; + diff --git a/demos/array_along_curve_demo.scad b/demos/array_along_curve_demo.scad index 0ce252c6..eadaf023 100644 --- a/demos/array_along_curve_demo.scad +++ b/demos/array_along_curve_demo.scad @@ -1,23 +1,22 @@ +include ; -include; +//center reference point +translate([0,0,0]) +#cube([5,5,5],center=true); -// center reference point -translate([ 0, 0, 0 ]) -#cube([ 5, 5, 5 ], center = true); - - spin(3, 30, Z) +spin(3,30,Z) { - translate([ 5, 5, 5 ]) -#cube([ 5, 5, 5 ], center = true); - // square([25,10]); - // square([25,10]); - // square([25,10]); - // square([25,10]); - // square([25,10]); + translate([5,5,5]) +#cube([5,5,5],center=true); + // square([25,10]); + // square([25,10]); + // square([25,10]); + // square([25,10]); + // square([25,10]); } -// cubic array of 5*5*5 objects spaced 10*10*10 center relative -// array_linear(20) +//cubic array of 5*5*5 objects spaced 10*10*10 center relative +//array_linear(20) //{ // sphere(2.5,center=true,$fn=60); // cylinder(h=10,r=.5,center=true); @@ -27,8 +26,8 @@ translate([ 0, 0, 0 ]) // cylinder(h=10,r=.5,center=true); //} // -// translate([0,0,10]) -// array_linear_grid(30,15,false,3) +//translate([0,0,10]) +//array_linear_grid(30,15,false,3) //{ // square([25,10]); // square([25,10]); diff --git a/demos/array_linear_demo.scad b/demos/array_linear_demo.scad index 8f547c34..ca14dfa7 100644 --- a/demos/array_linear_demo.scad +++ b/demos/array_linear_demo.scad @@ -1,36 +1,38 @@ +include ; -include; +//center reference point +translate([0,0,0]) +#cube([5,5,5],center=true); -// center reference point -translate([ 0, 0, 0 ]) -#cube([ 5, 5, 5 ], center = true); - - array_linear(25) +array_linear(25) { - square([ 25, 10 ]); - square([ 25, 10 ]); - square([ 25, 10 ]); - square([ 25, 10 ]); - square([ 25, 10 ]); + square([25,10]); + square([25,10]); + square([25,10]); + square([25,10]); + square([25,10]); } -// cubic array of 5*5*5 objects spaced 10*10*10 center relative +//cubic array of 5*5*5 objects spaced 10*10*10 center relative array_linear(20) { - sphere(2.5, center = true, $fn = 60); - cylinder(h = 10, r = .5, center = true); - rotate([ 90, 0, 0 ]) cylinder(h = 10, r = .5, center = true); - rotate([ 0, 90, 0 ]) cylinder(h = 10, r = .5, center = true); + sphere(2.5,center=true,$fn=60); + cylinder(h=10,r=.5,center=true); + rotate([90,0,0]) + cylinder(h=10,r=.5,center=true); + rotate([0,90,0]) + cylinder(h=10,r=.5,center=true); } -translate([ 0, 0, 10 ]) array_linear_grid(30, 15, false, 3) + translate([0,0,10]) +array_linear_grid(30,15,false,3) { - square([ 25, 10 ]); - square([ 25, 10 ]); - square([ 25, 10 ]); - square([ 25, 10 ]); - square([ 25, 10 ]); - square([ 25, 10 ]); - square([ 25, 10 ]); - square([ 25, 10 ]); + square([25,10]); + square([25,10]); + square([25,10]); + square([25,10]); + square([25,10]); + square([25,10]); + square([25,10]); + square([25,10]); } diff --git a/demos/array_polar_demo.scad b/demos/array_polar_demo.scad index 596707b7..bf3c6311 100644 --- a/demos/array_polar_demo.scad +++ b/demos/array_polar_demo.scad @@ -1,25 +1,29 @@ +include ; +include ; -include; -include; +//center reference point +translate([0,0,0]) +#cube([5,5,5],center=true); -// center reference point -translate([ 0, 0, 0 ]) -#cube([ 5, 5, 5 ], center = true); - - // radial array of 32 objects rotated though 10 degrees - translate([ 0, 0, 0 ]) array_polar(10, 32, 40) + //radial array of 32 objects rotated though 10 degrees + translate([0,0,0]) +array_polar(10,32,40) { - cube([ 2, 4, 6 ], center = true); + cube([2,4,6],center=true); } -// a radial array of linear arrays +// a radial array of linear arrays -rotate([ 45, 45, 45 ]) array_polar(10, 36, 40) + rotate([45,45,45]) +array_polar(10,36,40) { - translate([ 0, 10, 0 ]) array_rectangular(0, 10, 0, 1, 5, 1, center = false) - { - cube([ 2, 3, 4 ], center = true); - cylinder(h = 10, r = .5, center = true); - rotate([ 90, 0, 0 ]) cylinder(h = 10, r = .5, center = true); - } + translate([0,10,0]) + array_rectangular(0,10,0,1,5,1,center=false) + { + cube([2,3,4],center=true); + cylinder(h=10,r=.5,center=true); + rotate([90,0,0]) + cylinder(h=10,r=.5,center=true); + } } + diff --git a/demos/array_rectangular_demo.scad b/demos/array_rectangular_demo.scad index 855384ea..0d3195c9 100644 --- a/demos/array_rectangular_demo.scad +++ b/demos/array_rectangular_demo.scad @@ -1,38 +1,43 @@ +include ; -include; +//center reference point +translate([0,0,0]) +#cube([5,5,5],center=true); -// center reference point -translate([ 0, 0, 0 ]) -#cube([ 5, 5, 5 ], center = true); - - // cubic array of 5*5*5 objects spaced 10*10*10 center relative - array_rectangular(10, 10, 10, 5, 5, 5, center = true) + //cubic array of 5*5*5 objects spaced 10*10*10 center relative +array_rectangular(10,10,10,5,5,5,center=true) { - sphere(2.5, center = true, $fn = 60); - cylinder(h = 10, r = .5, center = true); - rotate([ 90, 0, 0 ]) cylinder(h = 10, r = .5, center = true); - rotate([ 0, 90, 0 ]) cylinder(h = 10, r = .5, center = true); + sphere(2.5,center=true,$fn=60); + cylinder(h=10,r=.5,center=true); + rotate([90,0,0]) + cylinder(h=10,r=.5,center=true); + rotate([0,90,0]) + cylinder(h=10,r=.5,center=true); } -// a linear array allong x can be derived from the cubic array simply -translate([ 60, 0, 0 ]) array_rectangular(10, 0, 0, 5, 1, 1, center = false) +//a linear array allong x can be derived from the cubic array simply + translate([60,0,0]) +array_rectangular(10,0,0,5,1,1,center=false) { - cube([ 5, 5, 5 ], center = true); -} -// a linear array allong y can be derived from the cubic array simply -translate([ 0, 60, 0 ]) array_rectangular(0, 10, 0, 1, 5, 1, center = false) + cube([5,5,5],center=true); +} +//a linear array allong y can be derived from the cubic array simply + translate([0,60,0]) +array_rectangular(0,10,0,1,5,1,center=false) { - cube([ 5, 5, 5 ], center = true); -} + cube([5,5,5],center=true); +} -// a linear array allong z can be derived from the cubic array simply -translate([ 0, 0, 60 ]) array_rectangular(0, 0, 10, 1, 1, 5, center = false) +//a linear array allong z can be derived from the cubic array simply + translate([0,0,60]) +array_rectangular(0,0,10,1,1,5,center=false) { - cube([ 5, 5, 5 ], center = true); -} + cube([5,5,5],center=true); +} -// a grid array allong x,y can be derived from the cubic array simply -translate([ 0, 0, -60 ]) array_rectangular(10, 10, 0, 5, 5, 1, center = true) +//a grid array allong x,y can be derived from the cubic array simply + translate([0,0,-60]) +array_rectangular(10,10,0,5,5,1,center=true) { - cube([ 5, 5, 5 ], center = true); -} + cube([5,5,5],center=true); +} diff --git a/demos/bearing_demo.scad b/demos/bearing_demo.scad index 95a132fc..e2933cec 100644 --- a/demos/bearing_demo.scad +++ b/demos/bearing_demo.scad @@ -1,25 +1,18 @@ - -include; +include ; // Example, uncomment to view test_bearing(); -translate([ 0, 40, 0 ]) test_bearing_hole(); +translate([0,40,0]) test_bearing_hole(); -module -test_bearing() -{ +module test_bearing(){ bearing(); - bearing(pos = [ 5 * length_cm, 0, 0 ], angle = [ 90, 0, 0 ]); - bearing(pos = [ -2.5 * length_cm, 0, 0 ], model = 624); + bearing(pos=[5*length_cm, 0,0], angle=[90,0,0]); + bearing(pos=[-2.5*length_cm, 0,0], model=624); } -module -test_bearing_hole() -{ - difference() - { - translate([ 0, 0, 3.5 ]) - cube(size = [ 30, 30, 7 - 10 * epsilon ], center = true); - bearing(outline = true); +module test_bearing_hole(){ + difference(){ + translate([0, 0, 3.5]) cube(size=[30, 30, 7-10*epsilon], center=true); + bearing(outline=true); } } \ No newline at end of file diff --git a/demos/constants_demo.scad b/demos/constants_demo.scad index a9ed9746..b581bb2d 100644 --- a/demos/constants_demo.scad +++ b/demos/constants_demo.scad @@ -1,13 +1,12 @@ - -include; +include ; echo(const_e = const_e); echo(const_pi = const_pi); echo(const_tau = const_tau); echo(const_phi = const_phi); echo(const_sqrt2 = const_sqrt2); -echo(const_sqrt2* const_sqrt2); +echo(const_sqrt2 * const_sqrt2); echo(const_sqrt3 = const_sqrt3); -echo(const_sqrt3* const_sqrt3); +echo(const_sqrt3 * const_sqrt3); echo(const_sqrt5 = const_sqrt5); -echo(const_sqrt5* const_sqrt5); +echo(const_sqrt5 * const_sqrt5); diff --git a/demos/hardware_demo.scad b/demos/hardware_demo.scad index 8f0967e0..7cc3be41 100644 --- a/demos/hardware_demo.scad +++ b/demos/hardware_demo.scad @@ -1,11 +1,10 @@ - -include; +include ; rod(20); -translate([ rodsize * 2.5, 0, 0 ]) rod(20, true); -translate([ rodsize * 5, 0, 0 ]) screw(10, true); -translate([ rodsize * 7.5, 0, 0 ]) bearing(); -translate([ rodsize * 10, 0, 0 ]) rodnut(); -translate([ rodsize * 12.5, 0, 0 ]) rodwasher(); -translate([ rodsize * 15, 0, 0 ]) nut(); -translate([ rodsize * 17.5, 0, 0 ]) washer(); \ No newline at end of file +translate([rodsize * 2.5, 0, 0]) rod(20, true); +translate([rodsize * 5, 0, 0]) screw(10, true); +translate([rodsize * 7.5, 0, 0]) bearing(); +translate([rodsize * 10, 0, 0]) rodnut(); +translate([rodsize * 12.5, 0, 0]) rodwasher(); +translate([rodsize * 15, 0, 0]) nut(); +translate([rodsize * 17.5, 0, 0]) washer(); \ No newline at end of file diff --git a/demos/linear_bearing_demo.scad b/demos/linear_bearing_demo.scad index 38f133fb..3b5bbc4c 100644 --- a/demos/linear_bearing_demo.scad +++ b/demos/linear_bearing_demo.scad @@ -1,6 +1,5 @@ +include ; -include; - -// examples -linearBearing(model = "LM8UU"); -translate([ 20, 0, 0 ]) linearBearing(model = "LM10UU"); \ No newline at end of file +//examples +linearBearing(model="LM8UU"); +translate([20,0,0]) linearBearing(model="LM10UU"); \ No newline at end of file diff --git a/demos/materials_demo.scad b/demos/materials_demo.scad index afd5d1f2..7a109c78 100644 --- a/demos/materials_demo.scad +++ b/demos/materials_demo.scad @@ -1,12 +1,9 @@ - -include; +include ; // Example, uncomment to view color_demo(); -module -color_demo() -{ +module color_demo(){ // Wood colorTest(Oak, 0, 0); colorTest(Pine, 1, 0); @@ -25,7 +22,6 @@ color_demo() colorTest(BlackPaint, 0, 3); } -module colorTest(col, row = 0, c = 0) -{ - color(col) translate([ row * 30, c * 30, 0 ]) sphere(r = 10); +module colorTest(col, row=0, c=0) { + color(col) translate([row * 30,c*30,0]) sphere(r=10); } diff --git a/demos/metric_demo.scad b/demos/metric_demo.scad index 061b622b..fc2980bf 100644 --- a/demos/metric_demo.scad +++ b/demos/metric_demo.scad @@ -1,51 +1,34 @@ - -include; +include ; module metric_ruler(millimeters) { - difference() - { - // Body of ruler - color("Beige") - cube(size = [ length_mm(millimeters), length_cm(3), length_mm(1) ]); - // Centimeter markings - for (i = [0:length_cm(1):length_mm(millimeters) + epsilon]) { - translate([ i, length_cm(2.5), length_mm(0.75) ]) color("Red") - cube(size = - [ - length_mm(0.5), - length_cm(1) + epsilon, - length_mm(0.5) + - epsilon - ], - center = true); - } - // Half centimeter markings - for (i = [length_cm(0.5):length_cm(1):length_mm(millimeters) + - epsilon]) { - translate([ i, length_cm(2.7), length_mm(0.875) ]) color("Red") - cube(size = - [ - length_mm(0.5), - length_cm(0.6) + epsilon, - length_mm(0.25) + - epsilon - ], - center = true); - } - // Millimeter markings - for (i = [length_mm(1):length_mm(1):length_mm(millimeters) + epsilon]) { - translate([ i, length_cm(2.85), length_mm(0.9375) ]) color("Red") - cube(size = - [ - length_mm(0.5), - length_cm(0.3) + epsilon, - length_mm(0.125) + - epsilon - ], - center = true); - } - } + difference() + { + // Body of ruler + color("Beige") + cube(size = [length_mm(millimeters), length_cm(3), length_mm(1)]); + // Centimeter markings + for (i = [0:length_cm(1):length_mm(millimeters) + epsilon]) + { + translate([i,length_cm(2.5),length_mm(0.75)]) + color("Red") + cube(size = [length_mm(0.5), length_cm(1) + epsilon, length_mm(0.5) + epsilon], center = true); + } + // Half centimeter markings + for (i = [length_cm(0.5):length_cm(1):length_mm(millimeters) + epsilon]) + { + translate([i,length_cm(2.7),length_mm(0.875)]) + color("Red") + cube(size = [length_mm(0.5), length_cm(0.6) + epsilon, length_mm(0.25) + epsilon], center = true); + } + // Millimeter markings + for (i = [length_mm(1):length_mm(1):length_mm(millimeters) + epsilon]) + { + translate([i,length_cm(2.85),length_mm(0.9375)]) + color("Red") + cube(size = [length_mm(0.5), length_cm(0.3) + epsilon, length_mm(0.125) + epsilon], center = true); + } + } } metric_ruler(100); diff --git a/demos/polyhole_demo.scad b/demos/polyhole_demo.scad index b5dbe532..37e15914 100644 --- a/demos/polyhole_demo.scad +++ b/demos/polyhole_demo.scad @@ -1,22 +1,19 @@ include -module -polyhole_demo() -{ - difference() - { - cube(size = [ 100, 27, 3 ]); - union() - { - for (i = [1:10]) { - translate([ (i * i + i) / 2 + 3 * i, 8, -1 ]) - mcad_polyhole(h = 5, d = i); - assign(d = i + 0.5) - translate([ (d * d + d) / 2 + 3 * d, 19, -1 ]) - mcad_polyhole(h = 5, d = d); - } - } +module polyhole_demo(){ +difference() { + cube(size = [100,27,3]); + union() { + for(i = [1:10]) { + translate([(i * i + i)/2 + 3 * i , 8,-1]) + mcad_polyhole(h = 5, d = i); + + assign(d = i + 0.5) + translate([(d * d + d)/2 + 3 * d, 19,-1]) + mcad_polyhole(h = 5, d = d); + } } } +} polyhole_demo(); diff --git a/demos/rack_and_pinion_demo.scad b/demos/rack_and_pinion_demo.scad index c16ffb13..ddb03434 100644 --- a/demos/rack_and_pinion_demo.scad +++ b/demos/rack_and_pinion_demo.scad @@ -1,14 +1,10 @@ - -include; +include ; // examples of usage // include this in your code: // use // then: // a simple rack -rack(4, - 20, - 10, - 1); // CP (mm/tooth), width (mm), thickness(of base) (mm), # teeth +rack(4,20,10,1);//CP (mm/tooth), width (mm), thickness(of base) (mm), # teeth // a simple pinion and translation / rotation to make it mesh the rack -translate([ 0, -8.5, 0 ]) rotate([ 0, 0, 360 / 10 / 2 ]) pinion(4, 10, 10, 5); \ No newline at end of file +translate([0,-8.5,0])rotate([0,0,360/10/2]) pinion(4,10,10,5); \ No newline at end of file diff --git a/demos/stepper_demo.scad b/demos/stepper_demo.scad index fc9db053..08bd6425 100644 --- a/demos/stepper_demo.scad +++ b/demos/stepper_demo.scad @@ -1,27 +1,24 @@ - -include; +include ; // Demo, uncomment to show: nema_demo(); -module -test_nema14() +module test_nema14() { - motor(Nema14, NemaLong, dualAxis = false); - // motor(); + motor(Nema14, NemaLong, dualAxis=false); + //motor(); } -module -nema_demo() -{ - for (size = [ NemaShort, NemaMedium, NemaLong ]) { - translate([ -100, size * 100, 0 ]) motor(Nema34, size, dualAxis = true); - translate([ 0, size * 100, 0 ]) motor(Nema23, size, dualAxis = true); - translate([ 100, size * 100, 0 ]) motor(Nema17, size, dualAxis = true); - translate([ 200, size * 100, 0 ]) motor(Nema14, size, dualAxis = true); - translate([ 300, size * 100, 0 ]) motor(Nema11, size, dualAxis = true); - translate([ 400, size * 100, 0 ]) motor(Nema08, size, dualAxis = true); + +module nema_demo(){ + for (size = [NemaShort, NemaMedium, NemaLong]) { + translate([-100,size*100,0]) motor(Nema34, size, dualAxis=true); + translate([0,size*100,0]) motor(Nema23, size, dualAxis=true); + translate([100,size*100,0]) motor(Nema17, size, dualAxis=true); + translate([200,size*100,0]) motor(Nema14, size, dualAxis=true); + translate([300,size*100,0]) motor(Nema11, size, dualAxis=true); + translate([400,size*100,0]) motor(Nema08, size, dualAxis=true); } } -// test_nema14(); +//test_nema14(); diff --git a/demos/string_demo.scad b/demos/string_demo.scad index fd36ebae..c3e6560a 100644 --- a/demos/string_demo.scad +++ b/demos/string_demo.scad @@ -1,63 +1,59 @@ - -include; +include ; // Uncomment this bloc to see how to use this library. -// strToInt(string [,base]) - -// Resume : Converts a number in string. -// string : The string you wants to converts. -// base (optional) : The base conversion of the number : 2 for binay, 10 for -// decimal (default), 16 for hexadecimal. -echo("*** strToInt() ***"); -echo(strToInt("491585")); -echo(strToInt("01110", 2)); -echo(strToInt("D5A4", 16)); -echo(strToInt("-15")); -echo(strToInt("-5") + strToInt("10") + 5); - -// strcat(vector [,insert]) - -// Resume : Concatenates a vector of words into a string. -// vector : A vector of string. -// insert (optional) : A string which will added between each words. -echo("*** strcat() ***"); -v_data = [ "OpenScad", "is", "a", "free", "CAD", "software." ]; -echo(strcat(v_data)); // ECHO: "OpenScadisafreeCADsoftware." -echo(strcat(v_data, " ")); // ECHO: "OpenScad is a free CAD software." - -// substr(str, pos [,length]) - -// Resume : Substract a substring from a bigger string. -// str : The original string -// pos : The index of the position where the substring will begin. -// length (optional) : The length of the substring. If not specified, the -// substring will continue until the end of the string. -echo("*** substr() ***"); -str = "OpenScad is a free CAD software."; -echo(str); // ECHO: "OpenScad is a free CAD software." -echo(substr(str, 0, 11)); // ECHO: "OpenScad is" -echo(substr(str, 12)); // ECHO: "a free CAD software." -echo(substr(str, 12, 10)); // ECHO: "a free CAD" - -// fill(string, occurrences) - -// Resume : Fill a string with several characters (or strings). -// string : the character or string which will be copied. -// occurrences : The number of occurences of the string. -echo("*** Fill() ***"); -echo(fill("0", 4)); // ECHO: "0000" -echo(fill("hey", 3)); // ECHO: "heyheyhey" - -// getsplit(string, index [,separator]) - -// Resume : Split a string in several words. -// string : The original string. -// index : The index of the word to get. -// separator : The separator which cut the string (default is " "). -// Note : Nowadays it's impossible to get a vector of words because we can't -// append data in a vector. -echo("*** getsplit() ***"); -echo(getsplit(str)); -echo(getsplit(str, 3)); -echo(getsplit("123, 456, 789", 1, ", ")); \ No newline at end of file + // strToInt(string [,base]) + + // Resume : Converts a number in string. + // string : The string you wants to converts. + // base (optional) : The base conversion of the number : 2 for binay, 10 for decimal (default), 16 for hexadecimal. + echo("*** strToInt() ***"); + echo(strToInt("491585")); + echo(strToInt("01110", 2)); + echo(strToInt("D5A4", 16)); + echo(strToInt("-15")); + echo(strToInt("-5") + strToInt("10") + 5); + + // strcat(vector [,insert]) + + // Resume : Concatenates a vector of words into a string. + // vector : A vector of string. + // insert (optional) : A string which will added between each words. + echo("*** strcat() ***"); + v_data = ["OpenScad", "is", "a", "free", "CAD", "software."]; + echo(strcat(v_data)); // ECHO: "OpenScadisafreeCADsoftware." + echo(strcat(v_data, " ")); // ECHO: "OpenScad is a free CAD software." + + // substr(str, pos [,length]) + + // Resume : Substract a substring from a bigger string. + // str : The original string + // pos : The index of the position where the substring will begin. + // length (optional) : The length of the substring. If not specified, the substring will continue until the end of the string. + echo("*** substr() ***"); + str = "OpenScad is a free CAD software."; + echo(str); // ECHO: "OpenScad is a free CAD software." + echo(substr(str, 0, 11)); // ECHO: "OpenScad is" + echo(substr(str, 12)); // ECHO: "a free CAD software." + echo(substr(str, 12, 10)); // ECHO: "a free CAD" + + // fill(string, occurrences) + + // Resume : Fill a string with several characters (or strings). + // string : the character or string which will be copied. + // occurrences : The number of occurences of the string. + echo("*** Fill() ***"); + echo(fill("0", 4)); // ECHO: "0000" + echo(fill("hey", 3)); // ECHO: "heyheyhey" + + // getsplit(string, index [,separator]) + + // Resume : Split a string in several words. + // string : The original string. + // index : The index of the word to get. + // separator : The separator which cut the string (default is " "). + // Note : Nowadays it's impossible to get a vector of words because we can't append data in a vector. + echo("*** getsplit() ***"); + echo(getsplit(str)); + echo(getsplit(str, 3)); + echo(getsplit("123, 456, 789", 1, ", ")); \ No newline at end of file diff --git a/demos/teardrop_demo.scad b/demos/teardrop_demo.scad index 26cd2254..cc737512 100644 --- a/demos/teardrop_demo.scad +++ b/demos/teardrop_demo.scad @@ -1,13 +1,10 @@ +include ; -include; - -module -teardrop_demo() -{ - translate([ 0, -30, 0 ]) flat_teardrop(5, 20, 90); - translate([ 0, -15, 0 ]) teardrop(5, 20, 90); - translate([ 0, 0, 0 ]) teardrop(5, 20, 60); - translate([ 0, 15, 0 ]) teardrop(5, 20, 45); +module teardrop_demo(){ + translate([0, -30, 0]) flat_teardrop(5, 20, 90); + translate([0, -15, 0]) teardrop(5, 20, 90); + translate([0, 0, 0]) teardrop(5, 20, 60); + translate([0, 15, 0]) teardrop(5, 20, 45); } teardrop_demo(); diff --git a/demos/visibonecolors_demo.scad b/demos/visibonecolors_demo.scad index 91e22901..29351590 100644 --- a/demos/visibonecolors_demo.scad +++ b/demos/visibonecolors_demo.scad @@ -1,16 +1,14 @@ +include ; -include; - -module -visibonecolorstest() +module visibonecolorstest() { - /* - 216 colors: 12 x 18 matrix - Not all colors are tested because OpenSCAD has limited support - for variable re-assignment :( - 'nuff said! - */ - colors = + /* + 216 colors: 12 x 18 matrix + Not all colors are tested because OpenSCAD has limited support + for variable re-assignment :( + 'nuff said! + */ + colors = [PPR, PPM, RRP, MMP, DRP, DMP, LRP, LMP, DPR, DPM, LPR, LPM, MPR, MPM, OOY, OOR, YYO, RRO, DYO, DRO, LYO, LRO, DOY, DOR, LOY, LOR, MOY, MOR, SSG, SSY, GGS, YYS, DGS, DYS, LGS, LYS, @@ -30,12 +28,13 @@ visibonecolorstest() ODT, DDT, LDT, PDT, DHT, LHT, ODA, DDA, LDA, PDA, DHA, LHA, ODV, DDV, LDV, PDV, DHV, LHV, K, OG, DG, LG, PG, W]; - for (i = [1:12]) { - for (j = [1:18]) { - color(colors[i * j]) translate([ (i - 1) * 4, (j - 1) * 4, 0 ]) - sphere(2); - } - } + for (i=[1:12]) + { + for (j=[1:18]) + { + color(colors[i*j]) translate([(i-1)*4,(j-1)*4,0]) sphere(2); + } + } } visibonecolorstest(); diff --git a/electronics/ATXpowerSupply.scad b/electronics/ATXpowerSupply.scad index bb82fae2..c99108a0 100644 --- a/electronics/ATXpowerSupply.scad +++ b/electronics/ATXpowerSupply.scad @@ -1,4 +1,3 @@ -include /* * Copyright (C) 2012 Krallinger Sebastian * @@ -16,83 +15,63 @@ include * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - */ +*/ + +include -ATX_outlines = [ 86, 140, 150 ]; //!< metal box outline -ATX_threadedHoles = [ - [ 6, 30 ], - [ 16, 144 ], - [ 80, 6 ], - [ 80, 144 ] -]; //!< thread hols M4 in the x,z Coordinates 0:@powerconector corner +ATX_outlines = [86,140,150]; //!< metal box outline + +ATX_threadedHoles = [[6,30],[16,144],[80,6],[80,144]]; //!< thread hols M4 in the x,z Coordinates 0:@powerconector corner ATX_threadedHoleDiameter = 4; -ATX_threadedHoleDepth = 10; +ATX_threadedHoleDepth = 10; -ATX_fanPos = [ 43, 100 ]; -ATX_fanDiameter = 74; -ATX_fanDepth = 5; +ATX_fanPos = [43,100]; +ATX_fanDiameter = 74; +ATX_fanDepth = 5; -ATX_powConPos = [ 24, 30 ]; -ATX_powConSize = [ 22, 40 ]; -ATX_powHeight = 5; +ATX_powConPos = [24,30]; +ATX_powConSize = [22,40]; +ATX_powHeight = 5; -ATX_wireHarnesPos = [ 53, 16 ]; -ATX_wireHarnesDiameter = 14; -ATX_wireHarnesLenght = 10; +ATX_wireHarnesPos = [53,16]; +ATX_wireHarnesDiameter = 14; +ATX_wireHarnesLenght = 10; /** - * @brief ATX power Suply. - * - * http://www.formfactors.org/developer/specs/ATX12V_PSDG_2_2_public_br2.pdf. - * @param[in,out] VALUE DESCRIPTION - * @return DESCRIPTION - **/ -module -powerSuplyATX() -{ - difference() - { - union() - { - // box - color("Gainsboro") cube(size = ATX_outlines, center = false); +* @brief ATX power Suply. +* +* http://www.formfactors.org/developer/specs/ATX12V_PSDG_2_2_public_br2.pdf. +* @param[in,out] VALUE DESCRIPTION +* @return DESCRIPTION +**/ +module powerSuplyATX() { + difference() { + union(){ + // box + color("Gainsboro") cube(size=ATX_outlines, center=false); - // wireHarnest - color("DarkOrange") translate([ - ATX_wireHarnesPos[0], - ATX_outlines[1] + ATX_wireHarnesLenght - OS, - ATX_wireHarnesPos[1] - ]) rotate(a = 90, v = X) cylinder(r = ATX_wireHarnesDiameter / 2, - h = ATX_wireHarnesLenght + OS, - center = false); + // wireHarnest + color("DarkOrange") translate([ATX_wireHarnesPos[0], ATX_outlines[1]+ATX_wireHarnesLenght-OS, ATX_wireHarnesPos[1]]) rotate(a=90,v=X) + cylinder(r=ATX_wireHarnesDiameter/2, h=ATX_wireHarnesLenght+OS, center=false); - // power - color("DarkSlateGray") - translate([ ATX_powConPos[0], -OS, ATX_powConPos[1] ]) cube( - size = - [ ATX_powConSize[0], ATX_powHeight, ATX_powConSize[1] ], - center = true); - } - union() - { - // thread holse - for (i = ATX_threadedHoles) { - color("Black") - translate([ i[0], +ATX_threadedHoleDepth - OS, i[1] ]) - rotate(a = 90, v = X) - cylinder(r = ATX_threadedHoleDiameter / 2, - h = ATX_threadedHoleDepth + OS, - center = false); - } + // power + color("DarkSlateGray") translate([ATX_powConPos[0], -OS, ATX_powConPos[1]]) + cube(size=[ATX_powConSize[0], ATX_powHeight, ATX_powConSize[1]], center=true); + } + union(){ + // thread holse + for (i=ATX_threadedHoles) { + color("Black") translate([i[0], +ATX_threadedHoleDepth-OS, i[1]]) rotate(a=90,v=X) + cylinder(r=ATX_threadedHoleDiameter/2, h=ATX_threadedHoleDepth+OS, center=false); + } - // fan - color("Black") - translate([ ATX_fanPos[0], +ATX_fanDepth - OS, ATX_fanPos[1] ]) - rotate(a = 90, v = X) cylinder(r = ATX_fanDiameter / 2, - h = ATX_fanDepth + OS, - center = false); - } - } + // fan + color("Black") translate([ATX_fanPos[0], +ATX_fanDepth-OS, ATX_fanPos[1]]) rotate(a=90,v=X) + cylinder(r=ATX_fanDiameter/2, h=ATX_fanDepth+OS, center=false); + + + } + } } -// powerSuplyATX(); +//powerSuplyATX(); diff --git a/extrusions/8020.scad b/extrusions/8020.scad index 46a5e4cf..40b2d681 100644 --- a/extrusions/8020.scad +++ b/extrusions/8020.scad @@ -1,78 +1,50 @@ - -module -profile_8020_fractional_1010() -{ - profile_tslot_generic(pitch = 1, - slot = 0.26, - lip = 0.1, - web = 0.13, - core = 0.45, - hole = 0.28); +module profile_8020_fractional_1010 () { + profile_tslot_generic (pitch = 1, slot = 0.26, lip = 0.1, web = 0.13, core = 0.45, hole = 0.28); } // module extrusion_8020_1001(h) { - linear_extrude(height = h, - center = false, - convexity = 1, - twist = 0, - slices = 1, - scale = 1.0) - { - import("8020/8020-1001.dxf"); - } + linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) + { + import("8020/8020-1001.dxf"); + } } // module extrusion_8020_1002(h) { - linear_extrude(height = h, - center = false, - convexity = 1, - twist = 0, - slices = 1, - scale = 1.0) - { - import("8020/8020-1002.dxf"); - } + linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) + { + import("8020/8020-1002.dxf"); + } } // module extrusion_8020_1003(h) { - linear_extrude(height = h, - center = false, - convexity = 1, - twist = 0, - slices = 1, - scale = 1.0) - { - import("8020/8020-1003.dxf"); - } + linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) + { + import("8020/8020-1003.dxf"); + } } // module extrusion_8020_1004(h) { - linear_extrude(height = h, - center = false, - convexity = 1, - twist = 0, - slices = 1, - scale = 1.0) - { - import("8020/8020-1004.dxf"); - } + linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) + { + import("8020/8020-1004.dxf"); + } } module 8020_line_up_and_wait() { - extrusion_8020_1001(20, $fn = 36); - translate([ 30, 0, 0 ]) extrusion_8020_1002(20, $fn = 36); - translate([ 60, 0, 0 ]) extrusion_8020_1003(20, $fn = 36); - translate([ 90, 0, 0 ]) extrusion_8020_1004(20, $fn = 36); + extrusion_8020_1001(20, $fn=36); + translate([30,0,0]) extrusion_8020_1002(20, $fn=36); + translate([60,0,0]) extrusion_8020_1003(20, $fn=36); + translate([90,0,0]) extrusion_8020_1004(20, $fn=36); } 8020_line_up_and_wait(); \ No newline at end of file diff --git a/extrusions/extrusions.scad b/extrusions/extrusions.scad index 6d7f278b..2c269218 100644 --- a/extrusions/extrusions.scad +++ b/extrusions/extrusions.scad @@ -1,4 +1,3 @@ - // ============================================== // Miscellaneous profiles (aluminum etc) // By Vitaly Mankevich / contraptor.org, (c) 2012 @@ -22,91 +21,71 @@ // linear_extrude (height = 3.5) profile_square_tube(1.5, 1/8); // -include; -include; -include; -include; +include ; +include ; +include ; +include ; $fn = 24; -module profile_angle_equal(side, wall) -{ - difference() - { - square(side); - translate([ wall, wall, 0 ]) square(side - wall); - } +module profile_angle_equal(side, wall) { + difference () { + square (side); + translate([wall, wall, 0]) square (side - wall); + } } -module profile_angle_unequal(side_x, side_y, wall) -{ - difference() - { - square([ side_x, side_y ]); - translate([ wall, wall, 0 ]) square([ side_x - wall, side_y - wall ]); - } +module profile_angle_unequal(side_x, side_y, wall) { + difference () { + square ([side_x, side_y]); + translate ([wall, wall, 0]) square ([side_x - wall, side_y - wall]); + } } -module profile_square_tube(side, wall) -{ - difference() - { - square(side, center = true); - square(side - wall * 2, center = true); - } +module profile_square_tube(side, wall) { + difference () { + square (side, center = true); + square (side-wall*2, center = true); + } } -module profile_rect_tube(side_x, side_y, wall) -{ - difference() - { - square([ side_x, side_y ], center = true); - square([ side_x - wall * 2, side_y - wall * 2 ], center = true); - } +module profile_rect_tube(side_x, side_y, wall) { + difference () { + square ([side_x, side_y], center = true); + square ([side_x - wall*2, side_y - wall*2], center = true); + } } -module profile_channel(base, side, wall) -{ - translate([ 0, side / 2, 0 ]) difference() - { - square([ base, side ], center = true); - translate([ 0, wall / 2, 0 ]) - square([ base - wall * 2, side - wall ], center = true); - } +module profile_channel(base, side, wall) { + translate ([0, side/2, 0]) difference () { + square ([base, side], center = true); + translate ([0, wall/2, 0]) square ([base - wall*2, side - wall], center = true); + } } -module profile_tslot_generic(pitch, slot, lip, web, hole) -{ - // pitch = side width, slot = slot width, lip = thickness of the lip, web = - // thickness of the web, core = side of the center square, hole = center - // hole diameter - difference() - { - union() - { - difference() - { - square(pitch, center = true); - square(pitch - lip * 2, center = true); - square([ pitch, slot ], center = true); - square([ slot, pitch ], center = true); - } - rotate([ 0, 0, 45 ]) square([ pitch * 1.15, web ], center = true); - rotate([ 0, 0, -45 ]) square([ pitch * 1.15, web ], center = true); - square(core, center = true); - } - circle(hole / 2, center = true); - } +module profile_tslot_generic (pitch, slot, lip, web, hole) { + // pitch = side width, slot = slot width, lip = thickness of the lip, web = thickness of the web, core = side of the center square, hole = center hole diameter + difference () { + union() { + difference () { + square (pitch, center=true); + square (pitch - lip*2, center=true); + square ([pitch, slot], center=true); + square ([slot, pitch], center=true); + } + rotate ([0, 0, 45]) square ([pitch*1.15, web], center=true); + rotate ([0, 0, -45]) square ([pitch*1.15, web], center=true); + square (core, center=true); + } + circle (hole/2, center = true); + } } -module -profile_misumi_metric_2020() -{ - profile_tslot_generic( - pitch = 20, slot = 5.2, lip = 2, web = 2.6, core = 9, hole = 5.6); +module profile_misumi_metric_2020 () { + profile_tslot_generic (pitch = 20, slot = 5.2, lip = 2, web = 2.6, core = 9, hole = 5.6); } // Line up and wait extrusion_makerbeam(30); -translate([ 17.5, 0, 0 ]) extrusion_openbeam_v1(30); -translate([ 37.5, 0, 0 ]) extrusion_openbeam_v2(30, $fn = 36); +translate([17.5, 0, 0]) extrusion_openbeam_v1(30); +translate([37.5, 0, 0]) extrusion_openbeam_v2(30, $fn=36); diff --git a/extrusions/makerbeam.scad b/extrusions/makerbeam.scad index b8d90fe5..7b573763 100644 --- a/extrusions/makerbeam.scad +++ b/extrusions/makerbeam.scad @@ -1,12 +1,9 @@ - -module extrusion_makerbeam(h){ - linear_extrude(height = h, - center = false, - convexity = 1, - twist = 0, - slices = 1, - scale = 1.0){ import("MakerBeam_Cross_Section_Metric.DXF"); -} +module extrusion_makerbeam(h) +{ + linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) + { + import("MakerBeam_Cross_Section_Metric.DXF"); + } } *extrusion_makerbeam(30); diff --git a/extrusions/misumi_nfs5.scad b/extrusions/misumi_nfs5.scad index 4831bd35..4ccf859b 100644 --- a/extrusions/misumi_nfs5.scad +++ b/extrusions/misumi_nfs5.scad @@ -1,61 +1,40 @@ - // module extrusion_misumi_nfs5_2525(h) { - linear_extrude(height = h, - center = false, - convexity = 1, - twist = 0, - slices = 1, - scale = 1.0) - { - import("MISUMI/nfs5-2525.dxf"); - } + linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) + { + import("MISUMI/nfs5-2525.dxf"); + } } // module extrusion_misumi_nfs5_2550(h) { - linear_extrude(height = h, - center = false, - convexity = 1, - twist = 0, - slices = 1, - scale = 1.0) - { - import("MISUMI/nfs5-2550.dxf"); - } + linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) + { + import("MISUMI/nfs5-2550.dxf"); + } } // module extrusion_misumi_nfs5_4060(h) { - linear_extrude(height = h, - center = false, - convexity = 1, - twist = 0, - slices = 1, - scale = 1.0) - { - import("MISUMI/nfs5-4060.dxf"); - } + linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) + { + import("MISUMI/nfs5-4060.dxf"); + } } // module extrusion_misumi_nfs5_4080(h) { - linear_extrude(height = h, - center = false, - convexity = 1, - twist = 0, - slices = 1, - scale = 1.0) - { - import("MISUMI/nfs5-4080.dxf"); - } + linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) + { + import("MISUMI/nfs5-4080.dxf"); + } } extrusion_misumi_nfs5_2525(25); -translate([ 40, 0, 0 ]) extrusion_misumi_nfs5_2550(25); -translate([ 100, 0, 0 ]) extrusion_misumi_nfs5_4060(25); -translate([ 175, 0, 0 ]) extrusion_misumi_nfs5_4080(25); \ No newline at end of file +translate([40,0,0]) extrusion_misumi_nfs5_2550(25); +translate([100,0,0]) extrusion_misumi_nfs5_4060(25); +translate([175,0,0]) extrusion_misumi_nfs5_4080(25); \ No newline at end of file diff --git a/extrusions/openbeam.scad b/extrusions/openbeam.scad index edc15d5c..53a6fe60 100644 --- a/extrusions/openbeam.scad +++ b/extrusions/openbeam.scad @@ -1,36 +1,27 @@ - -// module extrusion_openbeam_v1_generate_dxf() +//module extrusion_openbeam_v1_generate_dxf() //{ // // Original STL has origin in lower left // translate([-7.5, -7.5, 0]) -// projection(cut = true) -//import("TL-400-0101-001CLR_-_OpenBeam_1515_Extrusion_Clear_Anodized.STL"); +// projection(cut = true) import("TL-400-0101-001CLR_-_OpenBeam_1515_Extrusion_Clear_Anodized.STL"); // export("TL-400-0101-001.DXF"); //} module extrusion_openbeam_v1(h) { - linear_extrude(height = h, - center = false, - convexity = 1, - twist = 0, - slices = 1, - scale = 1.0) - { - import("TL-400-0101-001.DXF"); - } + linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) + { + import("TL-400-0101-001.DXF"); + } } -module extrusion_openbeam_v2(h){ - linear_extrude(height = h, - center = false, - convexity = 1, - twist = 0, - slices = 1, - scale = 1.0){ import("TL-400-0101-002.DXF"); -} +module extrusion_openbeam_v2(h) +{ + linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) + { + import("TL-400-0101-002.DXF"); + } } -// extrusion_openbeam_v1_generate_dxf(); +//extrusion_openbeam_v1_generate_dxf(); *extrusion_openbeam_v1(30); -*translate([ 20, 0, 0 ]) extrusion_openbeam_v2(30, $fn = 36); +*translate([20, 0, 0]) extrusion_openbeam_v2(30, $fn=36); diff --git a/fasteners/iso4017.scad b/fasteners/iso4017.scad index 59bb2a4f..8873e9a1 100644 --- a/fasteners/iso4017.scad +++ b/fasteners/iso4017.scad @@ -1,6 +1,3 @@ -include -include -include // ISO 4017 — Hexagon head screws — Product grades A and B // // d = basic major diameter (nominal diameter) of thread @@ -8,115 +5,125 @@ include // // β = angle of the chamfer (hexagon head) +include +include +include + $fn = 36; module iso_hexagon_head_screw(diameter, length, grade = "A", tolerance = false) { - dimensions = iso_hexagon_head_screw_dimensions(diameter); - hex_side_nom = dimensions[18] / const_sqrt3; - hex_side_grade_a = dimensions[19] / const_sqrt3; - hex_side_grade_b = dimensions[20] / const_sqrt3; + dimensions = iso_hexagon_head_screw_dimensions(diameter); + hex_side_nom = dimensions[18] / const_sqrt3; + hex_side_grade_a = dimensions[19] / const_sqrt3; + hex_side_grade_b = dimensions[20] / const_sqrt3; - echo(dimensions); - echo(dimensions[8] / 2, hex_side_nom); + echo(dimensions); + echo(dimensions[8] / 2, hex_side_nom); - if (grade == "A") { - if (tolerance) { - // Use minimum dimensions - linear_extrude(height = dimensions[12]) - { - polygon(points = - [ - [ 0, dimensions[8] / 2 ], - [ dimensions[19] / 2, hex_side_grade_a / 2 ], - [ dimensions[19] / 2, -hex_side_grade_a / 2 ], - [ 0, -dimensions[8] / 2 ], - [ -dimensions[19] / 2, -hex_side_grade_a / 2 ], - [ -dimensions[19] / 2, hex_side_grade_a / 2 ] - ], - paths = [[ 0, 1, 2, 3, 4, 5 ]]); - } - // Ghost in maximum dimensions - % linear_extrude(height = dimensions[11]) - { - polygon(points = - [ - [ 0, hex_side_nom ], - [ dimensions[18] / 2, hex_side_nom / 2 ], - [ dimensions[18] / 2, -hex_side_nom / 2 ], - [ 0, -hex_side_nom ], - [ -dimensions[18] / 2, -hex_side_nom / 2 ], - [ -dimensions[18] / 2, hex_side_nom / 2 ] - ], - paths = [[ 0, 1, 2, 3, 4, 5 ]]); - } - } - // Use nominal dimensions - else { - linear_extrude(height = dimensions[10]) - { - polygon(points = - [ - [ 0, hex_side_nom ], - [ dimensions[18] / 2, hex_side_nom / 2 ], - [ dimensions[18] / 2, -hex_side_nom / 2 ], - [ 0, -hex_side_nom ], - [ -dimensions[18] / 2, -hex_side_nom / 2 ], - [ -dimensions[18] / 2, hex_side_nom / 2 ] - ], - paths = [[ 0, 1, 2, 3, 4, 5 ]]); - } - } - } else if (grade == "B") { - if (tolerance) { - // Use minimum dimensions - linear_extrude(height = dimensions[14]) - { - polygon(points = - [ - [ 0, dimensions[9] / 2 ], - [ dimensions[20] / 2, hex_side_grade_b / 2 ], - [ dimensions[20] / 2, -hex_side_grade_b / 2 ], - [ 0, -dimensions[9] / 2 ], - [ -dimensions[20] / 2, -hex_side_grade_b / 2 ], - [ -dimensions[20] / 2, hex_side_grade_b / 2 ] - ], - paths = [[ 0, 1, 2, 3, 4, 5 ]]); - } - // Ghost in nominal/maximum dimensions - % linear_extrude(height = dimensions[13]) - { - polygon(points = - [ - [ 0, hex_side_nom ], - [ dimensions[18] / 2, hex_side_nom / 2 ], - [ dimensions[18] / 2, -hex_side_nom / 2 ], - [ 0, -hex_side_nom ], - [ -dimensions[18] / 2, -hex_side_nom / 2 ], - [ -dimensions[18] / 2, hex_side_nom / 2 ] - ], - paths = [[ 0, 1, 2, 3, 4, 5 ]]); - } - } - // Use nominal dimensions - else { - linear_extrude(height = dimensions[10]) - { - polygon(points = - [ - [ 0, hex_side_nom ], - [ dimensions[18] / 2, hex_side_nom / 2 ], - [ dimensions[18] / 2, -hex_side_nom / 2 ], - [ 0, -hex_side_nom ], - [ -dimensions[18] / 2, -hex_side_nom / 2 ], - [ -dimensions[18] / 2, hex_side_nom / 2 ] - ], - paths = [[ 0, 1, 2, 3, 4, 5 ]]); - } - rotate([ 180, 0, 0 ]) - cylinder(h = length, d = dimensions[21], center = false); - } - } + if (grade == "A") + { + if (tolerance) + { + // Use minimum dimensions + linear_extrude(height = dimensions[12]) + { + polygon(points = [ + [0, dimensions[8] / 2], + [dimensions[19] / 2, hex_side_grade_a / 2], + [dimensions[19] / 2, -hex_side_grade_a / 2], + [0, -dimensions[8] / 2], + [-dimensions[19] / 2, -hex_side_grade_a / 2], + [-dimensions[19] / 2, hex_side_grade_a / 2] + ], + paths = [[0,1,2,3,4,5]] + ); + } + // Ghost in maximum dimensions + %linear_extrude(height = dimensions[11]) + { + polygon(points = [ + [0, hex_side_nom], + [dimensions[18] / 2, hex_side_nom / 2], + [dimensions[18] / 2, -hex_side_nom / 2], + [0, -hex_side_nom], + [-dimensions[18] / 2, -hex_side_nom / 2], + [-dimensions[18] / 2, hex_side_nom / 2] + ], + paths = [[0,1,2,3,4,5]] + ); + } + } + // Use nominal dimensions + else + { + linear_extrude(height = dimensions[10]) + { + polygon(points = [ + [0, hex_side_nom], + [dimensions[18] / 2, hex_side_nom / 2], + [dimensions[18] / 2, -hex_side_nom / 2], + [0, -hex_side_nom], + [-dimensions[18] / 2, -hex_side_nom / 2], + [-dimensions[18] / 2, hex_side_nom / 2] + ], + paths = [[0,1,2,3,4,5]] + ); + } + } + } + else if (grade == "B") + { + if (tolerance) + { + // Use minimum dimensions + linear_extrude(height = dimensions[14]) + { + polygon(points = [ + [0, dimensions[9] / 2], + [dimensions[20] / 2, hex_side_grade_b / 2], + [dimensions[20] / 2, -hex_side_grade_b / 2], + [0, -dimensions[9] / 2], + [-dimensions[20] / 2, -hex_side_grade_b / 2], + [-dimensions[20] / 2, hex_side_grade_b / 2] + ], + paths = [[0,1,2,3,4,5]] + ); + } + // Ghost in nominal/maximum dimensions + %linear_extrude(height = dimensions[13]) + { + polygon(points = [ + [0, hex_side_nom], + [dimensions[18] / 2, hex_side_nom / 2], + [dimensions[18] / 2, -hex_side_nom / 2], + [0, -hex_side_nom], + [-dimensions[18] / 2, -hex_side_nom / 2], + [-dimensions[18] / 2, hex_side_nom / 2] + ], + paths = [[0,1,2,3,4,5]] + ); + } + } + // Use nominal dimensions + else + { + linear_extrude(height = dimensions[10]) + { + polygon(points = [ + [0, hex_side_nom], + [dimensions[18] / 2, hex_side_nom / 2], + [dimensions[18] / 2, -hex_side_nom / 2], + [0, -hex_side_nom], + [-dimensions[18] / 2, -hex_side_nom / 2], + [-dimensions[18] / 2, hex_side_nom / 2] + ], + paths = [[0,1,2,3,4,5]] + ); + } + rotate([180,0,0]) cylinder(h = length, d = dimensions[21], center = false); + } + } } // Definitions from ISO 225 — Fasteners — Bolts, screws, studs and @@ -124,15 +131,15 @@ module iso_hexagon_head_screw(diameter, length, grade = "A", tolerance = false) // // For a given d: // 0:P: pitch of the thread -// 1:a max: maximum distance from the bearing face to the first full form (full -// profile) thread (screw) 2:a min: minimum distance from the bearing face to -// the first full form (full profile) thread (screw) 3:c max: maximum height of -// the washer-faced portion or thickness of the flange or collar 4:c min: -// minimum height of the washer-faced portion or thickness of the flange or -// collar 5:da max: maximum inner diameter of the bearing face 6:dw grade a min: -// minimum outer diameter of the washer face (bearing face) 7:dw grade b min: -// minimum outer diameter of the washer face (bearing face) 8:e grade a min: -// minimum width across corners 9:e grade b min: minimum width across corners +// 1:a max: maximum distance from the bearing face to the first full form (full profile) thread (screw) +// 2:a min: minimum distance from the bearing face to the first full form (full profile) thread (screw) +// 3:c max: maximum height of the washer-faced portion or thickness of the flange or collar +// 4:c min: minimum height of the washer-faced portion or thickness of the flange or collar +// 5:da max: maximum inner diameter of the bearing face +// 6:dw grade a min: minimum outer diameter of the washer face (bearing face) +// 7:dw grade b min: minimum outer diameter of the washer face (bearing face) +// 8:e grade a min: minimum width across corners +// 9:e grade b min: minimum width across corners // 10:k nom: nominal height of the head // 11:k grade a max: maximum height of the head // 12:k grade a min: minimum height of the head @@ -160,6 +167,6 @@ function iso_hexagon_head_screw_dimensions(diameter) = [8*length_mm, 22*length_mm, 7*length_mm]; // this is the default iso_hexagon_head_screw("M1.6", 20, "A", true); -translate([ 5, 0, 0 ]) iso_hexagon_head_screw("M1.6", 20, "A", false); -translate([ 0, 5, 0 ]) iso_hexagon_head_screw("M1.6", 20, "B", true); -translate([ 5, 5, 0 ]) iso_hexagon_head_screw("M1.6", 20, "B", false); \ No newline at end of file +translate([5,0,0]) iso_hexagon_head_screw("M1.6", 20, "A", false); +translate([0,5,0]) iso_hexagon_head_screw("M1.6", 20, "B", true); +translate([5,5,0]) iso_hexagon_head_screw("M1.6", 20, "B", false); \ No newline at end of file diff --git a/fasteners/metric_fastners.scad b/fasteners/metric_fastners.scad index 441e1805..7134c743 100644 --- a/fasteners/metric_fastners.scad +++ b/fasteners/metric_fastners.scad @@ -1,4 +1,3 @@ - /* * OpenSCAD Metric Fastners Library (www.openscad.org) * Copyright (C) 2010-2011 Giles Bathgate @@ -17,93 +16,96 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - */ +*/ // $fn=50; -apply_chamfer = true; +apply_chamfer=true; -module cap_bolt(dia, len) +module cap_bolt(dia,len) { - e = 1.5 * dia; - h1 = 1.25 * dia; - cylinder(r = dia / 2, h = len); - translate([ 0, 0, -h1 ]) cylinder(r = e / 2, h = h1); + e=1.5*dia; + h1=1.25*dia; + cylinder(r=dia/2,h=len); + translate([0,0,-h1]) cylinder(r=e/2,h=h1); } -module csk_bolt(dia, len) +module csk_bolt(dia,len) { - h1 = 0.6 * dia; - h2 = len - h1; - cylinder(r = dia / 2, h = h2); - cylinder(r1 = dia, r2 = dia / 2, h = h1); + h1=0.6*dia; + h2=len-h1; + cylinder(r=dia/2,h=h2); + cylinder(r1=dia,r2=dia/2,h=h1); } module washer(dia) { - t = 0.1 * dia; - difference() - { - cylinder(r = dia, h = t); - translate([ 0, 0, -t / 2 ]) cylinder(r = dia / 2, h = t * 2); - } + t=0.1*dia; + difference() + { + cylinder(r=dia,h=t); + translate([0,0,-t/2])cylinder(r=dia/2,h=t*2); + } } module flat_nut(dia) { - m = 0.8 * dia; - e = 1.8 * dia; - c = 0.2 * dia; - difference() - { - cylinder(r = e / 2, h = m, $fn = 6); - translate([ 0, 0, -m / 2 ]) cylinder(r = dia / 2, h = m * 2); - if (apply_chamfer) - translate([ 0, 0, c ]) cylinder_chamfer(e / 2, c); - } + m=0.8*dia; + e=1.8*dia; + c=0.2*dia; + difference() + { + cylinder(r=e/2,h=m,$fn=6); + translate([0,0,-m/2])cylinder(r=dia/2,h=m*2); + if(apply_chamfer) + translate([0,0,c])cylinder_chamfer(e/2,c); + } } -module bolt(dia, len) +module bolt(dia,len) { - e = 1.8 * dia; - k = 0.7 * dia; - c = 0.2 * dia; - difference() - { - cylinder(r = e / 2, h = k, $fn = 6); - if (apply_chamfer) - translate([ 0, 0, c ]) cylinder_chamfer(e / 2, c); - } + e=1.8*dia; + k=0.7*dia; + c=0.2*dia; + difference() + { + cylinder(r=e/2,h=k,$fn=6); + if(apply_chamfer) + translate([0,0,c])cylinder_chamfer(e/2,c); + } + + cylinder(r=dia/2,h=len); - cylinder(r = dia / 2, h = len); } -module cylinder_chamfer(r1, r2) +module cylinder_chamfer(r1,r2) { - t = r1 - r2; - p = r2 * 2; - rotate_extrude() difference() - { - translate([ t, -p ]) square([ p, p ]); - translate([ t, 0 ]) circle(r2); - } + t=r1-r2; + p=r2*2; + rotate_extrude() + difference() + { + translate([t,-p])square([p,p]); + translate([t,0])circle(r2); + } } -module chamfer(len, r) +module chamfer(len,r) { - p = r * 2; - linear_extrude(height = len) difference() - { - square([ p, p ]); - circle(r); - } + p=r*2; + linear_extrude(height=len) + difference() + { + square([p,p]); + circle(r); + } } union() { - // csk_bolt(3,14); - // washer(3); - // flat_nut(3); - // bolt(4,14); - // cylinder_chamfer(8,1); - // chamfer(10,2); +//csk_bolt(3,14); +//washer(3); +//flat_nut(3); +//bolt(4,14); +//cylinder_chamfer(8,1); +//chamfer(10,2); } diff --git a/fasteners/nuts_and_bolts.scad b/fasteners/nuts_and_bolts.scad index 4992ec35..a4cf8d54 100644 --- a/fasteners/nuts_and_bolts.scad +++ b/fasteners/nuts_and_bolts.scad @@ -6,184 +6,213 @@ include // This library is dual licensed under the GPL 3.0 and the GNU Lesser General // Public License as per http://creativecommons.org/licenses/LGPL/2.1/ . -module -mcad_test_nuts_and_bolts_1() +module mcad_test_nuts_and_bolts_1 () { - $fn = 360; + $fn = 360; - translate([ 0, 15 ]) mcad_nut_hole(3, proj = -1); + translate ([0, 15]) + mcad_nut_hole (3, proj = -1); + + mcad_bolt_hole (3, length = 30,tolerance =10, proj = -1); - mcad_bolt_hole(3, length = 30, tolerance = 10, proj = -1); } -// mcad_test_nuts_and_bolts_1 (); +//mcad_test_nuts_and_bolts_1 (); -module -mcad_test_nuts_and_bolts_2() +module mcad_test_nuts_and_bolts_2 () { - $fn = 360; - - difference() - { - cube(size = [ 10, 20, 10 ], center = true); - union() - { - translate([ 0, 15 ]) mcad_nut_hole(3, proj = 2); - - linear_extrude( - height = 20, center = true, convexity = 10, twist = 0) - mcad_bolt_hole(3, length = 30, proj = 2); - } - } + $fn = 360; + + difference(){ + cube(size = [10, 20, 10], center = true); + union(){ + translate ([0, 15]) + mcad_nut_hole (3, proj = 2); + + linear_extrude (height = 20, center = true, convexity = 10, + twist = 0) + mcad_bolt_hole (3, length = 30, proj = 2); + } + } } -// mcad_test_nuts_and_bolts_2 (); +//mcad_test_nuts_and_bolts_2 (); -module -mcad_test_nuts_and_bolts_3() +module mcad_test_nuts_and_bolts_3 () { - $fn = 360; + $fn = 360; - mcad_bolt_hole_with_nut(size = 3, length = 10); + mcad_bolt_hole_with_nut ( + size = 3, + length = 10 + ); } -// mcad_test_nuts_and_bolts_3 (); - -// Based on: http://www.roymech.co.uk/Useful_Tables/Screws/Hex_Screws.htm -METRIC_NUT_AC_WIDTHS = [ - -1, // 0 index is not used but reduces computation - -1, - 4.32, // m2 - 6.40, // m3 - 8.10, // m4 - 9.20, // m5 - 11.50, // m6 - -1, - 15.00, // m8 - -1, - 19.60, // m10 - -1, - 22.10, // m12 - -1, -1, -1, - 27.70, // m16 - -1, -1, -1, - 34.60, // m20 - -1, -1, -1, - 41.60, // m24 - -1, -1, -1, -1, -1, - 53.1, // m30 - -1, -1, -1, -1, -1, - 63.5 // m36 +//mcad_test_nuts_and_bolts_3 (); + +//Based on: http://www.roymech.co.uk/Useful_Tables/Screws/Hex_Screws.htm +METRIC_NUT_AC_WIDTHS = +[ + -1, //0 index is not used but reduces computation + -1, + 4.32, //m2 + 6.40,//m3 + 8.10,//m4 + 9.20,//m5 + 11.50,//m6 + -1, + 15.00,//m8 + -1, + 19.60,//m10 + -1, + 22.10,//m12 + -1, + -1, + -1, + 27.70,//m16 + -1, + -1, + -1, + 34.60,//m20 + -1, + -1, + -1, + 41.60,//m24 + -1, + -1, + -1, + -1, + -1, + 53.1,//m30 + -1, + -1, + -1, + -1, + -1, + 63.5//m36 ]; -METRIC_NUT_THICKNESS = [ - -1, // 0 index is not used but reduces computation - -1, - 1.6, // m2 - 2.40, // m3 - 3.20, // m4 - 4.00, // m5 - 5.00, // m6 - -1, - 6.50, // m8 - -1, - 8.00, // m10 - -1, - 10.00, // m12 - -1, - -1, - -1, - 13.00, // m16 - -1, - -1, - -1, - 16.00 // m20 - - 1, - -1, - -1, - 19.00, // m24 - -1, - -1, - -1, - -1, - -1, - 24.00, // m30 - -1, - -1, - -1, - -1, - -1, - 29.00 // m36 +METRIC_NUT_THICKNESS = +[ + -1, //0 index is not used but reduces computation + -1, + 1.6,//m2 + 2.40,//m3 + 3.20,//m4 + 4.00,//m5 + 5.00,//m6 + -1, + 6.50,//m8 + -1, + 8.00,//m10 + -1, + 10.00,//m12 + -1, + -1, + -1, + 13.00,//m16 + -1, + -1, + -1, + 16.00//m20 + -1, + -1, + -1, + 19.00,//m24 + -1, + -1, + -1, + -1, + -1, + 24.00,//m30 + -1, + -1, + -1, + -1, + -1, + 29.00//m36 ]; METRIC_BOLT_CAP_DIAMETERS = [ - -1, -1, -1, - 5.5, // m3 - 7, // m4 - 8.5, // m5 - 10, // m6 - -1, - 13, // m8 - -1, - 16, // m10 - -1, - 18, // m12 - -1, -1, -1, - 24, // m16 - -1, -1, -1, - 30, // m20 - -1, -1, -1, - 36 // m24 + -1, + -1, + -1, + 5.5, // m3 + 7, // m4 + 8.5, // m5 + 10, // m6 + -1, + 13, // m8 + -1, + 16, // m10 + -1, + 18, // m12 + -1, + -1, + -1, + 24, // m16 + -1, + -1, + -1, + 30, // m20 + -1, + -1, + -1, + 36 // m24 ]; -function mcad_metric_nut_ac_width(size) = METRIC_NUT_AC_WIDTHS[size]; -function mcad_metric_nut_thickness(size) = METRIC_NUT_THICKNESS[size]; -function mcad_metric_bolt_major_diameter(size) = size; -function mcad_metric_bolt_cap_height(size) = size; -function mcad_metric_bolt_cap_diameter(size) = - (METRIC_BOLT_CAP_DIAMETERS[size]); +function mcad_metric_nut_ac_width (size) = METRIC_NUT_AC_WIDTHS[size]; +function mcad_metric_nut_thickness (size) = METRIC_NUT_THICKNESS[size]; +function mcad_metric_bolt_major_diameter (size) = size; +function mcad_metric_bolt_cap_height (size) = size; +function mcad_metric_bolt_cap_diameter (size) = ( + METRIC_BOLT_CAP_DIAMETERS[size] +); -module mcad_nut_hole(size, tolerance = +0.0001, proj = -1) +module mcad_nut_hole (size, tolerance = +0.0001, proj = -1) { - // takes a metric screw/nut size and looksup nut dimensions - radius = mcad_metric_nut_ac_width(size) / 2 + tolerance; - height = mcad_metric_nut_thickness(size) + tolerance; + //takes a metric screw/nut size and looksup nut dimensions + radius = mcad_metric_nut_ac_width (size) / 2 + tolerance; + height = mcad_metric_nut_thickness (size) + tolerance; - if (proj == -1) { - cylinder(r = radius, h = height, $fn = 6, center = [ 0, 0 ]); - } + if (proj == -1) { + cylinder (r = radius, h = height, $fn = 6, center = [0, 0]); + } - else if (proj == 1) { - circle(r = radius, $fn = 6); - } + else if (proj == 1) { + circle(r = radius, $fn = 6); + } - else if (proj == 2) { - translate([ -radius / 2, 0 ]) square([ radius * 2, height ]); - } + else if (proj == 2) + { + translate ([-radius/2, 0]) + square ([radius*2, height]); + } } -module mcad_bolt_hole(size, - length, - cap_extra_length, - tolerance = +0.0001, - proj = -1) +module mcad_bolt_hole (size, length, cap_extra_length, tolerance = +0.0001, + proj = -1) { - radius = mcad_metric_bolt_major_diameter(size) / 2 + tolerance; - - cap_height = mcad_metric_bolt_cap_height(size) + tolerance; - cap_radius = mcad_metric_bolt_cap_diameter(size) / 2 + tolerance; - - if (proj == -1) { - translate([ 0, 0, -cap_height - cap_extra_length ]) - cylinder(r = cap_radius, h = cap_height + cap_extra_length); - cylinder(r = radius, h = length); - } - if (proj == 1) { - circle(r = radius); - } - if (proj == 2) { - translate([ -cap_radius, -cap_height ]) - square([ cap_radius * 2, cap_height ]); - translate([ -radius, 0 ]) square([ radius * 2, length ]); - } + radius = mcad_metric_bolt_major_diameter (size) / 2 + tolerance; + + cap_height = mcad_metric_bolt_cap_height (size) + tolerance; + cap_radius = mcad_metric_bolt_cap_diameter (size) / 2 + tolerance; + + if (proj == -1) + { + translate([0, 0, -cap_height - cap_extra_length]) + cylinder(r = cap_radius, h = cap_height + cap_extra_length); + cylinder(r = radius, h = length); + } + if (proj == 1) + { + circle(r = radius); + } + if (proj == 2) + { + translate([-cap_radius, - cap_height]) + square([cap_radius * 2, cap_height]); + translate([-radius, 0]) + square([radius * 2, length]); + } } /** @@ -195,51 +224,42 @@ module mcad_bolt_hole(size, * @param align_with Alignment of whole set (above_head, below_head, center, * below_nut, above_nut) */ -module mcad_bolt_hole_with_nut(size, - length, - nut_projection = "axial", - align_with = "above_head", - screw_extra_length = 9999, - head_extra_length = 9999, - nut_projection_length = 100, - bolt_tolerance = 0.15, - nut_tolerance = 0.001) +module mcad_bolt_hole_with_nut (size, length, nut_projection = "axial", + align_with = "above_head", + screw_extra_length = 9999, + head_extra_length = 9999, + nut_projection_length = 100, + bolt_tolerance = 0.15, + nut_tolerance = 0.001) { - cap_head_d = mcad_metric_bolt_cap_diameter(size); - cap_head_h = size; - - nut_thickness = mcad_metric_nut_thickness(size); - - elevation = - ((align_with == "above_head") - ? 0 - : (align_with == "below_head") - ? cap_head_h - : (align_with == "center") - ? cap_head_h + length / 2 - : (align_with == "below_nut") - ? cap_head_h + length - : (align_with == "above_nut") - ? cap_head_h + length + nut_thickness - : 0); - - translate([ 0, 0, -elevation ]) - { - /* screw head */ - translate([ 0, 0, cap_head_h ]) - mcad_bolt_hole(size = size, - length = length + screw_extra_length, - cap_extra_length = head_extra_length, - tolerance = bolt_tolerance); - - /* nut */ - translate([ 0, 0, cap_head_h + length - epsilon ]) hull() - { - axis = (nut_projection == "axial") ? +Z : +X; - - mcad_linear_multiply( - no = 2, separation = nut_projection_length, axis = axis) - mcad_nut_hole(size = size, tolerance = nut_tolerance); - } - } + cap_head_d = mcad_metric_bolt_cap_diameter (size); + cap_head_h = size; + + nut_thickness = mcad_metric_nut_thickness (size); + + elevation = ( + (align_with == "above_head") ? 0 : + (align_with == "below_head") ? cap_head_h : + (align_with == "center") ? cap_head_h + length / 2 : + (align_with == "below_nut") ? cap_head_h + length : + (align_with == "above_nut") ? cap_head_h + length + nut_thickness : 0 + ); + + translate ([0, 0, -elevation]) { + /* screw head */ + translate ([0, 0, cap_head_h]) + mcad_bolt_hole (size = size, length = length + screw_extra_length, + cap_extra_length = head_extra_length, + tolerance = bolt_tolerance); + + /* nut */ + translate ([0, 0, cap_head_h + length - epsilon]) + hull () { + axis = (nut_projection == "axial") ? +Z : +X; + + mcad_linear_multiply (no = 2, separation = nut_projection_length, + axis = axis) + mcad_nut_hole (size = size, tolerance = nut_tolerance); + } + } } diff --git a/fasteners/threads.scad b/fasteners/threads.scad index 3f91a10f..29527f84 100644 --- a/fasteners/threads.scad +++ b/fasteners/threads.scad @@ -1,6 +1,3 @@ -use -use -use /* * Dan Kirshner - dan_kirshner@yahoo.com * Chow Loong Jin - hyperair@debian.org @@ -8,115 +5,132 @@ use * You are welcome to make free use of this software. Retention of my * authorship credit would be appreciated. * - * Version 1.3. 2013-12-01 Correct loop over turns -- don't have early - * cut-off Version 1.2. 2012-09-09 Use discrete polyhedra rather than - * linear_extrude() Version 1.1. 2012-09-07 Corrected to right-hand threads! + * Version 1.3. 2013-12-01 Correct loop over turns -- don't have early cut-off + * Version 1.2. 2012-09-09 Use discrete polyhedra rather than linear_extrude() + * Version 1.1. 2012-09-07 Corrected to right-hand threads! */ // Examples: -test_threads(); +test_threads (); -module test_threads($fa = 5, $fs = 0.1) +module test_threads ($fa=5, $fs=0.1) { // M8 metric_thread(8, 1.5, 10); - translate([ 10, 0, 0 ]) square_thread(8, 1.5, 10); + translate ([10, 0, 0]) + square_thread(8, 1.5, 10); - translate([ 20, 0, 0 ]) acme_thread(8, 1.5, 10); + translate ([20, 0, 0]) + acme_thread(8, 1.5, 10); - translate([ 30, 0, 0 ]) buttress_thread(8, 1.5, 10); + translate ([30, 0, 0]) + buttress_thread(8, 1.5, 10); - translate([ 40, 0, 0 ]) english_thread(1 / 4, 20, 1); + translate ([40, 0, 0]) + english_thread(1/4, 20, 1); // Rohloff hub thread: - translate([ 65, 0, 0 ]) - metric_thread(34, 1, 10, internal = true, n_starts = 6); + translate ([65, 0, 0]) + metric_thread(34, 1, 10, internal=true, n_starts=6); } // ---------------------------------------------------------------------------- +use +use +use +use + -use - - // ---------------------------------------------------------------------------- - // internal - true = clearances for internal thread (e.g., a nut). - // false = clearances for external thread (e.g., a bolt). - // (Internal threads should be "cut out" from a solid using - // difference()). - // n_starts - Number of thread starts (e.g., DNA, a "double helix," has - // n_starts=2). See wikipedia Screw_thread. - module metric_thread(diameter = 8, - pitch = 1, - length = 1, - internal = false, - n_starts = 1) +// ---------------------------------------------------------------------------- +// internal - true = clearances for internal thread (e.g., a nut). +// false = clearances for external thread (e.g., a bolt). +// (Internal threads should be "cut out" from a solid using +// difference()). +// n_starts - Number of thread starts (e.g., DNA, a "double helix," has +// n_starts=2). See wikipedia Screw_thread. +module metric_thread ( + diameter = 8, + pitch = 1, + length = 1, + internal = false, + n_starts = 1 +) { - trapezoidal_thread(pitch = pitch, - length = length, - upper_angle = 30, - lower_angle = 30, - outer_flat_length = pitch / 8, - major_radius = diameter / 2, - minor_radius = diameter / 2 - 5 / 8 * cos(30) * pitch, - internal = internal, - n_starts = n_starts); + trapezoidal_thread ( + pitch = pitch, + length = length, + upper_angle = 30, lower_angle = 30, + outer_flat_length = pitch / 8, + major_radius = diameter / 2, + minor_radius = diameter / 2 - 5/8 * cos(30) * pitch, + internal = internal, + n_starts = n_starts + ); } -module square_thread(diameter = 8, - pitch = 1, - length = 1, - internal = false, - n_starts = 1) +module square_thread ( + diameter = 8, + pitch = 1, + length = 1, + internal = false, + n_starts = 1 +) { - trapezoidal_thread(pitch = pitch, - length = length, - upper_angle = 0, - lower_angle = 0, - outer_flat_length = pitch / 2, - major_radius = diameter / 2, - minor_radius = diameter / 2 - pitch / 2, - internal = internal, - n_starts = n_starts); + trapezoidal_thread ( + pitch = pitch, + length = length, + upper_angle = 0, lower_angle = 0, + outer_flat_length = pitch / 2, + major_radius = diameter / 2, + minor_radius = diameter / 2 - pitch / 2, + internal = internal, + n_starts = n_starts + ); } -module acme_thread(diameter = 8, - pitch = 1, - length = 1, - internal = false, - n_starts = 1) +module acme_thread ( + diameter = 8, + pitch = 1, + length = 1, + internal = false, + n_starts = 1 +) { - trapezoidal_thread(pitch = pitch, - length = length, - upper_angle = 29 / 2, - lower_angle = 29 / 2, - outer_flat_length = 0.3707 * pitch, - major_radius = diameter / 2, - minor_radius = diameter / 2 - pitch / 2, - internal = internal, - n_starts = n_starts); + trapezoidal_thread ( + pitch = pitch, + length = length, + upper_angle = 29/2, lower_angle = 29/2, + outer_flat_length = 0.3707 * pitch, + major_radius = diameter / 2, + minor_radius = diameter / 2 - pitch / 2, + internal = internal, + n_starts = n_starts + ); } -module buttress_thread(diameter = 8, - pitch = 1, - length = 1, - internal = false, - n_starts = 1, - buttress_angles = [ 3, 33 ], - pitch_flat_ratio = 6, // ratio of pitch to flat length - pitch_depth_ratio = 3 / - 2 // ratio of pitch to thread depth +module buttress_thread ( + diameter = 8, + pitch = 1, + length = 1, + internal = false, + n_starts = 1, + buttress_angles = [3, 33], + pitch_flat_ratio = 6, // ratio of pitch to flat length + pitch_depth_ratio = 3/2 // ratio of pitch to thread depth ) { - trapezoidal_thread(pitch = pitch, - length = length, - upper_angle = buttress_angles[0], - lower_angle = buttress_angles[1], - outer_flat_length = pitch / pitch_flat_ratio, - major_radius = diameter / 2, - minor_radius = diameter / 2 - pitch / pitch_depth_ratio, - internal = internal, - n_starts = n_starts); + trapezoidal_thread ( + pitch = pitch, + length = length, + upper_angle = buttress_angles[0], lower_angle = buttress_angles[1], + outer_flat_length = pitch / pitch_flat_ratio, + major_radius = diameter / 2, + minor_radius = diameter / 2 - pitch / pitch_depth_ratio, + internal = internal, + n_starts = n_starts + ); } /** @@ -133,15 +147,17 @@ module buttress_thread(diameter = 8, * internal = if true, generates a thread suitable for difference() to make nuts * n_starts = number of threads winding the screw */ -module trapezoidal_thread(pitch, - length, - upper_angle, - lower_angle, - outer_flat_length, - major_radius, - minor_radius, - internal = false, - n_starts = 1) +module trapezoidal_thread ( + pitch, + length, + upper_angle, + lower_angle, + outer_flat_length, + major_radius, + minor_radius, + internal = false, + n_starts = 1 +) { // trapezoid calculation: /* @@ -161,68 +177,69 @@ module trapezoidal_thread(pitch, left_angle = 90 - upper_angle; right_angle = 90 - lower_angle; upper_flat = outer_flat_length; - left_flat = tooth_height / tan(left_angle); - right_flat = tooth_height / tan(right_angle); + left_flat = tooth_height / tan (left_angle); + right_flat = tooth_height / tan (right_angle); lower_flat = upper_flat + left_flat + right_flat; - clearance = 0.3 / 8 * tooth_height; + clearance = 0.3/8 * tooth_height; tooth_profile = [ - [ 0, 0 ], - [ tooth_height + 0.001, right_flat ], - [ tooth_height + 0.001, right_flat + upper_flat ], - [ 0, lower_flat ] + [0, 0], + [tooth_height + 0.001, right_flat], + [tooth_height + 0.001, right_flat + upper_flat], + [0, lower_flat] ]; // convert length along the tooth profile to angle of twist of the screw - function length2twist(length) = length / pitch * (360 / n_starts); - function twist2length(angle) = angle / (360 / n_starts) * pitch; + function length2twist (length) = length / pitch * (360 / n_starts); + function twist2length (angle) = angle / (360 / n_starts) * pitch; // facet calculation - facets = get_fragments_from_r(minor_radius); + facets = get_fragments_from_r (minor_radius); fa = 360 / facets; - slices = length2twist(length) / fa; - - path_transforms = [for (i = [0:slices + length2twist(pitch) / fa]) - let(a = i * fa)(rotation(axis = [ 0, 0, a ]) * - translation([ 0, 0, twist2length(a) - pitch ]) * - translation([ minor_radius - 0.001, 0, 0 ]) * - rotation(axis = [ 90, 0, 0 ]))]; + slices = length2twist (length) / fa; + + path_transforms = [ + for (i=[0:slices + length2twist (pitch) / fa]) + let (a=i * fa) + ( + rotation (axis=[0, 0, a]) * + translation ([0, 0, twist2length (a) - pitch]) * + translation ([minor_radius - 0.001, 0, 0]) * + rotation (axis=[90, 0, 0]) + ) + ]; - cylinder(r = minor_radius, h = length); + cylinder (r=minor_radius, h=length); - difference() - { - for (i = [0:n_starts]) - rotate([ 0, 0, i / n_starts * 360 ]) - sweep(tooth_profile, path_transforms); + difference () { + for (i=[0:n_starts]) + rotate ([0, 0, i / n_starts * 360]) + sweep (tooth_profile, path_transforms); - translate([ 0, 0, length + pitch / 2 ]) - cube([ major_radius * 2 + .1, major_radius * 2 + .1, pitch ], - center = true); + translate ([0, 0, length + pitch / 2]) + cube ([major_radius * 2 + .1, major_radius * 2+ .1, pitch], + center=true); - translate([ 0, 0, -pitch / 2 ]) - cube([ major_radius * 2 + .1, major_radius * 2 + .1, pitch ], - center = true); + translate ([0, 0, -pitch / 2]) + cube ([major_radius * 2 + .1, major_radius * 2+ .1, pitch], + center=true); } } // ---------------------------------------------------------------------------- // Input units in inches. // Note: units of measure in drawing are mm! -module english_thread(diameter = 0.25, - threads_per_inch = 20, - length = 1, - internal = false, - n_starts = 1) +module english_thread(diameter=0.25, threads_per_inch=20, length=1, + internal=false, n_starts=1) { - // Convert to mm. - mm_diameter = diameter * 25.4; - mm_pitch = (1.0 / threads_per_inch) * 25.4; - mm_length = length * 25.4; - - echo(str("mm_diameter: ", mm_diameter)); - echo(str("mm_pitch: ", mm_pitch)); - echo(str("mm_length: ", mm_length)); - metric_thread(mm_diameter, mm_pitch, mm_length, internal, n_starts); + // Convert to mm. + mm_diameter = diameter*25.4; + mm_pitch = (1.0/threads_per_inch)*25.4; + mm_length = length*25.4; + + echo(str("mm_diameter: ", mm_diameter)); + echo(str("mm_pitch: ", mm_pitch)); + echo(str("mm_length: ", mm_length)); + metric_thread(mm_diameter, mm_pitch, mm_length, internal, n_starts); } diff --git a/format.py b/format.py deleted file mode 100755 index 33d43840..00000000 --- a/format.py +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/python3 - -import os -import shutil - -if shutil.which("openscad-format") is None: - os.system("npm install -g openscad-format") -os.system("openscad-format -i './**/*.scad'") diff --git a/gears/gears.scad b/gears/gears.scad index 613ae866..eb2a7d9b 100644 --- a/gears/gears.scad +++ b/gears/gears.scad @@ -1,10 +1,10 @@ - // Copyright 2010 D1plo1d // LGPL 2.1 -// test_involute_curve(); -// test_gears(); -// demo_3d_gears(); + +//test_involute_curve(); +//test_gears(); +//demo_3d_gears(); // Geometry Sources: // http://www.cartertools.com/involute.html @@ -12,197 +12,187 @@ // Usage: // Diametral pitch: Number of teeth per unit length. // Circular pitch: Length of the arc from one tooth to the next -// Clearance: Radial distance between top of tooth on one gear to bottom of gap -//on another. +// Clearance: Radial distance between top of tooth on one gear to bottom of gap on another. -function pitch_circular2diameter(number_of_teeth, circular_pitch) = - number_of_teeth * circular_pitch / 180; -function pitch_diametral2diameter(number_of_teeth, diametral_pitch) = - number_of_teeth / diametral_pitch; +function pitch_circular2diameter(number_of_teeth,circular_pitch) = number_of_teeth * circular_pitch / 180; +function pitch_diametral2diameter(number_of_teeth,diametral_pitch) = number_of_teeth / diametral_pitch; module gear(number_of_teeth, - circular_pitch = false, - diametral_pitch = false, - pressure_angle = 20, - clearance = 0, - verbose = false) + circular_pitch=false, diametral_pitch=false, + pressure_angle=20, clearance = 0, + verbose=false) { - if (verbose) { - echo("gear arguments:"); - echo(str(" number_of_teeth: ", number_of_teeth)); - echo(str(" circular_pitch: ", circular_pitch)); - echo(str(" diametral_pitch: ", diametral_pitch)); - echo(str(" pressure_angle: ", pressure_angle)); - echo(str(" clearance: ", clearance)); - } - if (circular_pitch == false && diametral_pitch == false) - echo("MCAD ERROR: gear module needs either a diametral_pitch or " - "circular_pitch"); - if (verbose) - echo("gear calculations:"); - - // Convert diametrial pitch to our native circular pitch - circular_pitch = - (circular_pitch != false ? circular_pitch : 180 / diametral_pitch); - - // Pitch diameter: Diameter of pitch circle. - pitch_diameter = pitch_circular2diameter(number_of_teeth, circular_pitch); - if (verbose) - echo(str(" pitch_diameter: ", pitch_diameter)); - pitch_radius = pitch_diameter / 2; - - // Base Circle - base_diameter = pitch_diameter * cos(pressure_angle); - if (verbose) - echo(str(" base_diameter: ", base_diameter)); - base_radius = base_diameter / 2; - - // Diametrial pitch: Number of teeth per unit length. - pitch_diametrial = number_of_teeth / pitch_diameter; - if (verbose) - echo(str(" pitch_diametrial: ", pitch_diametrial)); - - // Addendum: Radial distance from pitch circle to outside circle. - addendum = 1 / pitch_diametrial; - if (verbose) - echo(str(" addendum: ", addendum)); - - // Outer Circle - outer_radius = pitch_radius + addendum; - outer_diameter = outer_radius * 2; - if (verbose) - echo(str(" outer_diameter: ", outer_diameter)); - - // Dedendum: Radial distance from pitch circle to root diameter - dedendum = addendum + clearance; - if (verbose) - echo(str(" dedendum: ", dedendum)); - - // Root diameter: Diameter of bottom of tooth spaces. - root_radius = pitch_radius - dedendum; - root_diameter = root_radius * 2; - if (verbose) - echo(str(" root_diameter: ", root_diameter)); - - half_thick_angle = 360 / (4 * number_of_teeth); - if (verbose) - echo(str(" half_thick_angle: ", half_thick_angle)); - - union() - { - rotate(half_thick_angle) - circle($fn = number_of_teeth * 2, r = root_radius * 1.001); - - for (i = [1:number_of_teeth]) - // for (i = [0]) - { - rotate([ 0, 0, i * 360 / number_of_teeth ]) - { - involute_gear_tooth(pitch_radius = pitch_radius, - root_radius = root_radius, - base_radius = base_radius, - outer_radius = outer_radius, - half_thick_angle = half_thick_angle); - } - } - } + if(verbose) { + echo("gear arguments:"); + echo(str(" number_of_teeth: ", number_of_teeth)); + echo(str(" circular_pitch: ", circular_pitch)); + echo(str(" diametral_pitch: ", diametral_pitch)); + echo(str(" pressure_angle: ", pressure_angle)); + echo(str(" clearance: ", clearance)); + } + if (circular_pitch==false && diametral_pitch==false) echo("MCAD ERROR: gear module needs either a diametral_pitch or circular_pitch"); + if(verbose) echo("gear calculations:"); + + //Convert diametrial pitch to our native circular pitch + circular_pitch = (circular_pitch!=false?circular_pitch:180/diametral_pitch); + + // Pitch diameter: Diameter of pitch circle. + pitch_diameter = pitch_circular2diameter(number_of_teeth,circular_pitch); + if(verbose) echo (str(" pitch_diameter: ", pitch_diameter)); + pitch_radius = pitch_diameter/2; + + // Base Circle + base_diameter = pitch_diameter*cos(pressure_angle); + if(verbose) echo (str(" base_diameter: ", base_diameter)); + base_radius = base_diameter/2; + + // Diametrial pitch: Number of teeth per unit length. + pitch_diametrial = number_of_teeth / pitch_diameter; + if(verbose) echo (str(" pitch_diametrial: ", pitch_diametrial)); + + // Addendum: Radial distance from pitch circle to outside circle. + addendum = 1/pitch_diametrial; + if(verbose) echo (str(" addendum: ", addendum)); + + //Outer Circle + outer_radius = pitch_radius+addendum; + outer_diameter = outer_radius*2; + if(verbose) echo (str(" outer_diameter: ", outer_diameter)); + + // Dedendum: Radial distance from pitch circle to root diameter + dedendum = addendum + clearance; + if(verbose) echo (str(" dedendum: ", dedendum)); + + // Root diameter: Diameter of bottom of tooth spaces. + root_radius = pitch_radius-dedendum; + root_diameter = root_radius * 2; + if(verbose) echo (str(" root_diameter: ", root_diameter)); + + half_thick_angle = 360 / (4 * number_of_teeth); + if(verbose) echo (str(" half_thick_angle: ", half_thick_angle)); + + union() + { + rotate(half_thick_angle) circle($fn=number_of_teeth*2, r=root_radius*1.001); + + for (i= [1:number_of_teeth]) + //for (i = [0]) + { + rotate([0,0,i*360/number_of_teeth]) + { + involute_gear_tooth( + pitch_radius = pitch_radius, + root_radius = root_radius, + base_radius = base_radius, + outer_radius = outer_radius, + half_thick_angle = half_thick_angle); + } + } + } } -module involute_gear_tooth(pitch_radius, - root_radius, - base_radius, - outer_radius, - half_thick_angle) + +module involute_gear_tooth( + pitch_radius, + root_radius, + base_radius, + outer_radius, + half_thick_angle + ) { - pitch_to_base_angle = involute_intersect_angle(base_radius, pitch_radius); - - outer_to_base_angle = involute_intersect_angle(base_radius, outer_radius); - - base1 = 0 - pitch_to_base_angle - half_thick_angle; - pitch1 = 0 - half_thick_angle; - outer1 = outer_to_base_angle - pitch_to_base_angle - half_thick_angle; - - b1 = polar_to_cartesian([ base1, base_radius ]); - p1 = polar_to_cartesian([ pitch1, pitch_radius ]); - o1 = polar_to_cartesian([ outer1, outer_radius ]); - - b2 = polar_to_cartesian([ -base1, base_radius ]); - p2 = polar_to_cartesian([ -pitch1, pitch_radius ]); - o2 = polar_to_cartesian([ -outer1, outer_radius ]); - - // ( root_radius > base_radius variables ) - pitch_to_root_angle = pitch_to_base_angle - - involute_intersect_angle(base_radius, root_radius); - root1 = pitch1 - pitch_to_root_angle; - root2 = -pitch1 + pitch_to_root_angle; - r1_t = polar_to_cartesian([ root1, root_radius ]); - r2_t = polar_to_cartesian([ -root1, root_radius ]); - - // ( else ) - r1_f = polar_to_cartesian([ base1, root_radius ]); - r2_f = polar_to_cartesian([ -base1, root_radius ]); - - if (root_radius > base_radius) { - // echo("true"); - polygon(points = [ r1_t, p1, o1, o2, p2, r2_t ], convexity = 3); - } else { - polygon(points = [ r1_f, b1, p1, o1, o2, p2, b2, r2_f ], convexity = 3); - } + pitch_to_base_angle = involute_intersect_angle( base_radius, pitch_radius ); + + outer_to_base_angle = involute_intersect_angle( base_radius, outer_radius ); + + base1 = 0 - pitch_to_base_angle - half_thick_angle; + pitch1 = 0 - half_thick_angle; + outer1 = outer_to_base_angle - pitch_to_base_angle - half_thick_angle; + + b1 = polar_to_cartesian([ base1, base_radius ]); + p1 = polar_to_cartesian([ pitch1, pitch_radius ]); + o1 = polar_to_cartesian([ outer1, outer_radius ]); + + b2 = polar_to_cartesian([ -base1, base_radius ]); + p2 = polar_to_cartesian([ -pitch1, pitch_radius ]); + o2 = polar_to_cartesian([ -outer1, outer_radius ]); + + // ( root_radius > base_radius variables ) + pitch_to_root_angle = pitch_to_base_angle - involute_intersect_angle(base_radius, root_radius ); + root1 = pitch1 - pitch_to_root_angle; + root2 = -pitch1 + pitch_to_root_angle; + r1_t = polar_to_cartesian([ root1, root_radius ]); + r2_t = polar_to_cartesian([ -root1, root_radius ]); + + // ( else ) + r1_f = polar_to_cartesian([ base1, root_radius ]); + r2_f = polar_to_cartesian([ -base1, root_radius ]); + + if (root_radius > base_radius) + { + //echo("true"); + polygon( points = [ + r1_t,p1,o1,o2,p2,r2_t + ], convexity = 3); + } + else + { + polygon( points = [ + r1_f, b1,p1,o1,o2,p2,b2,r2_f + ], convexity = 3); + } + } // Mathematical Functions //=============== -// Finds the angle of the involute about the base radius at the given distance -// (radius) from it's center. -// source: -// http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html +// Finds the angle of the involute about the base radius at the given distance (radius) from it's center. +//source: http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html + +function involute_intersect_angle(base_radius, radius) = sqrt( pow(radius/base_radius,2) - 1); + -function involute_intersect_angle(base_radius, - radius) = sqrt(pow(radius / base_radius, 2) - - 1); // Polar coord [angle, radius] to cartesian coord [x,y] -function polar_to_cartesian(polar) = - [ polar[1] * cos(polar[0]), polar[1] * sin(polar[0]) ]; +function polar_to_cartesian(polar) = [ + polar[1]*cos(polar[0]), + polar[1]*sin(polar[0]) +]; + // Test Cases //=============== -module -test_gears() +module test_gears() { - gear(number_of_teeth = 51, circular_pitch = 200); - translate([ 0, 50 ]) gear(number_of_teeth = 17, circular_pitch = 200); - translate([ -50, 0 ]) gear(number_of_teeth = 17, diametral_pitch = 1); + gear(number_of_teeth=51,circular_pitch=200); + translate([0, 50])gear(number_of_teeth=17,circular_pitch=200); + translate([-50,0]) gear(number_of_teeth=17,diametral_pitch=1); } -module -demo_3d_gears() +module demo_3d_gears() { - // double helical gear - // (helics don't line up perfectly - for display purposes only ;) - translate([ 50, 0 ]) - { - linear_extrude(height = 10, center = true, convexity = 10, twist = -45) - gear(number_of_teeth = 17, diametral_pitch = 1); - translate([ 0, 0, 10 ]) linear_extrude( - height = 10, center = true, convexity = 10, twist = 45) - gear(number_of_teeth = 17, diametral_pitch = 1); - } - - // spur gear - translate([ 0, -50 ]) - linear_extrude(height = 10, center = true, convexity = 10, twist = 0) - gear(number_of_teeth = 17, diametral_pitch = 1); + //double helical gear + // (helics don't line up perfectly - for display purposes only ;) + translate([50,0]) + { + linear_extrude(height = 10, center = true, convexity = 10, twist = -45) + gear(number_of_teeth=17,diametral_pitch=1); + translate([0,0,10]) linear_extrude(height = 10, center = true, convexity = 10, twist = 45) + gear(number_of_teeth=17,diametral_pitch=1); + } + + //spur gear + translate([0,-50]) linear_extrude(height = 10, center = true, convexity = 10, twist = 0) + gear(number_of_teeth=17,diametral_pitch=1); + } -module -test_involute_curve() +module test_involute_curve() { - for (i = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ]) { - translate(polar_to_cartesian([ involute_intersect_angle(0.1, i), i ])) - circle($fn = 15, r = 0.5); - } + for (i=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]) + { + translate(polar_to_cartesian([involute_intersect_angle( 0.1,i) , i ])) circle($fn=15, r=0.5); + } } diff --git a/gears/involute_gears.scad b/gears/involute_gears.scad index f7833bd7..73e19f6a 100644 --- a/gears/involute_gears.scad +++ b/gears/involute_gears.scad @@ -1,728 +1,738 @@ -use // Parametric Involute Bevel and Spur Gears by GregFrost // It is licensed under the Creative Commons - GNU LGPL 2.1 license. // © 2010 by GregFrost, thingiverse.com/Amp -// http://www.thingiverse.com/thing:3575 and -// http://www.thingiverse.com/thing:3752 +// http://www.thingiverse.com/thing:3575 and http://www.thingiverse.com/thing:3752 + +use // Simple Test: -gear(number_of_teeth = 30, - circular_pitch = 700, - gear_thickness = 12, - rim_thickness = 15, - hub_thickness = 17, - circles = 8, - roundsize = 0); - -translate([ 700 * PI / 180 * 30 / 2 / PI * 2, 0, 0 ]) rotate(180 + 360 / 30 / 2) - gear(number_of_teeth = 30, - circular_pitch = 700, - gear_thickness = 12, - rim_thickness = 15, - hub_thickness = 17, - circles = 8, - roundsize = 1); - -// Complex Spur Gear Test: -// test_gears (); +gear ( + number_of_teeth = 30, + circular_pitch=700, + gear_thickness = 12, + rim_thickness = 15, + hub_thickness = 17, + circles=8, + roundsize = 0 + ); + +translate ([700 * PI / 180 * 30 / 2 / PI * 2,0,0]) +rotate (180 + 360 / 30 / 2) +gear ( + number_of_teeth = 30, + circular_pitch=700, + gear_thickness = 12, + rim_thickness = 15, + hub_thickness = 17, + circles=8, + roundsize = 1 + ); + +//Complex Spur Gear Test: +//test_gears (); // Meshing Double Helix: -// test_meshing_double_helix (); +//test_meshing_double_helix (); -module -test_meshing_double_helix() -{ - meshing_double_helix(); +module test_meshing_double_helix(){ + meshing_double_helix (); } // Demonstrate the backlash option for Spur gears. -// test_backlash (); +//test_backlash (); // Demonstrate how to make meshing bevel gears. -// test_bevel_gear_pair(); +//test_bevel_gear_pair(); -module -test_bevel_gear_pair() -{ - bevel_gear_pair(); +module test_bevel_gear_pair(){ + bevel_gear_pair (); } -module -test_bevel_gear() -{ - bevel_gear(); -} +module test_bevel_gear(){bevel_gear();} -// bevel_gear(); +//bevel_gear(); -pi = 3.1415926535897932384626433832795; +pi=3.1415926535897932384626433832795; //================================================== // Bevel Gears: -// Two gears with the same cone distance, circular pitch (measured at the cone -// distance) and pressure angle will mesh. - -module bevel_gear_pair(gear1_teeth = 41, - gear2_teeth = 7, - axis_angle = 90, - outside_circular_pitch = 1000) +// Two gears with the same cone distance, circular pitch (measured at the cone distance) +// and pressure angle will mesh. + +module bevel_gear_pair ( + gear1_teeth = 41, + gear2_teeth = 7, + axis_angle = 90, + outside_circular_pitch=1000) { - outside_pitch_radius1 = gear1_teeth * outside_circular_pitch / 360; - outside_pitch_radius2 = gear2_teeth * outside_circular_pitch / 360; - pitch_apex1 = - outside_pitch_radius2 * sin(axis_angle) + - (outside_pitch_radius2 * cos(axis_angle) + outside_pitch_radius1) / - tan(axis_angle); - cone_distance = sqrt(pow(pitch_apex1, 2) + pow(outside_pitch_radius1, 2)); - pitch_apex2 = sqrt(pow(cone_distance, 2) - pow(outside_pitch_radius2, 2)); - echo("cone_distance", cone_distance); - pitch_angle1 = asin(outside_pitch_radius1 / cone_distance); - pitch_angle2 = asin(outside_pitch_radius2 / cone_distance); - echo("pitch_angle1, pitch_angle2", pitch_angle1, pitch_angle2); - echo("pitch_angle1 + pitch_angle2", pitch_angle1 + pitch_angle2); - - rotate([ 0, 0, 90 ]) translate([ 0, 0, pitch_apex1 + 20 ]) - { - translate([ 0, 0, -pitch_apex1 ]) - bevel_gear(number_of_teeth = gear1_teeth, - cone_distance = cone_distance, - pressure_angle = 30, - outside_circular_pitch = outside_circular_pitch); - - rotate([ 0, -(pitch_angle1 + pitch_angle2), 0 ]) - translate([ 0, 0, -pitch_apex2 ]) - bevel_gear(number_of_teeth = gear2_teeth, - cone_distance = cone_distance, - pressure_angle = 30, - outside_circular_pitch = outside_circular_pitch); - } + outside_pitch_radius1 = gear1_teeth * outside_circular_pitch / 360; + outside_pitch_radius2 = gear2_teeth * outside_circular_pitch / 360; + pitch_apex1=outside_pitch_radius2 * sin (axis_angle) + + (outside_pitch_radius2 * cos (axis_angle) + outside_pitch_radius1) / tan (axis_angle); + cone_distance = sqrt (pow (pitch_apex1, 2) + pow (outside_pitch_radius1, 2)); + pitch_apex2 = sqrt (pow (cone_distance, 2) - pow (outside_pitch_radius2, 2)); + echo ("cone_distance", cone_distance); + pitch_angle1 = asin (outside_pitch_radius1 / cone_distance); + pitch_angle2 = asin (outside_pitch_radius2 / cone_distance); + echo ("pitch_angle1, pitch_angle2", pitch_angle1, pitch_angle2); + echo ("pitch_angle1 + pitch_angle2", pitch_angle1 + pitch_angle2); + + rotate([0,0,90]) + translate ([0,0,pitch_apex1+20]) + { + translate([0,0,-pitch_apex1]) + bevel_gear ( + number_of_teeth=gear1_teeth, + cone_distance=cone_distance, + pressure_angle=30, + outside_circular_pitch=outside_circular_pitch); + + rotate([0,-(pitch_angle1+pitch_angle2),0]) + translate([0,0,-pitch_apex2]) + bevel_gear ( + number_of_teeth=gear2_teeth, + cone_distance=cone_distance, + pressure_angle=30, + outside_circular_pitch=outside_circular_pitch); + } } -// Bevel Gear Finishing Options: +//Bevel Gear Finishing Options: bevel_gear_flat = 0; bevel_gear_back_cone = 1; -module bevel_gear(number_of_teeth = 11, - cone_distance = 100, - face_width = 20, - outside_circular_pitch = 1000, - pressure_angle = 30, - clearance = 0.2, - bore_diameter = 5, - gear_thickness = 15, - backlash = 0, - involute_facets = 0, - finish = -1) +module bevel_gear ( + number_of_teeth=11, + cone_distance=100, + face_width=20, + outside_circular_pitch=1000, + pressure_angle=30, + clearance = 0.2, + bore_diameter=5, + gear_thickness = 15, + backlash = 0, + involute_facets=0, + finish = -1) { - echo("bevel_gear", - "teeth", - number_of_teeth, - "cone distance", - cone_distance, - face_width, - outside_circular_pitch, - pressure_angle, - clearance, - bore_diameter, - involute_facets, - finish); - - // Pitch diameter: Diameter of pitch circle at the fat end of the gear. - outside_pitch_diameter = number_of_teeth * outside_circular_pitch / 180; - outside_pitch_radius = outside_pitch_diameter / 2; - - // The height of the pitch apex. - pitch_apex = sqrt(pow(cone_distance, 2) - pow(outside_pitch_radius, 2)); - pitch_angle = asin(outside_pitch_radius / cone_distance); - - echo("Num Teeth:", number_of_teeth, " Pitch Angle:", pitch_angle); - - finish = (finish != -1) - ? finish - : (pitch_angle < 45) ? bevel_gear_flat : bevel_gear_back_cone; - - apex_to_apex = cone_distance / cos(pitch_angle); - back_cone_radius = apex_to_apex * sin(pitch_angle); - - // Calculate and display the pitch angle. This is needed to determine the - // angle to mount two meshing cone gears. - - // Base Circle for forming the involute teeth shape. - base_radius = back_cone_radius * cos(pressure_angle); - - // Diametrial pitch: Number of teeth per unit length. - pitch_diametrial = number_of_teeth / outside_pitch_diameter; - - // Addendum: Radial distance from pitch circle to outside circle. - addendum = 1 / pitch_diametrial; - // Outer Circle - outer_radius = back_cone_radius + addendum; - - // Dedendum: Radial distance from pitch circle to root diameter - dedendum = addendum + clearance; - dedendum_angle = atan(dedendum / cone_distance); - root_angle = pitch_angle - dedendum_angle; - - root_cone_full_radius = tan(root_angle) * apex_to_apex; - back_cone_full_radius = apex_to_apex / tan(pitch_angle); - - back_cone_end_radius = outside_pitch_radius - dedendum * cos(pitch_angle) - - gear_thickness / tan(pitch_angle); - back_cone_descent = dedendum * sin(pitch_angle) + gear_thickness; - - // Root diameter: Diameter of bottom of tooth spaces. - root_radius = back_cone_radius - dedendum; - - half_tooth_thickness = - outside_pitch_radius * sin(360 / (4 * number_of_teeth)) - backlash / 4; - half_thick_angle = asin(half_tooth_thickness / back_cone_radius); - - face_cone_height = apex_to_apex - face_width / cos(pitch_angle); - face_cone_full_radius = face_cone_height / tan(pitch_angle); - face_cone_descent = dedendum * sin(pitch_angle); - face_cone_end_radius = outside_pitch_radius - - face_width / sin(pitch_angle) - - face_cone_descent / tan(pitch_angle); - - // For the bevel_gear_flat finish option, calculate the height of a cube to - // select the portion of the gear that includes the full pitch face. - bevel_gear_flat_height = - pitch_apex - (cone_distance - face_width) * cos(pitch_angle); - - // translate([0,0,-pitch_apex]) - difference() - { - intersection() - { - union() - { - rotate(half_thick_angle) - translate([ 0, 0, pitch_apex - apex_to_apex ]) - cylinder($fn = number_of_teeth * 2, - r1 = root_cone_full_radius, - r2 = 0, - h = apex_to_apex); - for (i = [1:number_of_teeth]) - // for (i = [1:1]) - { - rotate([ 0, 0, i * 360 / number_of_teeth ]) - { - involute_bevel_gear_tooth( - back_cone_radius = back_cone_radius, - root_radius = root_radius, - base_radius = base_radius, - outer_radius = outer_radius, - pitch_apex = pitch_apex, - cone_distance = cone_distance, - half_thick_angle = half_thick_angle, - involute_facets = involute_facets); - } - } - } - - if (finish == bevel_gear_back_cone) { - translate([ 0, 0, -back_cone_descent ]) - cylinder($fn = number_of_teeth * 2, - r1 = back_cone_end_radius, - r2 = back_cone_full_radius * 2, - h = apex_to_apex + back_cone_descent); - } else { - translate([ - -1.5 * outside_pitch_radius, - -1.5 * outside_pitch_radius, - 0 - ]) - cube([ - 3 * outside_pitch_radius, - 3 * outside_pitch_radius, - bevel_gear_flat_height - ]); - } - } - - if (finish == bevel_gear_back_cone) { - translate([ 0, 0, -face_cone_descent ]) - cylinder(r1 = face_cone_end_radius, - r2 = face_cone_full_radius * 2, - h = face_cone_height + face_cone_descent + pitch_apex); - } - - translate([ 0, 0, pitch_apex - apex_to_apex ]) - cylinder(r = bore_diameter / 2, h = apex_to_apex); - } + echo ("bevel_gear", + "teeth", number_of_teeth, + "cone distance", cone_distance, + face_width, + outside_circular_pitch, + pressure_angle, + clearance, + bore_diameter, + involute_facets, + finish); + + // Pitch diameter: Diameter of pitch circle at the fat end of the gear. + outside_pitch_diameter = number_of_teeth * outside_circular_pitch / 180; + outside_pitch_radius = outside_pitch_diameter / 2; + + // The height of the pitch apex. + pitch_apex = sqrt (pow (cone_distance, 2) - pow (outside_pitch_radius, 2)); + pitch_angle = asin (outside_pitch_radius/cone_distance); + + echo ("Num Teeth:", number_of_teeth, " Pitch Angle:", pitch_angle); + + finish = (finish != -1) ? finish : (pitch_angle < 45) ? bevel_gear_flat : bevel_gear_back_cone; + + apex_to_apex=cone_distance / cos (pitch_angle); + back_cone_radius = apex_to_apex * sin (pitch_angle); + + // Calculate and display the pitch angle. This is needed to determine the angle to mount two meshing cone gears. + + // Base Circle for forming the involute teeth shape. + base_radius = back_cone_radius * cos (pressure_angle); + + // Diametrial pitch: Number of teeth per unit length. + pitch_diametrial = number_of_teeth / outside_pitch_diameter; + + // Addendum: Radial distance from pitch circle to outside circle. + addendum = 1 / pitch_diametrial; + // Outer Circle + outer_radius = back_cone_radius + addendum; + + // Dedendum: Radial distance from pitch circle to root diameter + dedendum = addendum + clearance; + dedendum_angle = atan (dedendum / cone_distance); + root_angle = pitch_angle - dedendum_angle; + + root_cone_full_radius = tan (root_angle)*apex_to_apex; + back_cone_full_radius=apex_to_apex / tan (pitch_angle); + + back_cone_end_radius = + outside_pitch_radius - + dedendum * cos (pitch_angle) - + gear_thickness / tan (pitch_angle); + back_cone_descent = dedendum * sin (pitch_angle) + gear_thickness; + + // Root diameter: Diameter of bottom of tooth spaces. + root_radius = back_cone_radius - dedendum; + + half_tooth_thickness = outside_pitch_radius * sin (360 / (4 * number_of_teeth)) - backlash / 4; + half_thick_angle = asin (half_tooth_thickness / back_cone_radius); + + face_cone_height = apex_to_apex-face_width / cos (pitch_angle); + face_cone_full_radius = face_cone_height / tan (pitch_angle); + face_cone_descent = dedendum * sin (pitch_angle); + face_cone_end_radius = + outside_pitch_radius - + face_width / sin (pitch_angle) - + face_cone_descent / tan (pitch_angle); + + // For the bevel_gear_flat finish option, calculate the height of a cube to select the portion of the gear that includes the full pitch face. + bevel_gear_flat_height = pitch_apex - (cone_distance - face_width) * cos (pitch_angle); + +// translate([0,0,-pitch_apex]) + difference () + { + intersection () + { + union() + { + rotate (half_thick_angle) + translate ([0,0,pitch_apex-apex_to_apex]) + cylinder ($fn=number_of_teeth*2, r1=root_cone_full_radius,r2=0,h=apex_to_apex); + for (i = [1:number_of_teeth]) +// for (i = [1:1]) + { + rotate ([0,0,i*360/number_of_teeth]) + { + involute_bevel_gear_tooth ( + back_cone_radius = back_cone_radius, + root_radius = root_radius, + base_radius = base_radius, + outer_radius = outer_radius, + pitch_apex = pitch_apex, + cone_distance = cone_distance, + half_thick_angle = half_thick_angle, + involute_facets = involute_facets); + } + } + } + + if (finish == bevel_gear_back_cone) + { + translate ([0,0,-back_cone_descent]) + cylinder ( + $fn=number_of_teeth*2, + r1=back_cone_end_radius, + r2=back_cone_full_radius*2, + h=apex_to_apex + back_cone_descent); + } + else + { + translate ([-1.5*outside_pitch_radius,-1.5*outside_pitch_radius,0]) + cube ([3*outside_pitch_radius, + 3*outside_pitch_radius, + bevel_gear_flat_height]); + } + } + + if (finish == bevel_gear_back_cone) + { + translate ([0,0,-face_cone_descent]) + cylinder ( + r1=face_cone_end_radius, + r2=face_cone_full_radius * 2, + h=face_cone_height + face_cone_descent+pitch_apex); + } + + translate ([0,0,pitch_apex - apex_to_apex]) + cylinder (r=bore_diameter/2,h=apex_to_apex); + } } -module involute_bevel_gear_tooth(back_cone_radius, - root_radius, - base_radius, - outer_radius, - pitch_apex, - cone_distance, - half_thick_angle, - involute_facets) +module involute_bevel_gear_tooth ( + back_cone_radius, + root_radius, + base_radius, + outer_radius, + pitch_apex, + cone_distance, + half_thick_angle, + involute_facets) { - // echo ("involute_bevel_gear_tooth", - // back_cone_radius, - // root_radius, - // base_radius, - // outer_radius, - // pitch_apex, - // cone_distance, - // half_thick_angle); - - min_radius = max(base_radius * 2, root_radius * 2); - - pitch_point = involute( - base_radius * 2, - involute_intersect_angle(base_radius * 2, back_cone_radius * 2)); - pitch_angle = atan2(pitch_point[1], pitch_point[0]); - centre_angle = pitch_angle + half_thick_angle; - - start_angle = involute_intersect_angle(base_radius * 2, min_radius); - stop_angle = involute_intersect_angle(base_radius * 2, outer_radius * 2); - - res = (involute_facets != 0) ? involute_facets : ($fn == 0) ? 5 : $fn / 4; - - translate([ 0, 0, pitch_apex ]) - rotate([ 0, -atan(back_cone_radius / cone_distance), 0 ]) - translate([ -back_cone_radius * 2, 0, -cone_distance * 2 ]) union() - { - for (i = [1:res]) { - assign(point1 = involute(base_radius * 2, - start_angle + (stop_angle - start_angle) * - (i - 1) / res), - point2 = involute(base_radius * 2, - start_angle + (stop_angle - start_angle) * - (i) / res)) - { - assign(side1_point1 = rotate_2dvector(centre_angle, point1), - side1_point2 = rotate_2dvector(centre_angle, point2), - side2_point1 = mirror_2dvector( - rotate_2dvector(centre_angle, point1)), - side2_point2 = mirror_2dvector( - rotate_2dvector(centre_angle, point2))) - { - polyhedron( - points = - [[back_cone_radius * 2 + 0.1, 0, cone_distance * 2], - [side1_point1 [0], side1_point1 [1], 0], - [side1_point2 [0], side1_point2 [1], 0], - [side2_point2 [0], side2_point2 [1], 0], - [side2_point1 [0], side2_point1 [1], 0], - [0.1, 0, 0]], - triangles = [ - [ 0, 2, 1 ], - [ 0, 3, 2 ], - [ 0, 4, 3 ], - [ 0, 1, 5 ], - [ 1, 2, 5 ], - [ 2, 3, 5 ], - [ 3, 4, 5 ], - [ 0, 5, 4 ] - ]); - } - } - } - } +// echo ("involute_bevel_gear_tooth", +// back_cone_radius, +// root_radius, +// base_radius, +// outer_radius, +// pitch_apex, +// cone_distance, +// half_thick_angle); + + min_radius = max (base_radius*2,root_radius*2); + + pitch_point = + involute ( + base_radius*2, + involute_intersect_angle (base_radius*2, back_cone_radius*2)); + pitch_angle = atan2 (pitch_point[1], pitch_point[0]); + centre_angle = pitch_angle + half_thick_angle; + + start_angle = involute_intersect_angle (base_radius*2, min_radius); + stop_angle = involute_intersect_angle (base_radius*2, outer_radius*2); + + res=(involute_facets!=0)?involute_facets:($fn==0)?5:$fn/4; + + translate ([0,0,pitch_apex]) + rotate ([0,-atan(back_cone_radius/cone_distance),0]) + translate ([-back_cone_radius*2,0,-cone_distance*2]) + union () + { + for (i=[1:res]) + { + assign ( + point1= + involute (base_radius*2,start_angle+(stop_angle - start_angle)*(i-1)/res), + point2= + involute (base_radius*2,start_angle+(stop_angle - start_angle)*(i)/res)) + { + assign ( + side1_point1 = rotate_2dvector (centre_angle, point1), + side1_point2 = rotate_2dvector (centre_angle, point2), + side2_point1 = mirror_2dvector (rotate_2dvector (centre_angle, point1)), + side2_point2 = mirror_2dvector (rotate_2dvector (centre_angle, point2))) + { + polyhedron ( + points=[ + [back_cone_radius*2+0.1,0,cone_distance*2], + [side1_point1[0],side1_point1[1],0], + [side1_point2[0],side1_point2[1],0], + [side2_point2[0],side2_point2[1],0], + [side2_point1[0],side2_point1[1],0], + [0.1,0,0]], + triangles=[[0,2,1],[0,3,2],[0,4,3],[0,1,5],[1,2,5],[2,3,5],[3,4,5],[0,5,4]]); + } + } + } + } } -module gear(number_of_teeth = 15, - circular_pitch = false, - diametral_pitch = false, - pressure_angle = 28, - clearance = 0.2, - gear_thickness = 5, - rim_thickness = 8, - rim_width = 5, - hub_thickness = 10, - hub_diameter = 15, - bore_diameter = 5, - circles = 0, - backlash = 0, - twist = 0, - helix_angle = 0, - herringbone = false, - involute_facets = 0, - flat = false, - roundsize = 1, - internal = false) + + +module gear ( + number_of_teeth=15, + circular_pitch=false, diametral_pitch=false, + pressure_angle=28, + clearance = 0.2, + gear_thickness=5, + rim_thickness=8, + rim_width=5, + hub_thickness=10, + hub_diameter=15, + bore_diameter=5, + circles=0, + backlash=0, + twist=0, + helix_angle=0, + herringbone=false, + involute_facets=0, + flat=false, + roundsize=1, + internal = false) { - if (circular_pitch == false && diametral_pitch == false) - echo("MCAD ERROR: gear module needs either a diametral_pitch or " - "circular_pitch"); - - // Convert diametrial pitch to our native circular pitch - circular_pitch = - (circular_pitch != false ? circular_pitch : 180 / diametral_pitch); - - // Pitch diameter: Diameter of pitch circle. - pitch_diameter = number_of_teeth * circular_pitch / 180; - pitch_radius = pitch_diameter / 2; - pitch_circumference = PI * pitch_diameter; - echo("Teeth:", number_of_teeth, " Pitch radius:", pitch_radius); - - twist = - ((twist != 0) - ? twist - : (tan(helix_angle) * rim_thickness / pitch_circumference * 360)); - echo("Twist: ", twist); - - // Base Circle - base_radius = pitch_radius * cos(pressure_angle); - - // Diametrial pitch: Number of teeth per unit length. - pitch_diametrial = number_of_teeth / pitch_diameter; - - // Addendum: Radial distance from pitch circle to outside circle. - addendum = 1 / pitch_diametrial + (internal ? clearance : 0); - - // Outer Circle - outer_radius = pitch_radius + addendum; - - // Dedendum: Radial distance from pitch circle to root diameter - dedendum = addendum + (internal ? -clearance : clearance); - - // Root diameter: Diameter of bottom of tooth spaces. - root_radius = pitch_radius - dedendum; - backlash_angle = - (internal ? -backlash : backlash) / pitch_radius * 180 / pi; - half_thick_angle = (360 / number_of_teeth - backlash_angle) / 4; - - // Variables controlling the rim. - rim_radius = internal ? outer_radius + rim_width : root_radius - rim_width; - - // Variables controlling the circular holes in the gear. - circle_orbit_diameter = hub_diameter / 2 + min(rim_radius, root_radius); - circle_orbit_curcumference = pi * circle_orbit_diameter; - - max_thickness = max(rim_thickness, hub_thickness, gear_thickness); - - // Limit the circle size to 90% of the gear face. - circle_diameter = - min(0.70 * circle_orbit_curcumference / circles, - (min(rim_radius, root_radius) - hub_diameter / 2) * 0.9); - - module flat_gear() - { - module _gear_shape() - { - gear_shape(number_of_teeth, - pitch_radius = pitch_radius, - root_radius = root_radius, - base_radius = base_radius, - outer_radius = outer_radius, - half_thick_angle = half_thick_angle, - involute_facets = involute_facets); - } - - module rounding_circles() - { - path_radius = internal ? outer_radius : root_radius; - circle_positions = (internal ? [0:1:number_of_teeth] - : [0.5:1:number_of_teeth - 0.5]); - - if (roundsize > 0) - for (i = circle_positions) { - rotate([ 0, 0, (i * 360 / number_of_teeth) ]) - translate([ path_radius, 0 ]) circle( - r = ((360 / number_of_teeth - half_thick_angle) / - 360) * - pi * root_radius / 2 * roundsize, - $fa = 18, - $fs = 0.5); + if (circular_pitch==false && diametral_pitch==false) + echo("MCAD ERROR: gear module needs either a diametral_pitch or circular_pitch"); + + //Convert diametrial pitch to our native circular pitch + circular_pitch = (circular_pitch!=false?circular_pitch:180/diametral_pitch); + + // Pitch diameter: Diameter of pitch circle. + pitch_diameter = number_of_teeth * circular_pitch / 180; + pitch_radius = pitch_diameter/2; + pitch_circumference = PI * pitch_diameter; + echo ("Teeth:", number_of_teeth, " Pitch radius:", pitch_radius); + + twist = ( + (twist != 0) ? twist : + (tan (helix_angle) * rim_thickness / + pitch_circumference * 360) + ); + echo ("Twist: ", twist); + + // Base Circle + base_radius = pitch_radius*cos(pressure_angle); + + // Diametrial pitch: Number of teeth per unit length. + pitch_diametrial = number_of_teeth / pitch_diameter; + + // Addendum: Radial distance from pitch circle to outside circle. + addendum = 1/pitch_diametrial + (internal ? clearance : 0); + + //Outer Circle + outer_radius = pitch_radius+addendum; + + // Dedendum: Radial distance from pitch circle to root diameter + dedendum = addendum + (internal ? -clearance : clearance); + + // Root diameter: Diameter of bottom of tooth spaces. + root_radius = pitch_radius-dedendum; + backlash_angle = (internal ? -backlash : backlash) / pitch_radius * 180 / pi; + half_thick_angle = (360 / number_of_teeth - backlash_angle) / 4; + + // Variables controlling the rim. + rim_radius = internal ? outer_radius + rim_width : root_radius - rim_width; + + // Variables controlling the circular holes in the gear. + circle_orbit_diameter=hub_diameter/2+min(rim_radius, root_radius); + circle_orbit_curcumference=pi*circle_orbit_diameter; + + max_thickness = max (rim_thickness, hub_thickness, gear_thickness); + + // Limit the circle size to 90% of the gear face. + circle_diameter= + min ( + 0.70*circle_orbit_curcumference/circles, + (min(rim_radius, root_radius)-hub_diameter/2)*0.9); + + module flat_gear () + { + module _gear_shape () + { + gear_shape ( + number_of_teeth, + pitch_radius = pitch_radius, + root_radius = root_radius, + base_radius = base_radius, + outer_radius = outer_radius, + half_thick_angle = half_thick_angle, + involute_facets=involute_facets); + } + + module rounding_circles () + { + path_radius = internal ? outer_radius : root_radius; + circle_positions = (internal ? + [0:1:number_of_teeth] : + [0.5:1:number_of_teeth - 0.5]); + + if (roundsize > 0) + for (i=circle_positions) { + rotate([0, 0, (i*360/number_of_teeth)]) + translate([path_radius, 0]) + circle(r=((360/number_of_teeth - half_thick_angle)/360) * pi*root_radius/2 * roundsize, $fa = 18, $fs = 0.5); + } + } + + if (internal) + union () { + _gear_shape (); + rounding_circles (); + } else + difference() { + _gear_shape (); + rounding_circles (); } - } - - if (internal) - union() - { - _gear_shape(); - rounding_circles(); - } - else - difference() - { - _gear_shape(); - rounding_circles(); - } - } - - // render the extruded gear shape (or cutout for internal gear) - module extruded_gear() - { - lower_rim_thickness = - (rim_thickness / 2 + ((internal && gear_thickness == 0) ? 0.1 : 0)); - lower_twist = twist / rim_thickness * lower_rim_thickness; - - upper_rim_thickness = (rim_thickness / 2 + ((internal) ? 0.1 : 0)); - upper_twist = twist / rim_thickness * upper_rim_thickness; - - if (flat) { - flat_gear(); - - } else if (herringbone) { - translate([ 0, 0, rim_thickness / 2 ]) - { - linear_extrude(height = upper_rim_thickness, - convexity = 10, - twist = upper_twist) flat_gear(); - - mirror([ 0, 0, 1 ]) linear_extrude(height = lower_rim_thickness, - convexity = 10, - twist = lower_twist) - flat_gear(); - } - - } else { - linear_extrude(height = rim_thickness + (internal ? 0.2 : 0), - convexity = 10, - twist = twist) flat_gear(); - } - } - - module ensure_rim() - { - if (flat) { - children(); - - } else if (internal) { - difference() - { - linear_extrude(height = rim_thickness) circle(r = rim_radius); - - translate([ 0, 0, gear_thickness ]) children(); - } - - } else if (gear_thickness > rim_thickness) { - union() - { - children(); - - linear_extrude_flat_option(flat = flat, height = gear_thickness) - circle(r = rim_radius); - } - } else { - difference() - { - children(); - - translate([ 0, 0, gear_thickness ]) linear_extrude_flat_option( - flat = flat, - height = (rim_thickness - gear_thickness + 0.1)) - circle(r = rim_radius); - } - } - } - - module hub() - { - if (internal) - cylinder(d = hub_diameter, h = hub_thickness); - - else if (!flat) - translate([ 0, 0, gear_thickness ]) - cylinder(d = hub_diameter, h = hub_thickness - gear_thickness); - } - - module _circles() - { - if (circles > 1) - for (i = [0:circles - 1]) - rotate([ 0, 0, i * 360 / circles ]) - translate([ circle_orbit_diameter / 2, 0, 0 ]) - circle(r = circle_diameter / 2); - } - - module bore() { circle(d = bore_diameter); } - - difference() - { - union() - { - ensure_rim() extruded_gear(); - - hub(); - } - - linear_extrude_flat_option(flat = flat, - center = true, - height = (max_thickness + 0.1) * 2) union() - { - _circles(); - bore(); - } - } + } + + // render the extruded gear shape (or cutout for internal gear) + module extruded_gear () + { + lower_rim_thickness = ( + rim_thickness / 2 + + ((internal && gear_thickness == 0) ? 0.1 : 0) + ); + lower_twist = twist / rim_thickness * lower_rim_thickness; + + upper_rim_thickness = ( + rim_thickness / 2 + + ((internal) ? 0.1 : 0) + ); + upper_twist = twist / rim_thickness * upper_rim_thickness; + + if (flat) { + flat_gear (); + + } else if (herringbone) { + translate ([0, 0, rim_thickness / 2]) { + linear_extrude ( + height = upper_rim_thickness, + convexity = 10, + twist = upper_twist + ) + flat_gear (); + + mirror ([0, 0, 1]) + linear_extrude ( + height = lower_rim_thickness, + convexity = 10, + twist = lower_twist + ) + flat_gear (); + } + + } else { + linear_extrude( + height = rim_thickness + (internal ? 0.2 : 0), + convexity = 10, + twist = twist + ) + flat_gear (); + } + } + + module ensure_rim () + { + if (flat) { + children (); + + } else if (internal) { + difference () { + linear_extrude (height = rim_thickness) + circle (r = rim_radius); + + translate ([0, 0, gear_thickness]) + children (); + } + + } else if (gear_thickness > rim_thickness) { + union () { + children (); + + linear_extrude_flat_option ( + flat = flat, + height = gear_thickness + ) + circle (r = rim_radius); + } + } else { + difference () { + children (); + + translate ([0, 0, gear_thickness]) + linear_extrude_flat_option ( + flat = flat, + height = (rim_thickness - gear_thickness + + 0.1) + ) + circle (r = rim_radius); + } + } + } + + module hub () + { + if (internal) + cylinder (d=hub_diameter, h=hub_thickness); + + else if (!flat) + translate ([0, 0, gear_thickness]) + cylinder (d=hub_diameter, h=hub_thickness - gear_thickness); + } + + module _circles () + { + if (circles > 1) + for (i=[0:circles-1]) + rotate ([0, 0, i*360/circles]) + translate ([circle_orbit_diameter / 2, 0, 0]) + circle (r=circle_diameter / 2); + } + + module bore () + { + circle (d = bore_diameter); + } + + difference () { + union () { + ensure_rim () + extruded_gear (); + + hub (); + } + + linear_extrude_flat_option ( + flat = flat, + center = true, + height = (max_thickness + 0.1) * 2 + ) + union () { + _circles (); + bore (); + } + } } -module linear_extrude_flat_option(flat = false, - height = 10, - center = false, - convexity = 2, - twist = 0) +module linear_extrude_flat_option(flat =false, height = 10, center = false, convexity = 2, twist = 0) { - if (flat == false) { - linear_extrude(height = height, - center = center, - convexity = convexity, - twist = twist) children(); - } else { - children(); - } + if(flat==false) + { + linear_extrude(height = height, center = center, convexity = convexity, twist= twist) + children (); + } + else + { + children (); + } + } -module gear_shape(number_of_teeth, - pitch_radius, - root_radius, - base_radius, - outer_radius, - half_thick_angle, - involute_facets) + +module gear_shape ( + number_of_teeth, + pitch_radius, + root_radius, + base_radius, + outer_radius, + half_thick_angle, + involute_facets) { - union() - { - rotate(half_thick_angle) - circle($fn = number_of_teeth * 2, r = root_radius); - - for (i = [1:number_of_teeth]) { - - rotate([ 0, 0, i * 360 / number_of_teeth ]) - { - involute_gear_tooth(pitch_radius = pitch_radius, - root_radius = root_radius, - base_radius = base_radius, - outer_radius = outer_radius, - half_thick_angle = half_thick_angle, - involute_facets = involute_facets); - } - } - } + + union() + { + rotate (half_thick_angle) circle ($fn=number_of_teeth*2, r=root_radius); + + for (i = [1:number_of_teeth]) + { + + rotate ([0,0,i*360/number_of_teeth]) + { + involute_gear_tooth ( + pitch_radius = pitch_radius, + root_radius = root_radius, + base_radius = base_radius, + outer_radius = outer_radius, + half_thick_angle = half_thick_angle, + involute_facets=involute_facets); + } + } + } } -module involute_gear_tooth(pitch_radius, - root_radius, - base_radius, - outer_radius, - half_thick_angle, - involute_facets) + +module involute_gear_tooth ( + pitch_radius, + root_radius, + base_radius, + outer_radius, + half_thick_angle, + involute_facets) { - min_radius = max(base_radius, root_radius); + min_radius = max (base_radius,root_radius); - pitch_point = involute(base_radius, - involute_intersect_angle(base_radius, pitch_radius)); - pitch_angle = atan2(pitch_point[1], pitch_point[0]); - centre_angle = pitch_angle + half_thick_angle; + pitch_point = involute (base_radius, involute_intersect_angle (base_radius, pitch_radius)); + pitch_angle = atan2 (pitch_point[1], pitch_point[0]); + centre_angle = pitch_angle + half_thick_angle; - start_angle = involute_intersect_angle(base_radius, min_radius); - stop_angle = involute_intersect_angle(base_radius, outer_radius); + start_angle = involute_intersect_angle (base_radius, min_radius); + stop_angle = involute_intersect_angle (base_radius, outer_radius); - res = (involute_facets != 0) ? involute_facets : ($fn == 0) ? 5 : $fn / 4; + res=(involute_facets!=0)?involute_facets:($fn==0)?5:$fn/4; - function reverse(v) = [for (i = [1:len(v)]) v[len(v) - i]]; + function reverse (v) = [ + for (i = [1:len (v)]) + v[len (v) - i] + ]; - side1_points = [for (i = [0:res]) rotate_2dvector( - centre_angle, - involute(base_radius, - start_angle + (stop_angle - start_angle) * i / res))]; + side1_points = [ + for (i = [0:res]) + rotate_2dvector (centre_angle, involute (base_radius, start_angle + (stop_angle - start_angle) * i / res)) + ]; - side2_points = [for (i = reverse(side1_points)) mirror_2dvector(i)]; + side2_points = [ + for (i = reverse (side1_points)) + mirror_2dvector (i) + ]; - polygon(points = concat([[ 0, 0 ]], side1_points, side2_points)); + polygon (points = concat ([[0, 0]], side1_points, side2_points)); } // Mathematical Functions //=============== -// Finds the angle of the involute about the base radius at the given distance -// (radius) from it's center. -// source: -// http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html +// Finds the angle of the involute about the base radius at the given distance (radius) from it's center. +//source: http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html -function involute_intersect_angle(base_radius, radius) = - sqrt(pow(radius / base_radius, 2) - 1) * 180 / pi; +function involute_intersect_angle (base_radius, radius) = sqrt (pow (radius/base_radius, 2) - 1) * 180 / pi; // Calculate the involute position for a given base radius and involute angle. -function rotated_involute(rotate, base_radius, involute_angle) = [ - cos(rotate) * involute(base_radius, involute_angle)[0] + - sin(rotate) * involute(base_radius, involute_angle)[1], - cos(rotate) * involute(base_radius, involute_angle)[1] - - sin(rotate) * involute(base_radius, involute_angle)[0] +function rotated_involute (rotate, base_radius, involute_angle) = +[ + cos (rotate) * involute (base_radius, involute_angle)[0] + sin (rotate) * involute (base_radius, involute_angle)[1], + cos (rotate) * involute (base_radius, involute_angle)[1] - sin (rotate) * involute (base_radius, involute_angle)[0] ]; -function involute(base_radius, involute_angle) = [ - base_radius * - (cos(involute_angle) + involute_angle * pi / 180 * sin(involute_angle)), - base_radius*(sin(involute_angle) - - involute_angle * pi / 180 * cos(involute_angle)) +function involute (base_radius, involute_angle) = +[ + base_radius*(cos (involute_angle) + involute_angle*pi/180*sin (involute_angle)), + base_radius*(sin (involute_angle) - involute_angle*pi/180*cos (involute_angle)) ]; // For ease of conversion from proper circular pitch to this broken library's // values -function convertcp(circular_pitch) = circular_pitch / PI * 180; -function circumference2radius(circumference) = circumference / (2 * PI); -function gear_spacing(cp, nt1, nt2) = circumference2radius(cp * nt1) + - circumference2radius(cp * nt2); +function convertcp (circular_pitch) = circular_pitch / PI * 180; +function circumference2radius (circumference) = circumference / (2 * PI); +function gear_spacing (cp, nt1, nt2) = circumference2radius (cp * nt1) + + circumference2radius (cp * nt2); + // Test Cases //=============== -module -test_gears() +module test_gears() { - translate([ 17, -15 ]) - { -#gear(number_of_teeth = 17, - circular_pitch=500, + translate([17,-15]) + { + #gear (number_of_teeth=17, + circular_pitch=500, circles=8); - rotate([ 0, 0, 360 * 4 / 17 ]) translate([ 39.088888, 0, 0 ]) - { -#gear(number_of_teeth = 11, - circular_pitch=500, + rotate ([0,0,360*4/17]) + translate ([39.088888,0,0]) + { + #gear (number_of_teeth=11, + circular_pitch=500, hub_diameter=0, rim_width=65); - translate([ 0, 0, 8 ]) - { - gear(number_of_teeth = 6, - circular_pitch = 300, - hub_diameter = 0, - rim_width = 5, - rim_thickness = 6, - pressure_angle = 31); -#rotate([ 0, 0, 360 * 5 / 6 ]) - translate([ 22.5, 0, 1 ]) gear(number_of_teeth = 21, - circular_pitch = 300, - bore_diameter = 2, - hub_diameter = 4, - rim_width = 1, - hub_thickness = 4, - rim_thickness = 4, - gear_thickness = 3, - pressure_angle = 31); - } - } - - translate([ -61.1111111, 0, 0 ]) - { -#gear(number_of_teeth = 27, - circular_pitch=500, + translate ([0,0,8]) + { + gear (number_of_teeth=6, + circular_pitch=300, + hub_diameter=0, + rim_width=5, + rim_thickness=6, + pressure_angle=31); + #rotate ([0,0,360*5/6]) + translate ([22.5,0,1]) + gear (number_of_teeth=21, + circular_pitch=300, + bore_diameter=2, + hub_diameter=4, + rim_width=1, + hub_thickness=4, + rim_thickness=4, + gear_thickness=3, + pressure_angle=31); + } + } + + translate ([-61.1111111,0,0]) + { + #gear (number_of_teeth=27, + circular_pitch=500, circles=5, hub_diameter=2*8.88888889); - translate([ 0, 0, 10 ]) - { - gear(number_of_teeth = 14, - circular_pitch = 200, - pressure_angle = 5, - clearance = 0.2, - gear_thickness = 10, - rim_thickness = 10, - rim_width = 15, - bore_diameter = 5, - circles = 0); - translate ([13.8888888,0,1]) -#gear( + translate ([0,0,10]) + { + gear ( + number_of_teeth=14, + circular_pitch=200, + pressure_angle=5, + clearance = 0.2, + gear_thickness = 10, + rim_thickness = 10, + rim_width = 15, + bore_diameter=5, + circles=0); + translate ([13.8888888,0,1]) + #gear ( number_of_teeth=11, circular_pitch=200, pressure_angle=5, @@ -734,12 +744,12 @@ test_gears() hub_diameter=2*7.222222, bore_diameter=5, circles=0); - } - } + } + } - rotate ([0,0,360*-5/17]) + rotate ([0,0,360*-5/17]) translate ([44.444444444,0,0]) -#gear(number_of_teeth = 15, + #gear (number_of_teeth=15, circular_pitch=500, hub_diameter=10, rim_width=5, @@ -748,109 +758,117 @@ test_gears() hub_thickness=6, circles=9); - rotate ([0,0,360*-1/17]) + rotate ([0,0,360*-1/17]) translate ([30.5555555,0,-1]) -#gear(number_of_teeth = 5, + #gear (number_of_teeth=5, circular_pitch=500, hub_diameter=0, rim_width=5, rim_thickness=10); - } + } } -module -meshing_double_helix() +module meshing_double_helix () { - test_double_helix_gear(); + test_double_helix_gear (); - mirror([ 0, 1, 0 ]) translate([ 58.33333333, 0, 0 ]) - test_double_helix_gear(teeth = 13, circles = 6); + mirror ([0,1,0]) + translate ([58.33333333,0,0]) + test_double_helix_gear (teeth=13,circles=6); } -module test_double_helix_gear(teeth = 17, circles = 8) +module test_double_helix_gear ( + teeth=17, + circles=8) { - // double helical gear - { - twist = 200; - height = 20; - pressure_angle = 30; - - gear(number_of_teeth = teeth, - circular_pitch = 700, - pressure_angle = pressure_angle, - clearance = 0.2, - gear_thickness = height / 2 * 0.5, - rim_thickness = height / 2, - rim_width = 5, - hub_thickness = height / 2 * 1.2, - hub_diameter = 15, - bore_diameter = 5, - circles = circles, - helix_angle = 45, - herringbone = true); - *mirror([ 0, 0, 1 ]) gear(number_of_teeth = teeth, - circular_pitch = 700, - pressure_angle = pressure_angle, - clearance = 0.2, - gear_thickness = height / 2, - rim_thickness = height / 2, - rim_width = 5, - hub_thickness = height / 2, - hub_diameter = 15, - bore_diameter = 5, - circles = circles, - twist = twist / teeth); - } + //double helical gear + { + twist=200; + height=20; + pressure_angle=30; + + gear (number_of_teeth=teeth, + circular_pitch=700, + pressure_angle=pressure_angle, + clearance = 0.2, + gear_thickness = height/2*0.5, + rim_thickness = height/2, + rim_width = 5, + hub_thickness = height/2*1.2, + hub_diameter=15, + bore_diameter=5, + circles=circles, + helix_angle=45, + herringbone=true); + *mirror([0,0,1]) + gear (number_of_teeth=teeth, + circular_pitch=700, + pressure_angle=pressure_angle, + clearance = 0.2, + gear_thickness = height/2, + rim_thickness = height/2, + rim_width = 5, + hub_thickness = height/2, + hub_diameter=15, + bore_diameter=5, + circles=circles, + twist=twist/teeth); + } } -module -test_backlash() +module test_backlash () { - backlash = 2; - teeth = 15; - - translate([ -29.166666, 0, 0 ]) - { - translate([ 58.3333333, 0, 0 ]) rotate([ 0, 0, -360 / teeth / 4 ]) - gear(number_of_teeth = teeth, - circular_pitch = 700, - gear_thickness = 12, - rim_thickness = 15, - rim_width = 5, - hub_thickness = 17, - hub_diameter = 15, - bore_diameter = 5, - backlash = 2, - circles = 8); - - rotate([ 0, 0, 360 / teeth / 4 ]) gear(number_of_teeth = teeth, - circular_pitch = 700, - gear_thickness = 12, - rim_thickness = 15, - rim_width = 5, - hub_thickness = 17, - hub_diameter = 15, - bore_diameter = 5, - backlash = 2, - , circles = 8); - } - - color([ 0, 0, 128, 0.5 ]) translate([ 0, 0, -5 ]) - cylinder($fn = 20, r = backlash / 4, h = 25); + backlash = 2; + teeth = 15; + + translate ([-29.166666,0,0]) + { + translate ([58.3333333,0,0]) + rotate ([0,0,-360/teeth/4]) + gear ( + number_of_teeth = teeth, + circular_pitch=700, + gear_thickness = 12, + rim_thickness = 15, + rim_width = 5, + hub_thickness = 17, + hub_diameter=15, + bore_diameter=5, + backlash = 2, + circles=8); + + rotate ([0,0,360/teeth/4]) + gear ( + number_of_teeth = teeth, + circular_pitch=700, + gear_thickness = 12, + rim_thickness = 15, + rim_width = 5, + hub_thickness = 17, + hub_diameter=15, + bore_diameter=5, + backlash = 2, + circles=8); + } + + color([0,0,128,0.5]) + translate([0,0,-5]) + cylinder ($fn=20,r=backlash / 4,h=25); } -module -test_internal_gear() +module test_internal_gear () { - gear(number_of_teeth = 30, - circular_pitch = 5 * 180 / PI, - hub_thickness = 0, - rim_thickness = 10, - rim_width = 5, - gear_thickness = 0, - internal = true, - helix_angle = 45, - herringbone = true); + gear ( + number_of_teeth = 30, + circular_pitch = 5 * 180 / PI, + hub_thickness = 0, + rim_thickness = 10, + rim_width = 5, + gear_thickness = 0, + internal = true, + helix_angle = 45, + herringbone = true + ); } -*test_internal_gear(); +*test_internal_gear (); diff --git a/gears/rack_and_pinion.scad b/gears/rack_and_pinion.scad index 04cc19d1..8ed01a64 100644 --- a/gears/rack_and_pinion.scad +++ b/gears/rack_and_pinion.scad @@ -1,4 +1,3 @@ - // Rack and pinion gears GPL (c) SASA October 2013. // // Very simple rack and pinion gear based on GPL code. @@ -15,12 +14,12 @@ // Modular Rack by Mark "Ckaos" Moissette GNU GPL license. (Rack based on the // work of MattMoses and Fdavies // http://forums.reprap.org/read.php?1,51452,52099#msg-52099 and Forrest Higgs: -// +// // The originals have many fine additions such as helical gears which I've // dropped in favour of simplicity (as befits my needs) - it wouldn't be a big // jobs to nobble my changes backwards or their features forwards. -$fn = 50; +$fn=50; // examples of usage // include this in your code: @@ -31,257 +30,171 @@ $fn = 50; // a simple pinion and translation / rotation to make it mesh the rack // translate([0,-8.5,0])rotate([0,0,360/10/2]) pinion(4,10,10,5); -include; - -module rack(cp, N, width, thickness) -{ - // cp = circular pitch - for rack = pitch in mm/per tooth - // N = number of teeth - // width = width of rack - // thickness = thickness of support under teeth (0 for no support) - - a = 1.0 * cp / const_pi; // addendum (also known as "module") - d = 1.1 * cp / const_pi; // dedendum (this is set by a standard) - height = (d + a); - - // find the tangent of pressure angle once - tanPA = tan(20); - // length of bottom and top horizontal segments of tooth profile - botL = (cp / 2 - 2 * d * tanPA); - topL = (cp / 2 - 2 * a * tanPA); - - slantLng = tanPA * height; - realBase = 2 * slantLng + topL; - - offset = topL + botL + 2 * slantLng; - length = (realBase + botL) * N; - - supportSize = width; - translate([ botL / 2, 0, 0 ]) rotate([ 90, 0, 0 ]) - { - translate([ 0, supportSize / 2, 0 ]) - { - union() - { - cube(size = [ length, width, thickness ], center = true); - for (i = [0:N - 1]) { - translate([ - i * offset - length / 2 + realBase / 2, - 0, - thickness / 2 - ]) - { - trapezoid([ topL, supportSize ], - [ realBase, supportSize ], - height); - } - } - } - } - } -} - -module pinion(cp, N, width, shaft_diameter, backlash = 0) -{ - // cp= circular pitch - for pinion pitch in mm/per as measured along the - // ptich radius (~1/2 way up tooth) N= number of teeth width= width of the - // gear shaft_diameter= diameter of hole for shaft backlash - I think this - // is just a bodge for making things fit when printed but I never tested it - - if (cp == false && diametral_pitch == false) - echo("MCAD ERROR: pinion module needs either a diametral_pitch or cp"); - - // Convert diametrial pitch to our native circular pitch - cp = (cp != false ? cp : 180 / diametral_pitch); - - // Pitch diameter: Diameter of pitch circle. - pitch_diameter = N * cp / const_pi; - pitch_radius = pitch_diameter / 2; - echo("Teeth:", N, " Pitch radius:", pitch_radius); - // Base Circle - base_radius = pitch_radius * cos(20); - - // Addendum: Radial distance from pitch circle to outside circle. - addendum = cp / const_pi; - - // Outer Circle - outer_radius = pitch_radius + addendum; - - // Dedendum: Radial distance from pitch circle to root diameter - dedendum = addendum * 1.1; - - // Root diameter: Diameter of bottom of tooth spaces. - root_radius = pitch_radius - dedendum; - - backlash_angle = backlash / pitch_radius * 180 / const_pi; - half_thick_angle = (360 / N - backlash_angle) / 4; - - difference() - { - linear_extrude(height = width, convexity = 10, twist = 0) - pinion_shape(N, - pitch_radius = pitch_radius, - root_radius = root_radius, - base_radius = base_radius, - outer_radius = outer_radius, - half_thick_angle = half_thick_angle, - involute_facets = 0); - - translate([ 0, 0, -1 ]) cylinder(r = shaft_diameter / 2, h = 2 + width); - } - - echo("Root radius =", - root_radius, - "\nPitch radius=", - pitch_radius, - "\n Tip radius=", - outer_radius, - "\n"); -} - -module pinion_shape(N, - pitch_radius, - root_radius, - base_radius, - outer_radius, - half_thick_angle, - involute_facets) -{ - union() - { - rotate(half_thick_angle) circle($fn = N * 2, r = root_radius); - for (i = [1:N]) { - rotate([ 0, 0, i * 360 / N ]) - { - involute_pinion_tooth(pitch_radius = pitch_radius, - root_radius = root_radius, - base_radius = base_radius, - outer_radius = outer_radius, - half_thick_angle = half_thick_angle, - involute_facets = involute_facets); - } - } - } -} - -module involute_pinion_tooth(pitch_radius, - root_radius, - base_radius, - outer_radius, - half_thick_angle, - involute_facets) -{ - min_radius = max(base_radius, root_radius); - - pitch_point = involute(base_radius, - involute_intersect_angle(base_radius, pitch_radius)); - pitch_angle = atan2(pitch_point[1], pitch_point[0]); - centre_angle = pitch_angle + half_thick_angle; - - start_angle = involute_intersect_angle(base_radius, min_radius); - stop_angle = involute_intersect_angle(base_radius, outer_radius); - - res = (involute_facets != 0) ? involute_facets : ($fn == 0) ? 5 : $fn / 4; - - union() - { - for (i = [1:res]) - assign(point1 = involute(base_radius, - start_angle + (stop_angle - start_angle) * - (i - 1) / res), - point2 = involute(base_radius, - start_angle + - (stop_angle - start_angle) * i / res)) - { - assign(side1_point1 = rotate_point(centre_angle, point1), - side1_point2 = rotate_point(centre_angle, point2), - side2_point1 = - mirror_point(rotate_point(centre_angle, point1)), - side2_point2 = - mirror_point(rotate_point(centre_angle, point2))) - { - polygon(points = - [ - [ 0, 0 ], - side1_point1, - side1_point2, - side2_point2, - side2_point1 - ], - paths = [[ 0, 1, 2, 3, 4, 0 ]]); - } - } - } -} +include ; + + + +module rack(cp, N, width, thickness){ +// cp = circular pitch - for rack = pitch in mm/per tooth +// N = number of teeth +// width = width of rack +// thickness = thickness of support under teeth (0 for no support) + + a = 1.0*cp/const_pi; // addendum (also known as "module") + d = 1.1*cp/const_pi; // dedendum (this is set by a standard) + height=(d+a); + + // find the tangent of pressure angle once + tanPA = tan(20); + // length of bottom and top horizontal segments of tooth profile + botL = (cp/2 - 2*d*tanPA); + topL = (cp/2 - 2*a*tanPA); + + slantLng=tanPA*height; + realBase=2*slantLng+topL; + + offset=topL+botL+2*slantLng; + length=(realBase+botL)*N; + + supportSize=width; + translate([botL/2,0,0]) + rotate([90,0,0]){ + translate([0,supportSize/2,0]){ + union(){ + cube(size=[length,width,thickness],center=true); + for (i = [0:N-1]){ + translate([i*offset-length/2+realBase/2,0,thickness/2]){ + trapezoid([topL,supportSize],[realBase,supportSize],height); + } + } + } + } + } + } + +module pinion (cp, N, width, shaft_diameter, backlash=0){ +// cp= circular pitch - for pinion pitch in mm/per as measured along the ptich radius (~1/2 way up tooth) +// N= number of teeth +// width= width of the gear +// shaft_diameter= diameter of hole for shaft +// backlash - I think this is just a bodge for making things fit when printed but I never tested it + + if (cp==false && diametral_pitch==false) + echo("MCAD ERROR: pinion module needs either a diametral_pitch or cp"); + + //Convert diametrial pitch to our native circular pitch + cp = (cp!=false?cp:180/diametral_pitch); + + // Pitch diameter: Diameter of pitch circle. + pitch_diameter = N * cp / const_pi; + pitch_radius = pitch_diameter/2; + echo ("Teeth:", N, " Pitch radius:", pitch_radius); + // Base Circle + base_radius = pitch_radius*cos(20); + + // Addendum: Radial distance from pitch circle to outside circle. + addendum = cp/const_pi; + + //Outer Circle + outer_radius = pitch_radius+addendum; + + // Dedendum: Radial distance from pitch circle to root diameter + dedendum = addendum*1.1; + + // Root diameter: Diameter of bottom of tooth spaces. + root_radius = pitch_radius-dedendum; + + backlash_angle = backlash / pitch_radius * 180 / const_pi; + half_thick_angle = (360 / N - backlash_angle) / 4; + + difference(){ + linear_extrude (height=width, convexity=10, twist=0) + pinion_shape(N, pitch_radius = pitch_radius, root_radius = root_radius, + base_radius = base_radius, outer_radius = outer_radius, + half_thick_angle = half_thick_angle, involute_facets=0); + + translate([0,0,-1]) cylinder(r=shaft_diameter/2,h=2+width); + } + + echo("Root radius =",root_radius,"\nPitch radius=",pitch_radius,"\n Tip radius=",outer_radius,"\n"); + } + +module pinion_shape ( N, pitch_radius, root_radius, base_radius, outer_radius, half_thick_angle, involute_facets) { + union(){ + rotate (half_thick_angle) circle ($fn=N*2, r=root_radius); + for (i = [1:N]) { + rotate ([0,0,i*360/N]) { + involute_pinion_tooth ( + pitch_radius = pitch_radius, + root_radius = root_radius, + base_radius = base_radius, + outer_radius = outer_radius, + half_thick_angle = half_thick_angle, + involute_facets=involute_facets); + } + } + } + } + +module involute_pinion_tooth ( pitch_radius, root_radius, base_radius, outer_radius, half_thick_angle, involute_facets) { + min_radius = max (base_radius,root_radius); + + pitch_point = involute (base_radius, involute_intersect_angle (base_radius, pitch_radius)); + pitch_angle = atan2 (pitch_point[1], pitch_point[0]); + centre_angle = pitch_angle + half_thick_angle; + + start_angle = involute_intersect_angle (base_radius, min_radius); + stop_angle = involute_intersect_angle (base_radius, outer_radius); + + res=(involute_facets!=0)?involute_facets:($fn==0)?5:$fn/4; + + union () { + for (i=[1:res]) + assign ( point1=involute (base_radius,start_angle+(stop_angle - start_angle)*(i-1)/res), point2=involute (base_radius,start_angle+(stop_angle - start_angle)*i/res)) { + assign ( + side1_point1=rotate_point (centre_angle, point1), + side1_point2=rotate_point (centre_angle, point2), + side2_point1=mirror_point (rotate_point (centre_angle, point1)), + side2_point2=mirror_point (rotate_point (centre_angle, point2))) { + polygon ( points=[[0,0],side1_point1,side1_point2,side2_point2,side2_point1], paths=[[0,1,2,3,4,0]]); + } + } + } + } // Mathematical Functions //=============== -// Finds the angle of the involute about the base radius at the given distance -// (radius) from it's center. -// source: -// http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html +// Finds the angle of the involute about the base radius at the given distance (radius) from it's center. +//source: http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html -function involute_intersect_angle(base_radius, radius) = - sqrt(pow(radius / base_radius, 2) - 1) * 180 / const_pi; +function involute_intersect_angle (base_radius, radius) = sqrt (pow (radius/base_radius, 2) - 1) * 180 / const_pi; // Calculate the involute position for a given base radius and involute angle. -function rotated_involute(rotate, base_radius, involute_angle) = [ - cos(rotate) * involute(base_radius, involute_angle)[0] + - sin(rotate) * involute(base_radius, involute_angle)[1], - cos(rotate) * involute(base_radius, involute_angle)[1] - - sin(rotate) * involute(base_radius, involute_angle)[0] -]; - -function mirror_point(coord) = [ coord[0], -coord[1] ]; - -function rotate_point(rotate, coord) = [ - cos(rotate) * coord[0] + sin(rotate) * coord[1], - cos(rotate) * coord[1] - sin(rotate) * coord[0] -]; - -function involute(base_radius, involute_angle) = [ - base_radius * (cos(involute_angle) + - involute_angle * const_pi / 180 * sin(involute_angle)), - base_radius*(sin(involute_angle) - - involute_angle * const_pi / 180 * cos(involute_angle)) -]; - -module trapezoid(top, base, height) -{ - // echo ("test",base[0]); - basePT1 = [ -base[0] / 2, base[1] / 2, 0 ]; - basePT2 = [ base[0] / 2, base[1] / 2, 0 ]; - basePT3 = [ base[0] / 2, -base[1] / 2, 0 ]; - basePT4 = [ -base[0] / 2, -base[1] / 2, 0 ]; - topPT1 = [ -top[0] / 2, top[1] / 2, height ]; - topPT2 = [ top[0] / 2, top[1] / 2, height ]; - topPT3 = [ top[0] / 2, -top[1] / 2, height ]; - topPT4 = [ -top[0] / 2, -top[1] / 2, height ]; - polyhedron(points = - [ - basePT1, - basePT2, - basePT3, - basePT4, - topPT1, - topPT2, - topPT3, - topPT4 - ], - faces = [ - [ 0, 1, 2 ], - [ 0, 2, 3 ], - [ 3, 7, 0 ], - [ 7, 4, 0 ], - [ 1, 6, 2 ], - [ 1, 5, 6 ], - [ 2, 6, 3 ], - [ 3, 6, 7 ], - [ 5, 1, 0 ], - [ 4, 5, 0 ], - [ 7, 5, 4 ], - [ 5, 7, 6 ] - ]); -} +function rotated_involute(rotate,base_radius,involute_angle)=[cos(rotate)*involute(base_radius, involute_angle)[0]+sin(rotate)*involute(base_radius, involute_angle)[1],cos(rotate)*involute(base_radius, involute_angle)[1]-sin(rotate)*involute(base_radius, involute_angle)[0]]; + +function mirror_point(coord)=[coord[0],-coord[1]]; + +function rotate_point(rotate,coord)=[cos(rotate)*coord[0]+sin(rotate)*coord[1],cos(rotate)*coord[1]-sin(rotate)*coord[0]]; + +function involute (base_radius, involute_angle)=[base_radius*(cos(involute_angle)+involute_angle*const_pi/180*sin(involute_angle)),base_radius*(sin(involute_angle)-involute_angle*const_pi/180*cos(involute_angle))]; + + + + +module trapezoid(top,base,height){ + //echo ("test",base[0]); + basePT1=[ -base[0]/2, base[1]/2, 0]; + basePT2=[ base[0]/2, base[1]/2, 0]; + basePT3=[ base[0]/2, -base[1]/2, 0]; + basePT4=[ -base[0]/2, -base[1]/2, 0]; + topPT1=[ -top[0]/2, top[1]/2, height]; + topPT2=[ top[0]/2, top[1]/2, height]; + topPT3=[ top[0]/2, -top[1]/2, height]; + topPT4=[ -top[0]/2, -top[1]/2, height]; + polyhedron(points=[ basePT1, basePT2, basePT3, basePT4, topPT1, topPT2, topPT3, topPT4],faces=[[0,1,2], [0,2,3],[3,7,0], [7,4,0],[1,6,2], [1,5,6],[2,6,3], [3,6,7],[5,1,0],[4,5,0],[7,5,4],[5,7,6]]); + } + + + diff --git a/general/constants.scad b/general/constants.scad index a243009d..cb053d2a 100644 --- a/general/constants.scad +++ b/general/constants.scad @@ -1,4 +1,3 @@ - // MIT license // Author: Elmo Mäntynen @@ -6,7 +5,7 @@ const_e = 2.71828182845904523536028747135266249775724709369995; // http://oeis.org/A000796 const_pi = 3.14159265358979323846264338327950288419716939937510; -// +// const_pi_div_180 = 0.01745329251994329576923690768489; // const_180_div_pi = 57.295779513082320876798154814105; diff --git a/general/facets.scad b/general/facets.scad index 7125210f..66d2d260 100644 --- a/general/facets.scad +++ b/general/facets.scad @@ -1,15 +1,14 @@ - /** * Calculate the number of facets to generate for radius `r`. This is intended * to mimic OpenSCAD's internal get_fragments_from_r() function. * * @param r Radius of circle */ -function get_fragments_from_r(r) = - (($fn > 0) ? $fn - : (r < 0.00000095367431640625) - ? 3 - : ceil(max(min(360 / $fa, r * 2 * PI / $fs), 5))); +function get_fragments_from_r (r) = ( + ($fn > 0) ? $fn : + (r < 0.00000095367431640625) ? 3 : + ceil (max (min (360 / $fa, r * 2 * PI / $fs), 5)) +); /** * This is a function that generates a series of values ala $t for use as facet @@ -17,10 +16,19 @@ function get_fragments_from_r(r) = * * @param r Radius of circle */ -function gen_facet_series(r) = [0:1.0 / get_fragments_from_r(r):1.0001]; +function gen_facet_series (r) = [0 : 1.0 / get_fragments_from_r (r) : 1.0001]; // example -translate([ 0, 0, 10 ]) linear_extrude(1) circle(10, $fn = 10); +translate ([0, 0, 10]) +linear_extrude (1) +circle (10, $fn = 10); -linear_extrude(1) polygon([let(r = 10) for (t = gen_facet_series(r, $fn = 10)) - let(angle = t * 360)[cos(angle) * r, sin(angle) * r]]); +linear_extrude (1) +polygon ( + [ + let (r = 10) + for (t = gen_facet_series (r, $fn = 10)) + let (angle = t * 360) + [cos (angle) * r, sin (angle) * r] + ] +); diff --git a/general/math.scad b/general/math.scad index 230a9457..4dea9b0b 100644 --- a/general/math.scad +++ b/general/math.scad @@ -1,13 +1,13 @@ -include // MIT license -function deg(angle) = 360 * angle / const_tau; +include + +function deg(angle) = 360*angle/const_tau; // transformations.scad // License: GNU LGPL 2.1 or later. // © 2010 by Elmo Mäntynen -module local_scale(v, reference = [ 0, 0, 0 ]) -{ +module local_scale(v, reference=[0, 0, 0]) { translate(-reference) scale(v) translate(reference) children(0); } diff --git a/general/sweep.scad b/general/sweep.scad index 6752ff76..e7e3647e 100644 --- a/general/sweep.scad +++ b/general/sweep.scad @@ -1,70 +1,51 @@ +use +use +use -use use - use +function rotation_from_axis(x,y,z) = [[x[0],y[0],z[0]],[x[1],y[1],z[1]],[x[2],y[2],z[2]]]; - function rotation_from_axis(x, y, z) = [[x [0], y [0], z [0]], - [x [1], y [1], z [1]], - [x [2], y [2], z [2]]]; +function rotate_from_to(a,b,_axis=[]) = + len(_axis) == 0 + ? rotate_from_to(a,b,unit(cross(a,b))) + : _axis*_axis >= 0.99 ? rotation_from_axis(unit(b),_axis,cross(_axis,unit(b))) * + transpose_3(rotation_from_axis(unit(a),_axis,cross(_axis,unit(a)))) : identity3(); -function rotate_from_to(a, b, _axis = []) = - len(_axis) == 0 - ? rotate_from_to(a, b, unit(cross(a, b))) - : _axis * _axis >= 0.99 - ? rotation_from_axis(unit(b), _axis, cross(_axis, unit(b))) * - transpose_3(rotation_from_axis(unit(a), - _axis, - cross(_axis, unit(a)))) - : identity3(); +function make_orthogonal(u,v) = unit(u - unit(v) * (unit(v) * u)); -function make_orthogonal(u, v) = unit(u - unit(v) * (unit(v) * u)); +// Prevent creeping nonorthogonality +function coerce(m) = [unit(m[0]), make_orthogonal(m[1],m[0]), make_orthogonal(make_orthogonal(m[2],m[0]),m[1])]; -// Prevent creeping nonorthogonality -function coerce(m) = [ - unit(m[0]), - make_orthogonal(m[1], m[0]), - make_orthogonal(make_orthogonal(m[2], m[0]), m[1]) -]; +function tangent_path(path, i) = +i == 0 ? + unit(path[1] - path[0]) : + (i == len(path)-1 ? + unit(path[i] - path[i-1]) : + unit(path[i+1]-path[i-1])); -function tangent_path(path, i) = i == 0 - ? unit(path[1] - path[0]) - : (i == len(path) - 1 - ? unit(path[i] - path[i - 1]) - : unit(path[i + 1] - path[i - 1])); +function construct_rt(r,t) = [concat(r[0],t[0]),concat(r[1],t[1]),concat(r[2],t[2]),[0,0,0,1]]; -function construct_rt(r, t) = [ - concat(r[0], t[0]), - concat(r[1], t[1]), - concat(r[2], t[2]), - [ 0, 0, 0, 1 ] -]; +function construct_transform_path(path) = + [let (l=len(path)) + for (i=[0:l-1]) + construct_rt(rotate_from_to([0,0,1], tangent_path(path, i)), path[i])]; -function construct_transform_path(path) = [let(l = len(path)) for (i = [0:l - - 1]) - construct_rt(rotate_from_to([ 0, 0, 1 ], tangent_path(path, i)), - path[i])]; - -module sweep(shape, path_transforms, closed = false) -{ +module sweep(shape, path_transforms, closed=false) { pathlen = len(path_transforms); segments = pathlen + (closed ? 0 : -1); shape3d = to_3d(shape); - function sweep_points() = flatten( - [for (i = [0:pathlen - 1]) transform(path_transforms[i], shape3d)]); + function sweep_points() = + flatten([for (i=[0:pathlen-1]) transform(path_transforms[i], shape3d)]); - function loop_faces() = [let( - facets = len(shape3d)) for (s = [0:segments - 1], i = [0:facets - 1]) - [(s % pathlen) * facets + i, - (s % pathlen) * facets + (i + 1) % facets, - ((s + 1) % pathlen) * facets + (i + 1) % facets, - ((s + 1) % pathlen) * facets + i]]; + function loop_faces() = [let (facets=len(shape3d)) + for(s=[0:segments-1], i=[0:facets-1]) + [(s%pathlen) * facets + i, + (s%pathlen) * facets + (i + 1) % facets, + ((s + 1) % pathlen) * facets + (i + 1) % facets, + ((s + 1) % pathlen) * facets + i]]; - bottom_cap = closed ? [] : [[for (i = [len(shape3d) - 1:-1:0]) i]]; - top_cap = closed ? [] - : [[for (i = [0:len(shape3d) - 1]) i + - len(shape3d) * (pathlen - 1)]]; - polyhedron(points = sweep_points(), - faces = concat(loop_faces(), bottom_cap, top_cap), - convexity = 5); + bottom_cap = closed ? [] : [[for (i=[len(shape3d)-1:-1:0]) i]]; + top_cap = closed ? [] : [[for (i=[0:len(shape3d)-1]) i+len(shape3d)*(pathlen-1)]]; + polyhedron(points = sweep_points(), faces = concat(loop_faces(), bottom_cap, top_cap), convexity=5); } diff --git a/general/utilities.scad b/general/utilities.scad index 9e7a6927..897151c7 100644 --- a/general/utilities.scad +++ b/general/utilities.scad @@ -1,76 +1,81 @@ -include /* * Utility functions. * * Originally by Hans Häggström, 2010. - * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or - * later + * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later */ +include + + /******************** Disance Poins ******************************/ -function distance3D(a, b) = sqrt((a[0] - b[0]) * (a[0] - b[0]) + - (a[1] - b[1]) * (a[1] - b[1]) + - (a[2] - b[2]) * (a[2] - b[2])); -// Obsolet -function distance(a, b) = distance3D(a, b); +function distance3D(a,b) =sqrt( (a[0] - b[0])*(a[0] - b[0]) + + (a[1] - b[1])*(a[1] - b[1]) + + (a[2] - b[2])*(a[2] - b[2]) ); +//Obsolet +function distance(a, b) = distance3D(a,b); -function distance2D(a, b) = sqrt((a[0] - b[0]) * (a[0] - b[0]) + - (a[1] - b[1]) * (a[1] - b[1])); +function distance2D(a,b) = sqrt( (a[0] - b[0])*(a[0] - b[0]) + + (a[1] - b[1])*(a[1] - b[1])); + +function distance1D(a,b) = sqrt(a*a+b*b); +//Obsolet +function length2(a) = distance1D(a[0],a[1]); -function distance1D(a, b) = sqrt(a * a + b * b); -// Obsolet -function length2(a) = distance1D(a[0], a[1]); /************************ vector *************************/ -function normalized(a) = a / (max(distance3D([ 0, 0, 0 ], a), 0.00001)); +function normalized(a) = a / (max(distance3D([0,0,0], a), 0.00001)); -function normalized_axis(a) = a == "x" ? [ 1, 0, 0 ] - : a == "y" ? [ 0, 1, 0 ] - : a == "z" ? [ 0, 0, 1 ] - : normalized(a); +function normalized_axis(a) = a == "x" ? [1, 0, 0]: + a == "y" ? [0, 1, 0]: + a == "z" ? [0, 0, 1]: normalized(a); -function angleOfNormalizedVector(n) = - [ 0, -atan2(n[2], distance1D([ n[0], n[1] ])), atan2(n[1], n[0]) ]; +function angleOfNormalizedVector(n) = [0, -atan2(n[2], distance1D([n[0], n[1]])), atan2(n[1], n[0]) ]; function angle(v) = angleOfNormalizedVector(normalized(v)); -function angleBetweenTwoPoints(a, b) = angle(normalized(b - a)); +function angleBetweenTwoPoints(a, b) = angle(normalized(b-a)); -function _angleVectore2D(a) = atan2(a[0], a[1]); -function angle_betweentTwoPoints2D(a, b) = _angleVectore2D(b - a); +function _angleVectore2D(a) = atan2(a[0],a[1]); +function angle_betweentTwoPoints2D (a,b) = _angleVectore2D(b-a); -function mirror_2dvector(coord) = [ coord[0], -coord[1] ]; +function mirror_2dvector (coord) = +[ + coord[0], + -coord[1] +]; -function rotate_2dvector(rotate, coord) = [ - cos(rotate) * coord[0] + sin(rotate) * coord[1], - cos(rotate) * coord[1] - sin(rotate) * coord[0] +function rotate_2dvector (rotate, coord) = +[ + cos (rotate) * coord[0] + sin (rotate) * coord[1], + cos (rotate) * coord[1] - sin (rotate) * coord[0] ]; + + + /********************** Circel ***************************/ function circel_area(r) = const_pi * r * r; -function circel_radius3Points(a, b, c) = (distance2D(a, b) * distance2D(b, c) * - distance2D(c, a)) / - (4 * triangle_area3Points(a, b, c)); +function circel_radius3Points(a,b,c) = (distance2D(a,b) * distance2D(b,c) * distance2D(c,a)) / (4 * triangle_area3Points(a,b,c)); + +function circel_radius3lengths(a,b,c) = (a*b*c) / (4 * triangle_area3lengths(a,b,c)); -function circel_radius3lengths(a, b, c) = (a * b * c) / - (4 * triangle_area3lengths(a, b, c)); /********************** triangle **************************/ -// Satz des Heron -function triangle_area3lengths(a, b, c) = sqrt((a + b + c) * (a + b - c) * - (b + c - a) * (c + a - b)) / - 4; +//Satz des Heron +function triangle_area3lengths(a,b,c) = sqrt((a+b+c)*(a+b-c)*(b+c-a)*(c+a-b))/4; + +function triangle_area3Points(a,b,c) = triangle_area3lengths(distance2D(a,b),distance2D(b,c),distance2D(c,a)); + -function triangle_area3Points(a, b, c) = - triangle_area3lengths(distance2D(a, b), distance2D(b, c), distance2D(c, a)); /************************** coordinate systems translation ****/ //[radius,phi] <=> [x,y] -function conv2D_cartesian2polar(x) = - [ distance1D(x[0], x[1]), atan2(x[1], x[0]) ]; -function conv2D_polar2cartesian(x) = [ x[0] * cos(x[1]), x[0] * sin(x[1]) ]; +function conv2D_cartesian2polar(x) = [ distance1D(x[0],x[1]) , atan2(x[1],x[0]) ]; +function conv2D_polar2cartesian(x) = [ x[0]*cos(x[1]) , x[0]*sin(x[1]) ]; + CENTER = 0; LEFT = -0.5; @@ -78,73 +83,49 @@ RIGHT = 0.5; TOP = 0.5; BOTTOM = -0.5; -FlatCap = 0; -ExtendedCap = 0.5; -CutCap = -0.5; - -module fromTo(from = [ 0, 0, 0 ], - to = [ 1, 0, 0 ], - size = [ 1, 1 ], - align = [ CENTER, CENTER ], - material = [ 0.5, 0.5, 0.5 ], - name = "", - endExtras = [ 0, 0 ], - endCaps = [ FlatCap, FlatCap ], - rotation = [ 0, 0, 0 ], - printString = true) -{ +FlatCap =0; +ExtendedCap =0.5; +CutCap =-0.5; + + +module fromTo(from=[0,0,0], to=[1,0,0], size=[1, 1], align=[CENTER, CENTER], material=[0.5, 0.5, 0.5], name="", endExtras=[0,0], endCaps=[FlatCap, FlatCap], rotation=[0,0,0], printString=true) { - angle = angleBetweenTwoPoints(from, to); - length = distance(from, to) + endCaps[0] * size[0] + endCaps[1] * size[0] + - endExtras[0] + endExtras[1]; - - if (length > 0) { - if (printString) - echo(str(" ", - name, - " ", - size[0], - "mm x ", - size[1], - "mm, length ", - length, - "mm")); - - color(material) translate(from) rotate(angle) translate([ - -endCaps[0] * size[0] - endExtras[0], - size[0] * (-0.5 - align[0]), - size[1] * (-0.5 + align[1]) - ]) rotate(rotation) scale([ length, size[0], size[1] ]) child(); - } + angle = angleBetweenTwoPoints(from, to); + length = distance(from, to) + endCaps[0]*size[0] + endCaps[1]*size[0] + endExtras[0] + endExtras[1]; + + if (length > 0) { + if (printString) echo(str( " " ,name, " ", size[0], "mm x ", size[1], "mm, length ", length, "mm")); + + color(material) + translate(from) + rotate(angle) + translate( [ -endCaps[0]*size[0] - endExtras[0], size[0]*(-0.5-align[0]), size[1]*(-0.5+align[1]) ] ) + rotate(rotation) + scale([length, size[0], size[1]]) child(); + } } -module part(name) -{ - echo(""); - echo(str(name, ":")); +module part(name) { + echo(""); + echo(str(name, ":")); } -module mirror_duplicate(plane = [ 0, 0, 1 ]) union() -{ - child(); +module mirror_duplicate (plane = [0, 0, 1]) +union () { + child (); - mirror(plane) child(); + mirror (plane) + child (); } -module linear_extrude_if(condition, - height, - center = undef, - convexity = undef, - twist = undef, - slices = undef) +module linear_extrude_if (condition, height, center = undef, convexity = undef, + twist = undef, slices = undef) { - if (condition) - linear_extrude(height = height, - center = center, - convexity = convexity, - twist = twist, - slices = slices) children(); - - else - children(); + if (condition) + linear_extrude (height = height, center = center, convexity = convexity, + twist = twist, slices = slices) + children (); + + else + children (); } diff --git a/gridbeam.scad b/gridbeam.scad index 75800506..66366fb4 100644 --- a/gridbeam.scad +++ b/gridbeam.scad @@ -1,15 +1,13 @@ -include /********************************* - * OpenSCAD GridBeam Library * - * (c) Timothy Schmidt 2013 * - * http://www.github.com/gridbeam * - * License: LGPL 2.1 or later * - *********************************/ +* OpenSCAD GridBeam Library * +* (c) Timothy Schmidt 2013 * +* http://www.github.com/gridbeam * +* License: LGPL 2.1 or later * +*********************************/ /* Todo: - implement "dxf" mode - - implement hole cutout pattern - interference based on hole size, compatible - with two sizes above and below the currently set size. + - implement hole cutout pattern - interference based on hole size, compatible with two sizes above and below the currently set size. */ // zBeam(segments) - create a vertical gridbeam strut 'segments' long @@ -18,218 +16,174 @@ include // zBolt(segments) - create a bolt 'segments' in length // xBolt(segments) // yBolt(segments) -// topShelf(width, depth, corners) - create a shelf suitable for use in gridbeam -// structures width and depth in 'segments', corners == 1 notches corners -// bottomShelf(width, depth, corners) - like topShelf, but aligns shelf to -// underside of beams backBoard(width, height, corners) - create a backing board -// suitable for use in gridbeam structures width and height in 'segments', -// corners == 1 notches corners frontBoard(width, height, corners) - like -// backBoard, but aligns board to front side of beams translateBeam([x, y, z]) - -// translate gridbeam struts or shelves in X, Y, or Z axes in units 'segments' +// topShelf(width, depth, corners) - create a shelf suitable for use in gridbeam structures width and depth in 'segments', corners == 1 notches corners +// bottomShelf(width, depth, corners) - like topShelf, but aligns shelf to underside of beams +// backBoard(width, height, corners) - create a backing board suitable for use in gridbeam structures width and height in 'segments', corners == 1 notches corners +// frontBoard(width, height, corners) - like backBoard, but aligns board to front side of beams +// translateBeam([x, y, z]) - translate gridbeam struts or shelves in X, Y, or Z axes in units 'segments' // To render the DXF file from the command line: // openscad -x connector.dxf -D'mode="dxf"' connector.scad mode = "model"; -// mode = "dxf"; +//mode = "dxf"; + +include beam_width = length_inch * 1.5; -beam_hole_diameter = length_inch * 5 / 16; +beam_hole_diameter = length_inch * 5/16; beam_hole_radius = beam_hole_diameter / 2; beam_is_hollow = 1; -beam_wall_thickness = length_inch * 1 / 8; -beam_shelf_thickness = length_inch * 1 / 4; - -module zBeam(segments) -{ - if (mode == "model") { - difference() - { - cube([ beam_width, beam_width, beam_width * segments ]); - for (i = [0:segments - 1]) { - translate([ - beam_width / 2, - beam_width + 1, - beam_width * i + beam_width / 2 - ]) rotate([ 90, 0, 0 ]) - cylinder(r = beam_hole_radius, h = beam_width + 2); - - translate( - [ -1, beam_width / 2, beam_width * i + beam_width / 2 ]) - rotate([ 0, 90, 0 ]) - cylinder(r = beam_hole_radius, h = beam_width + 2); - } - if (beam_is_hollow == 1) { - translate([ beam_wall_thickness, beam_wall_thickness, -1 ]) - cube([ - beam_width - beam_wall_thickness * 2, - beam_width - beam_wall_thickness * 2, - beam_width * segments + 2 - ]); - } - } - } - - if (mode == "dxf") { - } -} - -module xBeam(segments) -{ - if (mode == "model") { - translate([ 0, 0, beam_width ]) rotate([ 0, 90, 0 ]) zBeam(segments); - } - - if (mode == "dxf") { - } -} - -module yBeam(segments) -{ - if (mode == "model") { - translate([ 0, 0, beam_width ]) rotate([ -90, 0, 0 ]) zBeam(segments); - } - - if (mode == "dxf") { - } -} - -module zBolt(segments) -{ - if (mode == "model") { - } - - if (mode == "dxf") { - } -} - -module xBolt(segments) -{ - if (mode == "model") { - } - - if (mode == "dxf") { - } -} - -module yBolt(segments) -{ - if (mode == "model") { - } - - if (mode == "dxf") { - } -} - -module translateBeam(v) -{ - for (i = [0:$children - 1]) { - translate(v * beam_width) child(i); - } -} - -module topShelf(width, depth, corners) -{ - if (mode == "model") { - difference() - { - cube([ - width * beam_width, - depth * beam_width, - beam_shelf_thickness - ]); - - if (corners == 1) { - translate([ -1, -1, -1 ]) cube([ - beam_width + 2, - beam_width + 2, - beam_shelf_thickness + 2 - ]); - translate([ -1, (depth - 1) * beam_width, -1 ]) cube([ - beam_width + 2, - beam_width + 2, - beam_shelf_thickness + 2 - ]); - translate([ (width - 1) * beam_width, -1, -1 ]) cube([ - beam_width + 2, - beam_width + 2, - beam_shelf_thickness + 2 - ]); - translate( - [ (width - 1) * beam_width, (depth - 1) * beam_width, -1 ]) - cube([ - beam_width + 2, - beam_width + 2, - beam_shelf_thickness + 2 - ]); - } - } - } - - if (mode == "dxf") { - } -} - -module bottomShelf(width, depth, corners) -{ - if (mode == "model") { - translate([ 0, 0, -beam_shelf_thickness ]) - topShelf(width, depth, corners); - } - - if (mode == "dxf") { - } -} - -module backBoard(width, height, corners) -{ - if (mode == "model") { - translate([ beam_width, 0, 0 ]) difference() - { - cube([ - beam_shelf_thickness, - width * beam_width, - height * - beam_width - ]); - - if (corners == 1) { - translate([ -1, -1, -1 ]) cube([ - beam_shelf_thickness + 2, - beam_width + 2, - beam_width + 2 - ]); - translate([ -1, -1, (height - 1) * beam_width ]) cube([ - beam_shelf_thickness + 2, - beam_width + 2, - beam_width + 2 - ]); - translate([ -1, (width - 1) * beam_width, -1 ]) cube([ - beam_shelf_thickness + 2, - beam_width + 2, - beam_width + 2 - ]); - translate( - [ -1, (width - 1) * beam_width, (height - 1) * beam_width ]) - cube([ - beam_shelf_thickness + 2, - beam_width + 2, - beam_width + 2 - ]); - } - } - } - - if (mode == "dxf") { - } -} - -module frontBoard(width, height, corners) -{ - if (mode == "model") { - translate([ -beam_width - beam_shelf_thickness, 0, 0 ]) - backBoard(width, height, corners); - } - - if (mode == "dxf") { - } +beam_wall_thickness = length_inch * 1/8; +beam_shelf_thickness = length_inch * 1/4; + +module zBeam(segments) { +if (mode == "model") { + difference() { + cube([beam_width, beam_width, beam_width * segments]); + for(i = [0 : segments - 1]) { + translate([beam_width / 2, beam_width + 1, beam_width * i + beam_width / 2]) + rotate([90,0,0]) + cylinder(r=beam_hole_radius, h=beam_width + 2); + + translate([-1, beam_width / 2, beam_width * i + beam_width / 2]) + rotate([0,90,0]) + cylinder(r=beam_hole_radius, h=beam_width + 2); + } + if (beam_is_hollow == 1) { + translate([beam_wall_thickness, beam_wall_thickness, -1]) + cube([beam_width - beam_wall_thickness * 2, beam_width - beam_wall_thickness * 2, beam_width * segments + 2]); + } +} +} + +if (mode == "dxf") { + +} +} + +module xBeam(segments) { +if (mode == "model") { + translate([0,0,beam_width]) + rotate([0,90,0]) + zBeam(segments); +} + +if (mode == "dxf") { + +} +} + +module yBeam(segments) { +if (mode == "model") { + translate([0,0,beam_width]) + rotate([-90,0,0]) + zBeam(segments); +} + +if (mode == "dxf") { + +} +} + +module zBolt(segments) { +if (mode == "model") { + +} + +if (mode == "dxf") { + +} +} + +module xBolt(segments) { +if (mode == "model") { +} + +if (mode == "dxf") { + +} +} + +module yBolt(segments) { +if (mode == "model") { +} + +if (mode == "dxf") { + +} +} + +module translateBeam(v) { + for (i = [0 : $children - 1]) { + translate(v * beam_width) child(i); + } +} + +module topShelf(width, depth, corners) { +if (mode == "model") { + difference() { + cube([width * beam_width, depth * beam_width, beam_shelf_thickness]); + + if (corners == 1) { + translate([-1, -1, -1]) + cube([beam_width + 2, beam_width + 2, beam_shelf_thickness + 2]); + translate([-1, (depth - 1) * beam_width, -1]) + cube([beam_width + 2, beam_width + 2, beam_shelf_thickness + 2]); + translate([(width - 1) * beam_width, -1, -1]) + cube([beam_width + 2, beam_width + 2, beam_shelf_thickness + 2]); + translate([(width - 1) * beam_width, (depth - 1) * beam_width, -1]) + cube([beam_width + 2, beam_width + 2, beam_shelf_thickness + 2]); + } + } +} + +if (mode == "dxf") { + +} +} + +module bottomShelf(width, depth, corners) { +if (mode == "model") { + translate([0,0,-beam_shelf_thickness]) + topShelf(width, depth, corners); +} + +if (mode == "dxf") { + +} +} + +module backBoard(width, height, corners) { +if (mode == "model") { + translate([beam_width, 0, 0]) + difference() { + cube([beam_shelf_thickness, width * beam_width, height * beam_width]); + + if (corners == 1) { + translate([-1, -1, -1]) + cube([beam_shelf_thickness + 2, beam_width + 2, beam_width + 2]); + translate([-1, -1, (height - 1) * beam_width]) + cube([beam_shelf_thickness + 2, beam_width + 2, beam_width + 2]); + translate([-1, (width - 1) * beam_width, -1]) + cube([beam_shelf_thickness + 2, beam_width + 2, beam_width + 2]); + translate([-1, (width - 1) * beam_width, (height - 1) * beam_width]) + cube([beam_shelf_thickness + 2, beam_width + 2, beam_width + 2]); + } + } +} + +if (mode == "dxf") { + +} +} + +module frontBoard(width, height, corners) { +if (mode == "model") { + translate([-beam_width - beam_shelf_thickness, 0, 0]) + backBoard(width, height, corners); +} + +if (mode == "dxf") { + +} } diff --git a/hardware/bearing.scad b/hardware/bearing.scad index 5e223c1e..2d9019de 100644 --- a/hardware/bearing.scad +++ b/hardware/bearing.scad @@ -1,18 +1,18 @@ -include -include /* * Bearing model. * * Originally by Hans Häggström, 2010. - * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or - * later + * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later */ /* change list 13/6/2013 - added ,604,606,607,628,629,6200,6201,6202,6203,6205,6206 bearing sizes + added ,604,606,607,628,629,6200,6201,6202,6203,6205,6206 bearing sizes */ +include +include + BEARING_INNER_DIAMETER = 0; BEARING_OUTER_DIAMETER = 1; BEARING_WIDTH = 2; @@ -23,8 +23,7 @@ SkateBearing = 608; // Bearing dimensions // model == XXX ? [inner dia, outer dia, width]: // http://www.gizmology.net/bearings.htm has some valuable information on that -// https://www.bearingworks.com/bearing-sizes has a very exhaustive table of -// dimensions +// https://www.bearingworks.com/bearing-sizes has a very exhaustive table of dimensions function bearingDimensions(model) = model == 603 ? [3*mm, 9*mm, 5*mm]: model == 604 ? [4*mm, 12*mm, 4*mm]: @@ -84,68 +83,54 @@ function bearingDimensions(model) = [8*length_mm, 22*length_mm, 7*length_mm]; // this is the default + function bearingWidth(model) = bearingDimensions(model)[BEARING_WIDTH]; -function bearingInnerDiameter(model) = - bearingDimensions(model)[BEARING_INNER_DIAMETER]; -function bearingOuterDiameter(model) = - bearingDimensions(model)[BEARING_OUTER_DIAMETER]; - -module bearing(pos = [ 0, 0, 0 ], - angle = [ 0, 0, 0 ], - model = SkateBearing, - outline = false, - material = Steel, - sideMaterial = Brass, - center = false) -{ - // Common bearing names - model = model == "Skate" ? 608 : model; - - w = bearingWidth(model); - innerD = outline == false ? bearingInnerDiameter(model) : 0; - outerD = bearingOuterDiameter(model); - - innerRim = innerD + (outerD - innerD) * 0.2; - outerRim = outerD - (outerD - innerD) * 0.2; - midSink = w * 0.1; - - centering_pos = (center) ? [ 0, 0, -w / 2 ] : [ 0, 0, 0 ]; - - translate(pos) rotate(angle) translate(centering_pos) union() - { - color(material) difference() - { - // Basic ring - Ring([ 0, 0, 0 ], outerD, innerD, w, material, material); - - if (outline == false) { - // Side shields - Ring([ 0, 0, -epsilon ], - outerRim, - innerRim, - epsilon + midSink, - sideMaterial, - material); - Ring([ 0, 0, w - midSink ], - outerRim, - innerRim, - epsilon + midSink, - sideMaterial, - material); - } +function bearingInnerDiameter(model) = bearingDimensions(model)[BEARING_INNER_DIAMETER]; +function bearingOuterDiameter(model) = bearingDimensions(model)[BEARING_OUTER_DIAMETER]; + +module bearing(pos=[0,0,0], angle=[0,0,0], model=SkateBearing, outline=false, + material=Steel, sideMaterial=Brass, center=false) { + // Common bearing names + model = + model == "Skate" ? 608 : + model; + + w = bearingWidth(model); + innerD = outline==false ? bearingInnerDiameter(model) : 0; + outerD = bearingOuterDiameter(model); + + innerRim = innerD + (outerD - innerD) * 0.2; + outerRim = outerD - (outerD - innerD) * 0.2; + midSink = w * 0.1; + + centering_pos = (center) ? [0, 0, -w/2] : [0, 0, 0]; + + translate(pos) rotate(angle) translate (centering_pos) union() { + color(material) + difference() { + // Basic ring + Ring([0,0,0], outerD, innerD, w, material, material); + + if (outline==false) { + // Side shields + Ring([0,0,-epsilon], outerRim, innerRim, epsilon+midSink, sideMaterial, material); + Ring([0,0,w-midSink], outerRim, innerRim, epsilon+midSink, sideMaterial, material); } - } - - module Ring(pos, od, id, h, material, holeMaterial) - { - color(material) - { - translate(pos) difference() - { - cylinder(r = od / 2, h = h, $fs = 0.01); - color(holeMaterial) translate([ 0, 0, -10 * epsilon ]) cylinder( - r = (id / 2) + epsilon, h = h + 20 * epsilon, $fs = 0.01); - } + } + } + + module Ring(pos, od, id, h, material, holeMaterial) { + color(material) { + translate(pos) + difference() { + cylinder(r=od/2, h=h, $fs = 0.01); + color(holeMaterial) + translate([0,0,-10*epsilon]) + cylinder(r=(id/2)+epsilon, h=h+20*epsilon, $fs = 0.01); } } + } + } + + diff --git a/hardware/hardware.scad b/hardware/hardware.scad index eb2b5f1a..aeda29a2 100644 --- a/hardware/hardware.scad +++ b/hardware/hardware.scad @@ -1,13 +1,14 @@ - // License: LGPL 2.1 -rodsize = 6; // threaded/smooth rod diameter in mm -xaxis = 182.5; // width of base in mm -yaxis = 266.5; // length of base in mm +rodsize = 6; //threaded/smooth rod diameter in mm +xaxis = 182.5; //width of base in mm +yaxis = 266.5; //length of base in mm + + +screwsize = 3; //bearing bore/screw diameter in mm +bearingsize = 10; //outer diameter of bearings in mm +bearingwidth = 4; //width of bearings in mm -screwsize = 3; // bearing bore/screw diameter in mm -bearingsize = 10; // outer diameter of bearings in mm -bearingwidth = 4; // width of bearings in mm rodpitch = rodsize / 6; rodnutsize = 0.8 * rodsize; @@ -22,130 +23,90 @@ washerdiameter = 2 * screwsize; partthick = 2 * rodsize; vertexrodspace = 2 * rodsize; -c = [ 0.3, 0.3, 0.3 ]; + +c = [0.3, 0.3, 0.3]; rodendoffset = rodnutsize + rodwashersize * 2 + partthick / 2; vertexoffset = vertexrodspace + rodendoffset; + renderrodthreads = false; renderscrewthreads = false; fn = 36; -module rod(length, threaded) if (threaded && renderrodthreads) -{ - linear_extrude(height = length, - center = true, - convexity = 10, - twist = -360 * length / rodpitch, - $fn = fn) translate([ rodsize * 0.1 / 2, 0, 0 ]) - circle(r = rodsize * 0.9 / 2, $fn = fn); -} -else cylinder(h = length, r = rodsize / 2, center = true, $fn = fn); - -module screw(length, nutpos, washer, bearingpos = -1) union() -{ - translate([ 0, 0, -length / 2 ]) if (renderscrewthreads) - { - linear_extrude(height = length, - center = true, - convexity = 10, - twist = -360 * length / screwpitch, - $fn = fn) translate([ screwsize * 0.1 / 2, 0, 0 ]) - circle(r = screwsize * 0.9 / 2, $fn = fn); - } - else cylinder(h = length, r = screwsize / 2, center = true, $fn = fn); - render() difference() - { - translate([ 0, 0, screwsize / 2 ]) - cylinder(h = screwsize, r = screwsize, center = true, $fn = fn); - translate([ 0, 0, screwsize ]) - cylinder(h = screwsize, r = screwsize / 2, center = true, $fn = 6); - } - if (washer > 0 && nutpos > 0) { - washer(nutpos); - nut(nutpos + washersize); - } else if (nutpos > 0) - nut(nutpos); - if (bearingpos >= 0) - bearing(bearingpos); + + +module rod(length, threaded) if (threaded && renderrodthreads) { + linear_extrude(height = length, center = true, convexity = 10, twist = -360 * length / rodpitch, $fn = fn) + translate([rodsize * 0.1 / 2, 0, 0]) + circle(r = rodsize * 0.9 / 2, $fn = fn); +} else cylinder(h = length, r = rodsize / 2, center = true, $fn = fn); + + +module screw(length, nutpos, washer, bearingpos = -1) union(){ + translate([0, 0, -length / 2]) if (renderscrewthreads) { + linear_extrude(height = length, center = true, convexity = 10, twist = -360 * length / screwpitch, $fn = fn) + translate([screwsize * 0.1 / 2, 0, 0]) + circle(r = screwsize * 0.9 / 2, $fn = fn); + } else cylinder(h = length, r = screwsize / 2, center = true, $fn = fn); + render() difference() { + translate([0, 0, screwsize / 2]) cylinder(h = screwsize, r = screwsize, center = true, $fn = fn); + translate([0, 0, screwsize]) cylinder(h = screwsize, r = screwsize / 2, center = true, $fn = 6); + } + if (washer > 0 && nutpos > 0) { + washer(nutpos); + nut(nutpos + washersize); + } else if (nutpos > 0) nut(nutpos); + if (bearingpos >= 0) bearing(bearingpos); } -module bearing(position) render() - translate([ 0, 0, -position - bearingwidth / 2 ]) union() -{ - difference() - { - cylinder( - h = bearingwidth, r = bearingsize / 2, center = true, $fn = fn); - cylinder(h = bearingwidth * 2, - r = bearingsize / 2 - 1, - center = true, - $fn = fn); - } - difference() - { - cylinder(h = bearingwidth - 0.5, - r = bearingsize / 2 - 0.5, - center = true, - $fn = fn); - cylinder(h = bearingwidth * 2, - r = screwsize / 2 + 0.5, - center = true, - $fn = fn); - } - difference() - { - cylinder( - h = bearingwidth, r = screwsize / 2 + 1, center = true, $fn = fn); - cylinder( - h = bearingwidth + 0.1, r = screwsize / 2, center = true, $fn = fn); - } + +module bearing(position) render() translate([0, 0, -position - bearingwidth / 2]) union() { + difference() { + cylinder(h = bearingwidth, r = bearingsize / 2, center = true, $fn = fn); + cylinder(h = bearingwidth * 2, r = bearingsize / 2 - 1, center = true, $fn = fn); + } + difference() { + cylinder(h = bearingwidth - 0.5, r = bearingsize / 2 - 0.5, center = true, $fn = fn); + cylinder(h = bearingwidth * 2, r = screwsize / 2 + 0.5, center = true, $fn = fn); + } + difference() { + cylinder(h = bearingwidth, r = screwsize / 2 + 1, center = true, $fn = fn); + cylinder(h = bearingwidth + 0.1, r = screwsize / 2, center = true, $fn = fn); + } } -module nut(position, washer) render() - translate([ 0, 0, -position - nutsize / 2 ]) -{ - intersection() - { - scale([ 1, 1, 0.5 ]) sphere(r = 1.05 * screwsize, center = true); - difference() - { - cylinder(h = nutsize, r = nutdiameter / 2, center = true, $fn = 6); - cylinder( - r = screwsize / 2, h = nutsize + 0.1, center = true, $fn = fn); - } - } - if (washer > 0) - washer(0); + +module nut(position, washer) render() translate([0, 0, -position - nutsize / 2]) { + intersection() { + scale([1, 1, 0.5]) sphere(r = 1.05 * screwsize, center = true); + difference() { + cylinder (h = nutsize, r = nutdiameter / 2, center = true, $fn = 6); + cylinder(r = screwsize / 2, h = nutsize + 0.1, center = true, $fn = fn); + } + } + if (washer > 0) washer(0); } -module washer(position) render() translate([ 0, 0, -position - washersize / 2 ]) - difference() -{ - cylinder(r = washerdiameter / 2, h = washersize, center = true, $fn = fn); - cylinder(r = screwsize / 2, h = washersize + 0.1, center = true, $fn = fn); + +module washer(position) render() translate ([0, 0, -position - washersize / 2]) difference() { + cylinder(r = washerdiameter / 2, h = washersize, center = true, $fn = fn); + cylinder(r = screwsize / 2, h = washersize + 0.1, center = true, $fn = fn); } -module rodnut(position, washer) render() translate([ 0, 0, position ]) -{ - intersection() - { - scale([ 1, 1, 0.5 ]) sphere(r = 1.05 * rodsize, center = true); - difference() - { - cylinder( - h = rodnutsize, r = rodnutdiameter / 2, center = true, $fn = 6); - rod(rodnutsize + 0.1); - } - } - if (washer == 1 || washer == 4) - rodwasher(((position > 0) ? -1 : 1) * (rodnutsize + rodwashersize) / 2); - if (washer == 2 || washer == 4) - rodwasher(((position > 0) ? 1 : -1) * (rodnutsize + rodwashersize) / 2); +module rodnut(position, washer) render() translate([0, 0, position]) { + intersection() { + scale([1, 1, 0.5]) sphere(r = 1.05 * rodsize, center = true); + difference() { + cylinder (h = rodnutsize, r = rodnutdiameter / 2, center = true, $fn = 6); + rod(rodnutsize + 0.1); + } + } + if (washer == 1 || washer == 4) rodwasher(((position > 0) ? -1 : 1) * (rodnutsize + rodwashersize) / 2); + if (washer == 2 || washer == 4) rodwasher(((position > 0) ? 1 : -1) * (rodnutsize + rodwashersize) / 2); } -module rodwasher(position) render() translate([ 0, 0, position ]) difference() -{ - cylinder( - r = rodwasherdiameter / 2, h = rodwashersize, center = true, $fn = fn); - rod(rodwashersize + 0.1); + +module rodwasher(position) render() translate ([0, 0, position]) difference() { + cylinder(r = rodwasherdiameter / 2, h = rodwashersize, center = true, $fn = fn); + rod(rodwashersize + 0.1); } diff --git a/hardware/linear_bearing.scad b/hardware/linear_bearing.scad index 4eae3d7e..aa88c915 100644 --- a/hardware/linear_bearing.scad +++ b/hardware/linear_bearing.scad @@ -1,17 +1,16 @@ +//By Glen Chung, 2013. +//Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later -// By Glen Chung, 2013. -// Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or -// later +include ; +include ; -include; -include; +LINEAR_BEARING_dr = 0; //Inscribed circle +LINEAR_BEARING_D = 1; //Outer diameter +LINEAR_BEARING_L = 2; //Length +LINEAR_BEARING_B = 3; //Outer locking groove B +LINEAR_BEARING_D1 = 4; //Outer locking groove D1 +LINEAR_BEARING_W = 5; //W -LINEAR_BEARING_dr = 0; // Inscribed circle -LINEAR_BEARING_D = 1; // Outer diameter -LINEAR_BEARING_L = 2; // Length -LINEAR_BEARING_B = 3; // Outer locking groove B -LINEAR_BEARING_D1 = 4; // Outer locking groove D1 -LINEAR_BEARING_W = 5; // W // Common bearing names LinearBearing = "LM8UU"; @@ -39,91 +38,57 @@ model == "LM80UU" ? [ 80*length_mm, 120*length_mm, 140*length_mm, 105.5*lengt model == "LM100UU" ? [100*length_mm, 150*length_mm, 150*length_mm, 125.5*length_mm, 145.0*length_mm, 4.15*length_mm]: /*model == "LM8UU" ?*/ [ 8*length_mm, 15*length_mm, 24*length_mm, 17.5*length_mm, 14.3*length_mm, 1.10*length_mm]; -function linearBearing_dr(model) = - linearBearingDimensions(model)[LINEAR_BEARING_dr]; -function linearBearing_D(model) = - linearBearingDimensions(model)[LINEAR_BEARING_D]; -function linearBearing_L(model) = - linearBearingDimensions(model)[LINEAR_BEARING_L]; -function linearBearing_B(model) = - linearBearingDimensions(model)[LINEAR_BEARING_B]; -function linearBearing_D1(model) = - linearBearingDimensions(model)[LINEAR_BEARING_D1]; -function linearBearing_W(model) = - linearBearingDimensions(model)[LINEAR_BEARING_W]; -module linearBearing(pos = [ 0, 0, 0 ], - angle = [ 0, 0, 0 ], - model = LinearBearing, - material = Steel, - sideMaterial = BlackPaint) -{ - dr = linearBearing_dr(model); - D = linearBearing_D(model); - L = linearBearing_L(model); - B = linearBearing_B(model); - D1 = linearBearing_D1(model); - W = linearBearing_W(model); +function linearBearing_dr(model) = linearBearingDimensions(model)[LINEAR_BEARING_dr]; +function linearBearing_D(model) = linearBearingDimensions(model)[LINEAR_BEARING_D]; +function linearBearing_L(model) = linearBearingDimensions(model)[LINEAR_BEARING_L]; +function linearBearing_B(model) = linearBearingDimensions(model)[LINEAR_BEARING_B]; +function linearBearing_D1(model) = linearBearingDimensions(model)[LINEAR_BEARING_D1]; +function linearBearing_W(model) = linearBearingDimensions(model)[LINEAR_BEARING_W]; - innerRim = dr + (D - dr) * 0.2; - outerRim = D - (D - dr) * 0.2; - midSink = W / 4; +module linearBearing(pos=[0,0,0], angle=[0,0,0], model=LinearBearing, + material=Steel, sideMaterial=BlackPaint) { + dr = linearBearing_dr(model); + D = linearBearing_D(model); + L = linearBearing_L(model); + B = linearBearing_B(model); + D1 = linearBearing_D1(model); + W = linearBearing_W(model); - translate(pos) rotate(angle) union() - { - color(material) difference() - { - // Basic ring - Ring([ 0, 0, 0 ], D, dr, L, material, material); + innerRim = dr + (D - dr) * 0.2; + outerRim = D - (D - dr) * 0.2; + midSink = W/4; - if (W) { - // Side shields - Ring([ 0, 0, -epsilon ], - outerRim, - innerRim, - L * epsilon + midSink, - sideMaterial, - material); - Ring([ 0, 0, L - midSink - epsilon ], - outerRim, - innerRim, - L * epsilon + midSink, - sideMaterial, - material); - // Outer locking groove - Ring([ 0, 0, (L - B) / 2 ], - D + epsilon, - outerRim + W / 2, - W, - material, - material); - Ring([ 0, 0, L - (L - B) / 2 ], - D + epsilon, - outerRim + W / 2, - W, - material, - material); - } - } - if (W) - Ring([ 0, 0, midSink ], - D - L * epsilon, - dr + L * epsilon, - L - midSink * 2, - sideMaterial, - sideMaterial); - } + translate(pos) rotate(angle) union() { + color(material) + difference() { + // Basic ring + Ring([0,0,0], D, dr, L, material, material); + + if(W) { + // Side shields + Ring([0,0,-epsilon], outerRim, innerRim, L*epsilon+midSink, sideMaterial, material); + Ring([0,0,L-midSink-epsilon], outerRim, innerRim, L*epsilon+midSink, sideMaterial, material); + //Outer locking groove + Ring([0,0,(L-B)/2], D+epsilon, outerRim+W/2, W, material, material); + Ring([0,0,L-(L-B)/2], D+epsilon, outerRim+W/2, W, material, material); + } + } + if(W) + Ring([0,0,midSink], D-L*epsilon, dr+L*epsilon, L-midSink*2, sideMaterial, sideMaterial); + } + + module Ring(pos, od, id, h, material, holeMaterial) { + color(material) { + translate(pos) + difference() { + cylinder(r=od/2, h=h, $fn = 100); + color(holeMaterial) + translate([0,0,-10*epsilon]) + cylinder(r=id/2, h=h+20*epsilon, $fn = 100); + } + } + } - module Ring(pos, od, id, h, material, holeMaterial) - { - color(material) - { - translate(pos) difference() - { - cylinder(r = od / 2, h = h, $fn = 100); - color(holeMaterial) translate([ 0, 0, -10 * epsilon ]) - cylinder(r = id / 2, h = h + 20 * epsilon, $fn = 100); - } - } - } } + diff --git a/layout/linear.scad b/layout/linear.scad index 6c37dfb2..53795705 100644 --- a/layout/linear.scad +++ b/layout/linear.scad @@ -1,4 +1,3 @@ - /* * OpenSCAD Layout Library (www.openscad.org) * Copyright (C) 2012 Peter Uithoven @@ -8,16 +7,16 @@ module array_linear(iHeight) { - for (i = [0:$children - 1]) - translate([ 0, i * iHeight ]) children(i); + for (i = [0 : $children-1]) + translate([0,i*iHeight]) children(i); } -module array_linear_grid(iWidth, iHeight, inYDir = true, limit = 3) +module array_linear_grid(iWidth,iHeight,inYDir = true,limit=3) { - for (i = [0:$children - 1]) { - translate([ - (inYDir) ? (iWidth) * (i % limit) : (iWidth)*floor(i / limit), - (inYDir) ? (iHeight)*floor(i / limit) : (iHeight) * (i % limit) - ]) children(i); - } + for (i = [0 : $children-1]) + { + translate([(inYDir)? (iWidth)*(i%limit) : (iWidth)*floor(i/limit), + (inYDir)? (iHeight)*floor(i/limit) : (iHeight)*(i%limit)]) + children(i); + } } diff --git a/lego_compatibility.scad b/lego_compatibility.scad index 9436cc27..4e402d9b 100644 --- a/lego_compatibility.scad +++ b/lego_compatibility.scad @@ -1,4 +1,3 @@ - // This file is placed under the public domain // from: http://www.thingiverse.com/thing:9512 @@ -16,261 +15,143 @@ // standard LEGO 2x1x5 brick has no pin and has hollow knobs // block(1,2,5,reinforcement=false,hollow_knob=true); -knob_diameter = 4.8; // knobs on top of blocks -knob_height = 2; -knob_spacing = 8.0; -wall_thickness = 1.45; -roof_thickness = 1.05; -block_height = 9.5; -pin_diameter = 3; // pin for bottom blocks with width or length of 1 -post_diameter = 6.5; -reinforcing_width = 1.5; -axle_spline_width = 2.0; -axle_diameter = 5; -cylinder_precision = 0.5; + +knob_diameter=4.8; //knobs on top of blocks +knob_height=2; +knob_spacing=8.0; +wall_thickness=1.45; +roof_thickness=1.05; +block_height=9.5; +pin_diameter=3; //pin for bottom blocks with width or length of 1 +post_diameter=6.5; +reinforcing_width=1.5; +axle_spline_width=2.0; +axle_diameter=5; +cylinder_precision=0.5; /* EXAMPLES: block(2,1,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true); translate([50,-10,0]) - block(1,2,1/3,axle_hole=false,circular_hole=true,reinforcement=false,hollow_knob=true,flat_top=true); + block(1,2,1/3,axle_hole=false,circular_hole=true,reinforcement=false,hollow_knob=true,flat_top=true); translate([10,0,0]) - block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true); + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true); translate([30,0,0]) - block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=false,flat_top=false); + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=false,flat_top=false); translate([50,0,0]) - block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false); + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false); translate([0,20,0]) - block(3,2,2/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false); + block(3,2,2/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false); translate([20,20,0]) - block(3,2,1,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false); + block(3,2,1,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false); translate([40,20,0]) - block(3,2,1/3,axle_hole=false,circular_hole=false,reinforcement=false,hollow_knob=false,flat_top=false); + block(3,2,1/3,axle_hole=false,circular_hole=false,reinforcement=false,hollow_knob=false,flat_top=false); translate([0,-10,0]) - block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false); + block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false); translate([0,-20,0]) - block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=false); + block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=false); translate([0,-30,0]) - block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=true); + block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=true); //*/ -module block(width, - length, - height, - axle_hole = false, - reinforcement = false, - hollow_knob = false, - flat_top = false, - circular_hole = false, - solid_bottom = true, - center = false) -{ - overall_length = - (length - 1) * knob_spacing + knob_diameter + wall_thickness * 2; - overall_width = - (width - 1) * knob_spacing + knob_diameter + wall_thickness * 2; - center = center == true ? 1 : 0; - translate(center * [ -overall_length / 2, -overall_width / 2, 0 ]) union() - { - difference() - { - union() - { - // body: - cube([ overall_length, overall_width, height * block_height ]); - // knobs: - if (flat_top != true) - translate([ - knob_diameter / 2 + wall_thickness, - knob_diameter / 2 + wall_thickness, - 0 - ]) for (ycount = [0:width - 1]) for (xcount = - [0:length - 1]) - { - translate( - [ xcount * knob_spacing, ycount * knob_spacing, 0 ]) - difference() - { - cylinder(r = knob_diameter / 2, - h = block_height * height + knob_height, - $fs = cylinder_precision); - if (hollow_knob == true) - translate([ 0, 0, -roof_thickness ]) cylinder( - r = pin_diameter / 2, - h = block_height * height + knob_height + - 2 * roof_thickness, - $fs = cylinder_precision); - } - } - } - // hollow bottom: - if (solid_bottom == false) - translate([ wall_thickness, wall_thickness, -roof_thickness ]) - cube([ - overall_length - wall_thickness * 2, - overall_width - wall_thickness * 2, - block_height * - height - ]); - // flat_top -> groove around bottom - if (flat_top == true) { - translate([ - -wall_thickness / 2, - -wall_thickness * 2 / 3, - -wall_thickness / 2 - ]) - cube([ - overall_length + wall_thickness, - wall_thickness, - wall_thickness - ]); - translate([ - -wall_thickness / 2, - overall_width - wall_thickness / 3, - -wall_thickness / 2 - ]) - cube([ - overall_length + wall_thickness, - wall_thickness, - wall_thickness - ]); - - translate([ - -wall_thickness * 2 / 3, - -wall_thickness / 2, - -wall_thickness / 2 - ]) - cube([ - wall_thickness, - overall_width + wall_thickness, - wall_thickness - ]); - translate([ - overall_length - wall_thickness / 3, - 0, - -wall_thickness / 2 - ]) - cube([ - wall_thickness, - overall_width + wall_thickness, - wall_thickness - ]); - } - if (axle_hole == true) - if (width > 1 && length > 1) - for (ycount = [1:width - 1]) - for (xcount = [1:length - 1]) - translate([ - xcount * knob_spacing, - ycount * knob_spacing, - roof_thickness - ]) axle(height); - if (circular_hole == true) - if (width > 1 && length > 1) - for (ycount = [1:width - 1]) - for (xcount = [1:length - 1]) - translate([ - xcount * knob_spacing, - ycount * knob_spacing, - roof_thickness - ]) cylinder(r = knob_diameter / 2, - h = height * block_height + - roof_thickness / 4, - $fs = cylinder_precision); - } - - if (reinforcement == true && width > 1 && length > 1) - difference() - { - for (ycount = [1:width - 1]) - for (xcount = [1:length - 1]) - translate( - [ xcount * knob_spacing, ycount * knob_spacing, 0 ]) - reinforcement(height); - for (ycount = [1:width - 1]) - for (xcount = [1:length - 1]) - translate([ - xcount * knob_spacing, - ycount * knob_spacing, - -roof_thickness / 2 - ]) cylinder(r = knob_diameter / 2, - h = height * block_height + roof_thickness, - $fs = cylinder_precision); - } - // posts: - if (solid_bottom == false) - if (width > 1 && length > 1) - for (ycount = [1:width - 1]) - for (xcount = [1:length - 1]) - translate( - [ xcount * knob_spacing, ycount * knob_spacing, 0 ]) - post(height); - - if (reinforcement == true && width == 1 && length != 1) - for (xcount = [1:length - 1]) - translate([ xcount * knob_spacing, overall_width / 2, 0 ]) - cylinder(r = pin_diameter / 2, - h = block_height * height, - $fs = cylinder_precision); - - if (reinforcement == true && length == 1 && width != 1) - for (ycount = [1:width - 1]) - translate([ overall_length / 2, ycount * knob_spacing, 0 ]) - cylinder(r = pin_diameter / 2, - h = block_height * height, - $fs = cylinder_precision); - } +module block(width,length,height,axle_hole=false,reinforcement=false, hollow_knob=false, flat_top=false, circular_hole=false, solid_bottom=true, center=false) { + overall_length=(length-1)*knob_spacing+knob_diameter+wall_thickness*2; + overall_width=(width-1)*knob_spacing+knob_diameter+wall_thickness*2; + center= center==true ? 1 : 0; + translate(center*[-overall_length/2, -overall_width/2, 0]) + union() { + difference() { + union() { + // body: + cube([overall_length,overall_width,height*block_height]); + // knobs: + if (flat_top != true) + translate([knob_diameter/2+wall_thickness,knob_diameter/2+wall_thickness,0]) + for (ycount=[0:width-1]) + for (xcount=[0:length-1]) { + translate([xcount*knob_spacing,ycount*knob_spacing,0]) + difference() { + cylinder(r=knob_diameter/2,h=block_height*height+knob_height,$fs=cylinder_precision); + if (hollow_knob==true) + translate([0,0,-roof_thickness]) + cylinder(r=pin_diameter/2,h=block_height*height+knob_height+2*roof_thickness,$fs=cylinder_precision); + } + } + } + // hollow bottom: + if (solid_bottom == false) + translate([wall_thickness,wall_thickness,-roof_thickness]) cube([overall_length-wall_thickness*2,overall_width-wall_thickness*2,block_height*height]); + // flat_top -> groove around bottom + if (flat_top == true) { + translate([-wall_thickness/2,-wall_thickness*2/3,-wall_thickness/2]) + cube([overall_length+wall_thickness,wall_thickness,wall_thickness]); + translate([-wall_thickness/2,overall_width-wall_thickness/3,-wall_thickness/2]) + cube([overall_length+wall_thickness,wall_thickness,wall_thickness]); + + translate([-wall_thickness*2/3,-wall_thickness/2,-wall_thickness/2]) + cube([wall_thickness,overall_width+wall_thickness,wall_thickness]); + translate([overall_length-wall_thickness/3,0,-wall_thickness/2]) + cube([wall_thickness,overall_width+wall_thickness,wall_thickness]); + } + if (axle_hole==true) + if (width>1 && length>1) for (ycount=[1:width-1]) + for (xcount=[1:length-1]) + translate([xcount*knob_spacing,ycount*knob_spacing,roof_thickness]) axle(height); + if (circular_hole==true) + if (width>1 && length>1) for (ycount=[1:width-1]) + for (xcount=[1:length-1]) + translate([xcount*knob_spacing,ycount*knob_spacing,roof_thickness]) + cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision); + } + + if (reinforcement==true && width>1 && length>1) + difference() { + for (ycount=[1:width-1]) + for (xcount=[1:length-1]) + translate([xcount*knob_spacing,ycount*knob_spacing,0]) reinforcement(height); + for (ycount=[1:width-1]) + for (xcount=[1:length-1]) + translate([xcount*knob_spacing,ycount*knob_spacing,-roof_thickness/2]) cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness, $fs=cylinder_precision); + } + // posts: + if (solid_bottom == false) + if (width>1 && length>1) for (ycount=[1:width-1]) + for (xcount=[1:length-1]) + translate([xcount*knob_spacing,ycount*knob_spacing,0]) post(height); + + if (reinforcement == true && width==1 && length!=1) + for (xcount=[1:length-1]) + translate([xcount*knob_spacing,overall_width/2,0]) cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision); + + if (reinforcement == true && length==1 && width!=1) + for (ycount=[1:width-1]) + translate([overall_length/2,ycount*knob_spacing,0]) cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision); + } } -module post(height) -{ - difference() - { - cylinder(r = post_diameter / 2, - h = height * block_height - roof_thickness / 2, - $fs = cylinder_precision); - translate([ 0, 0, -roof_thickness / 2 ]) - cylinder(r = knob_diameter / 2, - h = height * block_height + roof_thickness / 4, - $fs = cylinder_precision); - } +module post(height) { + difference() { + cylinder(r=post_diameter/2, h=height*block_height-roof_thickness/2,$fs=cylinder_precision); + translate([0,0,-roof_thickness/2]) + cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision); + } } -module reinforcement(height) -{ - union() - { - translate([ 0, 0, height * block_height / 2 ]) union() - { - cube( - [ - reinforcing_width, - knob_spacing + knob_diameter + wall_thickness / 2, - height * - block_height - ], - center = true); - rotate(v = [ 0, 0, 1 ], a = 90) cube( - [ - reinforcing_width, - knob_spacing + knob_diameter + wall_thickness / 2, - height * - block_height - ], - center = true); - } - } +module reinforcement(height) { + union() { + translate([0,0,height*block_height/2]) union() { + cube([reinforcing_width,knob_spacing+knob_diameter+wall_thickness/2,height*block_height],center=true); + rotate(v=[0,0,1],a=90) cube([reinforcing_width,knob_spacing+knob_diameter+wall_thickness/2,height*block_height], center=true); + } + } } -module axle(height) -{ - translate([ 0, 0, height * block_height / 2 ]) union() - { - cube([ axle_diameter, axle_spline_width, height * block_height ], - center = true); - cube([ axle_spline_width, axle_diameter, height * block_height ], - center = true); - } +module axle(height) { + translate([0,0,height*block_height/2]) union() { + cube([axle_diameter,axle_spline_width,height*block_height],center=true); + cube([axle_spline_width,axle_diameter,height*block_height],center=true); + } } + diff --git a/materials/materials.scad b/materials/materials.scad index 8af629e9..5afc293b 100644 --- a/materials/materials.scad +++ b/materials/materials.scad @@ -1,21 +1,19 @@ - /* * Material colors. - * + * * Originally by Hans Häggström, 2010. - * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or - * later + * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later */ // Material colors -Oak = [ 0.65, 0.5, 0.4 ]; -Pine = [ 0.85, 0.7, 0.45 ]; -Birch = [ 0.9, 0.8, 0.6 ]; -FiberBoard = [ 0.7, 0.67, 0.6 ]; -BlackPaint = [ 0.2, 0.2, 0.2 ]; -Iron = [ 0.36, 0.33, 0.33 ]; -Steel = [ 0.65, 0.67, 0.72 ]; -Stainless = [ 0.45, 0.43, 0.5 ]; -Aluminum = [ 0.77, 0.77, 0.8 ]; -Brass = [ 0.88, 0.78, 0.5 ]; -Transparent = [ 1, 1, 1, 0.2 ]; +Oak = [0.65, 0.5, 0.4]; +Pine = [0.85, 0.7, 0.45]; +Birch = [0.9, 0.8, 0.6]; +FiberBoard = [0.7, 0.67, 0.6]; +BlackPaint = [0.2, 0.2, 0.2]; +Iron = [0.36, 0.33, 0.33]; +Steel = [0.65, 0.67, 0.72]; +Stainless = [0.45, 0.43, 0.5]; +Aluminum = [0.77, 0.77, 0.8]; +Brass = [0.88, 0.78, 0.5]; +Transparent = [1, 1, 1, 0.2]; diff --git a/materials/visibonecolors.scad b/materials/visibonecolors.scad index bca5c029..701f4d41 100644 --- a/materials/visibonecolors.scad +++ b/materials/visibonecolors.scad @@ -1,4 +1,3 @@ - /************************************************************************** * File: visibonecolors.scad - a VisiBone-based color library for OpenSCAD * Date: 2011-02-24 @@ -13,7 +12,7 @@ * This program is free software; you can redistribute it and/or modify * it under the terms of the Creative Commons - LGPL License (cc-lgpl) as * published by the Creative Commons Corporation. - * + * * See http://creativecommons.org/licenses/LGPL/2.1/ for details. * * This program is distributed in the hope that it will be useful, @@ -22,441 +21,440 @@ **************************************************************************/ /* Visibone Colors http://www.visibone.com/colorlab/ */ -PPR = [ 255 / 255, 0 / 255, 102 / 255 ]; /* Pink Pink Red */ -PPM = [ 255 / 255, 0 / 255, 153 / 255 ]; /* Pink Pink Magenta */ -RRP = [ 255 / 255, 0 / 255, 51 / 255 ]; /* Red Red Pink */ -MMP = [ 255 / 255, 0 / 255, 204 / 255 ]; /* Magenta Magenta Pink */ -DRP = [ 204 / 255, 0 / 255, 51 / 255 ]; /* Dark Red Pink */ -DMP = [ 204 / 255, 0 / 255, 153 / 255 ]; /* Dark Magenta Pink */ -LRP = [ 255 / 255, 51 / 255, 102 / 255 ]; /* Light Red Pink */ -LMP = [ 255 / 255, 51 / 255, 204 / 255 ]; /* Light Magenta Pink */ -DPR = [ 153 / 255, 0 / 255, 51 / 255 ]; /* Dark Pink Red */ -DPM = [ 153 / 255, 0 / 255, 102 / 255 ]; /* Dark Pink Magenta */ -LPR = [ 255 / 255, 102 / 255, 153 / 255 ]; /* Light Pink Red */ -LPM = [ 255 / 255, 102 / 255, 204 / 255 ]; /* Light Pink Magenta */ -MPR = [ 204 / 255, 51 / 255, 102 / 255 ]; /* Medium Pink Red */ -MPM = [ 204 / 255, 51 / 255, 153 / 255 ]; /* Medium Pink Magenta */ -OOY = [ 255 / 255, 153 / 255, 0 / 255 ]; /* Orange Orange Yellow */ -OOR = [ 255 / 255, 102 / 255, 0 / 255 ]; /* Orange Orange Red */ -YYO = [ 255 / 255, 204 / 255, 0 / 255 ]; /* Yellow Yellow Orange */ -RRO = [ 255 / 255, 51 / 255, 0 / 255 ]; /* Red Red Orange */ -DYO = [ 204 / 255, 153 / 255, 0 / 255 ]; /* Dark Yellow Orange */ -DRO = [ 204 / 255, 51 / 255, 0 / 255 ]; /* Dark Red Orange */ -LYO = [ 255 / 255, 204 / 255, 51 / 255 ]; /* Light Yellow Orange */ -LRO = [ 255 / 255, 102 / 255, 51 / 255 ]; /* Light Red Orange */ -DOY = [ 153 / 255, 102 / 255, 0 / 255 ]; /* Dark Orange Yellow */ -DOR = [ 153 / 255, 51 / 255, 0 / 255 ]; /* Dark Orange Red */ -LOY = [ 255 / 255, 204 / 255, 102 / 255 ]; /* Light Orange Yellow */ -LOR = [ 255 / 255, 153 / 255, 102 / 255 ]; /* Light Orange Red */ -MOY = [ 204 / 255, 153 / 255, 51 / 255 ]; /* Medium Orange Yellow */ -MOR = [ 204 / 255, 102 / 255, 51 / 255 ]; /* Medium Orange Red */ -SSG = [ 102 / 255, 255 / 255, 0 / 255 ]; /* Spring Spring Green */ -SSY = [ 153 / 255, 255 / 255, 0 / 255 ]; /* Spring Spring Yellow */ -GGS = [ 51 / 255, 255 / 255, 0 / 255 ]; /* Green Green Spring */ -YYS = [ 204 / 255, 255 / 255, 0 / 255 ]; /* Yellow Yellow Spring */ -DGS = [ 51 / 255, 204 / 255, 0 / 255 ]; /* Dark Green Spring */ -DYS = [ 153 / 255, 204 / 255, 0 / 255 ]; /* Dark Yellow Spring */ -LGS = [ 102 / 255, 255 / 255, 51 / 255 ]; /* Light Green Spring */ -LYS = [ 204 / 255, 255 / 255, 51 / 255 ]; /* Light Yellow Spring */ -DSG = [ 51 / 255, 153 / 255, 0 / 255 ]; /* Dark Spring Green */ -DSY = [ 102 / 255, 153 / 255, 0 / 255 ]; /* Dark Spring Yellow */ -LSG = [ 153 / 255, 255 / 255, 102 / 255 ]; /* Light Spring Green */ -LSY = [ 204 / 255, 255 / 255, 102 / 255 ]; /* Light Spring Yellow */ -MSG = [ 102 / 255, 204 / 255, 51 / 255 ]; /* Medium Spring Green */ -MSY = [ 153 / 255, 204 / 255, 51 / 255 ]; /* Medium Spring Yellow */ -TTC = [ 0 / 255, 255 / 255, 153 / 255 ]; /* Teal Teal Cyan */ -TTG = [ 0 / 255, 255 / 255, 102 / 255 ]; /* Teal Teal Green */ -CCT = [ 0 / 255, 255 / 255, 204 / 255 ]; /* Cyan Cyan Teal */ -GGT = [ 0 / 255, 255 / 255, 51 / 255 ]; /* Green Green Teal */ -DCT = [ 0 / 255, 204 / 255, 153 / 255 ]; /* Dark Cyan Teal */ -,DGT = [ 0 / 255, 204 / 255, 51 / 255 ]; /* Dark Green Teal */ -LCT = [ 51 / 255, 255 / 255, 204 / 255 ]; /* Light Cyan Teal */ -LGT = [ 51 / 255, 255 / 255, 102 / 255 ]; /* Light Green Teal */ -DTC = [ 0 / 255, 153 / 255, 102 / 255 ]; /* Dark Teal Cyan */ -DTG = [ 0 / 255, 153 / 255, 51 / 255 ]; /* Dark Teal Green */ -LTC = [ 102 / 255, 255 / 255, 204 / 255 ]; /* Light Teal Cyan */ -LTG = [ 102 / 255, 255 / 255, 153 / 255 ]; /* Light Teal Green */ -MTC = [ 51 / 255, 204 / 255, 153 / 255 ]; /* Medium Teal Cyan */ -MTG = [ 51 / 255, 204 / 255, 102 / 255 ]; /* Medium Teal Green */ -AAB = [ 0 / 255, 102 / 255, 255 / 255 ]; /* Azure Azure Blue */ -AAC = [ 0 / 255, 153 / 255, 255 / 255 ]; /* Azure Azure Cyan */ -BBA = [ 0 / 255, 51 / 255, 255 / 255 ]; /* Blue Blue Azure */ -CCA = [ 0 / 255, 204 / 255, 255 / 255 ]; /* Cyan Cyan Azure */ -DBA = [ 0 / 255, 51 / 255, 204 / 255 ]; /* Dark Blue Azure */ -DCA = [ 0 / 255, 153 / 255, 204 / 255 ]; /* Dark Cyan Azure */ -LBA = [ 51 / 255, 102 / 255, 255 / 255 ]; /* Light Blue Azure */ -LCA = [ 51 / 255, 204 / 255, 255 / 255 ]; /* Light Cyan Azure */ -DAB = [ 0 / 255, 51 / 255, 153 / 255 ]; /* Dark Azure Blue */ -DAC = [ 0 / 255, 102 / 255, 153 / 255 ]; /* Dark Azure Cyan */ -LAB = [ 102 / 255, 153 / 255, 255 / 255 ]; /* Light Azure Blue */ -LAC = [ 102 / 255, 204 / 255, 255 / 255 ]; /* Light Azure Cyan */ -MAB = [ 51 / 255, 102 / 255, 204 / 255 ]; /* Medium Azure Blue */ -MAC = [ 51 / 255, 153 / 255, 204 / 255 ]; /* Medium Azure Cyan */ -VVM = [ 153 / 255, 0 / 255, 255 / 255 ]; /* Violet Violet Magenta */ -VVB = [ 102 / 255, 0 / 255, 255 / 255 ]; /* Violet Violet Blue */ -MMV = [ 204 / 255, 0 / 255, 255 / 255 ]; /* Magenta Magenta Violet */ -BBV = [ 51 / 255, 0 / 255, 255 / 255 ]; /* Blue Blue Violet */ -DMV = [ 153 / 255, 0 / 255, 204 / 255 ]; /* Dark Magenta Violet */ -DBV = [ 51 / 255, 0 / 255, 204 / 255 ]; /* Dark Blue Violet */ -LMV = [ 204 / 255, 51 / 255, 255 / 255 ]; /* Light Magenta Violet */ -LBV = [ 102 / 255, 51 / 255, 255 / 255 ]; /* Light Blue Violet */ -DVM = [ 102 / 255, 0 / 255, 153 / 255 ]; /* Dark Violet Magenta */ -DVB = [ 51 / 255, 0 / 255, 153 / 255 ]; /* Dark Violet Blue */ -LVM = [ 204 / 255, 102 / 255, 255 / 255 ]; /* Light Violet Magenta */ -LVB = [ 153 / 255, 102 / 255, 255 / 255 ]; /* Light Violet Blue */ -MVM = [ 153 / 255, 51 / 255, 204 / 255 ]; /* Medium Violet Magenta */ -MVB = [ 102 / 255, 51 / 255, 204 / 255 ]; /* Medium Violet Blue */ -OWM = [ 51 / 255, 0 / 255, 51 / 255 ]; /* Obscure Weak Magenta */ -ODM = [ 102 / 255, 0 / 255, 102 / 255 ]; /* Obscure Dull Magenta */ -DFM = [ 153 / 255, 0 / 255, 153 / 255 ]; /* Dark Faded Magenta */ -DHM = [ 204 / 255, 0 / 255, 204 / 255 ]; /* Dark Hard Magenta */ -M = [ 255 / 255, 0 / 255, 255 / 255 ]; /* Magenta */ -DWM = [ 102 / 255, 51 / 255, 102 / 255 ]; /* Dark Weak Magenta */ -DDM = [ 153 / 255, 51 / 255, 153 / 255 ]; /* Dark Dull Magenta */ -MFM = [ 204 / 255, 51 / 255, 204 / 255 ]; /* Medium Faded Magenta */ -LHM = [ 255 / 255, 51 / 255, 255 / 255 ]; /* Light Hard Magenta */ -MWM = [ 153 / 255, 102 / 255, 153 / 255 ]; /* Medium Weak Magenta */ -LDM = [ 204 / 255, 102 / 255, 204 / 255 ]; /* Light Dull Magenta */ -LFM = [ 255 / 255, 102 / 255, 255 / 255 ]; /* Light Faded Magenta */ -LWM = [ 204 / 255, 153 / 255, 204 / 255 ]; /* Light Weak Magenta */ -PDM = [ 255 / 255, 153 / 255, 255 / 255 ]; /* Pale Dull Magenta */ -PWM = [ 255 / 255, 204 / 255, 255 / 255 ]; /* Pale Weak Magenta */ -OWR = [ 51 / 255, 0 / 255, 0 / 255 ]; /* Obscure Weak Red */ -ODR = [ 102 / 255, 0 / 255, 0 / 255 ]; /* Obscure Dull Red */ -DFR = [ 153 / 255, 0 / 255, 0 / 255 ]; /* Dark Faded Red */ -DHR = [ 204 / 255, 0 / 255, 0 / 255 ]; /* Dark Hard Red */ -R = [ 255 / 255, 0 / 255, 0 / 255 ]; /* Red */ -DWR = [ 102 / 255, 51 / 255, 51 / 255 ]; /* Dark Weak Red */ -DDR = [ 153 / 255, 51 / 255, 51 / 255 ]; /* Dark Dull Red */ -MFR = [ 204 / 255, 51 / 255, 51 / 255 ]; /* Medium Faded Red */ -LHR = [ 255 / 255, 51 / 255, 51 / 255 ]; /* Light Hard Red */ -MWR = [ 153 / 255, 102 / 255, 102 / 255 ]; /* Medium Weak Red */ -LDR = [ 204 / 255, 102 / 255, 102 / 255 ]; /* Light Dull Red */ -LFR = [ 255 / 255, 102 / 255, 102 / 255 ]; /* Light Faded Red */ -LWR = [ 204 / 255, 153 / 255, 153 / 255 ]; /* Light Weak Red */ -PDR = [ 255 / 255, 153 / 255, 153 / 255 ]; /* Pale Dull Red */ -PWR = [ 255 / 255, 204 / 255, 204 / 255 ]; /* Pale Weak Red */ -OWY = [ 51 / 255, 51 / 255, 0 / 255 ]; /* Obscure Weak Yellow */ -ODY = [ 102 / 255, 102 / 255, 0 / 255 ]; /* Obscure Dull Yellow */ -DFY = [ 153 / 255, 153 / 255, 0 / 255 ]; /* Dark Faded Yellow */ -DHY = [ 204 / 255, 204 / 255, 0 / 255 ]; /* Dark Hard Yellow */ -Y = [ 255 / 255, 255 / 255, 0 / 255 ]; /* Yellow */ -DWY = [ 102 / 255, 102 / 255, 51 / 255 ]; /* Dark Weak Yellow */ -DDY = [ 153 / 255, 153 / 255, 51 / 255 ]; /* Dark Dull Yellow */ -MFY = [ 204 / 255, 204 / 255, 51 / 255 ]; /* Medium Faded Yellow */ -LHY = [ 255 / 255, 255 / 255, 51 / 255 ]; /* Light Hard Yellow */ -MWY = [ 153 / 255, 153 / 255, 102 / 255 ]; /* Medium Weak Yellow */ -LDY = [ 204 / 255, 204 / 255, 102 / 255 ]; /* Light Dull Yellow */ -LFY = [ 255 / 255, 255 / 255, 102 / 255 ]; /* Light Faded Yellow */ -LWY = [ 204 / 255, 204 / 255, 153 / 255 ]; /* Light Weak Yellow */ -PDY = [ 255 / 255, 255 / 255, 153 / 255 ]; /* Pale Dull Yellow */ -PWY = [ 255 / 255, 255 / 255, 204 / 255 ]; /* Pale Weak Yellow */ -OWG = [ 0 / 255, 51 / 255, 0 / 255 ]; /* Obscure Weak Green */ -ODG = [ 0 / 255, 102 / 255, 0 / 255 ]; /* Obscure Dull Green */ -DFG = [ 0 / 255, 153 / 255, 0 / 255 ]; /* Dark Faded Green */ -DHG = [ 0 / 255, 204 / 255, 0 / 255 ]; /* Dark Hard Green */ -G = [ 0 / 255, 255 / 255, 0 / 255 ]; /* Green */ -DWG = [ 51 / 255, 102 / 255, 51 / 255 ]; /* Dark Weak Green */ -DDG = [ 51 / 255, 153 / 255, 51 / 255 ]; /* Dark Dull Green */ -MFG = [ 51 / 255, 204 / 255, 51 / 255 ]; /* Medium Faded Green */ -LHG = [ 51 / 255, 255 / 255, 51 / 255 ]; /* Light Hard Green */ -MWG = [ 102 / 255, 153 / 255, 102 / 255 ]; /* Medium Weak Green */ -LDG = [ 102 / 255, 204 / 255, 102 / 255 ]; /* Light Dull Green */ -LFG = [ 102 / 255, 255 / 255, 102 / 255 ]; /* Light Faded Green */ -LWG = [ 153 / 255, 204 / 255, 153 / 255 ]; /* Light Weak Green */ -PDG = [ 153 / 255, 255 / 255, 153 / 255 ]; /* Pale Dull Green */ -PWG = [ 204 / 255, 255 / 255, 204 / 255 ]; /* Pale Weak Green */ -OWC = [ 0 / 255, 51 / 255, 51 / 255 ]; /* Obscure Weak Cyan */ -ODC = [ 0 / 255, 102 / 255, 102 / 255 ]; /* Obscure Dull Cyan */ -DFC = [ 0 / 255, 153 / 255, 153 / 255 ]; /* Dark Faded Cyan */ -DHC = [ 0 / 255, 204 / 255, 204 / 255 ]; /* Dark Hard Cyan */ -C = [ 0 / 255, 255 / 255, 255 / 255 ]; /* Cyan */ -DWC = [ 51 / 255, 102 / 255, 102 / 255 ]; /* Dark Weak Cyan */ -DDC = [ 51 / 255, 153 / 255, 153 / 255 ]; /* Dark Dull Cyan */ -MFC = [ 51 / 255, 204 / 255, 204 / 255 ]; /* Medium Faded Cyan */ -LHC = [ 51 / 255, 255 / 255, 255 / 255 ]; /* Light Hard Cyan */ -MWC = [ 102 / 255, 153 / 255, 153 / 255 ]; /* Medium Weak Cyan */ -LDC = [ 102 / 255, 204 / 255, 204 / 255 ]; /* Light Dull Cyan */ -LFC = [ 102 / 255, 255 / 255, 255 / 255 ]; /* Light Faded Cyan */ -LWC = [ 153 / 255, 204 / 255, 204 / 255 ]; /* Light Weak Cyan */ -PDC = [ 153 / 255, 255 / 255, 255 / 255 ]; /* Pale Dull Cyan */ -PWC = [ 204 / 255, 255 / 255, 255 / 255 ]; /* Pale Weak Cyan */ -OWB = [ 0 / 255, 0 / 255, 51 / 255 ]; /* Obscure Weak Blue */ -ODB = [ 0 / 255, 0 / 255, 102 / 255 ]; /* Obscure Dull Blue */ -DFB = [ 0 / 255, 0 / 255, 153 / 255 ]; /* Dark Faded Blue */ -DHB = [ 0 / 255, 0 / 255, 204 / 255 ]; /* Dark Hard Blue */ -B = [ 0 / 255, 0 / 255, 255 / 255 ]; /* Blue */ -DWB = [ 51 / 255, 51 / 255, 102 / 255 ]; /* Dark Weak Blue */ -DDB = [ 51 / 255, 51 / 255, 153 / 255 ]; /* Dark Dull Blue */ -MFB = [ 51 / 255, 51 / 255, 204 / 255 ]; /* Medium Faded Blue */ -LHB = [ 51 / 255, 51 / 255, 255 / 255 ]; /* Light Hard Blue */ -MWB = [ 102 / 255, 102 / 255, 153 / 255 ]; /* Medium Weak Blue */ -LDB = [ 102 / 255, 102 / 255, 204 / 255 ]; /* Light Dull Blue */ -LFB = [ 102 / 255, 102 / 255, 255 / 255 ]; /* Light Faded Blue */ -LWB = [ 153 / 255, 153 / 255, 204 / 255 ]; /* Light Weak Blue */ -PDB = [ 153 / 255, 153 / 255, 255 / 255 ]; /* Pale Dull Blue */ -PWB = [ 204 / 255, 204 / 255, 255 / 255 ]; /* Pale Weak Blue */ -ODP = [ 102 / 255, 0 / 255, 51 / 255 ]; /* Obscure Dull Pink */ -DDP = [ 153 / 255, 51 / 255, 102 / 255 ]; /* Dark Dull Pink */ -LDP = [ 204 / 255, 102 / 255, 153 / 255 ]; /* Light Dull Pink */ -PDP = [ 255 / 255, 153 / 255, 204 / 255 ]; /* Pale Dull Pink */ -DHP = [ 204 / 255, 0 / 255, 102 / 255 ]; /* Dark Hard Pink */ -LHP = [ 255 / 255, 51 / 255, 153 / 255 ]; /* Light Hard Pink */ -ODO = [ 102 / 255, 51 / 255, 0 / 255 ]; /* Obscure Dull Orange */ -DDO = [ 153 / 255, 102 / 255, 51 / 255 ]; /* Dark Dull Orange */ -LDO = [ 204 / 255, 153 / 255, 102 / 255 ]; /* Light Dull Orange */ -PDO = [ 255 / 255, 204 / 255, 153 / 255 ]; /* Pale Dull Orange */ -DHO = [ 204 / 255, 102 / 255, 0 / 255 ]; /* Dark Hard Orange */ -LHO = [ 255 / 255, 153 / 255, 51 / 255 ]; /* Light Hard Orange */ -ODS = [ 51 / 255, 102 / 255, 0 / 255 ]; /* Obscure Dull Spring */ -DDS = [ 102 / 255, 153 / 255, 51 / 255 ]; /* Dark Dull Spring */ -LDS = [ 153 / 255, 204 / 255, 102 / 255 ]; /* Light Dull Spring */ -PDS = [ 204 / 255, 255 / 255, 153 / 255 ]; /* Pale Dull Spring */ -DHS = [ 102 / 255, 204 / 255, 0 / 255 ]; /* Dark Hard Spring */ -LHS = [ 153 / 255, 255 / 255, 51 / 255 ]; /* Light Hard Spring */ -ODT = [ 0 / 255, 102 / 255, 51 / 255 ]; /* Obscure Dull Teal */ -DDT = [ 51 / 255, 153 / 255, 102 / 255 ]; /* Dark Dull Teal */ -LDT = [ 102 / 255, 204 / 255, 153 / 255 ]; /* Light Dull Teal */ -PDT = [ 153 / 255, 255 / 255, 204 / 255 ]; /* Pale Dull Teal */ -DHT = [ 0 / 255, 204 / 255, 102 / 255 ]; /* Dark Hard Teal */ -LHT = [ 51 / 255, 255 / 255, 153 / 255 ]; /* Light Hard Teal */ -ODA = [ 0 / 255, 51 / 255, 102 / 255 ]; /* Obscure Dull Azure */ -DDA = [ 51 / 255, 102 / 255, 153 / 255 ]; /* Dark Dull Azure */ -LDA = [ 102 / 255, 153 / 255, 204 / 255 ]; /* Light Dull Azure */ -PDA = [ 153 / 255, 204 / 255, 255 / 255 ]; /* Pale Dull Azure */ -DHA = [ 0 / 255, 102 / 255, 204 / 255 ]; /* Dark Hard Azure */ -LHA = [ 51 / 255, 153 / 255, 255 / 255 ]; /* Light Hard Azure */ -ODV = [ 51 / 255, 0 / 255, 102 / 255 ]; /* Obscure Dull Violet */ -DDV = [ 102 / 255, 51 / 255, 153 / 255 ]; /* Dark Dull Violet */ -LDV = [ 153 / 255, 102 / 255, 204 / 255 ]; /* Light Dull Violet */ -PDV = [ 204 / 255, 153 / 255, 255 / 255 ]; /* Pale Dull Violet */ -DHV = [ 102 / 255, 0 / 255, 204 / 255 ]; /* Dark Hard Violet */ -LHV = [ 153 / 255, 51 / 255, 255 / 255 ]; /* Light Hard Violet */ -K = [ 0 / 255, 0 / 255, 0 / 255 ]; /* Black */ -OG = [ 51 / 255, 51 / 255, 51 / 255 ]; /* Obscure Gray */ -DG = [ 102 / 255, 102 / 255, 102 / 255 ]; /* Dark Gray */ -LG = [ 153 / 255, 153 / 255, 153 / 255 ]; /* Light Gray */ -PG = [ 204 / 255, 204 / 255, 204 / 255 ]; /* Pale Gray */ -W = [ 255 / 255, 255 / 255, 255 / 255 ]; /* White */ +PPR = [255/255, 0/255, 102/255]; /* Pink Pink Red */ +PPM = [255/255, 0/255, 153/255]; /* Pink Pink Magenta */ +RRP = [255/255, 0/255, 51/255]; /* Red Red Pink */ +MMP = [255/255, 0/255, 204/255]; /* Magenta Magenta Pink */ +DRP = [204/255, 0/255, 51/255]; /* Dark Red Pink */ +DMP = [204/255, 0/255, 153/255]; /* Dark Magenta Pink */ +LRP = [255/255, 51/255, 102/255]; /* Light Red Pink */ +LMP = [255/255, 51/255, 204/255]; /* Light Magenta Pink */ +DPR = [153/255, 0/255, 51/255]; /* Dark Pink Red */ +DPM = [153/255, 0/255, 102/255]; /* Dark Pink Magenta */ +LPR = [255/255, 102/255, 153/255]; /* Light Pink Red */ +LPM = [255/255, 102/255, 204/255]; /* Light Pink Magenta */ +MPR = [204/255, 51/255, 102/255]; /* Medium Pink Red */ +MPM = [204/255, 51/255, 153/255]; /* Medium Pink Magenta */ +OOY = [255/255, 153/255, 0/255]; /* Orange Orange Yellow */ +OOR = [255/255, 102/255, 0/255]; /* Orange Orange Red */ +YYO = [255/255, 204/255, 0/255]; /* Yellow Yellow Orange */ +RRO = [255/255, 51/255, 0/255]; /* Red Red Orange */ +DYO = [204/255, 153/255, 0/255]; /* Dark Yellow Orange */ +DRO = [204/255, 51/255, 0/255]; /* Dark Red Orange */ +LYO = [255/255, 204/255, 51/255]; /* Light Yellow Orange */ +LRO = [255/255, 102/255, 51/255]; /* Light Red Orange */ +DOY = [153/255, 102/255, 0/255]; /* Dark Orange Yellow */ +DOR = [153/255, 51/255, 0/255]; /* Dark Orange Red */ +LOY = [255/255, 204/255, 102/255]; /* Light Orange Yellow */ +LOR = [255/255, 153/255, 102/255]; /* Light Orange Red */ +MOY = [204/255, 153/255, 51/255]; /* Medium Orange Yellow */ +MOR = [204/255, 102/255, 51/255]; /* Medium Orange Red */ +SSG = [102/255, 255/255, 0/255]; /* Spring Spring Green */ +SSY = [153/255, 255/255, 0/255]; /* Spring Spring Yellow */ +GGS = [ 51/255, 255/255, 0/255]; /* Green Green Spring */ +YYS = [204/255, 255/255, 0/255]; /* Yellow Yellow Spring */ +DGS = [ 51/255, 204/255, 0/255]; /* Dark Green Spring */ +DYS = [153/255, 204/255, 0/255]; /* Dark Yellow Spring */ +LGS = [102/255, 255/255, 51/255]; /* Light Green Spring */ +LYS = [204/255, 255/255, 51/255]; /* Light Yellow Spring */ +DSG = [ 51/255, 153/255, 0/255]; /* Dark Spring Green */ +DSY = [102/255, 153/255, 0/255]; /* Dark Spring Yellow */ +LSG = [153/255, 255/255, 102/255]; /* Light Spring Green */ +LSY = [204/255, 255/255, 102/255]; /* Light Spring Yellow */ +MSG = [102/255, 204/255, 51/255]; /* Medium Spring Green */ +MSY = [153/255, 204/255, 51/255]; /* Medium Spring Yellow */ +TTC = [ 0/255, 255/255, 153/255]; /* Teal Teal Cyan */ +TTG = [ 0/255, 255/255, 102/255]; /* Teal Teal Green */ +CCT = [ 0/255, 255/255, 204/255]; /* Cyan Cyan Teal */ +GGT = [ 0/255, 255/255, 51/255]; /* Green Green Teal */ +DCT = [ 0/255, 204/255, 153/255]; /* Dark Cyan Teal */ +DGT = [ 0/255, 204/255, 51/255]; /* Dark Green Teal */ +LCT = [ 51/255, 255/255, 204/255]; /* Light Cyan Teal */ +LGT = [ 51/255, 255/255, 102/255]; /* Light Green Teal */ +DTC = [ 0/255, 153/255, 102/255]; /* Dark Teal Cyan */ +DTG = [ 0/255, 153/255, 51/255]; /* Dark Teal Green */ +LTC = [102/255, 255/255, 204/255]; /* Light Teal Cyan */ +LTG = [102/255, 255/255, 153/255]; /* Light Teal Green */ +MTC = [ 51/255, 204/255, 153/255]; /* Medium Teal Cyan */ +MTG = [ 51/255, 204/255, 102/255]; /* Medium Teal Green */ +AAB = [ 0/255, 102/255, 255/255]; /* Azure Azure Blue */ +AAC = [ 0/255, 153/255, 255/255]; /* Azure Azure Cyan */ +BBA = [ 0/255, 51/255, 255/255]; /* Blue Blue Azure */ +CCA = [ 0/255, 204/255, 255/255]; /* Cyan Cyan Azure */ +DBA = [ 0/255, 51/255, 204/255]; /* Dark Blue Azure */ +DCA = [ 0/255, 153/255, 204/255]; /* Dark Cyan Azure */ +LBA = [ 51/255, 102/255, 255/255]; /* Light Blue Azure */ +LCA = [ 51/255, 204/255, 255/255]; /* Light Cyan Azure */ +DAB = [ 0/255, 51/255, 153/255]; /* Dark Azure Blue */ +DAC = [ 0/255, 102/255, 153/255]; /* Dark Azure Cyan */ +LAB = [102/255, 153/255, 255/255]; /* Light Azure Blue */ +LAC = [102/255, 204/255, 255/255]; /* Light Azure Cyan */ +MAB = [ 51/255, 102/255, 204/255]; /* Medium Azure Blue */ +MAC = [ 51/255, 153/255, 204/255]; /* Medium Azure Cyan */ +VVM = [153/255, 0/255, 255/255]; /* Violet Violet Magenta */ +VVB = [102/255, 0/255, 255/255]; /* Violet Violet Blue */ +MMV = [204/255, 0/255, 255/255]; /* Magenta Magenta Violet */ +BBV = [ 51/255, 0/255, 255/255]; /* Blue Blue Violet */ +DMV = [153/255, 0/255, 204/255]; /* Dark Magenta Violet */ +DBV = [ 51/255, 0/255, 204/255]; /* Dark Blue Violet */ +LMV = [204/255, 51/255, 255/255]; /* Light Magenta Violet */ +LBV = [102/255, 51/255, 255/255]; /* Light Blue Violet */ +DVM = [102/255, 0/255, 153/255]; /* Dark Violet Magenta */ +DVB = [ 51/255, 0/255, 153/255]; /* Dark Violet Blue */ +LVM = [204/255, 102/255, 255/255]; /* Light Violet Magenta */ +LVB = [153/255, 102/255, 255/255]; /* Light Violet Blue */ +MVM = [153/255, 51/255, 204/255]; /* Medium Violet Magenta */ +MVB = [102/255, 51/255, 204/255]; /* Medium Violet Blue */ +OWM = [ 51/255, 0/255, 51/255]; /* Obscure Weak Magenta */ +ODM = [102/255, 0/255, 102/255]; /* Obscure Dull Magenta */ +DFM = [153/255, 0/255, 153/255]; /* Dark Faded Magenta */ +DHM = [204/255, 0/255, 204/255]; /* Dark Hard Magenta */ +M = [255/255, 0/255, 255/255]; /* Magenta */ +DWM = [102/255, 51/255, 102/255]; /* Dark Weak Magenta */ +DDM = [153/255, 51/255, 153/255]; /* Dark Dull Magenta */ +MFM = [204/255, 51/255, 204/255]; /* Medium Faded Magenta */ +LHM = [255/255, 51/255, 255/255]; /* Light Hard Magenta */ +MWM = [153/255, 102/255, 153/255]; /* Medium Weak Magenta */ +LDM = [204/255, 102/255, 204/255]; /* Light Dull Magenta */ +LFM = [255/255, 102/255, 255/255]; /* Light Faded Magenta */ +LWM = [204/255, 153/255, 204/255]; /* Light Weak Magenta */ +PDM = [255/255, 153/255, 255/255]; /* Pale Dull Magenta */ +PWM = [255/255, 204/255, 255/255]; /* Pale Weak Magenta */ +OWR = [ 51/255, 0/255, 0/255]; /* Obscure Weak Red */ +ODR = [102/255, 0/255, 0/255]; /* Obscure Dull Red */ +DFR = [153/255, 0/255, 0/255]; /* Dark Faded Red */ +DHR = [204/255, 0/255, 0/255]; /* Dark Hard Red */ +R = [255/255, 0/255, 0/255]; /* Red */ +DWR = [102/255, 51/255, 51/255]; /* Dark Weak Red */ +DDR = [153/255, 51/255, 51/255]; /* Dark Dull Red */ +MFR = [204/255, 51/255, 51/255]; /* Medium Faded Red */ +LHR = [255/255, 51/255, 51/255]; /* Light Hard Red */ +MWR = [153/255, 102/255, 102/255]; /* Medium Weak Red */ +LDR = [204/255, 102/255, 102/255]; /* Light Dull Red */ +LFR = [255/255, 102/255, 102/255]; /* Light Faded Red */ +LWR = [204/255, 153/255, 153/255]; /* Light Weak Red */ +PDR = [255/255, 153/255, 153/255]; /* Pale Dull Red */ +PWR = [255/255, 204/255, 204/255]; /* Pale Weak Red */ +OWY = [ 51/255, 51/255, 0/255]; /* Obscure Weak Yellow */ +ODY = [102/255, 102/255, 0/255]; /* Obscure Dull Yellow */ +DFY = [153/255, 153/255, 0/255]; /* Dark Faded Yellow */ +DHY = [204/255, 204/255, 0/255]; /* Dark Hard Yellow */ +Y = [255/255, 255/255, 0/255]; /* Yellow */ +DWY = [102/255, 102/255, 51/255]; /* Dark Weak Yellow */ +DDY = [153/255, 153/255, 51/255]; /* Dark Dull Yellow */ +MFY = [204/255, 204/255, 51/255]; /* Medium Faded Yellow */ +LHY = [255/255, 255/255, 51/255]; /* Light Hard Yellow */ +MWY = [153/255, 153/255, 102/255]; /* Medium Weak Yellow */ +LDY = [204/255, 204/255, 102/255]; /* Light Dull Yellow */ +LFY = [255/255, 255/255, 102/255]; /* Light Faded Yellow */ +LWY = [204/255, 204/255, 153/255]; /* Light Weak Yellow */ +PDY = [255/255, 255/255, 153/255]; /* Pale Dull Yellow */ +PWY = [255/255, 255/255, 204/255]; /* Pale Weak Yellow */ +OWG = [ 0/255, 51/255, 0/255]; /* Obscure Weak Green */ +ODG = [ 0/255, 102/255, 0/255]; /* Obscure Dull Green */ +DFG = [ 0/255, 153/255, 0/255]; /* Dark Faded Green */ +DHG = [ 0/255, 204/255, 0/255]; /* Dark Hard Green */ +G = [ 0/255, 255/255, 0/255]; /* Green */ +DWG = [ 51/255, 102/255, 51/255]; /* Dark Weak Green */ +DDG = [ 51/255, 153/255, 51/255]; /* Dark Dull Green */ +MFG = [ 51/255, 204/255, 51/255]; /* Medium Faded Green */ +LHG = [ 51/255, 255/255, 51/255]; /* Light Hard Green */ +MWG = [102/255, 153/255, 102/255]; /* Medium Weak Green */ +LDG = [102/255, 204/255, 102/255]; /* Light Dull Green */ +LFG = [102/255, 255/255, 102/255]; /* Light Faded Green */ +LWG = [153/255, 204/255, 153/255]; /* Light Weak Green */ +PDG = [153/255, 255/255, 153/255]; /* Pale Dull Green */ +PWG = [204/255, 255/255, 204/255]; /* Pale Weak Green */ +OWC = [ 0/255, 51/255, 51/255]; /* Obscure Weak Cyan */ +ODC = [ 0/255, 102/255, 102/255]; /* Obscure Dull Cyan */ +DFC = [ 0/255, 153/255, 153/255]; /* Dark Faded Cyan */ +DHC = [ 0/255, 204/255, 204/255]; /* Dark Hard Cyan */ +C = [ 0/255, 255/255, 255/255]; /* Cyan */ +DWC = [ 51/255, 102/255, 102/255]; /* Dark Weak Cyan */ +DDC = [ 51/255, 153/255, 153/255]; /* Dark Dull Cyan */ +MFC = [ 51/255, 204/255, 204/255]; /* Medium Faded Cyan */ +LHC = [ 51/255, 255/255, 255/255]; /* Light Hard Cyan */ +MWC = [102/255, 153/255, 153/255]; /* Medium Weak Cyan */ +LDC = [102/255, 204/255, 204/255]; /* Light Dull Cyan */ +LFC = [102/255, 255/255, 255/255]; /* Light Faded Cyan */ +LWC = [153/255, 204/255, 204/255]; /* Light Weak Cyan */ +PDC = [153/255, 255/255, 255/255]; /* Pale Dull Cyan */ +PWC = [204/255, 255/255, 255/255]; /* Pale Weak Cyan */ +OWB = [ 0/255, 0/255, 51/255]; /* Obscure Weak Blue */ +ODB = [ 0/255, 0/255, 102/255]; /* Obscure Dull Blue */ +DFB = [ 0/255, 0/255, 153/255]; /* Dark Faded Blue */ +DHB = [ 0/255, 0/255, 204/255]; /* Dark Hard Blue */ +B = [ 0/255, 0/255, 255/255]; /* Blue */ +DWB = [ 51/255, 51/255, 102/255]; /* Dark Weak Blue */ +DDB = [ 51/255, 51/255, 153/255]; /* Dark Dull Blue */ +MFB = [ 51/255, 51/255, 204/255]; /* Medium Faded Blue */ +LHB = [ 51/255, 51/255, 255/255]; /* Light Hard Blue */ +MWB = [102/255, 102/255, 153/255]; /* Medium Weak Blue */ +LDB = [102/255, 102/255, 204/255]; /* Light Dull Blue */ +LFB = [102/255, 102/255, 255/255]; /* Light Faded Blue */ +LWB = [153/255, 153/255, 204/255]; /* Light Weak Blue */ +PDB = [153/255, 153/255, 255/255]; /* Pale Dull Blue */ +PWB = [204/255, 204/255, 255/255]; /* Pale Weak Blue */ +ODP = [102/255, 0/255, 51/255]; /* Obscure Dull Pink */ +DDP = [153/255, 51/255, 102/255]; /* Dark Dull Pink */ +LDP = [204/255, 102/255, 153/255]; /* Light Dull Pink */ +PDP = [255/255, 153/255, 204/255]; /* Pale Dull Pink */ +DHP = [204/255, 0/255, 102/255]; /* Dark Hard Pink */ +LHP = [255/255, 51/255, 153/255]; /* Light Hard Pink */ +ODO = [102/255, 51/255, 0/255]; /* Obscure Dull Orange */ +DDO = [153/255, 102/255, 51/255]; /* Dark Dull Orange */ +LDO = [204/255, 153/255, 102/255]; /* Light Dull Orange */ +PDO = [255/255, 204/255, 153/255]; /* Pale Dull Orange */ +DHO = [204/255, 102/255, 0/255]; /* Dark Hard Orange */ +LHO = [255/255, 153/255, 51/255]; /* Light Hard Orange */ +ODS = [ 51/255, 102/255, 0/255]; /* Obscure Dull Spring */ +DDS = [102/255, 153/255, 51/255]; /* Dark Dull Spring */ +LDS = [153/255, 204/255, 102/255]; /* Light Dull Spring */ +PDS = [204/255, 255/255, 153/255]; /* Pale Dull Spring */ +DHS = [102/255, 204/255, 0/255]; /* Dark Hard Spring */ +LHS = [153/255, 255/255, 51/255]; /* Light Hard Spring */ +ODT = [ 0/255, 102/255, 51/255]; /* Obscure Dull Teal */ +DDT = [ 51/255, 153/255, 102/255]; /* Dark Dull Teal */ +LDT = [102/255, 204/255, 153/255]; /* Light Dull Teal */ +PDT = [153/255, 255/255, 204/255]; /* Pale Dull Teal */ +DHT = [ 0/255, 204/255, 102/255]; /* Dark Hard Teal */ +LHT = [ 51/255, 255/255, 153/255]; /* Light Hard Teal */ +ODA = [ 0/255, 51/255, 102/255]; /* Obscure Dull Azure */ +DDA = [ 51/255, 102/255, 153/255]; /* Dark Dull Azure */ +LDA = [102/255, 153/255, 204/255]; /* Light Dull Azure */ +PDA = [153/255, 204/255, 255/255]; /* Pale Dull Azure */ +DHA = [ 0/255, 102/255, 204/255]; /* Dark Hard Azure */ +LHA = [ 51/255, 153/255, 255/255]; /* Light Hard Azure */ +ODV = [ 51/255, 0/255, 102/255]; /* Obscure Dull Violet */ +DDV = [102/255, 51/255, 153/255]; /* Dark Dull Violet */ +LDV = [153/255, 102/255, 204/255]; /* Light Dull Violet */ +PDV = [204/255, 153/255, 255/255]; /* Pale Dull Violet */ +DHV = [102/255, 0/255, 204/255]; /* Dark Hard Violet */ +LHV = [153/255, 51/255, 255/255]; /* Light Hard Violet */ +K = [ 0/255, 0/255, 0/255]; /* Black */ +OG = [ 51/255, 51/255, 51/255]; /* Obscure Gray */ +DG = [102/255, 102/255, 102/255]; /* Dark Gray */ +LG = [153/255, 153/255, 153/255]; /* Light Gray */ +PG = [204/255, 204/255, 204/255]; /* Pale Gray */ +W = [255/255, 255/255, 255/255]; /* White */ -module -colorshelp() +module colorshelp() { - echo("--- visibonecolorshelp ---"); - echo("color(PPR); /* Pink Pink Red */"); - echo("color(PPM); /* Pink Pink Magenta */"); - echo("color(RRP); /* Red Red Pink */"); - echo("color(MMP); /* Magenta Magenta Pink */"); - echo("color(DRP); /* Dark Red Pink */"); - echo("color(DMP); /* Dark Magenta Pink */"); - echo("color(LRP); /* Light Red Pink */"); - echo("color(LMP); /* Light Magenta Pink */"); - echo("color(DPR); /* Dark Pink Red */"); - echo("color(DPM); /* Dark Pink Magenta */"); - echo("color(LPR); /* Light Pink Red */"); - echo("color(LPM); /* Light Pink Magenta */"); - echo("color(MPR); /* Medium Pink Red */"); - echo("color(MPM); /* Medium Pink Magenta */"); - echo("color(OOY); /* Orange Orange Yellow */"); - echo("color(OOR); /* Orange Orange Red */"); - echo("color(YYO); /* Yellow Yellow Orange */"); - echo("color(RRO); /* Red Red Orange */"); - echo("color(DYO); /* Dark Yellow Orange */"); - echo("color(DRO); /* Dark Red Orange */"); - echo("color(LYO); /* Light Yellow Orange */"); - echo("color(LRO); /* Light Red Orange */"); - echo("color(DOY); /* Dark Orange Yellow */"); - echo("color(DOR); /* Dark Orange Red */"); - echo("color(LOY); /* Light Orange Yellow */"); - echo("color(LOR); /* Light Orange Red */"); - echo("color(MOY); /* Medium Orange Yellow */"); - echo("color(MOR); /* Medium Orange Red */"); - echo("color(SSG); /* Spring Spring Green */"); - echo("color(SSY); /* Spring Spring Yellow */"); - echo("color(GGS); /* Green Green Spring */"); - echo("color(YYS); /* Yellow Yellow Spring */"); - echo("color(DGS); /* Dark Green Spring */"); - echo("color(DYS); /* Dark Yellow Spring */"); - echo("color(LGS); /* Light Green Spring */"); - echo("color(LYS); /* Light Yellow Spring */"); - echo("color(DSG); /* Dark Spring Green */"); - echo("color(DSY); /* Dark Spring Yellow */"); - echo("color(LSG); /* Light Spring Green */"); - echo("color(LSY); /* Light Spring Yellow */"); - echo("color(MSG); /* Medium Spring Green */"); - echo("color(MSY); /* Medium Spring Yellow */"); - echo("color(TTC); /* Teal Teal Cyan */"); - echo("color(TTG); /* Teal Teal Green */"); - echo("color(CCT); /* Cyan Cyan Teal */"); - echo("color(GGT); /* Green Green Teal */"); - echo("color(DCT); /* Dark Cyan Teal */"); - echo("color(DGT); /* Dark Green Teal */"); - echo("color(LCT); /* Light Cyan Teal */"); - echo("color(LGT); /* Light Green Teal */"); - echo("color(DTC); /* Dark Teal Cyan */"); - echo("color(DTG); /* Dark Teal Green */"); - echo("color(LTC); /* Light Teal Cyan */"); - echo("color(LTG); /* Light Teal Green */"); - echo("color(MTC); /* Medium Teal Cyan */"); - echo("color(MTG); /* Medium Teal Green */"); - echo("color(AAB); /* Azure Azure Blue */"); - echo("color(AAC); /* Azure Azure Cyan */"); - echo("color(BBA); /* Blue Blue Azure */"); - echo("color(CCA); /* Cyan Cyan Azure */"); - echo("color(DBA); /* Dark Blue Azure */"); - echo("color(DCA); /* Dark Cyan Azure */"); - echo("color(LBA); /* Light Blue Azure */"); - echo("color(LCA); /* Light Cyan Azure */"); - echo("color(DAB); /* Dark Azure Blue */"); - echo("color(DAC); /* Dark Azure Cyan */"); - echo("color(LAB); /* Light Azure Blue */"); - echo("color(LAC); /* Light Azure Cyan */"); - echo("color(MAB); /* Medium Azure Blue */"); - echo("color(MAC); /* Medium Azure Cyan */"); - echo("color(VVM); /* Violet Violet Magenta */"); - echo("color(VVB); /* Violet Violet Blue */"); - echo("color(MMV); /* Magenta Magenta Violet */"); - echo("color(BBV); /* Blue Blue Violet */"); - echo("color(DMV); /* Dark Magenta Violet */"); - echo("color(DBV); /* Dark Blue Violet */"); - echo("color(LMV); /* Light Magenta Violet */"); - echo("color(LBV); /* Light Blue Violet */"); - echo("color(DVM); /* Dark Violet Magenta */"); - echo("color(DVB); /* Dark Violet Blue */"); - echo("color(LVM); /* Light Violet Magenta */"); - echo("color(LVB); /* Light Violet Blue */"); - echo("color(MVM); /* Medium Violet Magenta */"); - echo("color(MVB); /* Medium Violet Blue */"); - echo("color(OWM); /* Obscure Weak Magenta */"); - echo("color(ODM); /* Obscure Dull Magenta */"); - echo("color(DFM); /* Dark Faded Magenta */"); - echo("color(DHM); /* Dark Hard Magenta */"); - echo("color(M); /* Magenta */"); - echo("color(DWM); /* Dark Weak Magenta */"); - echo("color(DDM); /* Dark Dull Magenta */"); - echo("color(MFM); /* Medium Faded Magenta */"); - echo("color(LHM); /* Light Hard Magenta */"); - echo("color(MWM); /* Medium Weak Magenta */"); - echo("color(LDM); /* Light Dull Magenta */"); - echo("color(LFM); /* Light Faded Magenta */"); - echo("color(LWM); /* Light Weak Magenta */"); - echo("color(PDM); /* Pale Dull Magenta */"); - echo("color(PWM); /* Pale Weak Magenta */"); - echo("color(OWR); /* Obscure Weak Red */"); - echo("color(ODR); /* Obscure Dull Red */"); - echo("color(DFR); /* Dark Faded Red */"); - echo("color(DHR); /* Dark Hard Red */"); - echo("color(R); /* Red */"); - echo("color(DWR); /* Dark Weak Red */"); - echo("color(DDR); /* Dark Dull Red */"); - echo("color(MFR); /* Medium Faded Red */"); - echo("color(LHR); /* Light Hard Red */"); - echo("color(MWR); /* Medium Weak Red */"); - echo("color(LDR); /* Light Dull Red */"); - echo("color(LFR); /* Light Faded Red */"); - echo("color(LWR); /* Light Weak Red */"); - echo("color(PDR); /* Pale Dull Red */"); - echo("color(PWR); /* Pale Weak Red */"); - echo("color(OWY); /* Obscure Weak Yellow */"); - echo("color(ODY); /* Obscure Dull Yellow */"); - echo("color(DFY); /* Dark Faded Yellow */"); - echo("color(DHY); /* Dark Hard Yellow */"); - echo("color(Y); /* Yellow */"); - echo("color(DWY); /* Dark Weak Yellow */"); - echo("color(DDY); /* Dark Dull Yellow */"); - echo("color(MFY); /* Medium Faded Yellow */"); - echo("color(LHY); /* Light Hard Yellow */"); - echo("color(MWY); /* Medium Weak Yellow */"); - echo("color(LDY); /* Light Dull Yellow */"); - echo("color(LFY); /* Light Faded Yellow */"); - echo("color(LWY); /* Light Weak Yellow */"); - echo("color(PDY); /* Pale Dull Yellow */"); - echo("color(PWY); /* Pale Weak Yellow */"); - echo("color(OWG); /* Obscure Weak Green */"); - echo("color(ODG); /* Obscure Dull Green */"); - echo("color(DFG); /* Dark Faded Green */"); - echo("color(DHG); /* Dark Hard Green */"); - echo("color(G); /* Green */"); - echo("color(DWG); /* Dark Weak Green */"); - echo("color(DDG); /* Dark Dull Green */"); - echo("color(MFG); /* Medium Faded Green */"); - echo("color(LHG); /* Light Hard Green */"); - echo("color(MWG); /* Medium Weak Green */"); - echo("color(LDG); /* Light Dull Green */"); - echo("color(LFG); /* Light Faded Green */"); - echo("color(LWG); /* Light Weak Green */"); - echo("color(PDG); /* Pale Dull Green */"); - echo("color(PWG); /* Pale Weak Green */"); - echo("color(OWC); /* Obscure Weak Cyan */"); - echo("color(ODC); /* Obscure Dull Cyan */"); - echo("color(DFC); /* Dark Faded Cyan */"); - echo("color(DHC); /* Dark Hard Cyan */"); - echo("color(C); /* Cyan */"); - echo("color(DWC); /* Dark Weak Cyan */"); - echo("color(DDC); /* Dark Dull Cyan */"); - echo("color(MFC); /* Medium Faded Cyan */"); - echo("color(LHC); /* Light Hard Cyan */"); - echo("color(MWC); /* Medium Weak Cyan */"); - echo("color(LDC); /* Light Dull Cyan */"); - echo("color(LFC); /* Light Faded Cyan */"); - echo("color(LWC); /* Light Weak Cyan */"); - echo("color(PDC); /* Pale Dull Cyan */"); - echo("color(PWC); /* Pale Weak Cyan */"); - echo("color(OWB); /* Obscure Weak Blue */"); - echo("color(ODB); /* Obscure Dull Blue */"); - echo("color(DFB); /* Dark Faded Blue */"); - echo("color(DHB); /* Dark Hard Blue */"); - echo("color(B); /* Blue */"); - echo("color(DWB); /* Dark Weak Blue */"); - echo("color(DDB); /* Dark Dull Blue */"); - echo("color(MFB); /* Medium Faded Blue */"); - echo("color(LHB); /* Light Hard Blue */"); - echo("color(MWB); /* Medium Weak Blue */"); - echo("color(LDB); /* Light Dull Blue */"); - echo("color(LFB); /* Light Faded Blue */"); - echo("color(LWB); /* Light Weak Blue */"); - echo("color(PDB); /* Pale Dull Blue */"); - echo("color(PWB); /* Pale Weak Blue */"); - echo("color(ODP); /* Obscure Dull Pink */"); - echo("color(DDP); /* Dark Dull Pink */"); - echo("color(LDP); /* Light Dull Pink */"); - echo("color(PDP); /* Pale Dull Pink */"); - echo("color(DHP); /* Dark Hard Pink */"); - echo("color(LHP); /* Light Hard Pink */"); - echo("color(ODO); /* Obscure Dull Orange */"); - echo("color(DDO); /* Dark Dull Orange */"); - echo("color(LDO); /* Light Dull Orange */"); - echo("color(PDO); /* Pale Dull Orange */"); - echo("color(DHO); /* Dark Hard Orange */"); - echo("color(LHO); /* Light Hard Orange */"); - echo("color(ODS); /* Obscure Dull Spring */"); - echo("color(DDS); /* Dark Dull Spring */"); - echo("color(LDS); /* Light Dull Spring */"); - echo("color(PDS); /* Pale Dull Spring */"); - echo("color(DHS); /* Dark Hard Spring */"); - echo("color(LHS); /* Light Hard Spring */"); - echo("color(ODT); /* Obscure Dull Teal */"); - echo("color(DDT); /* Dark Dull Teal */"); - echo("color(LDT); ,/* Light Dull Teal */"); - echo("color(PDT); /* Pale Dull Teal */"); - echo("color(DHT); /* Dark Hard Teal */"); - echo("color(LHT); /* Light Hard Teal */"); - echo("color(ODA); /* Obscure Dull Azure */"); - echo("color(DDA); /* Dark Dull Azure */"); - echo("color(LDA); /* Light Dull Azure */"); - echo("color(PDA); /* Pale Dull Azure */"); - echo("color(DHA); /* Dark Hard Azure */"); - echo("color(LHA); /* Light Hard Azure */"); - echo("color(ODV); /* Obscure Dull Violet */"); - echo("color(DDV); /* Dark Dull Violet */"); - echo("color(LDV); /* Light Dull Violet */"); - echo("color(PDV); /* Pale Dull Violet */"); - echo("color(DHV); /* Dark Hard Violet */"); - echo("color(LHV); /* Light Hard Violet */"); - echo("color(K); /* Black */"); - echo("color(OG); /* Obscure Gray */"); - echo("color(DG); /* Dark Gray */"); - echo("color(LG); /* Light Gray */"); - echo("color(PG); /* Pale Gray */"); - echo("color(W); /* White */"); + echo("--- visibonecolorshelp ---"); + echo("color(PPR); /* Pink Pink Red */"); + echo("color(PPM); /* Pink Pink Magenta */"); + echo("color(RRP); /* Red Red Pink */"); + echo("color(MMP); /* Magenta Magenta Pink */"); + echo("color(DRP); /* Dark Red Pink */"); + echo("color(DMP); /* Dark Magenta Pink */"); + echo("color(LRP); /* Light Red Pink */"); + echo("color(LMP); /* Light Magenta Pink */"); + echo("color(DPR); /* Dark Pink Red */"); + echo("color(DPM); /* Dark Pink Magenta */"); + echo("color(LPR); /* Light Pink Red */"); + echo("color(LPM); /* Light Pink Magenta */"); + echo("color(MPR); /* Medium Pink Red */"); + echo("color(MPM); /* Medium Pink Magenta */"); + echo("color(OOY); /* Orange Orange Yellow */"); + echo("color(OOR); /* Orange Orange Red */"); + echo("color(YYO); /* Yellow Yellow Orange */"); + echo("color(RRO); /* Red Red Orange */"); + echo("color(DYO); /* Dark Yellow Orange */"); + echo("color(DRO); /* Dark Red Orange */"); + echo("color(LYO); /* Light Yellow Orange */"); + echo("color(LRO); /* Light Red Orange */"); + echo("color(DOY); /* Dark Orange Yellow */"); + echo("color(DOR); /* Dark Orange Red */"); + echo("color(LOY); /* Light Orange Yellow */"); + echo("color(LOR); /* Light Orange Red */"); + echo("color(MOY); /* Medium Orange Yellow */"); + echo("color(MOR); /* Medium Orange Red */"); + echo("color(SSG); /* Spring Spring Green */"); + echo("color(SSY); /* Spring Spring Yellow */"); + echo("color(GGS); /* Green Green Spring */"); + echo("color(YYS); /* Yellow Yellow Spring */"); + echo("color(DGS); /* Dark Green Spring */"); + echo("color(DYS); /* Dark Yellow Spring */"); + echo("color(LGS); /* Light Green Spring */"); + echo("color(LYS); /* Light Yellow Spring */"); + echo("color(DSG); /* Dark Spring Green */"); + echo("color(DSY); /* Dark Spring Yellow */"); + echo("color(LSG); /* Light Spring Green */"); + echo("color(LSY); /* Light Spring Yellow */"); + echo("color(MSG); /* Medium Spring Green */"); + echo("color(MSY); /* Medium Spring Yellow */"); + echo("color(TTC); /* Teal Teal Cyan */"); + echo("color(TTG); /* Teal Teal Green */"); + echo("color(CCT); /* Cyan Cyan Teal */"); + echo("color(GGT); /* Green Green Teal */"); + echo("color(DCT); /* Dark Cyan Teal */"); + echo("color(DGT); /* Dark Green Teal */"); + echo("color(LCT); /* Light Cyan Teal */"); + echo("color(LGT); /* Light Green Teal */"); + echo("color(DTC); /* Dark Teal Cyan */"); + echo("color(DTG); /* Dark Teal Green */"); + echo("color(LTC); /* Light Teal Cyan */"); + echo("color(LTG); /* Light Teal Green */"); + echo("color(MTC); /* Medium Teal Cyan */"); + echo("color(MTG); /* Medium Teal Green */"); + echo("color(AAB); /* Azure Azure Blue */"); + echo("color(AAC); /* Azure Azure Cyan */"); + echo("color(BBA); /* Blue Blue Azure */"); + echo("color(CCA); /* Cyan Cyan Azure */"); + echo("color(DBA); /* Dark Blue Azure */"); + echo("color(DCA); /* Dark Cyan Azure */"); + echo("color(LBA); /* Light Blue Azure */"); + echo("color(LCA); /* Light Cyan Azure */"); + echo("color(DAB); /* Dark Azure Blue */"); + echo("color(DAC); /* Dark Azure Cyan */"); + echo("color(LAB); /* Light Azure Blue */"); + echo("color(LAC); /* Light Azure Cyan */"); + echo("color(MAB); /* Medium Azure Blue */"); + echo("color(MAC); /* Medium Azure Cyan */"); + echo("color(VVM); /* Violet Violet Magenta */"); + echo("color(VVB); /* Violet Violet Blue */"); + echo("color(MMV); /* Magenta Magenta Violet */"); + echo("color(BBV); /* Blue Blue Violet */"); + echo("color(DMV); /* Dark Magenta Violet */"); + echo("color(DBV); /* Dark Blue Violet */"); + echo("color(LMV); /* Light Magenta Violet */"); + echo("color(LBV); /* Light Blue Violet */"); + echo("color(DVM); /* Dark Violet Magenta */"); + echo("color(DVB); /* Dark Violet Blue */"); + echo("color(LVM); /* Light Violet Magenta */"); + echo("color(LVB); /* Light Violet Blue */"); + echo("color(MVM); /* Medium Violet Magenta */"); + echo("color(MVB); /* Medium Violet Blue */"); + echo("color(OWM); /* Obscure Weak Magenta */"); + echo("color(ODM); /* Obscure Dull Magenta */"); + echo("color(DFM); /* Dark Faded Magenta */"); + echo("color(DHM); /* Dark Hard Magenta */"); + echo("color(M); /* Magenta */"); + echo("color(DWM); /* Dark Weak Magenta */"); + echo("color(DDM); /* Dark Dull Magenta */"); + echo("color(MFM); /* Medium Faded Magenta */"); + echo("color(LHM); /* Light Hard Magenta */"); + echo("color(MWM); /* Medium Weak Magenta */"); + echo("color(LDM); /* Light Dull Magenta */"); + echo("color(LFM); /* Light Faded Magenta */"); + echo("color(LWM); /* Light Weak Magenta */"); + echo("color(PDM); /* Pale Dull Magenta */"); + echo("color(PWM); /* Pale Weak Magenta */"); + echo("color(OWR); /* Obscure Weak Red */"); + echo("color(ODR); /* Obscure Dull Red */"); + echo("color(DFR); /* Dark Faded Red */"); + echo("color(DHR); /* Dark Hard Red */"); + echo("color(R); /* Red */"); + echo("color(DWR); /* Dark Weak Red */"); + echo("color(DDR); /* Dark Dull Red */"); + echo("color(MFR); /* Medium Faded Red */"); + echo("color(LHR); /* Light Hard Red */"); + echo("color(MWR); /* Medium Weak Red */"); + echo("color(LDR); /* Light Dull Red */"); + echo("color(LFR); /* Light Faded Red */"); + echo("color(LWR); /* Light Weak Red */"); + echo("color(PDR); /* Pale Dull Red */"); + echo("color(PWR); /* Pale Weak Red */"); + echo("color(OWY); /* Obscure Weak Yellow */"); + echo("color(ODY); /* Obscure Dull Yellow */"); + echo("color(DFY); /* Dark Faded Yellow */"); + echo("color(DHY); /* Dark Hard Yellow */"); + echo("color(Y); /* Yellow */"); + echo("color(DWY); /* Dark Weak Yellow */"); + echo("color(DDY); /* Dark Dull Yellow */"); + echo("color(MFY); /* Medium Faded Yellow */"); + echo("color(LHY); /* Light Hard Yellow */"); + echo("color(MWY); /* Medium Weak Yellow */"); + echo("color(LDY); /* Light Dull Yellow */"); + echo("color(LFY); /* Light Faded Yellow */"); + echo("color(LWY); /* Light Weak Yellow */"); + echo("color(PDY); /* Pale Dull Yellow */"); + echo("color(PWY); /* Pale Weak Yellow */"); + echo("color(OWG); /* Obscure Weak Green */"); + echo("color(ODG); /* Obscure Dull Green */"); + echo("color(DFG); /* Dark Faded Green */"); + echo("color(DHG); /* Dark Hard Green */"); + echo("color(G); /* Green */"); + echo("color(DWG); /* Dark Weak Green */"); + echo("color(DDG); /* Dark Dull Green */"); + echo("color(MFG); /* Medium Faded Green */"); + echo("color(LHG); /* Light Hard Green */"); + echo("color(MWG); /* Medium Weak Green */"); + echo("color(LDG); /* Light Dull Green */"); + echo("color(LFG); /* Light Faded Green */"); + echo("color(LWG); /* Light Weak Green */"); + echo("color(PDG); /* Pale Dull Green */"); + echo("color(PWG); /* Pale Weak Green */"); + echo("color(OWC); /* Obscure Weak Cyan */"); + echo("color(ODC); /* Obscure Dull Cyan */"); + echo("color(DFC); /* Dark Faded Cyan */"); + echo("color(DHC); /* Dark Hard Cyan */"); + echo("color(C); /* Cyan */"); + echo("color(DWC); /* Dark Weak Cyan */"); + echo("color(DDC); /* Dark Dull Cyan */"); + echo("color(MFC); /* Medium Faded Cyan */"); + echo("color(LHC); /* Light Hard Cyan */"); + echo("color(MWC); /* Medium Weak Cyan */"); + echo("color(LDC); /* Light Dull Cyan */"); + echo("color(LFC); /* Light Faded Cyan */"); + echo("color(LWC); /* Light Weak Cyan */"); + echo("color(PDC); /* Pale Dull Cyan */"); + echo("color(PWC); /* Pale Weak Cyan */"); + echo("color(OWB); /* Obscure Weak Blue */"); + echo("color(ODB); /* Obscure Dull Blue */"); + echo("color(DFB); /* Dark Faded Blue */"); + echo("color(DHB); /* Dark Hard Blue */"); + echo("color(B); /* Blue */"); + echo("color(DWB); /* Dark Weak Blue */"); + echo("color(DDB); /* Dark Dull Blue */"); + echo("color(MFB); /* Medium Faded Blue */"); + echo("color(LHB); /* Light Hard Blue */"); + echo("color(MWB); /* Medium Weak Blue */"); + echo("color(LDB); /* Light Dull Blue */"); + echo("color(LFB); /* Light Faded Blue */"); + echo("color(LWB); /* Light Weak Blue */"); + echo("color(PDB); /* Pale Dull Blue */"); + echo("color(PWB); /* Pale Weak Blue */"); + echo("color(ODP); /* Obscure Dull Pink */"); + echo("color(DDP); /* Dark Dull Pink */"); + echo("color(LDP); /* Light Dull Pink */"); + echo("color(PDP); /* Pale Dull Pink */"); + echo("color(DHP); /* Dark Hard Pink */"); + echo("color(LHP); /* Light Hard Pink */"); + echo("color(ODO); /* Obscure Dull Orange */"); + echo("color(DDO); /* Dark Dull Orange */"); + echo("color(LDO); /* Light Dull Orange */"); + echo("color(PDO); /* Pale Dull Orange */"); + echo("color(DHO); /* Dark Hard Orange */"); + echo("color(LHO); /* Light Hard Orange */"); + echo("color(ODS); /* Obscure Dull Spring */"); + echo("color(DDS); /* Dark Dull Spring */"); + echo("color(LDS); /* Light Dull Spring */"); + echo("color(PDS); /* Pale Dull Spring */"); + echo("color(DHS); /* Dark Hard Spring */"); + echo("color(LHS); /* Light Hard Spring */"); + echo("color(ODT); /* Obscure Dull Teal */"); + echo("color(DDT); /* Dark Dull Teal */"); + echo("color(LDT); /* Light Dull Teal */"); + echo("color(PDT); /* Pale Dull Teal */"); + echo("color(DHT); /* Dark Hard Teal */"); + echo("color(LHT); /* Light Hard Teal */"); + echo("color(ODA); /* Obscure Dull Azure */"); + echo("color(DDA); /* Dark Dull Azure */"); + echo("color(LDA); /* Light Dull Azure */"); + echo("color(PDA); /* Pale Dull Azure */"); + echo("color(DHA); /* Dark Hard Azure */"); + echo("color(LHA); /* Light Hard Azure */"); + echo("color(ODV); /* Obscure Dull Violet */"); + echo("color(DDV); /* Dark Dull Violet */"); + echo("color(LDV); /* Light Dull Violet */"); + echo("color(PDV); /* Pale Dull Violet */"); + echo("color(DHV); /* Dark Hard Violet */"); + echo("color(LHV); /* Light Hard Violet */"); + echo("color(K); /* Black */"); + echo("color(OG); /* Obscure Gray */"); + echo("color(DG); /* Dark Gray */"); + echo("color(LG); /* Light Gray */"); + echo("color(PG); /* Pale Gray */"); + echo("color(W); /* White */"); } diff --git a/motors/motors.scad b/motors/motors.scad index 5f4f97ec..bff35023 100644 --- a/motors/motors.scad +++ b/motors/motors.scad @@ -1,109 +1,96 @@ +// Copyright 2010 D1plo1d + +// This library is dual licensed under the GPL 3.0 and the GNU Lesser General Public License as per http://creativecommons.org/licenses/LGPL/2.1/ . + include include include -// Copyright 2010 D1plo1d -// This library is dual licensed under the GPL 3.0 and the GNU Lesser General -// Public License as per http://creativecommons.org/licenses/LGPL/2.1/ . - -// generates a motor mount for the specified nema standard #. -module stepper_motor_mount(nema_standard, - slide_distance = 0, - mochup = true, - tolerance = 0) -{ - // dimensions from: - // http://www.numberfactory.com/NEMA%20Motor%20Dimensions.htm - if (nema_standard == 17) { - _stepper_motor_mount(motor_shaft_diameter = 0.1968 * length_in, - motor_shaft_length = 0.945 * length_in, - pilot_diameter = 0.866 * length_in, - pilot_length = 0.80 * length_in, - mounting_bolt_circle = 1.725 * length_in, - bolt_hole_size = 3.5, - bolt_hole_distance = 1.220 * length_in, - slide_distance = slide_distance, - mochup = mochup, - tolerance = tolerance); - } - if (nema_standard == 23) { - _stepper_motor_mount(motor_shaft_diameter = 0.250 * length_in, - motor_shaft_length = 0.81 * length_in, - pilot_diameter = 1.500 * length_in, - pilot_length = 0.062 * length_in, - mounting_bolt_circle = 2.625 * length_in, - bolt_hole_size = 0.195 * length_in, - bolt_hole_distance = 1.856 * length_in, - slide_distance = slide_distance, - mochup = mochup, - tolerance = tolerance); - } +//generates a motor mount for the specified nema standard #. +module stepper_motor_mount(nema_standard,slide_distance=0, mochup=true, tolerance=0) { + //dimensions from: + // http://www.numberfactory.com/NEMA%20Motor%20Dimensions.htm + if (nema_standard == 17) + { + _stepper_motor_mount( + motor_shaft_diameter = 0.1968*length_in, + motor_shaft_length = 0.945*length_in, + pilot_diameter = 0.866*length_in, + pilot_length = 0.80*length_in, + mounting_bolt_circle = 1.725*length_in, + bolt_hole_size = 3.5, + bolt_hole_distance = 1.220*length_in, + slide_distance = slide_distance, + mochup = mochup, + tolerance=tolerance); + } + if (nema_standard == 23) + { + _stepper_motor_mount( + motor_shaft_diameter = 0.250*length_in, + motor_shaft_length = 0.81*length_in, + pilot_diameter = 1.500*length_in, + pilot_length = 0.062*length_in, + mounting_bolt_circle = 2.625*length_in, + bolt_hole_size = 0.195*length_in, + bolt_hole_distance = 1.856*length_in, + slide_distance = slide_distance, + mochup = mochup, + tolerance=tolerance); + } + } -// inner mehod for creating a stepper motor mount of any dimensions -module _stepper_motor_mount(motor_shaft_diameter, - motor_shaft_length, - pilot_diameter, - pilot_length, - mounting_bolt_circle, - bolt_hole_size, - bolt_hole_distance, - slide_distance = 0, - motor_length = 40, // arbitray - not standardized - mochup, - tolerance = 0) -{ - union() - { - // == centered mount points == - // mounting circle inset - translate([ 0, slide_distance / 2, 0 ]) - circle(r = pilot_diameter / 2 + tolerance); - square([ pilot_diameter, slide_distance ], center = true); - translate([ 0, -slide_distance / 2, 0 ]) - circle(r = pilot_diameter / 2 + tolerance); - // todo: motor shaft hole +//inner mehod for creating a stepper motor mount of any dimensions +module _stepper_motor_mount( + motor_shaft_diameter, + motor_shaft_length, + pilot_diameter, + pilot_length, + mounting_bolt_circle, + bolt_hole_size, + bolt_hole_distance, + slide_distance = 0, + motor_length = 40, //arbitray - not standardized + mochup, + tolerance = 0 +) +{ + union() + { + // == centered mount points == + //mounting circle inset + translate([0,slide_distance/2,0]) circle(r = pilot_diameter/2 + tolerance); + square([pilot_diameter,slide_distance],center=true); + translate([0,-slide_distance/2,0]) circle(r = pilot_diameter/2 + tolerance); - // mounting screw holes - for (x = [ -1, 1 ]) - for (y = [ -1, 1 ]) { - translate([ - x * bolt_hole_distance / 2, - y * bolt_hole_distance / 2, - 0 - ]) - { - translate([ 0, slide_distance / 2, 0 ]) - circle(bolt_hole_size / 2 + tolerance); - translate([ 0, -slide_distance / 2, 0 ]) - circle(bolt_hole_size / 2 + tolerance); - square([ bolt_hole_size + 2 * tolerance, slide_distance ], - center = true); - } - } - // == motor mock-up == - // motor box - if (mochup == true) { - % translate([ 0, 0, -5 ]) cylinder(h = 5, r = pilot_diameter / 2); - % translate(v = [ 0, 0, -motor_length / 2 ]) - { - cube(size = - [ - bolt_hole_distance + bolt_hole_size + 5, - bolt_hole_distance + bolt_hole_size + 5, - motor_length - ], - center = true); - } - // shaft - % translate( - v = [ 0, 0, -(motor_length - motor_shaft_length - 2) / 2 ]) - { - % cylinder(r = motor_shaft_diameter / 2, - h = motor_length + motor_shaft_length-- 1, - center = true); - } - } - } + //todo: motor shaft hole + + //mounting screw holes + for (x = [-1,1]) for (y = [-1,1]) + { + translate([x*bolt_hole_distance/2,y*bolt_hole_distance/2,0]) + { + translate([0,slide_distance/2,0]) circle(bolt_hole_size/2 + tolerance); + translate([0,-slide_distance/2,0]) circle(bolt_hole_size/2 + tolerance); + square([bolt_hole_size+2*tolerance,slide_distance],center=true); + } + } + // == motor mock-up == + //motor box + if (mochup == true) + { + %translate([0,0,-5]) cylinder(h = 5, r = pilot_diameter/2); + %translate(v=[0,0,-motor_length/2]) + { + cube(size=[bolt_hole_distance+bolt_hole_size+5,bolt_hole_distance+bolt_hole_size+5,motor_length], center = true); + } + //shaft + %translate(v=[0,0,-(motor_length-motor_shaft_length-2)/2]) + { + %cylinder(r=motor_shaft_diameter/2,h=motor_length+motor_shaft_length--1, center = true); + } + } + } } diff --git a/motors/servos.scad b/motors/servos.scad index 6b946dca..0f3f39c2 100644 --- a/motors/servos.scad +++ b/motors/servos.scad @@ -1,4 +1,3 @@ -use /** * Servo outline library * @@ -8,86 +7,101 @@ use * License: LGPL 2.1 */ +use + /** * Align DS420 digital servo * * @param vector position The position vector * @param vector rotation The rotation vector - * @param boolean screws If defined then "screws" will be added and when the - * module is differenced() from something if will have holes for the screws - * @param number axle_lenght If defined this will draw "backgound" indicator for - * the main axle + * @param boolean screws If defined then "screws" will be added and when the module is differenced() from something if will have holes for the screws + * @param number axle_lenght If defined this will draw "backgound" indicator for the main axle */ module alignds420(position, rotation, screws = 0, axle_lenght = 0) { - translate(position) - { - rotate(rotation) - { - union() - { - // Main axle - translate([ 0, 0, 17 ]) - { - cylinder(r = 6, h = 8, $fn = 30); - cylinder(r = 2.5, h = 10.5, $fn = 20); - } - // Box and ears - translate([ -6, -6, 0 ]) - { - cube([ 12, 22.8, 19.5 ], false); - translate([ 0, -5, 17 ]) { cube([ 12, 7, 2.5 ]); } - translate([ 0, 20.8, 17 ]) { cube([ 12, 7, 2.5 ]); } - } - if (screws > 0) { - translate([ 0, (-10.2 + 1.8), 11.5 ]) - { -#cylinder(r = 1.8 / 2, h = 6, $fn = 6); - } - translate([ 0, (21.0 - 1.8), 11.5 ]) - { -#cylinder(r = 1.8 / 2, h = 6, $fn = 6); - } - } - // The large slope - translate([ -6, 0, 19 ]) - { - rotate([ 90, 0, 90 ]) { triangle(4, 18, 12); } - } + translate(position) + { + rotate(rotation) + { + union() + { + // Main axle + translate([0,0,17]) + { + cylinder(r=6, h=8, $fn=30); + cylinder(r=2.5, h=10.5, $fn=20); + } + // Box and ears + translate([-6,-6,0]) + { + cube([12, 22.8,19.5], false); + translate([0,-5, 17]) + { + cube([12, 7, 2.5]); + } + translate([0, 20.8, 17]) + { + cube([12, 7, 2.5]); + } + } + if (screws > 0) + { + translate([0,(-10.2 + 1.8),11.5]) + { + # cylinder(r=1.8/2, h=6, $fn=6); + } + translate([0,(21.0 - 1.8),11.5]) + { + # cylinder(r=1.8/2, h=6, $fn=6); + } - /** - * This seems to get too complex fast - // Small additional axes - translate([0,6,17]) - { - cylinder(r=2.5, h=6, $fn=10); - cylinder(r=1.25, h=8, $fn=10); - } - // Small slope - difference() - { - translate([-6,-6,19.0]) - { - cube([12,6.5,4]); - } - translate([7,-7,24.0]) - { - rotate([-90,0,90]) - { - triangle(3, 8, 14); - } - } + } + // The large slope + translate([-6,0,19]) + { + rotate([90,0,90]) + { + triangle(4, 18, 12); + } + } + + /** + * This seems to get too complex fast + // Small additional axes + translate([0,6,17]) + { + cylinder(r=2.5, h=6, $fn=10); + cylinder(r=1.25, h=8, $fn=10); + } + // Small slope + difference() + { + translate([-6,-6,19.0]) + { + cube([12,6.5,4]); + } + translate([7,-7,24.0]) + { + rotate([-90,0,90]) + { + triangle(3, 8, 14); + } + } - } - */ - // So we render a cube instead of the small slope on a cube - translate([ -6, -6, 19.0 ]) { cube([ 12, 6.5, 4 ]); } - } - if (axle_lenght > 0) { - % cylinder(r = 0.9, h = axle_lenght, center = true, $fn = 8); - } - } - } + } + */ + // So we render a cube instead of the small slope on a cube + translate([-6,-6,19.0]) + { + cube([12,6.5,4]); + } + } + if (axle_lenght > 0) + { + % cylinder(r=0.9, h=axle_lenght, center=true, $fn=8); + } + } + } } /** @@ -98,51 +112,45 @@ module alignds420(position, rotation, screws = 0, axle_lenght = 0) */ module futabas3003(position, rotation) { - translate(position) - { - rotate(rotation) - { - union() - { - // Box and ears - translate([ 0, 0, 0 ]) - { - cube([ 20.1, 39.9, 36.1 ], false); - translate([ 1.1, -7.6, 26.6 ]) - { - difference() - { - cube([ 18, 7.6, 2.5 ]); - translate([ 4, 3.5, 0 ]) cylinder(100, 2); - translate([ 14, 3.5, 0 ]) cylinder(100, 2); + translate(position) + { + rotate(rotation) + { + union() + { + // Box and ears + translate([0,0,0]) + { + cube([20.1, 39.9, 36.1], false); + translate([1.1, -7.6, 26.6]) + { + difference() { + cube([18, 7.6, 2.5]); + translate([4, 3.5, 0]) cylinder(100, 2); + translate([14, 3.5, 0]) cylinder(100, 2); } - } + } - translate([ 1.1, 39.9, 26.6 ]) - { - difference() - { - cube([ 18, 7.6, 2.5 ]); - translate([ 4, 4.5, 0 ]) cylinder(100, 2); - translate([ 14, 4.5, 0 ]) cylinder(100, 2); + translate([1.1, 39.9, 26.6]) + { + difference() { + cube([18, 7.6, 2.5]); + translate([4, 4.5, 0]) cylinder(100, 2); + translate([14, 4.5, 0]) cylinder(100, 2); } } - } + } - // Main axle - translate([ 10, 30, 36.1 ]) - { - cylinder(r = 6, h = 0.4, $fn = 30); - cylinder(r = 2.5, h = 4.9, $fn = 20); - } - } - } - } + // Main axle + translate([10, 30, 36.1]) + { + cylinder(r=6, h=0.4, $fn=30); + cylinder(r=2.5, h=4.9, $fn=20); + } + } + } + } } // Tests: -module -test_alignds420() -{ - alignds420(screws = 1); -} +module test_alignds420(){alignds420(screws=1);} diff --git a/motors/stepper.scad b/motors/stepper.scad index 291e18d0..1c8e5856 100644 --- a/motors/stepper.scad +++ b/motors/stepper.scad @@ -1,15 +1,15 @@ -include -include -include /* * A nema standard stepper motor module. - * + * * Originally by Hans Häggström, 2010. - * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or - * later + * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later */ -// Parameters: +include +include +include + +// Parameters: NemaModel = 0; NemaLengthShort = 1; NemaLengthMedium = 2; @@ -38,127 +38,138 @@ NemaShort = NemaA; NemaMedium = NemaB; NemaLong = NemaC; -// TODO: The small motors seem to be a bit too long, I picked the size specs -// from all over the place, is there some canonical reference? -Nema08 = [[NemaModel, 8], - [NemaLengthShort, 33 * length_mm], - [NemaLengthMedium, 43 * length_mm], - [NemaLengthLong, 43 * length_mm], - [NemaSideSize, 20 * length_mm], - [NemaDistanceBetweenMountingHoles, 15.4 * length_mm], - [NemaMountingHoleDiameter, 2 * length_mm], - [NemaMountingHoleDepth, 1.75 * length_mm], - [NemaMountingHoleLip, -1 * length_mm], - [NemaMountingHoleCutoutRadius, 0 * length_mm], - [NemaEdgeRoundingRadius, 2 * length_mm], - [NemaRoundExtrusionDiameter, 16 * length_mm], - [NemaRoundExtrusionHeight, 1.5 * length_mm], - [NemaAxleDiameter, 4 * length_mm], - [NemaFrontAxleLength, 13.5 * length_mm], - [NemaBackAxleLength, 9.9 * length_mm], - [NemaAxleFlatDepth, -1 * length_mm], - [NemaAxleFlatLengthFront, 0 * length_mm], - [NemaAxleFlatLengthBack, 0 * length_mm]]; - -Nema11 = [[NemaModel, 11], - [NemaLengthShort, 32 * length_mm], - [NemaLengthMedium, 40 * length_mm], - [NemaLengthLong, 52 * length_mm], - [NemaSideSize, 28 * length_mm], - [NemaDistanceBetweenMountingHoles, 23 * length_mm], - [NemaMountingHoleDiameter, 2.5 * length_mm], - [NemaMountingHoleDepth, 2 * length_mm], - [NemaMountingHoleLip, -1 * length_mm], - [NemaMountingHoleCutoutRadius, 0 * length_mm], - [NemaEdgeRoundingRadius, 2.5 * length_mm], - [NemaRoundExtrusionDiameter, 22 * length_mm], - [NemaRoundExtrusionHeight, 1.8 * length_mm], - [NemaAxleDiameter, 5 * length_mm], - [NemaFrontAxleLength, 13.7 * length_mm], - [NemaBackAxleLength, 10 * length_mm], - [NemaAxleFlatDepth, 0.5 * length_mm], - [NemaAxleFlatLengthFront, 10 * length_mm], - [NemaAxleFlatLengthBack, 9 * length_mm]]; - -Nema14 = [[NemaModel, 14], - [NemaLengthShort, 26 * length_mm], - [NemaLengthMedium, 28 * length_mm], - [NemaLengthLong, 34 * length_mm], - [NemaSideSize, 35.3 * length_mm], - [NemaDistanceBetweenMountingHoles, 26 * length_mm], - [NemaMountingHoleDiameter, 3 * length_mm], - [NemaMountingHoleDepth, 3.5 * length_mm], - [NemaMountingHoleLip, -1 * length_mm], - [NemaMountingHoleCutoutRadius, 0 * length_mm], - [NemaEdgeRoundingRadius, 5 * length_mm], - [NemaRoundExtrusionDiameter, 22 * length_mm], - [NemaRoundExtrusionHeight, 1.9 * length_mm], - [NemaAxleDiameter, 5 * length_mm], - [NemaFrontAxleLength, 18 * length_mm], - [NemaBackAxleLength, 10 * length_mm], - [NemaAxleFlatDepth, 0.5 * length_mm], - [NemaAxleFlatLengthFront, 15 * length_mm], - [NemaAxleFlatLengthBack, 9 * length_mm]]; - -Nema17 = [[NemaModel, 17], - [NemaLengthShort, 33 * length_mm], - [NemaLengthMedium, 39 * length_mm], - [NemaLengthLong, 47 * length_mm], - [NemaSideSize, 42.20 * length_mm], - [NemaDistanceBetweenMountingHoles, 31.04 * length_mm], - [NemaMountingHoleDiameter, 4 * length_mm], - [NemaMountingHoleDepth, 4.5 * length_mm], - [NemaMountingHoleLip, -1 * length_mm], - [NemaMountingHoleCutoutRadius, 0 * length_mm], - [NemaEdgeRoundingRadius, 7 * length_mm], - [NemaRoundExtrusionDiameter, 22 * length_mm], - [NemaRoundExtrusionHeight, 1.9 * length_mm], - [NemaAxleDiameter, 5 * length_mm], - [NemaFrontAxleLength, 21 * length_mm], - [NemaBackAxleLength, 15 * length_mm], - [NemaAxleFlatDepth, 0.5 * length_mm], - [NemaAxleFlatLengthFront, 15 * length_mm], - [NemaAxleFlatLengthBack, 14 * length_mm]]; - -Nema23 = [[NemaModel, 23], - [NemaLengthShort, 39 * length_mm], - [NemaLengthMedium, 54 * length_mm], - [NemaLengthLong, 76 * length_mm], - [NemaSideSize, 56.4 * length_mm], - [NemaDistanceBetweenMountingHoles, 47.14 * length_mm], - [NemaMountingHoleDiameter, 4.75 * length_mm], - [NemaMountingHoleDepth, 5 * length_mm], - [NemaMountingHoleLip, 4.95 * length_mm], - [NemaMountingHoleCutoutRadius, 9.5 * length_mm], - [NemaEdgeRoundingRadius, 2.5 * length_mm], - [NemaRoundExtrusionDiameter, 38.10 * length_mm], - [NemaRoundExtrusionHeight, 1.52 * length_mm], - [NemaAxleDiameter, 6.36 * length_mm], - [NemaFrontAxleLength, 18.80 * length_mm], - [NemaBackAxleLength, 15.60 * length_mm], - [NemaAxleFlatDepth, 0.5 * length_mm], - [NemaAxleFlatLengthFront, 16 * length_mm], - [NemaAxleFlatLengthBack, 14 * length_mm]]; - -Nema34 = [[NemaModel, 34], - [NemaLengthShort, 66 * length_mm], - [NemaLengthMedium, 96 * length_mm], - [NemaLengthLong, 126 * length_mm], - [NemaSideSize, 85 * length_mm], - [NemaDistanceBetweenMountingHoles, 69.58 * length_mm], - [NemaMountingHoleDiameter, 6.5 * length_mm], - [NemaMountingHoleDepth, 5.5 * length_mm], - [NemaMountingHoleLip, 5 * length_mm], - [NemaMountingHoleCutoutRadius, 17 * length_mm], - [NemaEdgeRoundingRadius, 3 * length_mm], - [NemaRoundExtrusionDiameter, 73.03 * length_mm], - [NemaRoundExtrusionHeight, 1.9 * length_mm], - [NemaAxleDiameter, 0.5 * length_inch], - [NemaFrontAxleLength, 37 * length_mm], - [NemaBackAxleLength, 34 * length_mm], - [NemaAxleFlatDepth, 1.20 * length_mm], - [NemaAxleFlatLengthFront, 25 * length_mm], - [NemaAxleFlatLengthBack, 25 * length_mm]]; +// TODO: The small motors seem to be a bit too long, I picked the size specs from all over the place, is there some canonical reference? +Nema08 = [ + [NemaModel, 8], + [NemaLengthShort, 33*length_mm], + [NemaLengthMedium, 43*length_mm], + [NemaLengthLong, 43*length_mm], + [NemaSideSize, 20*length_mm], + [NemaDistanceBetweenMountingHoles, 15.4*length_mm], + [NemaMountingHoleDiameter, 2*length_mm], + [NemaMountingHoleDepth, 1.75*length_mm], + [NemaMountingHoleLip, -1*length_mm], + [NemaMountingHoleCutoutRadius, 0*length_mm], + [NemaEdgeRoundingRadius, 2*length_mm], + [NemaRoundExtrusionDiameter, 16*length_mm], + [NemaRoundExtrusionHeight, 1.5*length_mm], + [NemaAxleDiameter, 4*length_mm], + [NemaFrontAxleLength, 13.5*length_mm], + [NemaBackAxleLength, 9.9*length_mm], + [NemaAxleFlatDepth, -1*length_mm], + [NemaAxleFlatLengthFront, 0*length_mm], + [NemaAxleFlatLengthBack, 0*length_mm] + ]; + +Nema11 = [ + [NemaModel, 11], + [NemaLengthShort, 32*length_mm], + [NemaLengthMedium, 40*length_mm], + [NemaLengthLong, 52*length_mm], + [NemaSideSize, 28*length_mm], + [NemaDistanceBetweenMountingHoles, 23*length_mm], + [NemaMountingHoleDiameter, 2.5*length_mm], + [NemaMountingHoleDepth, 2*length_mm], + [NemaMountingHoleLip, -1*length_mm], + [NemaMountingHoleCutoutRadius, 0*length_mm], + [NemaEdgeRoundingRadius, 2.5*length_mm], + [NemaRoundExtrusionDiameter, 22*length_mm], + [NemaRoundExtrusionHeight, 1.8*length_mm], + [NemaAxleDiameter, 5*length_mm], + [NemaFrontAxleLength, 13.7*length_mm], + [NemaBackAxleLength, 10*length_mm], + [NemaAxleFlatDepth, 0.5*length_mm], + [NemaAxleFlatLengthFront, 10*length_mm], + [NemaAxleFlatLengthBack, 9*length_mm] + ]; + +Nema14 = [ + [NemaModel, 14], + [NemaLengthShort, 26*length_mm], + [NemaLengthMedium, 28*length_mm], + [NemaLengthLong, 34*length_mm], + [NemaSideSize, 35.3*length_mm], + [NemaDistanceBetweenMountingHoles, 26*length_mm], + [NemaMountingHoleDiameter, 3*length_mm], + [NemaMountingHoleDepth, 3.5*length_mm], + [NemaMountingHoleLip, -1*length_mm], + [NemaMountingHoleCutoutRadius, 0*length_mm], + [NemaEdgeRoundingRadius, 5*length_mm], + [NemaRoundExtrusionDiameter, 22*length_mm], + [NemaRoundExtrusionHeight, 1.9*length_mm], + [NemaAxleDiameter, 5*length_mm], + [NemaFrontAxleLength, 18*length_mm], + [NemaBackAxleLength, 10*length_mm], + [NemaAxleFlatDepth, 0.5*length_mm], + [NemaAxleFlatLengthFront, 15*length_mm], + [NemaAxleFlatLengthBack, 9*length_mm] + ]; + +Nema17 = [ + [NemaModel, 17], + [NemaLengthShort, 33*length_mm], + [NemaLengthMedium, 39*length_mm], + [NemaLengthLong, 47*length_mm], + [NemaSideSize, 42.20*length_mm], + [NemaDistanceBetweenMountingHoles, 31.04*length_mm], + [NemaMountingHoleDiameter, 4*length_mm], + [NemaMountingHoleDepth, 4.5*length_mm], + [NemaMountingHoleLip, -1*length_mm], + [NemaMountingHoleCutoutRadius, 0*length_mm], + [NemaEdgeRoundingRadius, 7*length_mm], + [NemaRoundExtrusionDiameter, 22*length_mm], + [NemaRoundExtrusionHeight, 1.9*length_mm], + [NemaAxleDiameter, 5*length_mm], + [NemaFrontAxleLength, 21*length_mm], + [NemaBackAxleLength, 15*length_mm], + [NemaAxleFlatDepth, 0.5*length_mm], + [NemaAxleFlatLengthFront, 15*length_mm], + [NemaAxleFlatLengthBack, 14*length_mm] + ]; + +Nema23 = [ + [NemaModel, 23], + [NemaLengthShort, 39*length_mm], + [NemaLengthMedium, 54*length_mm], + [NemaLengthLong, 76*length_mm], + [NemaSideSize, 56.4*length_mm], + [NemaDistanceBetweenMountingHoles, 47.14*length_mm], + [NemaMountingHoleDiameter, 4.75*length_mm], + [NemaMountingHoleDepth, 5*length_mm], + [NemaMountingHoleLip, 4.95*length_mm], + [NemaMountingHoleCutoutRadius, 9.5*length_mm], + [NemaEdgeRoundingRadius, 2.5*length_mm], + [NemaRoundExtrusionDiameter, 38.10*length_mm], + [NemaRoundExtrusionHeight, 1.52*length_mm], + [NemaAxleDiameter, 6.36*length_mm], + [NemaFrontAxleLength, 18.80*length_mm], + [NemaBackAxleLength, 15.60*length_mm], + [NemaAxleFlatDepth, 0.5*length_mm], + [NemaAxleFlatLengthFront, 16*length_mm], + [NemaAxleFlatLengthBack, 14*length_mm] + ]; + +Nema34 = [ + [NemaModel, 34], + [NemaLengthShort, 66*length_mm], + [NemaLengthMedium, 96*length_mm], + [NemaLengthLong, 126*length_mm], + [NemaSideSize, 85*length_mm], + [NemaDistanceBetweenMountingHoles, 69.58*length_mm], + [NemaMountingHoleDiameter, 6.5*length_mm], + [NemaMountingHoleDepth, 5.5*length_mm], + [NemaMountingHoleLip, 5*length_mm], + [NemaMountingHoleCutoutRadius, 17*length_mm], + [NemaEdgeRoundingRadius, 3*length_mm], + [NemaRoundExtrusionDiameter, 73.03*length_mm], + [NemaRoundExtrusionHeight, 1.9*length_mm], + [NemaAxleDiameter, 0.5*length_inch], + [NemaFrontAxleLength, 37*length_mm], + [NemaBackAxleLength, 34*length_mm], + [NemaAxleFlatDepth, 1.20*length_mm], + [NemaAxleFlatLengthFront, 25*length_mm], + [NemaAxleFlatLengthBack, 25*length_mm] + ]; NemaDefinitions = [ -1, @@ -198,196 +209,128 @@ NemaDefinitions = [ Nema34 ]; -function motorWidth(model = Nema23) = lookup(NemaSideSize, model); -function motorLength(model = Nema23, size = NemaMedium) = lookup(size, model); -function motorScrewSpacing(model = Nema23) = - lookup(NemaDistanceBetweenMountingHoles, model); + +function motorWidth(model=Nema23) = lookup(NemaSideSize, model); +function motorLength(model=Nema23, size=NemaMedium) = lookup(size, model); +function motorScrewSpacing(model=Nema23) = lookup(NemaDistanceBetweenMountingHoles, model); function Nema(number) = NemaDefinitions[number]; -module motor(model = Nema23, - size = NemaMedium, - dualAxis = false, - pos = [ 0, 0, 0 ], - orientation = [ 0, 0, 0 ]) -{ - - // motorDef = NemaDefinitions[model]; - // echo(model); - motorDef = model; - echo(motorDef); - length = lookup(size, motorDef); - - echo(str(" Motor: Nema", - lookup(NemaModel, motorDef), - ", length= ", - length, - "mm, dual axis=", - dualAxis)); - - stepperBlack = BlackPaint; - stepperAluminum = Aluminum; - - side = lookup(NemaSideSize, motorDef); - - cutR = lookup(NemaMountingHoleCutoutRadius, motorDef); - lip = lookup(NemaMountingHoleLip, motorDef); - holeDepth = lookup(NemaMountingHoleDepth, motorDef); - - axleLengthFront = lookup(NemaFrontAxleLength, motorDef); - axleLengthBack = lookup(NemaBackAxleLength, motorDef); - axleRadius = lookup(NemaAxleDiameter, motorDef) * 0.5; - - extrSize = lookup(NemaRoundExtrusionHeight, motorDef); - extrRad = lookup(NemaRoundExtrusionDiameter, motorDef) * 0.5; - - holeDist = lookup(NemaDistanceBetweenMountingHoles, motorDef) * 0.5; - holeRadius = lookup(NemaMountingHoleDiameter, motorDef) * 0.5; - - mid = side / 2; - - roundR = lookup(NemaEdgeRoundingRadius, motorDef); - - axleFlatDepth = lookup(NemaAxleFlatDepth, motorDef); - axleFlatLengthFront = lookup(NemaAxleFlatLengthFront, motorDef); - axleFlatLengthBack = lookup(NemaAxleFlatLengthBack, motorDef); - - color(stepperBlack) - { - translate(pos) rotate(orientation) - { - translate([ -mid, -mid, 0 ]) difference() - { - cube(size = [ side, side, length + extrSize ]); - - // Corner cutouts - if (lip > 0) { - translate([ 0, 0, lip ]) cylinder(h = length, r = cutR); - translate([ side, 0, lip ]) cylinder(h = length, r = cutR); - translate([ 0, side, lip ]) cylinder(h = length, r = cutR); - translate([ side, side, lip ]) - cylinder(h = length, r = cutR); - } - - // Rounded edges - if (roundR > 0) { - translate([ mid + mid, mid + mid, length / 2 ]) - rotate([ 0, 0, 45 ]) - cube(size = - [ - roundR, - roundR * 2, - 4 + length + extrSize + 2 - ], - center = true); - translate([ mid - (mid), mid + (mid), length / 2 ]) - rotate([ 0, 0, 45 ]) - cube(size = - [ - roundR * 2, - roundR, - 4 + length + extrSize + 2 - ], - center = true); - translate([ mid + mid, mid - mid, length / 2 ]) - rotate([ 0, 0, 45 ]) - cube(size = - [ - roundR * 2, - roundR, - 4 + length + extrSize + 2 - ], - center = true); - translate([ mid - mid, mid - mid, length / 2 ]) - rotate([ 0, 0, 45 ]) - cube(size = - [ - roundR, - roundR * 2, - 4 + length + extrSize + 2 - ], - center = true); - } - - // Bolt holes - color(stepperAluminum, $fs = holeRadius / 8) - { - translate([ mid + holeDist, mid + holeDist ]) - cylinder(h = holeDepth + 1 * length_mm, r = holeRadius); - translate([ mid - holeDist, mid + holeDist ]) - cylinder(h = holeDepth + 1 * length_mm, r = holeRadius); - translate([ mid + holeDist, mid - holeDist ]) - cylinder(h = holeDepth + 1 * length_mm, r = holeRadius); - translate([ mid - holeDist, mid - holeDist ]) - cylinder(h = holeDepth + 1 * length_mm, r = holeRadius); - } - - // Grinded flat - color(stepperAluminum) - { - difference() - { - translate( - [ -1 * length_mm, -1 * length_mm, -1 * length_mm ]) - cube(size = [ - side + 2 * length_mm, - side + 2 * length_mm, - extrSize + 1 * - length_mm - ]); - translate([ side / 2, side / 2, -1.1 * length_mm ]) - cylinder(h = 4 * length_mm, r = extrRad); - } - } +module motor(model=Nema23, size=NemaMedium, dualAxis=false, pos=[0,0,0], orientation = [0,0,0]) { + + //motorDef = NemaDefinitions[model]; + //echo(model); + motorDef = model; + echo(motorDef); + length = lookup(size, motorDef); + + echo(str(" Motor: Nema",lookup(NemaModel, motorDef),", length= ",length,"mm, dual axis=",dualAxis)); + + stepperBlack = BlackPaint; + stepperAluminum = Aluminum; + + side = lookup(NemaSideSize, motorDef); + + cutR = lookup(NemaMountingHoleCutoutRadius, motorDef); + lip = lookup(NemaMountingHoleLip, motorDef); + holeDepth = lookup(NemaMountingHoleDepth, motorDef); + + axleLengthFront = lookup(NemaFrontAxleLength, motorDef); + axleLengthBack = lookup(NemaBackAxleLength, motorDef); + axleRadius = lookup(NemaAxleDiameter, motorDef) * 0.5; + + extrSize = lookup(NemaRoundExtrusionHeight, motorDef); + extrRad = lookup(NemaRoundExtrusionDiameter, motorDef) * 0.5; + + holeDist = lookup(NemaDistanceBetweenMountingHoles, motorDef) * 0.5; + holeRadius = lookup(NemaMountingHoleDiameter, motorDef) * 0.5; + + mid = side / 2; + + roundR = lookup(NemaEdgeRoundingRadius, motorDef); + + axleFlatDepth = lookup(NemaAxleFlatDepth, motorDef); + axleFlatLengthFront = lookup(NemaAxleFlatLengthFront, motorDef); + axleFlatLengthBack = lookup(NemaAxleFlatLengthBack, motorDef); + + color(stepperBlack){ + translate(pos) rotate(orientation) { + translate([-mid, -mid, 0]) + difference() { + cube(size=[side, side, length + extrSize]); + + // Corner cutouts + if (lip > 0) { + translate([0, 0, lip]) cylinder(h=length, r=cutR); + translate([side, 0, lip]) cylinder(h=length, r=cutR); + translate([0, side, lip]) cylinder(h=length, r=cutR); + translate([side, side, lip]) cylinder(h=length, r=cutR); + + } + + // Rounded edges + if (roundR > 0) { + translate([mid+mid, mid+mid, length/2]) + rotate([0,0,45]) + cube(size=[roundR, roundR*2, 4+length + extrSize+2], center=true); + translate([mid-(mid), mid+(mid), length/2]) + rotate([0,0,45]) + cube(size=[roundR*2, roundR, 4+length + extrSize+2], center=true); + translate([mid+mid, mid-mid, length/2]) + rotate([0,0,45]) + cube(size=[roundR*2, roundR, 4+length + extrSize+2], center=true); + translate([mid-mid, mid-mid, length/2]) + rotate([0,0,45]) + cube(size=[roundR, roundR*2, 4+length + extrSize+2], center=true); + + } + + // Bolt holes + color(stepperAluminum, $fs=holeRadius/8) { + translate([mid+holeDist,mid+holeDist]) cylinder(h=holeDepth+1*length_mm, r=holeRadius); + translate([mid-holeDist,mid+holeDist]) cylinder(h=holeDepth+1*length_mm, r=holeRadius); + translate([mid+holeDist,mid-holeDist]) cylinder(h=holeDepth+1*length_mm, r=holeRadius); + translate([mid-holeDist,mid-holeDist]) cylinder(h=holeDepth+1*length_mm, r=holeRadius); + + } + + // Grinded flat + color(stepperAluminum) { + difference() { + translate([-1*length_mm, -1*length_mm, -1*length_mm]) + cube(size=[side+2*length_mm, side+2*length_mm, extrSize + 1*length_mm]); + translate([side/2, side/2, -1.1*length_mm]) + cylinder(h=4*length_mm, r=extrRad); } + } - // Axle - translate([ 0, 0, extrSize - axleLengthFront ]) - color(stepperAluminum) difference() - { - - cylinder(h = axleLengthFront + 1 * length_mm, - r = axleRadius, - $fs = axleRadius / 10); - - // Flat - if (axleFlatDepth > 0) - translate([ - axleRadius - axleFlatDepth, - -5 * length_mm, - -extrSize * length_mm - - (axleLengthFront - axleFlatLengthFront) - ]) - cube(size = [ - 5 * length_mm, - 10 * length_mm, - axleLengthFront - ]); - } + } - if (dualAxis) { - translate([ 0, 0, length + extrSize ]) color(stepperAluminum) - difference() - { - - cylinder(h = axleLengthBack + 0 * length_mm, - r = axleRadius, - $fs = axleRadius / 10); - - // Flat - if (axleFlatDepth > 0) - translate([ - axleRadius - axleFlatDepth, - -5 * length_mm, - (axleLengthBack - axleFlatLengthBack) - ]) - cube(size = [ - 5 * length_mm, - 10 * length_mm, - axleLengthBack - ]); - } - } + // Axle + translate([0, 0, extrSize-axleLengthFront]) color(stepperAluminum) + difference() { + + cylinder(h=axleLengthFront + 1*length_mm , r=axleRadius, $fs=axleRadius/10); + + // Flat + if (axleFlatDepth > 0) + translate([axleRadius - axleFlatDepth,-5*length_mm,-extrSize*length_mm -(axleLengthFront-axleFlatLengthFront)] ) cube(size=[5*length_mm, 10*length_mm, axleLengthFront]); } + + if (dualAxis) { + translate([0, 0, length+extrSize]) color(stepperAluminum) + difference() { + + cylinder(h=axleLengthBack + 0*length_mm, r=axleRadius, $fs=axleRadius/10); + + // Flat + if (axleFlatDepth > 0) + translate([axleRadius - axleFlatDepth,-5*length_mm,(axleLengthBack-axleFlatLengthBack)]) cube(size=[5*length_mm, 10*length_mm, axleLengthBack]); + } + + } + } + } } + diff --git a/motors/stepper_mount.scad b/motors/stepper_mount.scad index fbd82499..419c111e 100644 --- a/motors/stepper_mount.scad +++ b/motors/stepper_mount.scad @@ -1,5 +1,4 @@ - -// stepper twist mount +// stepper twist mount // tigger@interthingy.com // 201029061241 @@ -12,10 +11,11 @@ // 3 - interference check // 4 - single stl -mode = 4; +mode = 4; // variables -nema = 17; +nema = 17; + bolt = 3; size = 42; @@ -29,257 +29,245 @@ clip_depth = 15; clip_thickness = 4; slot_height = 15; -clip_count = 6; +clip_count = 6; + +//extras -// extras overlap = 0.1; clearance = 0.1; -inc = 360 / clip_count; +inc = 360/clip_count; splitter = 150; -module -pip() +module pip() { - inc = 360 / (2 * clip_count); - clip_rad = boss_radius + clip_thickness / 2 - clip_thickness / 2; - difference() - { - translate([ boss_radius + clip_thickness / 2, 0, clearance ]) - cylinder(h = slot_height - 2 * clearance, - r = clip_thickness / 2 - clearance / 2); - translate( - [ 0, 0, -boss_radius - clip_thickness + slot_height - clearance ]) - cylinder(h = boss_radius + clip_thickness + overlap, - r1 = 0, - r2 = boss_radius + clip_thickness); - translate([ 0, 0, clearance ]) - cylinder(h = boss_radius + clip_thickness + overlap * 2, - r2 = 0, - r1 = boss_radius + clip_thickness); - } + inc = 360/(2*clip_count); + clip_rad = boss_radius+clip_thickness/2-clip_thickness/2; + difference() + { + translate([boss_radius+clip_thickness/2,0,clearance]) + cylinder(h=slot_height-2*clearance,r=clip_thickness/2-clearance/2); + translate([0,0,-boss_radius-clip_thickness+slot_height-clearance]) + cylinder(h=boss_radius+clip_thickness+overlap,r1=0,r2=boss_radius+clip_thickness); + translate([0,0,clearance]) + cylinder(h=boss_radius+clip_thickness+overlap*2,r2=0,r1=boss_radius+clip_thickness); + } } -module -slot() +module slot() { - inc = 360 / (2 * clip_count); - clip_rad = boss_radius + clip_thickness / 2 - clip_thickness / 2; - difference() - { - rotate([ 0, 0, inc ]) - translate([ boss_radius + clip_thickness / 2, 0, 0 ]) - cylinder(h = slot_height - overlap, r = clip_thickness / 2); - union() - { - translate( - [ 0, 0, -boss_radius - clip_thickness + slot_height + overlap ]) - cylinder(h = boss_radius + clip_thickness, - r1 = 0, - r2 = boss_radius + clip_thickness); - translate([ 0, 0, -overlap ]) - cylinder(h = boss_radius + clip_thickness + overlap * 2, - r2 = 0, - r1 = boss_radius + clip_thickness); - } - } - difference() - { - union() - { - translate([ boss_radius + clip_thickness / 2, 0, 0 ]) - cylinder(h = clip_depth + overlap, r = clip_thickness / 2); - intersection() - { - intersection() - { - rotate(-90, [ 0, 0, 1 ]) rotate(inc, [ 0, 0, 1 ]) - cube(size = boss_radius * 4); - cube(size = boss_radius * 4); - } - difference() - { - cylinder(h = slot_height, - r = boss_radius + clip_thickness + overlap); - translate([ 0, 0, -overlap ]) - cylinder(h = slot_height + overlap * 2, r = clip_rad); - translate([ - 0, - 0, - -boss_radius - clip_thickness + slot_height + - overlap - ]) cylinder(h = boss_radius + clip_thickness, - r1 = 0, - r2 = boss_radius + clip_thickness); - } - } - } - translate([ 0, 0, -overlap ]) - cylinder(h = boss_radius + clip_thickness + overlap * 2, - r2 = 0, - r1 = boss_radius + clip_thickness); - } + inc = 360/(2*clip_count); + clip_rad = boss_radius+clip_thickness/2-clip_thickness/2; + difference() + { + rotate([0,0,inc]) + translate([boss_radius+clip_thickness/2,0,0]) + cylinder(h=slot_height-overlap,r=clip_thickness/2); + union() + { + translate([0,0,-boss_radius-clip_thickness+slot_height+overlap]) + cylinder(h=boss_radius+clip_thickness,r1=0,r2=boss_radius+clip_thickness); + translate([0,0,-overlap]) + cylinder(h=boss_radius+clip_thickness+overlap*2,r2=0,r1=boss_radius+clip_thickness); + } + } + difference() + { + union() + { + translate([boss_radius+clip_thickness/2,0,0]) + cylinder(h=clip_depth+overlap,r=clip_thickness/2); + intersection() + { + intersection() + { + rotate(-90,[0,0,1]) + rotate(inc,[0,0,1]) + cube(size=boss_radius*4); + cube(size=boss_radius*4); + + } + difference() + { + cylinder(h=slot_height,r=boss_radius+clip_thickness+overlap); + translate([0,0,-overlap]) + cylinder(h=slot_height+overlap*2, r=clip_rad); + translate([0,0,-boss_radius-clip_thickness+slot_height+overlap]) + cylinder(h=boss_radius+clip_thickness,r1=0,r2=boss_radius+clip_thickness); + } + } + } + translate([0,0,-overlap]) + cylinder(h=boss_radius+clip_thickness+overlap*2,r2=0,r1=boss_radius+clip_thickness); + } } -module -pips() +module pips() { - inc = 360 / clip_count; - for (z = [1:clip_count]) { - rotate(z * inc, [ 0, 0, 1 ]) pip(); - } + inc = 360/clip_count; + for ( z = [1:clip_count]) + { + rotate(z*inc,[0,0,1]) + pip(); + } } -module -slots() +module slots() { - inc = 360 / clip_count; - for (z = [1:clip_count]) { - rotate(z * inc, [ 0, 0, 1 ]) slot(); - } + inc = 360/clip_count; + for ( z = [1:clip_count]) + { + rotate(z*inc,[0,0,1]) + slot(); + } } -module -bolt_hole() +module bolt_hole() { - union() - { - cylinder(h = base_thickness * 10, r = bolt / 2, center = true); - // translate([0,0,base_thickness*2]) - // cylinder(h=base_thickness*10,r=bolt,center=false); - } + union() + { + cylinder(h=base_thickness*10,r=bolt/2,center=true); +// translate([0,0,base_thickness*2]) +// cylinder(h=base_thickness*10,r=bolt,center=false); + } } -module -holes() +module holes() { - union() - { - // bolt holes - translate([ hole_size / 2, hole_size / 2, -2 * base_thickness ]) - bolt_hole(); - translate([ hole_size / 2, -hole_size / 2, -2 * base_thickness ]) - bolt_hole(); - translate([ -hole_size / 2, -hole_size / 2, -2 * base_thickness ]) - bolt_hole(); - translate([ -hole_size / 2, hole_size / 2, -2 * base_thickness ]) - bolt_hole(); - - // center hole - cylinder(h = base_thickness + 3 * mount_height, - r = inner_hole_radius, - center = true); - } + union() + { + // bolt holes + translate([hole_size/2,hole_size/2,-2*base_thickness]) + bolt_hole(); + translate([hole_size/2,-hole_size/2,-2*base_thickness]) + bolt_hole(); + translate([-hole_size/2,-hole_size/2,-2*base_thickness]) + bolt_hole(); + translate([-hole_size/2,hole_size/2,-2*base_thickness]) + bolt_hole(); + + // center hole + cylinder(h = base_thickness+3*mount_height , r = inner_hole_radius, center=true); + } } -module -socket_base() +module socket_base() { - union() - { - difference() - { - cylinder(h = mount_height - clearance, - r = boss_radius + clip_thickness); - cylinder(h = mount_height - clearance, - r = boss_radius + clip_thickness / 2 + clearance / 2); - } - translate([ 0, 0, (clip_depth - slot_height) ]) - rotate([ 0, 0, inc / 2 ]) pips(); - } + union() + { + difference() + { + cylinder(h=mount_height-clearance,r=boss_radius+clip_thickness); + cylinder(h=mount_height-clearance,r=boss_radius+clip_thickness/2+clearance/2); + } + translate([0,0,(clip_depth-slot_height)]) + rotate([0,0,inc/2]) + pips(); + } } -module -twist_base() +module twist_base() { - union() - { - difference() - { - translate([ 0, 0, -overlap ]) - cylinder(h = mount_height + overlap, - r = boss_radius + clip_thickness / 2); - union() { translate([ 0, 0, mount_height - clip_depth ]) slots(); } - } - } + union() + { + difference() + { + translate([0,0,-overlap]) + cylinder(h=mount_height+overlap,r=boss_radius+clip_thickness/2); + union() + { + translate([0,0,mount_height-clip_depth]) + slots(); + } + } + } } -module -base() +module base() { - - difference() - { - union() - { - translate([ 0, 0, base_thickness / 2 ]) - cube(size = [ size, size, base_thickness ], center = true); - translate([ 0, 0, base_thickness ]) twist_base(); - } - holes(); - } + + difference() + { + union() + { + translate([0,0,base_thickness/2]) + cube( size = [size,size,base_thickness] , center = true); + translate([0,0,base_thickness]) + twist_base(); + } + holes(); + } } -module -socket() +module socket() { - difference() - { - union() - { - translate([ 0, 0, base_thickness / 2 ]) - cube(size = [ size, size, base_thickness ], center = true); - translate([ 0, 0, base_thickness ]) socket_base(); - } - holes(); - } + difference() + { + union() + { + translate([0,0,base_thickness/2]) + cube( size = [size,size,base_thickness] , center = true); + translate([0,0,base_thickness]) + socket_base(); + } + holes(); + } } -module -placed_socket() +module placed_socket() { - translate([ 0, 0, 2 * base_thickness + mount_height ]) rotate([ 0, 180, 0 ]) + translate([0,0,2*base_thickness+mount_height]) + rotate([0,180,0]) - socket(); + socket(); } -module -splitter() +module splitter() { - // for checking internal layout - translate([ 0, -splitter / 2, -splitter / 2 ]) cube(splitter); + // for checking internal layout + translate([0,-splitter/2,-splitter/2]) + cube(splitter); } -// modal display +// modal display -if (mode == 0) { - base(); +if ( mode == 0) +{ + base(); } -if (mode == 1) { - socket(); +if (mode == 1) +{ + socket(); } -if (mode == 2) { - rotate([ 0, 0, inc / 2 ]) difference() - { - placed_socket(); - // socket(); - rotate([ 0, 0, inc / 2 ]) splitter(); - } - base(); +if ( mode == 2) +{ + rotate([0,0,inc/2]) + difference() + { + placed_socket(); + //socket(); + rotate([0,0,inc/2]) + splitter(); + } + base(); } -if (mode == 3) { - intersection() - { - placed_socket(); - base(); - } +if (mode == 3) +{ + intersection() + { + placed_socket(); + base(); + } } -if (mode == 4) { - translate([ size / 2 + 5, 0, 0 ]) socket(); - translate([ -size / 2 - 5, 0, 0 ]) base(); +if( mode == 4) +{ + translate([size/2+5,0,0]) + socket(); + translate([-size/2-5,0,0]) + base(); } \ No newline at end of file diff --git a/multiply.scad b/multiply.scad index 991e0709..8c214f4a 100644 --- a/multiply.scad +++ b/multiply.scad @@ -1,22 +1,25 @@ -use include +use + /** * @deprecated * Evenly place children `no` number of times around `axis` for `angle / 360` * turns, */ -module spin(no, angle = 360, axis = Z) +module spin (no, angle = 360, axis = Z) { - mcad_rotate_multiply(no, angle / no, axis) children(); + mcad_rotate_multiply (no, angle / no, axis) + children (); } /** * @deprecated * Duplicate by rotating a copy 180° around `axis` */ -module duplicate(axis = Z) +module duplicate (axis = Z) { - mcad_duplicate(axis = axis) children(); + mcad_duplicate (axis = axis) + children (); } /** @@ -24,8 +27,8 @@ module duplicate(axis = Z) * Evenly multiply children `no` times by translating by `separation` distance * along `axis`. */ -module linear_multiply(no, separation, axis = Z) +module linear_multiply (no, separation, axis = Z) { - mcad_linear_multiply(no = no, separation = separation, axis = axis) - children(); + mcad_linear_multiply (no = no, separation = separation, axis = axis) + children (); } diff --git a/nuts_and_bolts.scad b/nuts_and_bolts.scad index 027fc0d0..6612289e 100644 --- a/nuts_and_bolts.scad +++ b/nuts_and_bolts.scad @@ -1,22 +1,22 @@ -include // THIS IS A BACKWARD COMPATIBILITY SHIM +include + // @deprecated -module -SKIPtestNutsAndBolts() +module SKIPtestNutsAndBolts () { - mcad_test_nuts_and_bolts_1(); + mcad_test_nuts_and_bolts_1 (); } // @deprecated -module nutHole(size, units = MM, tolerance = +0.0001, proj = -1) +module nutHole (size, units = MM, tolerance = +0.0001, proj = -1) { - mcad_nut_hole(size = size, tolerance = tolerance, proj = proj); + mcad_nut_hole (size = size, tolerance = tolerance, proj = proj); } // @deprecated -module boltHole(size, units = MM, length, tolerance = +0.0001, proj = -1) +module boltHole (size, units = MM, length, tolerance = +0.0001, proj = -1) { - mcad_bolt_hole( - size = size, length = length, tolerance = tolerance, proj = proj); + mcad_bolt_hole (size = size, length = length, tolerance = tolerance, + proj = proj); } diff --git a/oshw.scad b/oshw.scad index cbbcd619..c906f682 100644 --- a/oshw.scad +++ b/oshw.scad @@ -1,4 +1,3 @@ - // OSHW Logo Generator // Open Source Hardware Logo : http://oshwlogo.com/ // ------------------------------------------------- @@ -12,39 +11,31 @@ // // cc-by-sa, pierre-alain dorange, july 2012 -module gear_tooth_2d(d) -{ - polygon(points = [ - [ 0.0, 10.0 * d / 72.0 ], - [ 0.5 * d, d / 15.0 ], - [ 0.5 * d, -d / 15.0 ], - [ 0.0, -10.0 * d / 72.0 ] - ]); +module gear_tooth_2d(d) { + polygon( points=[ + [0.0,10.0*d/72.0], [0.5*d,d/15.0], + [0.5*d,-d/15.0], [0.0,-10.0*d/72.0] ] ); } -module oshw_logo_2d(d = 10.0) -{ - rotate(-135) - { - difference() - { - union() - { - circle(r = 14.0 * d / 36.0, $fn = 20); - for (i = [1:7]) - assign(rotAngle = 45 * i + 45) rotate(rotAngle) - gear_tooth_2d(d); - } - circle(r = 10.0 * d / 72.0, $fn = 20); - intersection() - { - rotate(-20) square(size = [ 10.0 * d / 18.0, 10.0 * d / 18.0 ]); - rotate(20) square(size = [ 10.0 * d / 18.0, 10.0 * d / 18.0 ]); - } - } - } +module oshw_logo_2d(d=10.0) { + rotate(-135) { + difference() { + union() { + circle(r=14.0*d/36.0,$fn=20); + for(i=[1:7]) assign(rotAngle=45*i+45) + rotate(rotAngle) gear_tooth_2d(d); + } + circle(r=10.0*d/72.0,$fn=20); + intersection() { + rotate(-20) square(size=[10.0*d/18.0,10.0*d/18.0]); + rotate(20) square(size=[10.0*d/18.0,10.0*d/18.0]); + } + } + } } // usage : oshw_logo_2d(diameter) -linear_extrude(height = 2) oshw_logo_2d(25); +linear_extrude(height=2) + oshw_logo_2d(25); + diff --git a/polyhole.scad b/polyhole.scad index dec22e4f..60029ac7 100644 --- a/polyhole.scad +++ b/polyhole.scad @@ -1,3 +1,5 @@ use + // @deprecated -module polyhole(h, d) mcad_polyhole(d, (h < 0) ? undef : h); +module polyhole (h, d) +mcad_polyhole (d, (h < 0) ? undef : h); diff --git a/rounder.scad b/rounder.scad index 7cde1b3a..53304b02 100644 --- a/rounder.scad +++ b/rounder.scad @@ -1 +1 @@ -use \ No newline at end of file +use diff --git a/screw.scad b/screw.scad index 0e0db495..eb444ec0 100644 --- a/screw.scad +++ b/screw.scad @@ -1,8 +1,9 @@ -include // Parametric screw-like things (ball screws, augers) // License: GNU LGPL 2.1 or later. // © 2010 by Elmo Mäntynen +include + /* common screw parameter length pitch = length/rotations: the distance between the turns of the thread @@ -10,83 +11,54 @@ outside_diameter inner_diameter: thickness of the shaft */ -// Uncomment to see examples -// test_auger(); -// test_ball_groove(); -// test_ball_groove2(); -// test_ball_screw(); +//Uncomment to see examples +//test_auger(); +//test_ball_groove(); +//test_ball_groove2(); +//test_ball_screw(); -module helix(pitch, length, slices = 500) -{ - rotations = length / pitch; - linear_extrude(height = length, - center = false, - convexity = 10, - twist = 360 * rotations, - slices = slices, - $fn = 100) child(0); +module helix(pitch, length, slices=500){ + rotations = length/pitch; + linear_extrude(height=length, center=false, convexity=10, twist=360*rotations, slices=slices, $fn=100) + child(0); } -module auger(pitch, length, outside_radius, inner_radius, taper_ratio = 0.25) -{ - union() - { - helix(pitch, length) polygon( - points = - [ - [ 0, inner_radius ], - [ outside_radius, (inner_radius * taper_ratio) ], - [ outside_radius, (inner_radius * -1 * taper_ratio) ], - [ 0, (-1 * inner_radius) ] - ], - paths = [[ 0, 1, 2, 3 ]]); - cylinder(h = length, r = inner_radius); +module auger(pitch, length, outside_radius, inner_radius, taper_ratio = 0.25) { + union(){ + helix(pitch, length) + polygon(points=[[0,inner_radius],[outside_radius,(inner_radius * taper_ratio)],[outside_radius,(inner_radius * -1 * taper_ratio)],[0,(-1 * inner_radius)]], paths=[[0,1,2,3]]); + cylinder(h=length, r=inner_radius); } } -module -test_auger() -{ - translate([ 50, 0, 0 ]) auger(40, 80, 25, 5); -} +module test_auger(){translate([50, 0, 0]) auger(40, 80, 25, 5);} + -module ball_groove(pitch, length, diameter, ball_radius = 10) -{ - helix(pitch, length, slices = 100) translate([ diameter, 0, 0 ]) +module ball_groove(pitch, length, diameter, ball_radius=10) { + helix(pitch, length, slices=100) + translate([diameter, 0, 0]) circle(r = ball_radius); } -module -test_ball_groove() -{ - translate([ 0, 300, 0 ]) ball_groove(100, 300, 10); -} +module test_ball_groove(){ translate([0, 300, 0]) ball_groove(100, 300, 10);} -module ball_groove2(pitch, length, diameter, ball_radius, slices = 200) -{ - rotations = length / pitch; - radius = diameter / 2; - offset = length / slices; - union() - { +module ball_groove2(pitch, length, diameter, ball_radius, slices=200){ + rotations = length/pitch; + radius=diameter/2; + offset = length/slices; + union(){ for (i = [0:slices]) { - assign(z = i * offset) - { - translate(helix_curve(pitch, radius, z)) - sphere(ball_radius, $fa = 5, $fs = 1); + assign (z = i*offset){ + translate(helix_curve(pitch, radius, z)) sphere(ball_radius, $fa=5, $fs=1); } } } } -module -test_ball_groove2() -{ - translate([ 0, 0, 0 ]) ball_groove2(100, 300, 100, 10); -} +module test_ball_groove2(){translate([0, 0, 0]) ball_groove2(100, 300, 100, 10);} -module ball_screw(pitch, length, bearing_radius = 2) {} +module ball_screw(pitch, length, bearing_radius=2) { + +} -module -test_ball_screw() -{} +module test_ball_screw(){} diff --git a/shapes/2Dshapes.scad b/shapes/2Dshapes.scad index 32f7e83a..d7b4cdb1 100644 --- a/shapes/2Dshapes.scad +++ b/shapes/2Dshapes.scad @@ -1,322 +1,282 @@ - /* * OpenSCAD 2D Shapes Library (www.openscad.org) * Copyright (C) 2012 Peter Uithoven * * License: LGPL 2.1 or later - */ +*/ // 2D Shapes -// ngon(sides, radius, center=false); -// complexRoundSquare(size,rads1=[0,0], rads2=[0,0], rads3=[0,0], rads4=[0,0], -// center=true) roundedSquare(pos=[10,10],r=2) csquare(size, center = false) -// trapezoid (bottom, height, top = undef, left_angle = undef, right_angle = -// undef) +//ngon(sides, radius, center=false); +//complexRoundSquare(size,rads1=[0,0], rads2=[0,0], rads3=[0,0], rads4=[0,0], center=true) +//roundedSquare(pos=[10,10],r=2) +//csquare(size, center = false) +//trapezoid (bottom, height, top = undef, left_angle = undef, right_angle = undef) -// ring(inside_diameter, thickness) -// ellipse(width, height) -// ellipsePart(width,height,numQuarters) -// egg_outline(width, length) +//ring(inside_diameter, thickness) +//ellipse(width, height) +//ellipsePart(width,height,numQuarters) +//egg_outline(width, length) -// donutSlice(innerSize,outerSize, start_angle, end_angle) -// pieSlice(size, start_angle, end_angle) //size in radius(es) +//donutSlice(innerSize,outerSize, start_angle, end_angle) +//pieSlice(size, start_angle, end_angle) //size in radius(es) // Examples /*use ; grid(105,105,true,4) { - // ellipse - ellipse(50,75); - - // part of ellipse (a number of quarters) - ellipsePart(50,75,3); - ellipsePart(50,75,2); - ellipsePart(50,75,1); - - // complexRoundSquare examples - complexRoundSquare([75,100],[20,10],[20,10],[20,10],[20,10]); - complexRoundSquare([75,100],[0,0],[0,0],[30,50],[20,10]); - complexRoundSquare([50,50],[10,20],[10,20],[10,20],[10,20],false); - complexRoundSquare([100,100]); - complexRoundSquare([100,100],rads1=[20,20],rads3=[20,20]); - - // pie slice - pieSlice(50,0,10); - pieSlice(50,45,190); - pieSlice([50,20],180,270); - - // donut slice - donutSlice(20,50,0,350); - donutSlice(30,50,190,270); - donutSlice([40,22],[50,30],180,270); - donutSlice([50,20],50,180,270); - donutSlice([20,30],[50,40],0,270); + // ellipse + ellipse(50,75); + + // part of ellipse (a number of quarters) + ellipsePart(50,75,3); + ellipsePart(50,75,2); + ellipsePart(50,75,1); + + // complexRoundSquare examples + complexRoundSquare([75,100],[20,10],[20,10],[20,10],[20,10]); + complexRoundSquare([75,100],[0,0],[0,0],[30,50],[20,10]); + complexRoundSquare([50,50],[10,20],[10,20],[10,20],[10,20],false); + complexRoundSquare([100,100]); + complexRoundSquare([100,100],rads1=[20,20],rads3=[20,20]); + + // pie slice + pieSlice(50,0,10); + pieSlice(50,45,190); + pieSlice([50,20],180,270); + + // donut slice + donutSlice(20,50,0,350); + donutSlice(30,50,190,270); + donutSlice([40,22],[50,30],180,270); + donutSlice([50,20],50,180,270); + donutSlice([20,30],[50,40],0,270); }*/ //---------------------- // Regular 2D shapes // The orientation might change with the implementation of circle... -module ngon(sides, radius, center = false) -{ - rotate([ 0, 0, 360 / sides / 2 ]) - circle(r = radius, $fn = sides, center = center); +module ngon(sides, radius, center=false){ + rotate([0, 0, 360/sides/2]) circle(r=radius, $fn=sides, center=center); } // 2D regular shapes -module reg_polygon(sides, radius, center = false) +module reg_polygon(sides, radius, center=false) { - function dia(r) = sqrt( - pow(r * 2, 2) / 2); // sqrt((r*2^2)/2) if only we had an exponention op - if (sides < 2) - square([ radius, 0 ]); - if (sides == 3) - triangle(radius); - if (sides == 4) - square([ dia(radius), dia(radius) ], center = true); - if (sides > 4) - circle(r = radius, $fn = sides, center = center); + function dia(r) = sqrt(pow(r*2,2)/2); //sqrt((r*2^2)/2) if only we had an exponention op + if(sides<2) square([radius,0]); + if(sides==3) triangle(radius); + if(sides==4) square([dia(radius),dia(radius)],center=true); + if(sides>4) circle(r=radius,$fn=sides,center=center); } module pentagon(radius) { - reg_polygon(5, radius); + reg_polygon(5,radius); } module hexagon(radius) { - reg_polygon(6, radius); + reg_polygon(6,radius); } module heptagon(radius) { - reg_polygon(7, radius); + reg_polygon(7,radius); } module octagon(radius) { - reg_polygon(8, radius); + reg_polygon(8,radius); } module nonagon(radius) { - reg_polygon(9, radius); + reg_polygon(9,radius); } module decagon(radius) { - reg_polygon(10, radius); + reg_polygon(10,radius); } module hendecagon(radius) { - reg_polygon(11, radius); + reg_polygon(11,radius); } module dodecagon(radius) { - reg_polygon(12, radius); + reg_polygon(12,radius); } -// size, top left radius, top right radius, bottom right radius, bottom left -// radius, center -module complexRoundSquare(size, - rads1 = [ 0, 0 ], - rads2 = [ 0, 0 ], - rads3 = [ 0, 0 ], - rads4 = [ 0, 0 ], - center = true) +// size, top left radius, top right radius, bottom right radius, bottom left radius, center +module complexRoundSquare(size,rads1=[0,0], rads2=[0,0], rads3=[0,0], rads4=[0,0], center=true) { - width = size[0]; - height = size[1]; - //%square(size=[width, height],center=true); - x1 = 0 - width / 2 + rads1[0]; - y1 = 0 - height / 2 + rads1[1]; - x2 = width / 2 - rads2[0]; - y2 = 0 - height / 2 + rads2[1]; - x3 = width / 2 - rads3[0]; - y3 = height / 2 - rads3[1]; - x4 = 0 - width / 2 + rads4[0]; - y4 = height / 2 - rads4[1]; - - scs = 0.1; // straight corner size - - x = (center) ? 0 : width / 2; - y = (center) ? 0 : height / 2; - - translate([ x, y, 0 ]) - { - hull() - { - // top left - if (rads1[0] > 0 && rads1[1] > 0) - translate([ x1, y1 ]) mirror([ 1, 0 ]) - ellipsePart(rads1[0] * 2, rads1[1] * 2, 1); - else - translate([ x1, y1 ]) square(size = [ scs, scs ]); - - // top right - if (rads2[0] > 0 && rads2[1] > 0) - translate([ x2, y2 ]) - ellipsePart(rads2[0] * 2, rads2[1] * 2, 1); - else - translate([ width / 2 - scs, 0 - height / 2 ]) - square(size = [ scs, scs ]); - - // bottom right - if (rads3[0] > 0 && rads3[1] > 0) - translate([ x3, y3 ]) mirror([ 0, 1 ]) - ellipsePart(rads3[0] * 2, rads3[1] * 2, 1); - else - translate([ width / 2 - scs, height / 2 - scs ]) - square(size = [ scs, scs ]); - - // bottom left - if (rads4[0] > 0 && rads4[1] > 0) - translate([ x4, y4 ]) rotate([ 0, 0, -180 ]) - ellipsePart(rads4[0] * 2, rads4[1] * 2, 1); - else -#translate([ x4, height / 2 - scs ]) square(size = [ scs, scs ]); - } - } + width = size[0]; + height = size[1]; + //%square(size=[width, height],center=true); + x1 = 0-width/2+rads1[0]; + y1 = 0-height/2+rads1[1]; + x2 = width/2-rads2[0]; + y2 = 0-height/2+rads2[1]; + x3 = width/2-rads3[0]; + y3 = height/2-rads3[1]; + x4 = 0-width/2+rads4[0]; + y4 = height/2-rads4[1]; + + scs = 0.1; //straight corner size + + x = (center)? 0: width/2; + y = (center)? 0: height/2; + + translate([x,y,0]) + { + hull() { + // top left + if(rads1[0] > 0 && rads1[1] > 0) + translate([x1,y1]) mirror([1,0]) ellipsePart(rads1[0]*2,rads1[1]*2,1); + else + translate([x1,y1]) square(size=[scs, scs]); + + // top right + if(rads2[0] > 0 && rads2[1] > 0) + translate([x2,y2]) ellipsePart(rads2[0]*2,rads2[1]*2,1); + else + translate([width/2-scs,0-height/2]) square(size=[scs, scs]); + + // bottom right + if(rads3[0] > 0 && rads3[1] > 0) + translate([x3,y3]) mirror([0,1]) ellipsePart(rads3[0]*2,rads3[1]*2,1); + else + translate([width/2-scs,height/2-scs]) square(size=[scs, scs]); + + // bottom left + if(rads4[0] > 0 && rads4[1] > 0) + translate([x4,y4]) rotate([0,0,-180]) ellipsePart(rads4[0]*2,rads4[1]*2,1); + else + #translate([x4,height/2-scs]) square(size=[scs, scs]); + } + } } -module roundedSquare(pos = [ 10, 10 ], r = 2) -{ - minkowski() - { - square([ pos[0] - r * 2, pos[1] - r * 2 ], center = true); - circle(r = r); - } +module roundedSquare(pos=[10,10],r=2) { + minkowski() { + square([pos[0]-r*2,pos[1]-r*2],center=true); + circle(r=r); + } } -module csquare(size, center = false) +module csquare (size, center = false) { - center = (len(center) == undef) ? [ center, center ] : center; - size = (len(size) == undef) ? [ size, size ] : size; + center = (len (center) == undef) ? [center, center] : center; + size = (len (size) == undef) ? [size, size] : size; - function get_offset(i) = center[i] ? -size[i] / 2 : 0; + function get_offset (i) = center[i] ? - size[i] / 2 : 0; - translate([ get_offset(0), get_offset(1) ]) square(size); + translate ([get_offset (0), get_offset (1)]) + square (size); } module triangle(radius) { - o = radius / 2; // equivalent to radius*sin(30) - a = radius * sqrt(3) / 2; // equivalent to radius*cos(30) - polygon(points = [ [ -a, -o ], [ 0, radius ], [ a, -o ] ], - paths = [[ 0, 1, 2 ]]); + o=radius/2; //equivalent to radius*sin(30) + a=radius*sqrt(3)/2; //equivalent to radius*cos(30) + polygon(points=[[-a,-o],[0,radius],[a,-o]],paths=[[0,1,2]]); } -module trapezoid(bottom, - height, - top = undef, - left_angle = undef, - right_angle = undef) +module trapezoid (bottom, height, top = undef, + left_angle = undef, right_angle = undef) { - function tan90(angle) = (angle == 90) ? 0 : tan(angle); - - function get_trapezoid_offset(adjacent, opposite) = - ((adjacent == undef && opposite == undef) - ? (bottom - top) / 2 - : (adjacent == undef) - ? bottom - tan90(90 - opposite) * height - top - : tan90(90 - adjacent) * height); - - offset_left = get_trapezoid_offset(left_angle, right_angle); - offset_right = get_trapezoid_offset(right_angle, left_angle); - - polygon([ - [ -bottom / 2, 0 ], - [ bottom / 2, 0 ], - [ bottom / 2 - offset_right, height ], - [ -bottom / 2 + offset_left, height ] - ]); + function tan90 (angle) = (angle == 90) ? 0 : tan (angle); + + function get_trapezoid_offset (adjacent, opposite) = ( + (adjacent == undef && opposite == undef) ? (bottom - top) / 2 : + (adjacent == undef) ? bottom - tan90 (90 - opposite) * height - top : + tan90 (90 - adjacent) * height + ); + + offset_left = get_trapezoid_offset (left_angle, right_angle); + offset_right = get_trapezoid_offset (right_angle, left_angle); + + polygon ([ + [-bottom / 2, 0], + [bottom / 2, 0], + [bottom / 2 - offset_right, height], + [-bottom / 2 + offset_left, height] + ]); } -module ring(inside_diameter, thickness) -{ - difference() - { - circle(r = (inside_diameter + thickness * 2) / 2); - circle(r = inside_diameter / 2); - } +module ring(inside_diameter, thickness){ + difference(){ + circle(r=(inside_diameter+thickness*2)/2); + circle(r=inside_diameter/2); + } } -module ellipse(width, height) -{ - scale([ 1, height / width, 1 ]) circle(r = width / 2); +module ellipse(width, height) { + scale([1, height/width, 1]) circle(r=width/2); } -module ellipsePart(width, height, numQuarters) +module ellipsePart(width,height,numQuarters) { - o = 1; // slight overlap to fix a bug - difference() - { - ellipse(width, height); - if (numQuarters <= 3) - translate([ 0 - width / 2 - o, 0 - height / 2 - o, 0 ]) - square([ width / 2 + o, height / 2 + o ]); - if (numQuarters <= 2) - translate([ 0 - width / 2 - o, -o, 0 ]) - square([ width / 2 + o, height / 2 + o * 2 ]); - if (numQuarters < 2) - translate([ -o, 0, 0 ]) - square([ width / 2 + o * 2, height / 2 + o ]); - } + o = 1; //slight overlap to fix a bug + difference() + { + ellipse(width,height); + if(numQuarters <= 3) + translate([0-width/2-o,0-height/2-o,0]) square([width/2+o,height/2+o]); + if(numQuarters <= 2) + translate([0-width/2-o,-o,0]) square([width/2+o,height/2+o*2]); + if(numQuarters < 2) + translate([-o,0,0]) square([width/2+o*2,height/2+o]); + } } // The ratio of length and width is about 1.39 for a real egg -module egg_outline(width, length) -{ - translate([ 0, width / 2, 0 ]) union() - { - rotate([ 0, 0, 180 ]) difference() - { - ellipse(width, 2 * length - width); - translate([ -length / 2, 0, 0 ]) square(length); +module egg_outline(width, length){ + translate([0, width/2, 0]) union(){ + rotate([0, 0, 180]) difference(){ + ellipse(width, 2*length-width); + translate([-length/2, 0, 0]) square(length); } - circle(r = width / 2); + circle(r=width/2); } } -module donutSlice(innerSize, outerSize, start_angle, end_angle) -{ +module donutSlice(innerSize,outerSize, start_angle, end_angle) +{ difference() { pieSlice(outerSize, start_angle, end_angle); - if (len(innerSize) > 1) - ellipse(innerSize[0] * 2, innerSize[1] * 2); - else - circle(innerSize); + if(len(innerSize) > 1) ellipse(innerSize[0]*2,innerSize[1]*2); + else circle(innerSize); } } -module pieSlice(size, start_angle, end_angle) // size in radius(es) -{ - rx = ((len(size) > 1) ? size[0] : size); - ry = ((len(size) > 1) ? size[1] : size); - trx = rx * sqrt(2) + 1; - try - = ry * sqrt(2) + 1; +module pieSlice(size, start_angle, end_angle) //size in radius(es) +{ + rx = ((len(size) > 1)? size[0] : size); + ry = ((len(size) > 1)? size[1] : size); + trx = rx* sqrt(2) + 1; + try = ry* sqrt(2) + 1; a0 = (4 * start_angle + 0 * end_angle) / 4; a1 = (3 * start_angle + 1 * end_angle) / 4; a2 = (2 * start_angle + 2 * end_angle) / 4; a3 = (1 * start_angle + 3 * end_angle) / 4; a4 = (0 * start_angle + 4 * end_angle) / 4; - if (end_angle > start_angle) - intersection() - { - if (len(size) > 1) - ellipse(rx * 2, ry * 2); - else - circle(rx); - polygon([ - [ 0, 0 ], - [ trx * cos(a0), try * sin(a0) ], - [ trx * cos(a1), try * sin(a1) ], - [ trx * cos(a2), try * sin(a2) ], - [ trx * cos(a3), try * sin(a3) ], - [ trx * cos(a4), try * sin(a4) ], - [ 0, 0 ] - ]); - } + if(end_angle > start_angle) + intersection() { + if(len(size) > 1) + ellipse(rx*2,ry*2); + else + circle(rx); + polygon([ + [0,0], + [trx * cos(a0), try * sin(a0)], + [trx * cos(a1), try * sin(a1)], + [trx * cos(a2), try * sin(a2)], + [trx * cos(a3), try * sin(a3)], + [trx * cos(a4), try * sin(a4)], + [0,0] + ]); + } } diff --git a/shapes/3Dshapes.scad b/shapes/3Dshapes.scad index 58f17c50..45d155ba 100644 --- a/shapes/3Dshapes.scad +++ b/shapes/3Dshapes.scad @@ -1,4 +1,3 @@ -use /* * OpenSCAD Shapes Library (www.openscad.org) * Copyright (C) 2009 Catarina Mota @@ -11,41 +10,44 @@ use */ // 3D Shapes -// box(width, height, depth); -// mcad_rounded_box (size, radius, sidesonly, center=false); -// ccube (size, center = false); +//box(width, height, depth); +//mcad_rounded_box (size, radius, sidesonly, center=false); +//ccube (size, center = false); + +//cone(height, radius); +//ellipsoid(width, height); +//teardrop(radius, length, angle); +//flat_teardrop(radius, length, angle); + +//torus(outerRadius, innerRadius); +//torus2(r1, r2); +//oval_torus(inner_radius, thickness=[0, 0]); -// cone(height, radius); -// ellipsoid(width, height); -// teardrop(radius, length, angle); -// flat_teardrop(radius, length, angle); +//tube(height, radius, wall, center = false); +//tube2(height, ID, OD, center = false); +//oval_tube(width, height, depth, wall, center = false); -// torus(outerRadius, innerRadius); -// torus2(r1, r2); -// oval_torus(inner_radius, thickness=[0, 0]); +//hexagon(height, depth); +//octagon(height, depth); +//dodecagon(height, depth); +//hexagram(height, depth); -// tube(height, radius, wall, center = false); -// tube2(height, ID, OD, center = false); -// oval_tube(width, height, depth, wall, center = false); +//rightTriangle(adjacent, opposite, depth); +//equiTriangle(side, depth); +//triangle_pyramid(radius); +//square_pyramid(base_x, base_y,height); -// hexagon(height, depth); -// octagon(height, depth); -// dodecagon(height, depth); -// hexagram(height, depth); -// rightTriangle(adjacent, opposite, depth); -// equiTriangle(side, depth); -// triangle_pyramid(radius); -// square_pyramid(base_x, base_y,height); +//12ptStar(height, depth); -// 12ptStar(height, depth); //---------------------- +use + // size is a vector [w, h, d] -module box(width, height, depth) -{ - cube([ width, height, depth ], true); +module box(width, height, depth) { + cube([width, height, depth], true); } // Author: Marius Kintel @@ -58,54 +60,53 @@ module box(width, height, depth) // mcad_rounded_box([20, 30, 40], 5, true); // size is a vector [w, h, d] -module mcad_rounded_box(size, radius, sidesonly, center = false) -{ - module - place_xy() for (x = [ - size[0] / 2 - radius, - -size[0] / 2 + - radius - ]) for (y = [ size[1] / 2 - radius, -size[1] / 2 + - radius ]) translate([ x, y, 0 ]) children(); - - translate(center ? [ 0, 0, 0 ] : size / 2) hull() if (sidesonly) - { - place_xy() cylinder(r = radius, h = size[2], center = true); - } - else - { - for (z = [ size[2] / 2 - radius, -size[2] / 2 + radius ]) - translate([ 0, 0, z ]) place_xy() sphere(r = radius); +module mcad_rounded_box (size, radius, sidesonly, center=false) +{ + module place_xy () + for (x = [size[0]/2 - radius, -size[0]/2 + radius]) + for (y = [size[1]/2 - radius, -size[1]/2 + radius]) + translate ([x, y, 0]) + children (); + + translate (center ? [0, 0, 0] : size / 2) + hull () + if (sidesonly) { + place_xy () + cylinder (r = radius, h = size[2], center=true); + + } else { + for (z = [size[2]/2 - radius, -size[2]/2 + radius]) + translate ([0, 0, z]) + place_xy () + sphere (r = radius); } } -module ccube(size, center = false) +module ccube (size, center = false) { - center = (len(center) == undef) ? [ center, center, center ] : center; - size = (len(size) == undef) ? [ size, size, size ] : size; + center = (len (center) == undef) ? [center, center, center] : center; + size = (len (size) == undef) ? [size, size, size] : size; - function get_offset(i) = center[i] ? -size[i] / 2 : 0; + function get_offset (i) = center[i] ? - size[i] / 2 : 0; - translate([ get_offset(0), get_offset(1), get_offset(2) ]) cube(size); + translate ([get_offset (0), get_offset (1), get_offset (2)]) + cube (size); } -module cone(height, radius, center = false) -{ - cylinder(height, radius, 0, center); +module cone(height, radius, center = false) { + cylinder(height, radius, 0, center); } -module ellipsoid(w, h, center = false) -{ - scale([ 1, h / w, 1 ]) sphere(r = w / 2, center = center); +module ellipsoid(w, h, center = false) { + scale([1, h/w, 1]) sphere(r=w/2, center=center); } -module egg(width, lenght) -{ - rotate_extrude() difference() - { - egg_outline(width, lenght); - translate([ -lenght, 0, 0 ]) cube(2 * lenght, center = true); - } +module egg(width, lenght){ + rotate_extrude() + difference(){ + egg_outline(width, lenght); + translate([-lenght, 0, 0]) cube(2*lenght, center=true); + } } /* From http://www.thingiverse.com/thing:3457 @@ -125,322 +126,247 @@ module egg(width, lenght) along with this program. If not, see . */ + /* -This script generates a teardrop shape at the appropriate angle -to prevent overhangs greater than 45 degrees. The angle is in degrees, -and is a rotation around the Y axis. You can then rotate around Z -to point it in any direction. Rotation around X or Y will cause the angle to +This script generates a teardrop shape at the appropriate angle +to prevent overhangs greater than 45 degrees. The angle is in degrees, +and is a rotation around the Y axis. You can then rotate around Z +to point it in any direction. Rotation around X or Y will cause the angle to be wrong. */ -module teardrop(radius, length, angle) -{ - rotate([ 0, angle, 0 ]) union() - { - linear_extrude( - height = length, center = true, convexity = radius, twist = 0) - circle(r = radius, center = true, $fn = 30); - linear_extrude( - height = length, center = true, convexity = radius, twist = 0) - projection(cut = false) rotate([ 0, -angle, 0 ]) - translate([ 0, 0, radius * sin(45) * 1.5 ]) - cylinder(h = radius * sin(45), - r1 = radius * sin(45), - r2 = 0, - center = true, - $fn = 30); - } - - // I worked this portion out when a bug was causing the projection - // above to take FOREVER to calculate. It works as a replacement, - // and I figured I'd leave it here just in case. - /* - #polygon(points = [[radius * cos(-angle / 2), radius * sin(-angle / - 2), 0],[radius * cos(-angle / 2), radius * -sin(-angle / 2), - 0],[(sin(-angle - 45) + cos(-angle - 45)) * radius, 0, 0]], paths = [[0, - 1, 2]]); #polygon(points = [[radius * -cos(-angle / 2), radius * - sin(-angle / 2), 0],[radius * -cos(-angle / 2), radius * -sin(-angle / - 2), 0],[(sin(-angle - 45) + cos(-angle - 45)) * radius, 0, 0]], paths = - [[0, 1, 2]]); #polygon(points = [[radius * sin(-angle / 2), radius * - cos(-angle / 2), 0],[radius * sin(-angle / 2), radius * -cos(-angle / 2), - 0],[(sin(-angle - 45) + cos(-angle - 45)) * radius, 0, 0]], paths = [[0, - 1, 2]]); - */ +module teardrop(radius, length, angle) { + rotate([0, angle, 0]) union() { + linear_extrude(height = length, center = true, convexity = radius, twist = 0) + circle(r = radius, center = true, $fn = 30); + linear_extrude(height = length, center = true, convexity = radius, twist = 0) + projection(cut = false) rotate([0, -angle, 0]) translate([0, 0, radius * sin(45) * 1.5]) cylinder(h = radius * sin(45), r1 = radius * sin(45), r2 = 0, center = true, $fn = 30); + } + +//I worked this portion out when a bug was causing the projection +//above to take FOREVER to calculate. It works as a replacement, +//and I figured I'd leave it here just in case. +/* + #polygon(points = [[radius * cos(-angle / 2), radius * sin(-angle / 2), 0],[radius * cos(-angle / 2), radius * -sin(-angle / 2), 0],[(sin(-angle - 45) + cos(-angle - 45)) * radius, 0, 0]], paths = [[0, 1, 2]]); + #polygon(points = [[radius * -cos(-angle / 2), radius * sin(-angle / 2), 0],[radius * -cos(-angle / 2), radius * -sin(-angle / 2), 0],[(sin(-angle - 45) + cos(-angle - 45)) * radius, 0, 0]], paths = [[0, 1, 2]]); + #polygon(points = [[radius * sin(-angle / 2), radius * cos(-angle / 2), 0],[radius * sin(-angle / 2), radius * -cos(-angle / 2), 0],[(sin(-angle - 45) + cos(-angle - 45)) * radius, 0, 0]], paths = [[0, 1, 2]]); + */ } /* * Simple intersection method to implement a flat/truncated teardrop */ -module flat_teardrop(radius, length, angle) -{ - intersection() - { - rotate([ 0, angle, 0 ]) - { - cube(size = [ radius * 2, radius * 2, length ], center = true); - } - teardrop(radius, length, angle); - } +module flat_teardrop(radius, length, angle) { + intersection() { + rotate([0, angle, 0]) { + cube(size=[radius * 2, radius * 2, length], center=true); + } + teardrop(radius, length, angle); + } } module torus(outerRadius, innerRadius) { - r = (outerRadius - innerRadius) / 2; - rotate_extrude() translate([ innerRadius + r, 0, 0 ]) circle(r); + r=(outerRadius-innerRadius)/2; + rotate_extrude() translate([innerRadius+r,0,0]) circle(r); } module torus2(r1, r2) { - rotate_extrude() translate([ r1, 0, 0 ]) circle(r2); + rotate_extrude() translate([r1,0,0]) circle(r2); } -module oval_torus(inner_radius, thickness = [ 0, 0 ]) +module oval_torus(inner_radius, thickness=[0, 0]) { - rotate_extrude() translate([ inner_radius + thickness[0] / 2, 0, 0 ]) - ellipse(width = thickness[0], height = thickness[1]); + rotate_extrude() translate([inner_radius+thickness[0]/2,0,0]) ellipse(width=thickness[0], height=thickness[1]); } // wall is wall thickness -module tube(h, r, wall, center = false) -{ - linear_extrude(height = h, center = center) difference() - { - circle(r = r, center = center); - circle(r = r - wall, center = center); - } +module tube(h, r, wall, center = false) { + linear_extrude (height=h, center=center) + difference() { + circle(r=r, center=center); + circle(r=r-wall, center=center); + } } -module tube2(height, ID, OD, center = false) -{ - difference() - { - cylinder(h = height, r = OD / 2, center = center); - cylinder(h = height, r = ID / 2, center = center); - } +module tube2(height, ID, OD, center = false) { + difference() { + cylinder(h=height, r=OD/2, center=center); + cylinder(h=height, r=ID/2, center=center); + } } module oval_prism(height, rx, ry, center = false) { - scale([ 1, rx / ry, 1 ]) cylinder(h = height, r = ry, center = center); + scale([1, rx/ry, 1]) cylinder(h=height, r=ry, center=center); } // wall is wall thickness -module oval_tube(height, rx, ry, wall, center = false) -{ - difference() - { - scale([ 1, ry / rx, 1 ]) cylinder(h = height, r = rx, center = center); - translate([ 0, 0, -0.1 ]) -#scale([ (rx - wall) / rx, (ry - wall) / rx, 1 ]) \ - cylinder(h = height + 0.2, r = rx, center = center); - } +module oval_tube(height, rx, ry, wall, center = false) { + difference() { + scale([1, ry/rx, 1]) cylinder(h=height, r=rx, center=center); + translate([0,0,-0.1]) + #scale([(rx-wall)/rx, (ry-wall)/rx, 1]) cylinder(h=height+0.2, r=rx, center=center); + } } -// Tubifies any regular prism -module tubify(radius, wall) +//Tubifies any regular prism +module tubify(radius,wall) { - difference() - { - child(0); - translate([ 0, 0, -0.1 ]) - scale([ (radius - wall) / radius, (radius - wall) / radius, 2 ]) - child(0); - } + difference() + { + child(0); + translate([0, 0, -0.1]) scale([(radius-wall)/radius, (radius-wall)/radius, 2]) child(0); + } } module cylinder_tube(height, radius, wall, center = false) { - tubify(radius, wall) cylinder(h = height, r = radius, center = center); + tubify(radius,wall) + cylinder(h=height, r=radius, center=center); } -module triangle_prism(height, radius) +module triangle_prism(height,radius) { - linear_extrude(height = height) triangle(radius); + linear_extrude(height=height) triangle(radius); } -module triangle_tube(height, radius, wall) +module triangle_tube(height,radius,wall) { - tubify(radius, wall) triangle_prism(height, radius); + tubify(radius,wall) triangle_prism(height,radius); } -module pentagon_prism(height, radius) +module pentagon_prism(height,radius) { - linear_extrude(height = height) pentagon(radius); + linear_extrude(height=height) pentagon(radius); } -module pentagon_tube(height, radius, wall) +module pentagon_tube(height,radius,wall) { - tubify(radius, wall) pentagon_prism(height, radius); + tubify(radius,wall) pentagon_prism(height,radius); } -module hexagon_prism(height, radius) +module hexagon_prism(height,radius) { - linear_extrude(height = height) hexagon(radius); + linear_extrude(height=height) hexagon(radius); } -module hexagon_tube(height, radius, wall) +module hexagon_tube(height,radius,wall) { - tubify(radius, wall) hexagon_prism(height, radius); + tubify(radius,wall) hexagon_prism(height,radius); } -module heptagon_prism(height, radius) +module heptagon_prism(height,radius) { - linear_extrude(height = height) heptagon(radius); + linear_extrude(height=height) heptagon(radius); } -module heptagon_tube(height, radius, wall) +module heptagon_tube(height,radius,wall) { - tubify(radius, wall) heptagon_prism(height, radius); + tubify(radius,wall) heptagon_prism(height,radius); } -module octagon_prism(height, radius) +module octagon_prism(height,radius) { - linear_extrude(height = height) octagon(radius); + linear_extrude(height=height) octagon(radius); } -module octagon_tube(height, radius, wall) +module octagon_tube(height,radius,wall) { - tubify(radius, wall) octagon_prism(height, radius); + tubify(radius,wall) octagon_prism(height,radius); } -module nonagon_prism(height, radius) +module nonagon_prism(height,radius) { - linear_extrude(height = height) nonagon(radius); + linear_extrude(height=height) nonagon(radius); } -module decagon_prism(height, radius) +module decagon_prism(height,radius) { - linear_extrude(height = height) decagon(radius); + linear_extrude(height=height) decagon(radius); } -module hendecagon_prism(height, radius) +module hendecagon_prism(height,radius) { - linear_extrude(height = height) hendecagon(radius); + linear_extrude(height=height) hendecagon(radius); } -module dodecagon_prism(height, radius) +module dodecagon_prism(height,radius) { - linear_extrude(height = height) dodecagon(radius); + linear_extrude(height=height) dodecagon(radius); } -module rightTriangle(adjacent, opposite, height) -{ - difference() - { - translate([ -adjacent / 2, opposite / 2, 0 ]) - cube([ adjacent, opposite, height ], true); - translate([ -adjacent, 0, 0 ]) - { - rotate([ 0, 0, atan(opposite / adjacent) ]) - dislocateBox(adjacent * 2, opposite, height + 2); - } +module rightTriangle(adjacent, opposite, height) { + difference() { + translate([-adjacent/2,opposite/2,0]) cube([adjacent, opposite, height], true); + translate([-adjacent,0,0]) { + rotate([0,0,atan(opposite/adjacent)]) dislocateBox(adjacent*2, opposite, height+2); } + } } -module equiTriangle(side, height) -{ - difference() - { - translate([ -side / 2, side / 2, 0 ]) - cube([ side, side, height ], true); - rotate([ 0, 0, 30 ]) dislocateBox(side * 2, side, height); - translate([ -side, 0, 0 ]) - { - rotate([ 0, 0, 60 ]) dislocateBox(side * 2, side, height); - } +module equiTriangle(side, height) { + difference() { + translate([-side/2,side/2,0]) cube([side, side, height], true); + rotate([0,0,30]) dislocateBox(side*2, side, height); + translate([-side,0,0]) { + rotate([0,0,60]) dislocateBox(side*2, side, height); } + } } module triangle_pyramid(radius) { - o = radius / 2; // equivalent to radius*sin(30) - a = radius * sqrt(3) / 2; // equivalent to radius*cos(30) - polyhedron(points = - [ - [ -a, -o, -o ], - [ a, -o, -o ], - [ 0, radius, -o ], - [ 0, 0, radius ] - ], - triangles = - [ [ 0, 1, 2 ], [ 1, 2, 3 ], [ 0, 1, 3 ], [ 0, 2, 3 ] ]); -} - -module square_pyramid(base_x, base_y, height) + o=radius/2; //equivalent to radius*sin(30) + a=radius*sqrt(3)/2; //equivalent to radius*cos(30) + polyhedron(points=[[-a,-o,-o],[a,-o,-o],[0,radius,-o],[0,0,radius]],triangles=[[0,1,2],[1,2,3],[0,1,3],[0,2,3]]); +} + +module square_pyramid(base_x, base_y,height) { - w = base_x / 2; - h = base_y / 2; - polyhedron(points = - [ - [ -w, -h, 0 ], - [ -w, h, 0 ], - [ w, h, 0 ], - [ w, -h, 0 ], - [ 0, 0, height ] - ], - triangles = [ - [ 0, 3, 2, 1 ], - [ 0, 1, 4 ], - [ 1, 2, 4 ], - [ 2, 3, 4 ], - [ 3, 0, 4 ] - ]); + w=base_x/2; + h=base_y/2; + polyhedron(points=[[-w,-h,0],[-w,h,0],[w,h,0],[w,-h,0],[0,0,height]],triangles=[[0,3,2,1], [0,1,4], [1,2,4], [2,3,4], [3,0,4]]); } // Tests: -module -test_square_pyramid() +module test_square_pyramid() { square_pyramid(10, 20, 30); } -module 12ptStar(size, height) -{ - starNum = 3; - starAngle = 360 / starNum; - for (s = [1:starNum]) { - rotate([ 0, 0, s * starAngle ]) cube([ size, size, height ], true); - } + +module 12ptStar(size, height) { + starNum = 3; + starAngle = 360/starNum; + for (s = [1:starNum]) { + rotate([0, 0, s*starAngle]) cube([size, size, height], true); + } } //----------------------- -// MOVES THE ROTATION AXIS OF A BOX FROM ITS CENTER TO THE BOTTOM LEFT CORNER -module dislocateBox(w, h, d) -{ - translate([ 0, 0, -d / 2 ]) cube([ w, h, d ]); +//MOVES THE ROTATION AXIS OF A BOX FROM ITS CENTER TO THE BOTTOM LEFT CORNER +module dislocateBox(w, h, d) { + translate([0,0,-d/2]) cube([w,h,d]); } //----------------------- // Tests -// module test2D_ellipse(){ellipse(10, 5);} -module -test_ellipsoid() -{ - ellipsoid(10, 5); -} +//module test2D_ellipse(){ellipse(10, 5);} +module test_ellipsoid(){ellipsoid(10, 5);} -// module test2D_egg_outline(){egg_outline();} +//module test2D_egg_outline(){egg_outline();} // unregular_shapes.scad // Copyright 2011 Elmo Mäntynen // LGPL 2.1 -// Give a list of 4+4 points (check order) to form an 8 point polyhedron -module connect_squares(points) -{ - polyhedron(points = points, triangles = [ - [ 0, 1, 2 ], - [ 3, 0, 2 ], - [ 7, 6, 5 ], - [ 7, 5, 4 ], // Given polygons - [ 0, 4, 1 ], - [ 4, 5, 1 ], - [ 1, 5, 2 ], - [ 2, 5, 6 ], // Connecting - [ 2, 6, 3 ], - [ 3, 6, 7 ], - [ 3, 4, 0 ], - [ 3, 7, 4 ] - ]); // sides +// Give a list of 4+4 points (check order) to form an 8 point polyhedron +module connect_squares(points){ + polyhedron(points=points, + triangles=[[0,1,2], [3,0,2], [7,6,5], [7,5,4], // Given polygons + [0,4,1], [4,5,1], [1,5,2], [2,5,6], // Connecting + [2,6,3], [3,6,7], [3,4,0], [3,7,4]]);// sides } diff --git a/shapes/3d_triangle.scad b/shapes/3d_triangle.scad index 197f842c..f313433a 100644 --- a/shapes/3d_triangle.scad +++ b/shapes/3d_triangle.scad @@ -1,5 +1,4 @@ - -// Enhancement of OpenSCAD Primitives Solid with Trinagles +// Enhancement of OpenSCAD Primitives Solid with Trinagles // Copyright (C) 2011 Rene BAUMANN, Switzerland // // This library is free software; you can redistribute it and/or @@ -13,16 +12,16 @@ // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public -// License along with this library; If not, see -// or write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// License along with this library; If not, see +// or write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // ================================================================ // -// File providing functions and modules to draw 3D - triangles -// created in the X-Y plane with hight h, using various triangle -// specification methods. -// Standard traingle geometrical definition is used. Vertices are named A,B,C, -// side a is opposite vertex A a.s.o. the angle at vertex A is named alpha, +// File providing functions and modules to draw 3D - triangles +// created in the X-Y plane with hight h, using various triangle +// specification methods. +// Standard traingle geometrical definition is used. Vertices are named A,B,C, +// side a is opposite vertex A a.s.o. the angle at vertex A is named alpha, // B(beta), C(gamma). // // This SW is a contribution to the Free Software Community doing a marvelous @@ -43,8 +42,8 @@ // co-ordinates. The trinagle's c-side lies on the x-axis // and A-corner in the co-ordinates center [0,0,0]. Geometry rules // required that a + b is greater then c. The traingle's vertices are -// computed such that it is located in the X-Y plane, side c is on the -// positive x-axis. +// computed such that it is located in the X-Y plane, side c is on the +// positive x-axis. // PARAMETER: // a : real length of side a // b : real length of side b @@ -54,18 +53,14 @@ // // COMMENT: // vertices = 3dtri_sides2coord (3,4,5); -// vertices[0] : Acord vertex A cordinates the like [x,y,z] -// ------------------------------------------------------------------------------------- +// vertices[0] : Acord vertex A cordinates the like [x,y,z] +// ------------------------------------------------------------------------------------- // -function 3dtri_sides2coord(a, b, c) = [ - [ 0, 0, 0 ], - [ c, 0, 0 ], - [ - (pow(c, 2) + pow(a, 2) - pow(b, 2)) / (2 * c), - sqrt(pow(a, 2) - pow((pow(c, 2) + pow(a, 2) - pow(b, 2)) / (2 * c), 2)), - 0 - ] -]; +function 3dtri_sides2coord (a,b,c) = [ + [0,0,0], + [c,0,0], + [(pow(c,2)+pow(a,2)-pow(b,2))/(2*c),sqrt ( pow(a,2) - + pow((pow(c,2)+pow(a,2)-pow(b,2))/(2*c),2)),0]]; // // // =========================================== @@ -74,7 +69,7 @@ function 3dtri_sides2coord(a, b, c) = [ // DESCRIPTION: // Enter triangle A,B,C - corner coordinates to get the // triangles Center of Gravity coordinates. It is assumed -// the triangle is parallel to the X-Y plane. The function +// the triangle is parallel to the X-Y plane. The function // returns always zero for the z-coordinate // PARAMETER: // Acord : [x,y,z] Coordinates of vertex A @@ -86,13 +81,10 @@ function 3dtri_sides2coord(a, b, c) = [ // COMMENT: // vertices = 3dtri_sides2coord (3,4,5); // cg = 3dtri_centerOfGravityCoord(vertices[0],vertices[1],vertices[2]); -// ------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------- // -function 3dtri_centerOfGravityCoord(Acord, Bcord, Ccord) = [ - (Acord[0] + Bcord[0] + Ccord[0]) / 3, - (Acord[1] + Bcord[1] + Ccord[1]) / 3, - 0 -]; +function 3dtri_centerOfGravityCoord (Acord,Bcord,Ccord) = [ + (Acord[0]+Bcord[0]+Ccord[0])/3,(Acord[1]+Bcord[1]+Ccord[1])/3,0]; // // // =========================================== @@ -101,7 +93,7 @@ function 3dtri_centerOfGravityCoord(Acord, Bcord, Ccord) = [ // DESCRIPTION: // Enter triangle A,B,C - corner coordinates to get the // circum circle coordinates. It is assumed -// the triangle is parallel to the X-Y plane. The function +// the triangle is parallel to the X-Y plane. The function // returns always zero for the z-coordinate // PARAMETER: // Acord : [x,y,z] Coordinates of vertex A @@ -113,23 +105,21 @@ function 3dtri_centerOfGravityCoord(Acord, Bcord, Ccord) = [ // COMMENT: // vertices = 3dtri_sides2coord (3,4,5); // cc = 3dtri_centerOfcircumcircle (vertices[0],vertices[1],vertices[2]); -// ------------------------------------------------------------------------------------- -// -function 3dtri_centerOfcircumcircle(Acord, Bcord, Ccord) = [ - 0.5 * Bcord[0], - 0.5 * ((pow(Ccord[1], 2) + pow(Ccord[0], 2) - Bcord[0] * Ccord[0]) / - Ccord[1]), - 0 -]; +// ------------------------------------------------------------------------------------- // +function 3dtri_centerOfcircumcircle (Acord,Bcord,Ccord) = + [0.5*Bcord[0], + 0.5*((pow(Ccord[1],2)+pow(Ccord[0],2)-Bcord[0]*Ccord[0])/Ccord[1]), + 0]; // +// // // =========================================== // // FUNCTION: 3dtri_radiusOfcircumcircle // DESCRIPTION: // Provides the triangle's radius from circumcircle to the vertices. -// It is assumed the triangle is parallel to the X-Y plane. The function +// It is assumed the triangle is parallel to the X-Y plane. The function // returns always zero for the z-coordinate // PARAMETER: // Vcord : [x,y,z] Coordinates of a vertex A or B,C @@ -139,14 +129,15 @@ function 3dtri_centerOfcircumcircle(Acord, Bcord, Ccord) = [ // RETURNS: // cr : Circumcircle radius // -// COMMENT: Calculate circumcircle radius of trinagle with round vertices -//having radius R = 2 vertices = 3dtri_sides2coord (3,4,5); cc = -//3dtri_centerOfcircumcircle (vertices[0],vertices[1],vertices[2]); cr = -//3dtri_radiusOfcircumcircle (vertices[0],cc,2); -// ------------------------------------------------------------------------------------- +// COMMENT: Calculate circumcircle radius of trinagle with round vertices having +// radius R = 2 +// vertices = 3dtri_sides2coord (3,4,5); +// cc = 3dtri_centerOfcircumcircle (vertices[0],vertices[1],vertices[2]); +// cr = 3dtri_radiusOfcircumcircle (vertices[0],cc,2); +// ------------------------------------------------------------------------------------- // -function 3dtri_radiusOfcircumcircle(Vcord, CCcord, R) = - sqrt(pow(CCcord[0] - Vcord[0], 2) + pow(CCcord[1] - Vcord[1], 2)) + R; +function 3dtri_radiusOfcircumcircle (Vcord,CCcord,R) = + sqrt(pow(CCcord[0]-Vcord[0],2)+pow(CCcord[1]-Vcord[1],2))+ R; // // // @@ -155,28 +146,27 @@ function 3dtri_radiusOfcircumcircle(Vcord, CCcord, R) = // FUNCTION: 3dtri_radiusOfIn_circle // DESCRIPTION: // Enter triangle A,B,C - corner coordinates to get the -// in-circle radius. It is assumed the triangle is parallel to the -// X-Y plane. The function always returns zero for the z-coordinate. +// in-circle radius. It is assumed the triangle is parallel to the +// X-Y plane. The function always returns zero for the z-coordinate. // Formula used for inner circle radius: r = 2A /(a+b+c) // PARAMETER: // Acord : [x,y,z] Coordinates of vertex A // Bcord : [x,y,z] Coordinates of vertex B // Ccord : [x,y,z] Coordinates of vertex C -// +// // RETURNS: // ir : real radius of in-circle // // COMMENT: // vertices = 3dtri_sides2coord (3,4,5); // ir = 3dtri_radiusOfIn_circle (vertices[0],vertices[1],vertices[2]); -// ------------------------------------------------------------------------------------- -// -function 3dtri_radiusOfIn_circle(Acord, Bcord, Ccord) = - Bcord[0] * Ccord[1] / - (Bcord[0] + sqrt(pow(Ccord[0] - Bcord[0], 2) + pow(Ccord[1], 2)) + - sqrt(pow(Ccord[0], 2) + pow(Ccord[1], 2))); +// ------------------------------------------------------------------------------------- // +function 3dtri_radiusOfIn_circle (Acord,Bcord,Ccord) = + Bcord[0]*Ccord[1]/(Bcord[0]+sqrt(pow(Ccord[0]-Bcord[0],2)+pow(Ccord[1],2))+ + sqrt(pow(Ccord[0],2)+pow(Ccord[1],2))); // +// // // =========================================== // @@ -184,7 +174,7 @@ function 3dtri_radiusOfIn_circle(Acord, Bcord, Ccord) = // DESCRIPTION: // Enter triangle A,B,C - corner coordinates to get the // in-circle coordinates. It is assumed -// the triangle is parallel to the X-Y plane. The function +// the triangle is parallel to the X-Y plane. The function // returns always zero for the z-coordinate // PARAMETER: // Acord : [x,y,z] Coordinates of vertex A @@ -198,24 +188,19 @@ function 3dtri_radiusOfIn_circle(Acord, Bcord, Ccord) = // vertices = 3dtri_sides2coord (3,4,5); // ir = 3dtri_radiusOfIn_circle (vertices[0],vertices[1],vertices[2]); // ic = 3dtri_centerOfIn_circle (vertices[0],vertices[1],vertices[2],ir); -// ------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------- // -function 3dtri_centerOfIn_circle(Acord, Bcord, Ccord, r) = [ - (Bcord[0] + sqrt(pow(Ccord[0] - Bcord[0], 2) + pow(Ccord[1], 2)) + - sqrt(pow(Ccord[0], 2) + pow(Ccord[1], 2))) / - 2 - - sqrt(pow(Ccord[0] - Bcord[0], 2) + pow(Ccord[1], 2)), - r, - 0 -]; +function 3dtri_centerOfIn_circle (Acord,Bcord,Ccord,r) = + [(Bcord[0]+sqrt(pow(Ccord[0]-Bcord[0],2)+pow(Ccord[1],2))+ + sqrt(pow(Ccord[0],2)+pow(Ccord[1],2)))/2-sqrt(pow(Ccord[0]-Bcord[0],2)+pow(Ccord[1],2)),r,0]; // // // ============================================ // // MODULE: 3dtri_draw // DESCRIPTION: -// Draw a standard solid triangle with A,B,C - vertices specified by its -// co-ordinates and height "h", as given by the input parameters. +// Draw a standard solid triangle with A,B,C - vertices specified by its +// co-ordinates and height "h", as given by the input parameters. // PARAMETER: // Acord : [x,y,z] Coordinates of vertex A // Bcord : [x,y,z] Coordinates of vertex B @@ -226,30 +211,16 @@ function 3dtri_centerOfIn_circle(Acord, Bcord, Ccord, r) = [ // // COMMENT: // You might use the result from function 3dtri_sides2coord -// to call module 3dtri_draw ( vertices[0],vertices[1],vertices[2], h) -// ------------------------------------------------------------------------------------- -// -module 3dtri_draw(Acord, Bcord, Ccord, h) -{ - polyhedron(points = - [ - Acord, - Bcord, - Ccord, - Acord + [ 0, 0, h ], - Bcord + [ 0, 0, h ], - Ccord + [ 0, 0, h ] - ], - triangles = [ - [ 0, 1, 2 ], - [ 0, 2, 3 ], - [ 3, 2, 5 ], - [ 3, 5, 4 ], - [ 1, 5, 2 ], - [ 4, 5, 1 ], - [ 4, 1, 0 ], - [ 0, 3, 4 ] - ]); +// to call module 3dtri_draw ( vertices[0],vertices[1],vertices[2], h) +// ------------------------------------------------------------------------------------- +// +module 3dtri_draw ( Acord, Bcord, Ccord, h) { +polyhedron (points=[Acord,Bcord,Ccord, + Acord+[0,0,h],Bcord+[0,0,h],Ccord+[0,0,h]], + triangles=[ [0,1,2],[0,2,3],[3,2,5], + [3,5,4],[1,5,2],[4,5,1], + [4,1,0],[0,3,4]]); + }; // // @@ -257,12 +228,12 @@ module 3dtri_draw(Acord, Bcord, Ccord, h) // // MODULE: 3dtri_rnd_draw // DESCRIPTION: -// Draw a round corner triangle with A,B,C - vertices specified by its +// Draw a round corner triangle with A,B,C - vertices specified by its // co-ordinates, height h and round vertices having radius "r". // As specified by the input parameters. // Please note, the tringles side lenght gets extended by "2 * r", -// and the vertices coordinates define the centers of the -// circles with radius "r". +// and the vertices coordinates define the centers of the +// circles with radius "r". // PARAMETER: // Acord : [x,y,z] Coordinates of vertex A // Bcord : [x,y,z] Coordinates of vertex B @@ -274,101 +245,72 @@ module 3dtri_draw(Acord, Bcord, Ccord, h) // // COMMENT: // You might use the result from function 3dtri_sides2coord -// to call module 3dtri_rnd_draw ( vertices[0],vertices[1],vertices[2], h, -//r) -// ------------------------------------------------------------------------------------- -// -module 3dtri_rnd_draw(Acord, Bcord, Ccord, h, r) -{ - Avect = Ccord - Bcord; // vector pointing from vertex B to vertex C - p0 = Acord + [ 0, -r, 0 ]; - p1 = Bcord + [ 0, -r, 0 ]; - p2 = Bcord + [ - r * Avect[1] / sqrt(pow(Avect[0], 2) + pow(Avect[1], 2)), - -r * Avect[0] / sqrt(pow(Avect[0], 2) + pow(Avect[1], 2)), - 0 - ]; - p3 = Ccord + [ - r * Avect[1] / sqrt(pow(Avect[0], 2) + pow(Avect[1], 2)), - -r * Avect[0] / sqrt(pow(Avect[0], 2) + pow(Avect[1], 2)), - 0 - ]; - p4 = Ccord + [ - -r * Ccord[1] / sqrt(pow(Ccord[0], 2) + pow(Ccord[1], 2)), - r * Ccord[0] / sqrt(pow(Ccord[0], 2) + pow(Ccord[1], 2)), - 0 - ]; - p5 = Acord + [ - -r * Ccord[1] / sqrt(pow(Ccord[0], 2) + pow(Ccord[1], 2)), - r * Ccord[0] / sqrt(pow(Ccord[0], 2) + pow(Ccord[1], 2)), - 0 - ]; - bottom_triangles = [ [ 0, 1, 2 ], [ 0, 2, 3 ], [ 0, 3, 4 ], [ 0, 4, 5 ] ]; - c_side_triangles = [ [ 7, 1, 0 ], [ 0, 6, 7 ] ]; - a_side_triangles = [ [ 2, 8, 3 ], [ 8, 9, 3 ] ]; - b_side_triangles = [ [ 4, 10, 5 ], [ 10, 11, 5 ] ]; - A_edge_triangles = [ [ 0, 5, 11 ], [ 0, 11, 6 ] ]; - B_edge_triangles = [ [ 1, 7, 2 ], [ 2, 7, 8 ] ]; - C_edge_triangles = [ [ 3, 9, 4 ], [ 9, 10, 4 ] ]; - top_triangles = [ [ 11, 7, 6 ], [ 11, 8, 7 ], [ 11, 10, 8 ], [ 8, 10, 9 ] ]; - union() - { - polyhedron( - points = - [ - p0, - p1, - p2, - p3, - p4, - p5, - p0 + [ 0, 0, h ], - p1 + [ 0, 0, h ], - p2 + [ 0, 0, h ], - p3 + [ 0, 0, h ], - p4 + [ 0, 0, h ], - p5 + [ 0, 0, h ] - ], - triangles = [ - bottom_triangles[0], bottom_triangles[1], bottom_triangles[2], - bottom_triangles[3], A_edge_triangles[0], A_edge_triangles[1], - c_side_triangles[0], c_side_triangles[1], B_edge_triangles[0], - B_edge_triangles[1], a_side_triangles[0], a_side_triangles[1], - C_edge_triangles[0], C_edge_triangles[1], b_side_triangles[0], - b_side_triangles[1], top_triangles[0], top_triangles[1], - top_triangles[2], top_triangles[3] - ]); - translate(Acord) cylinder(r1 = r, r2 = r, h = h, center = false); - translate(Bcord) cylinder(r1 = r, r2 = r, h = h, center = false); - translate(Ccord) cylinder(r1 = r, r2 = r, h = h, center = false); - }; +// to call module 3dtri_rnd_draw ( vertices[0],vertices[1],vertices[2], h, r) +// ------------------------------------------------------------------------------------- +// +module 3dtri_rnd_draw ( Acord, Bcord, Ccord, h, r) { +Avect=Ccord-Bcord; // vector pointing from vertex B to vertex C +p0=Acord + [0,-r,0]; +p1=Bcord + [0,-r,0]; +p2=Bcord + [r*Avect[1]/sqrt(pow(Avect[0],2)+pow(Avect[1],2)), + -r*Avect[0]/sqrt(pow(Avect[0],2)+pow(Avect[1],2)) ,0]; +p3=Ccord + [r*Avect[1]/sqrt(pow(Avect[0],2)+pow(Avect[1],2)), + -r*Avect[0]/sqrt(pow(Avect[0],2)+pow(Avect[1],2)) ,0]; +p4=Ccord +[- r*Ccord[1]/sqrt(pow(Ccord[0],2)+pow(Ccord[1],2)), + r*Ccord[0]/sqrt(pow(Ccord[0],2)+pow(Ccord[1],2)) ,0]; +p5=Acord + [- r*Ccord[1]/sqrt(pow(Ccord[0],2)+pow(Ccord[1],2)), + r*Ccord[0]/sqrt(pow(Ccord[0],2)+pow(Ccord[1],2)) ,0]; +bottom_triangles = [[0,1,2],[0,2,3],[0,3,4],[0,4,5]]; +c_side_triangles = [[7,1,0],[0,6,7]]; +a_side_triangles = [[2,8,3],[8,9,3]]; +b_side_triangles = [[4,10,5],[10,11,5]]; +A_edge_triangles = [[0,5,11],[0,11,6]]; +B_edge_triangles = [[1,7,2],[2,7,8]]; +C_edge_triangles = [[3,9,4],[9,10,4]]; +top_triangles = [[11,7,6],[11,8,7],[11,10,8],[8,10,9]]; +union () { + polyhedron (points=[p0,p1,p2,p3,p4,p5, + p0+[0,0,h],p1+[0,0,h],p2+[0,0,h],p3+[0,0,h],p4+[0,0,h],p5+[0,0,h]], + triangles=[ bottom_triangles[0],bottom_triangles[1],bottom_triangles[2],bottom_triangles[3], + A_edge_triangles[0],A_edge_triangles[1], + c_side_triangles[0],c_side_triangles[1], + B_edge_triangles[0],B_edge_triangles[1], + a_side_triangles[0],a_side_triangles[1], + C_edge_triangles[0],C_edge_triangles[1], + b_side_triangles[0],b_side_triangles[1], + top_triangles[0],top_triangles[1],top_triangles[2],top_triangles[3]]); + translate(Acord) cylinder(r1=r,r2=r,h=h,center=false); + translate(Bcord) cylinder(r1=r,r2=r,h=h,center=false); + translate(Ccord) cylinder(r1=r,r2=r,h=h,center=false); +}; } // // ============================================== // // Demo Application - copy into new file and uncomment or uncomment here but -// without uncommenting the use <...> statement, then press F6 - Key +// without uncommenting the use <...> statement, then press F6 - Key // // use ; //$fn=50; // h =4; // r=2; // echo ("Draws a right angle triangle with its circumcircle and in-circle"); -// echo ("The calculated co-ordinates and radius are show in this console -// window"); echo ("Geometry rules for a right angle triangle say, that the -// circumcircle is the"); echo ("Thales Circle which center must be in the -// middle of the triangle's c - side"); echo -// ("==========================================="); vertices = -// 3dtri_sides2coord (30,40,50); echo("A = ",vertices[0]," B = ",vertices[1]," -// C = ",vertices[2]); cg = 3dtri_centerOfGravityCoord -// (vertices[0],vertices[1],vertices[2]); echo (" Center of gravity = ",cg); cc -// = 3dtri_centerOfcircumcircle (vertices[0],vertices[1],vertices[2]); echo (" -// Center of circumcircle = ",cc); cr = 3dtri_radiusOfcircumcircle -// (vertices[0],cc,r); echo(" Radius of circumcircle ",cr); ir = -// 3dtri_radiusOfIn_circle (vertices[0],vertices[1],vertices[2]); echo (" -// Radius of in-circle = ",ir); ic = 3dtri_centerOfIn_circle -// (vertices[0],vertices[1],vertices[2],ir); echo (" Center of in-circle = -// ",ic); +// echo ("The calculated co-ordinates and radius are show in this console window"); +// echo ("Geometry rules for a right angle triangle say, that the circumcircle is the"); +// echo ("Thales Circle which center must be in the middle of the triangle's c - side"); +// echo ("==========================================="); +// vertices = 3dtri_sides2coord (30,40,50); +// echo("A = ",vertices[0]," B = ",vertices[1]," C = ",vertices[2]); +// cg = 3dtri_centerOfGravityCoord (vertices[0],vertices[1],vertices[2]); +// echo (" Center of gravity = ",cg); +// cc = 3dtri_centerOfcircumcircle (vertices[0],vertices[1],vertices[2]); +// echo (" Center of circumcircle = ",cc); +// cr = 3dtri_radiusOfcircumcircle (vertices[0],cc,r); +// echo(" Radius of circumcircle ",cr); +// ir = 3dtri_radiusOfIn_circle (vertices[0],vertices[1],vertices[2]); +// echo (" Radius of in-circle = ",ir); +// ic = 3dtri_centerOfIn_circle (vertices[0],vertices[1],vertices[2],ir); +// echo (" Center of in-circle = ",ic); // translate(cc+[0,0,5*h/2]) difference () { // cylinder (h=5*h,r1=cr+4,r2=cr+4,center=true); // cylinder (h=6*h,r1=cr,r2=cr,center=true);} @@ -376,12 +318,10 @@ module 3dtri_rnd_draw(Acord, Bcord, Ccord, h, r) // union () { // difference () { // 3dtri_rnd_draw (vertices[0], vertices[1], vertices[2],5*h,r); -// scale([0.8,0.8,1]) translate([6,2,4*h]) 3dtri_rnd_draw -// (vertices[0], vertices[1], vertices[2],5*h,r); +// scale([0.8,0.8,1]) translate([6,2,4*h]) 3dtri_rnd_draw (vertices[0], vertices[1], vertices[2],5*h,r); // } -// translate (ic+[0,0,5*h]) -// cylinder(h=10*h,r1=ir+r,r2=ir+r,center=true); +// translate (ic+[0,0,5*h]) cylinder(h=10*h,r1=ir+r,r2=ir+r,center=true); // } -// translate (ic+[0,0,5*h]) -// cylinder(h=12*h,r1=0.5*ir,r2=0.5*ir,center=true); +// translate (ic+[0,0,5*h]) cylinder(h=12*h,r1=0.5*ir,r2=0.5*ir,center=true); // } + diff --git a/shapes/cylinder.scad b/shapes/cylinder.scad index bb70ef27..438fe124 100644 --- a/shapes/cylinder.scad +++ b/shapes/cylinder.scad @@ -1,95 +1,107 @@ -use -use include -module mcad_rounded_cylinder( +use +use + +module mcad_rounded_cylinder ( // same options as cylinder() - r = undef, - h = undef, - d = undef, - r1 = undef, - r2 = undef, - d1 = undef, - d2 = undef, + r = undef, h = undef, d = undef, + r1 = undef, r2 = undef, + d1 = undef, d2 = undef, center = false, // rounding radius round_r = 0, - round_r1 = 0, - round_r2 = 0, - slices = 0) + round_r1 = 0, round_r2 = 0, + slices = 0 +) { // First resolve all the required values from arguments... r = (r == undef && d != undef) ? d / 2 : r; - function resolve_numbered_radius(rN, dN) = - ((rN == undef) ? ((dN != undef) ? dN / 2 : r) : rN); + function resolve_numbered_radius (rN, dN) = ( + (rN == undef) ? ( + (dN != undef) ? dN / 2 : + r + ) : rN + ); - r1 = resolve_numbered_radius(r1, d1); - r2 = resolve_numbered_radius(r2, d2); + r1 = resolve_numbered_radius (r1, d1); + r2 = resolve_numbered_radius (r2, d2); round_r1 = (round_r1 == 0) ? round_r : round_r1; round_r2 = (round_r2 == 0) ? round_r : round_r2; inv_gradient = (r2 - r1) / h; - module trapezoid(top, bottom, h) + module trapezoid (top, bottom, h) { - polygon([ [ 0, 0 ], [ 0, h ], [ top, h ], [ bottom, 0 ] ]); + polygon ([ + [0, 0], + [0, h], + [top, h], + [bottom, 0] + ]); } - module basic_section() { trapezoid(top = r2, bottom = r1, h = h); } - - module scale_at(factor, pos = [ 0, 0, 0 ]) + module basic_section () { - translate(pos) scale(factor) translate(pos * -1) children(); + trapezoid (top = r2, bottom = r1, h = h); } - module round_corner(r, pos) + module scale_at (factor, pos = [0, 0, 0]) { - offset(r = r, $fn = slices) offset(r = -r) scale_at(10, pos = pos) - children(); + translate (pos) + scale (factor) + translate (pos * -1) + children (); } - translate([ 0, 0, center ? -h / 2 : 0 ]) rotate_extrude() hull() + module round_corner (r, pos) { - intersection() - { - union() - { - difference() - { - round_corner(round_r2, [ r2, h ]) basic_section(); - - translate([ -epsilon, -epsilon ]) square([ - max(r1, r2) + epsilon * 2, - max(epsilon, round_r1 + epsilon) - ]); + offset (r = r, $fn = slices) + offset (r = -r) + scale_at (10, pos = pos) + children (); + } + + translate ([0, 0, center ? -h / 2 : 0]) + rotate_extrude () + hull () { + intersection () { + union () { + difference () { + round_corner (round_r2, [r2, h]) + basic_section (); + + translate ([-epsilon, -epsilon]) + square ([max (r1, r2) + epsilon * 2, + max (epsilon, round_r1 + epsilon)]); } - difference() - { - round_corner(round_r1, [ r1, 0 ]) basic_section(); + difference () { + round_corner (round_r1, [r1, 0]) + basic_section (); - translate([ -epsilon, h + epsilon ]) mirror(Y) - square([ max(r1, r2) + epsilon * 2, round_r2 ]); + translate ([-epsilon, h + epsilon]) + mirror (Y) + square ([max (r1, r2) + epsilon * 2, round_r2]); } } - basic_section(); + basic_section (); } } } -module mcad_tube(od, id, h = undef){ linear_extrude_if(h != undef, height = h) - difference(){ circle(d = od); -mcad_polyhole(d = id); -} +module mcad_tube (od, id, h = undef) +{ + linear_extrude_if (h != undef, height = h) + difference () { + circle (d = od); + mcad_polyhole (d = id); + } } -*mcad_rounded_cylinder(r1 = 3, - r2 = 10, - h = 40, - round_r1 = 3, - round_r2 = 10, - slices = 100); -*mcad_rounded_cylinder(r = 3, h = 40, round_r1 = 3, slices = 100); +*mcad_rounded_cylinder (r1 = 3, r2 = 10, h = 40, round_r1 = 3, round_r2 = 10, + slices = 100); +*mcad_rounded_cylinder (r = 3, h = 40, round_r1 = 3, slices = 100); diff --git a/shapes/polyhole.scad b/shapes/polyhole.scad index 7251fcb0..16d4654b 100644 --- a/shapes/polyhole.scad +++ b/shapes/polyhole.scad @@ -1,15 +1,20 @@ - // Copyright 2011 Nophead (of RepRap fame) -// This file is licensed under the terms of Creative Commons Attribution 3.0 -// Unported. +// This file is licensed under the terms of Creative Commons Attribution 3.0 Unported. // Using this holes should come out approximately right when printed -module mcad_polyhole(d, h = undef, center = false) -{ - n = max(round(2 * d), 3); +module mcad_polyhole(d, h = undef, center = false) { + n = max (round (2 * d), 3); flat = (h == undef); - rotate([ 0, 0, 180 ]) if (flat) circle(r = (d / 2) / cos(180 / n), $fn = n); - else cylinder(h = h, r = (d / 2) / cos(180 / n), center = center, $fn = n); + rotate([0,0,180]) + if (flat) + circle (r = (d / 2) / cos (180 / n), $fn = n); + else + cylinder ( + h = h, + r = (d / 2) / cos (180 / n), + center = center, + $fn = n + ); } diff --git a/shapes/standard_shapes.scad b/shapes/standard_shapes.scad index b039e8e1..fcf99f12 100644 --- a/shapes/standard_shapes.scad +++ b/shapes/standard_shapes.scad @@ -1,4 +1,3 @@ - /* * Copyright (C) 2012 Krallinger Sebastian * @@ -16,43 +15,38 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - */ +*/ -include; -include; +include ; +include ; -module cylinderSegment_angle(r, h, Phi, center = false) -{ - a = Phi / 2; - if (center == false) { - translate([ 0, 0, h / 2 ]) - { - _halfCircelSegment(radius = r, height = h, angle = abs(a)); - rotate(a = 180, v = X) - _halfCircelSegment(radius = r, height = h, angle = abs(a)); - } - } else { - _halfCircelSegment(radius = r, height = h, angle = abs(a)); - rotate(a = 180, v = X) - _halfCircelSegment(radius = r, height = h, angle = abs(a)); - } +module cylinderSegment_angle(r,h,Phi,center = false){ + a = Phi/2; + if(center == false ){ + translate([0, 0, h/2]){ + _halfCircelSegment(radius=r,height=h,angle=abs(a)); + rotate(a = 180, v = X) + _halfCircelSegment(radius=r,height=h,angle=abs(a)); + } + }else{ + _halfCircelSegment(radius=r,height=h,angle=abs(a)); + rotate(a = 180, v = X) + _halfCircelSegment(radius=r,height=h,angle=abs(a)); + } } -// cylinderSegment_angle(radius=10,height=1,Phi=360); +//cylinderSegment_angle(radius=10,height=1,Phi=360); -module _halfCircelSegment(radius, height, angle) -{ - difference() - { - union() { cylinder(h = height, r = radius, center = true); } - union() - { - translate([ 0, -radius / 2 - OS, 0 ]) - cube([ (radius + OS) * 2, radius + OS, height + 2 * OS ], - center = true); - rotate(a = angle, v = Z) translate([ 0, -radius / 2, 0 ]) - cube([ (radius + OS) * 2, radius + OS, height + 2 * OS ], - center = true); - } - } +module _halfCircelSegment(radius,height,angle){ + difference(){ + union(){ + cylinder(h = height, r = radius, center = true); + } + union(){ + translate([0, -radius/2-OS, 0]) + cube ([(radius+OS)*2,radius+OS,height+2*OS],center =true); + rotate(a = angle, v = Z) translate([0, -radius/2, 0]) + cube ([(radius+OS)*2,radius+OS,height+2*OS],center =true); + } + } } //_halfCircelSegment(10,1,111); diff --git a/shapes/triangles_pyramids.scad b/shapes/triangles_pyramids.scad index 3c9bab16..7bbd9a31 100644 --- a/shapes/triangles_pyramids.scad +++ b/shapes/triangles_pyramids.scad @@ -1,127 +1,70 @@ - -/* +/* MCAD triangles - Copyright (C) 2013 Alex Davies License: LGPL 2.1 or later -rightpyramid(rightpyramidx, rightpyramidy, rightpyramidz) -cornerpyramid(cornerpyramidx, cornerpyramidy, cornerpyramidz) -eqlpyramid(eqlpyramidx, eqlpyramidy, eqlpyramidz) +rightpyramid(rightpyramidx, rightpyramidy, rightpyramidz) +cornerpyramid(cornerpyramidx, cornerpyramidy, cornerpyramidz) +eqlpyramid(eqlpyramidx, eqlpyramidy, eqlpyramidz) rightprism(rightprismx,rightprismy,rightprismz) eqlprism(eqlprismx,eqlprismy,eqlprismz) -todo, make library work with negative lengths by adding triangles to the inside -of every surface. basicaly copy and paste the current triangles set and reverse -the first and last digit of every triangle. In 4 character triangles switch the -middle ones around as well. Not sure if that's actually useful though. +todo, make library work with negative lengths by adding triangles to the inside of every surface. basicaly copy and paste the current triangles set and reverse the first and last digit of every triangle. In 4 character triangles switch the middle ones around as well. Not sure if that's actually useful though. - Copyright Eero 'rambo' af Heurlin 2010- triangle(o_len, a_len, depth) a_triangle(tan_angle, a_len, depth) */ -module rightpyramid(rightpyramidx, rightpyramidy, rightpyramidz) -{ - polyhedron(points = - [ - [ 0, 0, 0 ], - [ rightpyramidx, 0, 0 ], - [ 0, rightpyramidy, 0 ], - [ rightpyramidx, rightpyramidy, 0 ], - [ rightpyramidx / 2, rightpyramidy, rightpyramidz ] - ], - - faces = [ - [ 0, 1, 2 ], - [ 2, 1, 3 ], - [ 4, 1, 0 ], - [ 3, 1, 4 ], - [ 2, 3, 4 ], - [ 0, 2, 4 ] - ]); +module rightpyramid(rightpyramidx, rightpyramidy, rightpyramidz) { + polyhedron ( points = [[0,0,0], + [rightpyramidx, 0, 0], + [0, rightpyramidy, 0], + [rightpyramidx, rightpyramidy, 0], + [rightpyramidx/2, rightpyramidy, rightpyramidz]], + + faces = [[0,1,2],[2,1,3],[4,1,0],[3,1,4],[2,3,4],[0,2,4]]); } -module cornerpyramid(cornerpyramidx, cornerpyramidy, cornerpyramidz) -{ - polyhedron(points = - [ - [ 0, 0, 0 ], - [ cornerpyramidx, 0, 0 ], - [ 0, cornerpyramidy, 0 ], - [ cornerpyramidx, cornerpyramidy, 0 ], - [ 0, cornerpyramidy, cornerpyramidz ] - ], - - faces = [ - [ 0, 1, 2 ], - [ 2, 1, 3 ], - [ 4, 1, 0 ], - [ 3, 1, 4 ], - [ 2, 3, 4 ], - [ 0, 2, 4 ] - ]); +module cornerpyramid(cornerpyramidx, cornerpyramidy, cornerpyramidz) { + polyhedron ( points = [[0,0,0], + [cornerpyramidx, 0, 0], + [0, cornerpyramidy, 0], + [cornerpyramidx, cornerpyramidy, 0], + [0, cornerpyramidy, cornerpyramidz]], + + faces = [[0,1,2],[2,1,3],[4,1,0],[3,1,4],[2,3,4],[0,2,4]]); } -module eqlpyramid(eqlpyramidx, eqlpyramidy, eqlpyramidz) -{ - polyhedron(points = - [ - [ 0, 0, 0 ], - [ eqlpyramidx, 0, 0 ], - [ 0, eqlpyramidy, 0 ], - [ eqlpyramidx, eqlpyramidy, 0 ], - [ eqlpyramidx / 2, eqlpyramidy / 2, eqlpyramidz ] - ], - - faces = [ - [ 0, 1, 2 ], - [ 2, 1, 3 ], - [ 4, 1, 0 ], - [ 3, 1, 4 ], - [ 2, 3, 4 ], - [ 0, 2, 4 ] - ]); +module eqlpyramid(eqlpyramidx, eqlpyramidy, eqlpyramidz) { + polyhedron ( points = [[0,0,0], + [eqlpyramidx, 0, 0], + [0, eqlpyramidy, 0], + [eqlpyramidx, eqlpyramidy, 0], + [eqlpyramidx/2, eqlpyramidy/2, eqlpyramidz]], + + faces = [[0,1,2],[2,1,3],[4,1,0],[3,1,4],[2,3,4],[0,2,4]]); } -module rightprism(rightprismx, rightprismy, rightprismz) -{ - polyhedron(points = - [ - [ 0, 0, 0 ], - [ rightprismx, 0, 0 ], - [ rightprismx, rightprismy, 0 ], - [ 0, rightprismy, 0 ], - [ 0, rightprismy, rightprismz ], - [ 0, 0, rightprismz ] - ], - faces = [ - [ 0, 1, 2, 3 ], - [ 5, 1, 0 ], - [ 5, 4, 2, 1 ], - [ 4, 3, 2 ], - [ 0, 3, 4, 5 ] - ]); +module rightprism(rightprismx,rightprismy,rightprismz){ + polyhedron ( points = [[0,0,0], + [rightprismx,0,0], + [rightprismx,rightprismy,0], + [0,rightprismy,0], + [0,rightprismy,rightprismz], + [0,0,rightprismz]], + faces = [[0,1,2,3],[5,1,0],[5,4,2,1],[4,3,2],[0,3,4,5]]); } -module eqlprism(eqlprismx, eqlprismy, eqlprismz) -{ - polyhedron(points = - [ - [ 0, 0, 0 ], - [ eqlprismx, 0, 0 ], - [ eqlprismx, eqlprismy, 0 ], - [ 0, eqlprismy, 0 ], - [ eqlprismx / 2, eqlprismy, eqlprismz ], - [ eqlprismx / 2, 0, eqlprismz ] - ], - faces = [ - [ 0, 1, 2, 3 ], - [ 5, 1, 0 ], - [ 5, 4, 2, 1 ], - [ 4, 3, 2 ], - [ 0, 3, 4, 5 ] - ]); +module eqlprism(eqlprismx,eqlprismy,eqlprismz){ + polyhedron ( points = [[0,0,0], + [eqlprismx,0,0], + [eqlprismx,eqlprismy,0], + [0,eqlprismy,0], + [eqlprismx/2,eqlprismy,eqlprismz], + [eqlprismx/2,0,eqlprismz]], + faces = [[0,1,2,3],[5,1,0],[5,4,2,1],[4,3,2],[0,3,4,5]]); } /** @@ -134,10 +77,9 @@ module eqlprism(eqlprismx, eqlprismy, eqlprismz) */ module triangle(o_len, a_len, depth) { - linear_extrude(height = depth) + linear_extrude(height=depth) { - polygon(points = [ [ 0, 0 ], [ a_len, 0 ], [ 0, o_len ] ], - paths = [[ 0, 1, 2 ]]); + polygon(points=[[0,0],[a_len,0],[0,o_len]], paths=[[0,1,2]]); } } @@ -150,38 +92,32 @@ module triangle(o_len, a_len, depth) */ module a_triangle(tan_angle, a_len, depth) { - linear_extrude(height = depth) + linear_extrude(height=depth) { - polygon(points = - [ [ 0, 0 ], [ a_len, 0 ], [ 0, tan(tan_angle) * a_len ] ], - paths = [[ 0, 1, 2 ]]); + polygon(points=[[0,0],[a_len,0],[0,tan(tan_angle) * a_len]], paths=[[0,1,2]]); } } // Tests: -module -test_triangle() -{ - triangle(5, 5, 5); -} -module -test_a_triangle() -{ - a_triangle(45, 5, 5); -} -module -test_triangles() +module test_triangle() { triangle(5, 5, 5); } +module test_a_triangle() { a_triangle(45, 5, 5); } +module test_triangles() { // Generate a bunch of triangles by sizes - for (i = [1:10]) { - translate([ i * 7, -30, i * 7 ]) + for (i = [1:10]) + { + translate([i*7, -30, i*7]) { - triangle(i * 5, sqrt(i * 5 + pow(i, 2)), 5); + triangle(i*5, sqrt(i*5+pow(i,2)), 5); } } // Generate a bunch of triangles by angle - for (i = [1:85 / 5]) { - translate([ i * 7, 22, i * 7 ]) { a_triangle(i * 5, 10, 5); } + for (i = [1:85/5]) + { + translate([i*7, 22, i*7]) + { + a_triangle(i*5, 10, 5); + } } } diff --git a/shapes/trochoids.scad b/shapes/trochoids.scad index c7a2e900..99083303 100644 --- a/shapes/trochoids.scad +++ b/shapes/trochoids.scad @@ -1,4 +1,3 @@ - //=========================================== // Public Domain Epi- and Hypo- trochoids in OpenSCAD // version 1.0 @@ -9,16 +8,16 @@ // applications. Attribution would be nice, but is not required. There is // no warranty of any kind, including its correctness, usefulness, or safety. // -// An EPITROCHOID is a curve traced by a point -// fixed at a distance "d" +// An EPITROCHOID is a curve traced by a point +// fixed at a distance "d" // to the center of a circle of radius "r" -// as the circle rolls +// as the circle rolls // outside another circle of radius "R". // -// An HYPOTROCHOID is a curve traced by a point -// fixed at a distance "d" +// An HYPOTROCHOID is a curve traced by a point +// fixed at a distance "d" // to the center of a circle of radius "r" -// as the circle rolls +// as the circle rolls // inside another circle of radius "R". // // An EPICYCLOID is an epitrochoid with d = r. @@ -27,7 +26,7 @@ // // See http://en.wikipedia.org/wiki/Epitrochoid // and http://en.wikipedia.org/wiki/Hypotrochoid -// +// // Beware the polar forms of the equations on Wikipedia... // They are correct, but theta is measured to the center of the small disk!! //=========================================== @@ -35,15 +34,16 @@ // There are several different methods for extruding. The best are probably // the ones using linear extrude. + //=========================================== // Demo - draws one of each, plus some little wheels and sticks. // -// Fun stuff to try: +// Fun stuff to try: // Animate, try FPS = 5 and Steps = 200 // R = 2, r = 1, d = 0.2 // R = 4, r = 1, d = 1 // R = 2, r = 1, d = 0.5 -// +// // What happens when you make d > r ?? // What happens when d < 0 ?? // What happens when r < 0 ?? @@ -58,385 +58,233 @@ r = 1; d = 1; n = 60; // number of wedge segments -alpha = 360 * $t; +alpha = 360*$t; -color([ 0, 0, 1 ]) translate([ 0, 0, -0.5 ]) - cylinder(h = 1, r = R, center = true); +color([0, 0, 1]) +translate([0, 0, -0.5]) + cylinder(h = 1, r= R, center = true); -color([ 0, 1, 0 ]) epitrochoid(R, r, d, n, thickness); +color([0, 1, 0]) +epitrochoid(R,r,d,n,thickness); -color([ 1, 0, 0 ]) - translate([ (R + r) * cos(alpha), (R + r) * sin(alpha), -0.5 ]) -{ - rotate([ 0, 0, alpha + R / r * alpha ]) - { - cylinder(h = 1, r = r, center = true); - translate([ -d, 0, 1.5 ]) { cylinder(h = 2.2, r = 0.1, center = true); } - } +color([1, 0, 0]) +translate([ (R+r)*cos(alpha) , (R+r)*sin(alpha), -0.5]) { + rotate([0, 0, alpha + R/r*alpha]) { + cylinder(h = 1, r = r, center = true); + translate([-d, 0, 1.5]) { + cylinder(h = 2.2, r = 0.1, center = true); + } + } } -translate([ 2 * (abs(R) + abs(r) + abs(d)), 0, 0 ]) -{ - color([ 0, 0, 1 ]) translate([ 0, 0, -0.5 ]) difference() - { - cylinder(h = 1, r = 1.1 * R, center = true); - cylinder(h = 1.1, r = R, center = true); - } - color([ 0, 1, 0 ]) hypotrochoid(R, r, d, n, thickness); +translate([2*(abs(R) + abs(r) + abs(d)), 0, 0]){ +color([0, 0, 1]) +translate([0, 0, -0.5]) + difference() { + cylinder(h = 1, r = 1.1*R, center = true); + cylinder(h = 1.1, r= R, center = true); + } - color([ 1, 0, 0 ]) - translate([ (R - r) * cos(alpha), (R - r) * sin(alpha), -0.5 ]) - { - rotate([ 0, 0, alpha - R / r * alpha ]) - { - cylinder(h = 1, r = r, center = true); - translate([ d, 0, 1.5 ]) - { - cylinder(h = 2.2, r = 0.1, center = true); - } - } - } +color([0, 1, 0]) +hypotrochoid(R,r,d,n,thickness); + +color([1, 0, 0]) +translate([ (R-r)*cos(alpha) , (R-r)*sin(alpha), -0.5]) { + rotate([0, 0, alpha - R/r*alpha]) { + cylinder(h = 1, r = r, center = true); + translate([d, 0, 1.5]) { + cylinder(h = 2.2, r = 0.1, center = true); + } + } +} } // This just makes a twisted hypotrochoid -translate([ 0, 14, 0 ]) hypotrochoidLinear(4, 1, 1, 40, 40, 10, 30); +translate([0,14, 0]) +hypotrochoidLinear(4, 1, 1, 40, 40, 10, 30); // End of Demo Section //=========================================== + //=========================================== // Epitrochoid // -module epitrochoid(R, r, d, n, thickness) -{ - dth = 360 / n; - for (i = [0:n - 1]) { - polyhedron( - points = - [ - [ 0, 0, 0 ], - [ - (R + r) * cos(dth * i) - d * cos((R + r) / r * dth * i), - (R + r) * sin(dth * i) - d * sin((R + r) / r * dth * i), - 0 - ], - [ - (R + r) * cos(dth * (i + 1)) - - d * cos((R + r) / r * dth * (i + 1)), - (R + r) * sin(dth * (i + 1)) - - d * sin((R + r) / r * dth * (i + 1)), - 0 - ], - [ 0, 0, thickness ], - [ - (R + r) * cos(dth * i) - d * cos((R + r) / r * dth * i), - (R + r) * sin(dth * i) - d * sin((R + r) / r * dth * i), - thickness - ], - [ - (R + r) * cos(dth * (i + 1)) - - d * cos((R + r) / r * dth * (i + 1)), - (R + r) * sin(dth * (i + 1)) - - d * sin((R + r) / r * dth * (i + 1)), - thickness - ] - ], - triangles = [ - [ 0, 2, 1 ], - [ 0, 1, 3 ], - [ 3, 1, 4 ], - [ 3, 4, 5 ], - [ 0, 3, 2 ], - [ 2, 3, 5 ], - [ 1, 2, 4 ], - [ 2, 5, 4 ] - ]); - } +module epitrochoid(R, r, d, n, thickness) { + dth = 360/n; + for ( i = [0:n-1] ) { + polyhedron(points = [[0,0,0], + [(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i), 0], + [(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1)), 0], + [0,0,thickness], + [(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i), thickness], + [(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1)), thickness]], + triangles = [[0, 2, 1], + [0, 1, 3], + [3, 1, 4], + [3, 4, 5], + [0, 3, 2], + [2, 3, 5], + [1, 2, 4], + [2, 5, 4]]); + } } //=========================================== + //=========================================== // Hypotrochoid // -module hypotrochoid(R, r, d, n, thickness) -{ - dth = 360 / n; - for (i = [0:n - 1]) { - polyhedron( - points = - [ - [ 0, 0, 0 ], - [ - (R - r) * cos(dth * i) + d * cos((R - r) / r * dth * i), - (R - r) * sin(dth * i) - d * sin((R - r) / r * dth * i), - 0 - ], - [ - (R - r) * cos(dth * (i + 1)) + - d * cos((R - r) / r * dth * (i + 1)), - (R - r) * sin(dth * (i + 1)) - - d * sin((R - r) / r * dth * (i + 1)), - 0 - ], - [ 0, 0, thickness ], - [ - (R - r) * cos(dth * i) + d * cos((R - r) / r * dth * i), - (R - r) * sin(dth * i) - d * sin((R - r) / r * dth * i), - thickness - ], - [ - (R - r) * cos(dth * (i + 1)) + - d * cos((R - r) / r * dth * (i + 1)), - (R - r) * sin(dth * (i + 1)) - - d * sin((R - r) / r * dth * (i + 1)), - thickness - ] - ], - triangles = [ - [ 0, 2, 1 ], - [ 0, 1, 3 ], - [ 3, 1, 4 ], - [ 3, 4, 5 ], - [ 0, 3, 2 ], - [ 2, 3, 5 ], - [ 1, 2, 4 ], - [ 2, 5, 4 ] - ]); - } +module hypotrochoid(R, r, d, n, thickness) { + dth = 360/n; + for ( i = [0:n-1] ) { + polyhedron(points = [[0,0,0], + [(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i), 0], + [(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1)), 0], + [0,0,thickness], + [(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i), thickness], + [(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1)), thickness]], + triangles = [[0, 2, 1], + [0, 1, 3], + [3, 1, 4], + [3, 4, 5], + [0, 3, 2], + [2, 3, 5], + [1, 2, 4], + [2, 5, 4]]); + } } //=========================================== + //=========================================== // Epitrochoid Wedge with Bore // -module epitrochoidWBore(R, r, d, n, p, thickness, rb) -{ - dth = 360 / n; - union() - { - for (i = [0:p - 1]) { - polyhedron( - points = - [[rb * cos(dth * i), rb * sin(dth * i), 0], - [(R + r) * cos(dth * i) - d * cos((R + r) / r * dth * i), - (R + r) * sin(dth * i) - d * sin((R + r) / r * dth * i), - 0], - [(R + r) * cos(dth * (i + 1)) - - d * cos((R + r) / r * dth * (i + 1)), - (R + r) * sin(dth * (i + 1)) - - d * sin((R + r) / r * dth * (i + 1)), - 0], - [rb * cos(dth * (i + 1)), rb * sin(dth * (i + 1)), 0], - [rb * cos(dth * i), rb * sin(dth * i), thickness], - [(R + r) * cos(dth * i) - d * cos((R + r) / r * dth * i), - (R + r) * sin(dth * i) - d * sin((R + r) / r * dth * i), - thickness], - [(R + r) * cos(dth * (i + 1)) - - d * cos((R + r) / r * dth * (i + 1)), - (R + r) * sin(dth * (i + 1)) - - d * sin((R + r) / r * dth * (i + 1)), - thickness], - [rb * cos(dth * (i + 1)), - rb * sin(dth * (i + 1)), - thickness]], - triangles = [ - [ 0, 1, 4 ], - [ 4, 1, 5 ], - [ 1, 2, 5 ], - [ 5, 2, 6 ], - [ 2, 3, 7 ], - [ 7, 6, 2 ], - [ 3, 0, 4 ], - [ 4, 7, 3 ], - [ 4, 5, 7 ], - [ 7, 5, 6 ], - [ 0, 3, 1 ], - [ 1, 3, 2 ] - ]); - } - } +module epitrochoidWBore(R, r, d, n, p, thickness, rb) { + dth = 360/n; + union() { + for ( i = [0:p-1] ) { + polyhedron(points = [[rb*cos(dth*i), rb*sin(dth*i),0], + [(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i), 0], + [(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1)), 0], + [rb*cos(dth*(i+1)), rb*sin(dth*(i+1)), 0], + [rb*cos(dth*i), rb*sin(dth*i), thickness], + [(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i), thickness], + [(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1)), thickness], + [rb*cos(dth*(i+1)), rb*sin(dth*(i+1)), thickness]], + triangles = [[0, 1, 4], [4, 1, 5], + [1, 2, 5], [5, 2, 6], + [2, 3, 7], [7, 6, 2], + [3, 0, 4], [4, 7, 3], + [4, 5, 7], [7, 5, 6], + [0, 3, 1], [1, 3, 2]]); + } + } } //=========================================== + //=========================================== // Epitrochoid Wedge with Bore, Linear Extrude // -module epitrochoidWBoreLinear(R, r, d, n, p, thickness, rb, twist) -{ - dth = 360 / n; - linear_extrude(height = thickness, convexity = 10, twist = twist) - { - union() - { - for (i = [0:p - 1]) { - polygon(points = [ - [rb * cos(dth * i), rb * sin(dth * i)], - [(R + r) * cos(dth * i) - - d * cos((R + r) / r * dth * i), - (R + r) * sin(dth * i) - - d * sin((R + r) / r * dth * i)], - [(R + r) * cos(dth * (i + 1)) - - d * cos((R + r) / r * dth * (i + 1)), - (R + r) * sin(dth * (i + 1)) - - d * sin((R + r) / r * dth * (i + 1))], - [rb * cos(dth * (i + 1)), rb * sin(dth * (i + 1))]], - paths = [[ 0, 1, 2, 3 ]], - convexity = 10); - } - } - } +module epitrochoidWBoreLinear(R, r, d, n, p, thickness, rb, twist) { + dth = 360/n; + linear_extrude(height = thickness, convexity = 10, twist = twist) { + union() { + for ( i = [0:p-1] ) { + polygon(points = [[rb*cos(dth*i), rb*sin(dth*i)], + [(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i)], + [(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1))], + [rb*cos(dth*(i+1)), rb*sin(dth*(i+1))]], + paths = [[0, 1, 2, 3]], convexity = 10); + } + } + } } //=========================================== + //=========================================== // Epitrochoid Wedge, Linear Extrude // -module epitrochoidLinear(R, r, d, n, p, thickness, twist) -{ - dth = 360 / n; - linear_extrude(height = thickness, convexity = 10, twist = twist) - { - union() - { - for (i = [0:p - 1]) { - polygon(points = - [ - [ 0, 0 ], - [ - (R + r) * cos(dth * i) - - d * cos((R + r) / r * dth * i), - (R + r) * sin(dth * i) - - d * sin((R + r) / r * dth * i) - ], - [ - (R + r) * cos(dth * (i + 1)) - - d * cos((R + r) / r * dth * (i + 1)), - (R + r) * sin(dth * (i + 1)) - - d * sin((R + r) / r * dth * (i + 1)) - ] - ], - paths = [[ 0, 1, 2 ]], - convexity = 10); - } - } - } +module epitrochoidLinear(R, r, d, n, p, thickness, twist) { + dth = 360/n; + linear_extrude(height = thickness, convexity = 10, twist = twist) { + union() { + for ( i = [0:p-1] ) { + polygon(points = [[0, 0], + [(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i)], + [(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1))]], + paths = [[0, 1, 2]], convexity = 10); + } + } + } } //=========================================== + //=========================================== // Hypotrochoid Wedge with Bore // -module hypotrochoidWBore(R, r, d, n, p, thickness, rb) -{ - dth = 360 / n; - union() - { - for (i = [0:p - 1]) { - polyhedron( - points = - [[rb * cos(dth * i), rb * sin(dth * i), 0], - [(R - r) * cos(dth * i) + d * cos((R - r) / r * dth * i), - (R - r) * sin(dth * i) - d * sin((R - r) / r * dth * i), - 0], - [(R - r) * cos(dth * (i + 1)) + - d * cos((R - r) / r * dth * (i + 1)), - (R - r) * sin(dth * (i + 1)) - - d * sin((R - r) / r * dth * (i + 1)), - 0], - [rb * cos(dth * (i + 1)), rb * sin(dth * (i + 1)), 0], - [rb * cos(dth * i), rb * sin(dth * i), thickness], - [(R - r) * cos(dth * i) + d * cos((R - r) / r * dth * i), - (R - r) * sin(dth * i) - d * sin((R - r) / r * dth * i), - thickness], - [(R - r) * cos(dth * (i + 1)) + - d * cos((R - r) / r * dth *, (i + 1)), - (R - r) * sin(dth * (i + 1)) - - d * sin((R - r) / r * dth * (i + 1)), - thickness], - [rb * cos(dth * (i + 1)), - rb * sin(dth * (i + 1)), - thickness]], - triangles = [ - [ 0, 1, 4 ], - [ 4, 1, 5 ], - [ 1, 2, 5 ], - [ 5, 2, 6 ], - [ 2, 3, 7 ], - [ 7, 6, 2 ], - [ 3, 0, 4 ], - [ 4, 7, 3 ], - [ 4, 5, 7 ], - [ 7, 5, 6 ], - [ 0, 3, 1 ], - [ 1, 3, 2 ] - ]); - } - } +module hypotrochoidWBore(R, r, d, n, p, thickness, rb) { + dth = 360/n; + union() { + for ( i = [0:p-1] ) { + polyhedron(points = [[rb*cos(dth*i), rb*sin(dth*i),0], + [(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i), 0], + [(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1)), 0], + [rb*cos(dth*(i+1)), rb*sin(dth*(i+1)), 0], + [rb*cos(dth*i), rb*sin(dth*i), thickness], + [(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i), thickness], + [(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1)), thickness], + [rb*cos(dth*(i+1)), rb*sin(dth*(i+1)), thickness]], + triangles = [[0, 1, 4], [4, 1, 5], + [1, 2, 5], [5, 2, 6], + [2, 3, 7], [7, 6, 2], + [3, 0, 4], [4, 7, 3], + [4, 5, 7], [7, 5, 6], + [0, 3, 1], [1, 3, 2]]); + } + } } //=========================================== + //=========================================== // Hypotrochoid Wedge with Bore, Linear Extrude // -module hypotrochoidWBoreLinear(R, r, d, n, p, thickness, rb, twist) -{ - dth = 360 / n; - linear_extrude(height = thickness, convexity = 10, twist = twist) - { - union() - { - for (i = [0:p - 1]) { - polygon(points = [ - [rb * cos(dth * i), rb * sin(dth * i)], - [(R - r) * cos(dth * i) + - d * cos((R - r) / r * dth * i), - (R - r) * sin(dth * i) - - d * sin((R - r) / r * dth * i)], - [(R - r) * cos(dth * (i + 1)) + - d * cos((R - r) / r * dth * (i + 1)), - (R - r) * sin(dth * (i + 1)) - - d * sin((R - r) / r * dth * (i + 1))], - [rb * cos(dth * (i + 1)), rb * sin(dth * (i + 1))]], - paths = [[ 0, 1, 2, 3 ]], - convexity = 10); - } - } - } +module hypotrochoidWBoreLinear(R, r, d, n, p, thickness, rb, twist) { + dth = 360/n; + linear_extrude(height = thickness, convexity = 10, twist = twist) { + union() { + for ( i = [0:p-1] ) { + polygon(points = [[rb*cos(dth*i), rb*sin(dth*i)], + [(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i)], + [(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1))], + [rb*cos(dth*(i+1)), rb*sin(dth*(i+1))]], + paths = [[0, 1, 2, 3]], convexity = 10); + } + } + } } //=========================================== + //=========================================== // Hypotrochoid Wedge, Linear Extrude // -module hypotrochoidLinear(R, r, d, n, p, thickness, twist) -{ - dth = 360 / n; - linear_extrude(height = thickness, convexity = 10, twist = twist) - { - union() - { - for (i = [0:p - 1]) { - polygon(points = - [ - [ 0, 0 ], - [ - (R - r) * cos(dth * i) + - d * cos((R - r) / r * dth * i), - (R - r) * sin(dth * i) - - d * sin((R - r) / r * dth * i) - ], - [ - (R - r) * cos(dth * (i + 1)) + - d * cos((R - r) / r * dth * (i + 1)), - (R - r) * sin(dth * (i + 1)) - - d * sin((R - r) / r * dth * (i + 1)) - ] - ], - paths = [[ 0, 1, 2 ]], - convexity = 10); - } - } - } +module hypotrochoidLinear(R, r, d, n, p, thickness, twist) { + dth = 360/n; + linear_extrude(height = thickness, convexity = 10, twist = twist) { + union() { + for ( i = [0:p-1] ) { + polygon(points = [[0, 0], + [(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i)], + [(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1))]], + paths = [[0, 1, 2]], convexity = 10); + } + } + } } -//=========================================== +//=========================================== diff --git a/text/alphabet_block.scad b/text/alphabet_block.scad index ef55d2e0..ff82cba2 100644 --- a/text/alphabet_block.scad +++ b/text/alphabet_block.scad @@ -1,21 +1,24 @@ -use /* -Parametric Alphabet Block +Parametric Alphabet Block Tony Buser http://tonybuser.com http://creativecommons.org/licenses/by/3.0/ */ +use + // change to any letter letter = "A"; -union() -{ - difference() - { - cube(size = 20); - translate(v = [ 2, 2, 17 ]) { cube(size = [ 16, 16, 5 ]); } - } +union() { + difference() { + cube(size = 20); + translate(v = [2, 2, 17]) { + cube(size = [16, 16, 5]); + } + } - translate(v = [ 10, 10, 15 ]) { 8bit_char(letter, 2, 5); } + translate(v = [10, 10, 15]) { + 8bit_char(letter, 2, 5); + } } diff --git a/text/bitmap.scad b/text/bitmap.scad index 63400720..3ae5db8a 100644 --- a/text/bitmap.scad +++ b/text/bitmap.scad @@ -1,4 +1,3 @@ - /* Bitmap and 8Bit Font Module Tony Buser @@ -6,1039 +5,1022 @@ http://tonybuser.com http://creativecommons.org/licenses/by/3.0/ */ -module bitmap(bitmap, block_size, height, row_size) -{ - width = block_size * row_size; - bitmap_size = row_size * row_size; - - function loc_x(loc) = floor(loc / row_size) * block_size; - function loc_y(loc) = loc % row_size * block_size; - function loc_z(loc) = (bitmap[loc] * height - height) / 2; +module bitmap(bitmap, block_size, height, row_size) { + width = block_size * row_size; + bitmap_size = row_size * row_size; + + function loc_x(loc) = floor(loc / row_size) * block_size; + function loc_y(loc) = loc % row_size * block_size; + function loc_z(loc) = (bitmap[loc]*height-height)/2; - translate(v = [ - -width / 2 + block_size / 2, - -width / 2 + block_size / 2, - height / 2 - ]) - { - for (loc = [0:bitmap_size - 1]) { - if (bitmap[loc] != 0) { - union() - { - translate(v = [ loc_x(loc), loc_y(loc), loc_z(loc) ]) - { - cube(size = - [ - block_size, - block_size, - height * bitmap[loc] - ], - center = true); - } - } - } - } - } + translate(v = [-width/2+block_size/2,-width/2+block_size/2,height/2]) { + for (loc = [0:bitmap_size - 1]) { + if (bitmap[loc] != 0) { + union() { + translate(v = [loc_x(loc), loc_y(loc), loc_z(loc)]) { + cube(size = [block_size, block_size, height * bitmap[loc]], center = true); + } + } + } + } + } } -module 8bit_char(char, block_size, height, include_base) -{ - if (char == "0") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, - 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "1") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "2") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "3") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "4") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, - 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "5") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "6") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "7") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, - 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "8") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "9") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, - 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "A") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "B") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "C") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "D") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, - 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, - 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "E") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "F") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "G") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "H") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - bloc,k_size, - height, - 8); - } else if (char == "I") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "J") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, - 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "K") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, - 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "L") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "M") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, - 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, - 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, - 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "N") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, - 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "O") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "P") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "Q") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, - 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "R") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "S") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "T") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "U") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "V") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "W") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, - 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, - 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, - 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "X") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "Y") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "Z") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "OE") { - bitmap( - [ - 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "a") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, - 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "b") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "c") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "d") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, - 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "e") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "f") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "g") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "h") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "i") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "j") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, - 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, - 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "k") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, - 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "l") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "m") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, - 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, - 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "n") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "o") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "p") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "q") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0 - ], - block_size, - height, - 8); - } else if (char == "r") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "s") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, - 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "t") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "u") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "v") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "w") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, - 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, - 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "x") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "y") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "z") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "+") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, - 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "-") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, - 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == ":") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == ".") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == ",") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "?") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "=") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "*") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "!") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "''") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "#") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "$") { - bitmap( - [ - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "%") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, - 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, - 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "&") { - bitmap( - [ - 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, - 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, - 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, - 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "@") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, - 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "'") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "(") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, - 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, - 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == ")") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, - 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, - 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_si,ze, - height, - 8); - } else if (char == "<") { - bitmap( - [ - 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == ">") { - bitmap( - [ - 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "[") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, - 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "]") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, - 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "/") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, - 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "\\") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ], - block_size, - height, - 8); - } else if (char == "_") { - bitmap( - [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 - ], - block_size, - height, - 8); - } else if (char == "|") { - bitmap( - [ - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 - ], - block_size, - height, - 8); - } else { - echo("Invalid Character: ", char); - } +module 8bit_char(char, block_size, height, include_base) { + if (char == "0") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,1,1,1,0, + 0,1,1,1,1,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "1") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "2") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "3") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "4") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,1,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,1,1,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "5") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,1,1,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,0,0,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "6") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "7") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "8") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "9") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,1,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "A") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "B") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "C") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "D") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,0,0,0, + 0,1,1,0,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,1,1,0,0, + 0,1,1,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "E") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,1,1,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "F") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,1,1,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "G") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,1,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,1,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "H") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "I") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "J") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,1,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "K") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,1,1,0,0, + 0,1,1,1,1,0,0,0, + 0,1,1,1,1,0,0,0, + 0,1,1,0,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "L") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "M") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,0,1,1, + 0,1,1,1,0,1,1,1, + 0,1,1,1,1,1,1,1, + 0,1,1,0,1,0,1,1, + 0,1,1,0,0,0,1,1, + 0,1,1,0,0,0,1,1, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "N") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,0,1,1,0, + 0,1,1,1,1,1,1,0, + 0,1,1,1,1,1,1,0, + 0,1,1,0,1,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "O") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "P") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "Q") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,0,0, + 0,0,1,1,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "R") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "S") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "T") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "U") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "V") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "W") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,0,1,1, + 0,1,1,0,0,0,1,1, + 0,1,1,0,1,0,1,1, + 0,1,1,1,1,1,1,1, + 0,1,1,1,0,1,1,1, + 0,1,1,0,0,0,1,1, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "X") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "Y") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "Z") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "OE") { + bitmap([ + 0,0,1,0,0,1,0,0, + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0 + ], block_size, height, 8); + } else if (char == "a") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "b") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "c") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "d") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "e") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,1,0, + 0,1,1,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "f") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,1,1,1,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,1,1,1,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "g") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,0,0,0,0,1,1,0, + 0,1,1,1,1,1,0,0 + ], block_size, height, 8); + } else if (char == "h") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "i") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "j") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,1,1,1,1,0,0 + ], block_size, height, 8); + } else if (char == "k") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,1,1,0,0, + 0,1,1,1,1,0,0,0, + 0,1,1,0,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "l") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "m") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,1,1, + 0,1,1,1,1,1,1,1, + 0,1,1,0,1,0,1,1, + 0,1,1,0,0,0,1,1, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "n") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "o") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "p") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "q") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,1,1,0 + ], block_size, height, 8); + } else if (char == "r") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "s") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,1,0, + 0,1,1,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,1,1,0, + 0,1,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "t") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "u") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "v") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "w") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,0,1,1, + 0,1,1,0,1,0,1,1, + 0,1,1,1,1,1,1,1, + 0,0,1,1,1,1,1,0, + 0,0,1,1,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "x") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "y") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,0,0,0,1,1,0,0, + 0,1,1,1,1,0,0,0 + ], block_size, height, 8); + } else if (char == "z") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "+") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,1,1,1,1,1,1,0, + 0,1,1,1,1,1,1,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "-") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == ":") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == ".") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == ",") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,0,0,0,0 + ], block_size, height, 8); + } else if (char == "?") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "=") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "*") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 1,1,1,1,1,1,1,1, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "!") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "''") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "#") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 1,1,1,1,1,1,1,1, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 1,1,1,1,1,1,1,1, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "$") { + bitmap([ + 0,0,0,1,1,0,0,0, + 0,0,1,1,1,1,1,0, + 0,1,1,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,1,1,0, + 0,1,1,1,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "%") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,1,1,0,0, + 0,0,1,1,1,0,0,0, + 0,0,1,1,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,0,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "&") { + bitmap([ + 0,0,0,1,1,1,0,0, + 0,0,1,1,0,1,1,0, + 0,0,0,1,1,1,0,0, + 0,0,1,1,1,0,0,0, + 0,1,1,0,1,1,1,1, + 0,1,1,0,1,1,1,0, + 0,0,1,1,1,0,1,1, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "@") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,1,1,1,0, + 0,1,1,0,1,1,1,0, + 0,1,1,0,0,0,0,0, + 0,0,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "'") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "(") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,1,0,0, + 0,0,1,1,1,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,1,1,1,0,0,0, + 0,0,0,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == ")") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,0,0,0, + 0,0,0,1,1,1,0,0, + 0,0,0,0,1,1,0,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,1,0,0, + 0,0,1,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "<") { + bitmap([ + 0,0,0,0,0,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,1,1,0,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == ">") { + bitmap([ + 0,1,1,0,0,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "[") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,1,1,0,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "]") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,1,1,0,0, + 0,0,0,0,1,1,0,0, + 0,0,0,0,1,1,0,0, + 0,0,0,0,1,1,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "/") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "\\") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,1,1,0,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,0,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "_") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 1,1,1,1,1,1,1,1 + ], block_size, height, 8); + } else if (char == "|") { + bitmap([ + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0 + ], block_size, height, 8); + } else { + echo("Invalid Character: ", char); + } + } -module 8bit_str(chars, char_count, block_size, height) -{ - echo(str("Total Width: ", block_size * 8 * char_count, "mm")); - union() - { - for (count = [0:char_count - 1]) { - translate(v = [ 0, count * block_size * 8, 0 ]) - { - 8bit_char(chars[count], block_size, height); - } - } - } +module 8bit_str(chars, char_count, block_size, height) { + echo(str("Total Width: ", block_size * 8 * char_count, "mm")); + union() { + for (count = [0:char_count-1]) { + translate(v = [0, count * block_size * 8, 0]) { + 8bit_char(chars[count], block_size, height); + } + } + } } /* @@ -1048,32 +1030,32 @@ block_size = 5; height = 10; union() { - translate(v = [0,0,5]) { - 8bit_char("A", block_size, height); + translate(v = [0,0,5]) { + 8bit_char("A", block_size, height); - //bitmap([ - // 1,1,1,1,1,1,1,1, - // 1,0,0,1,1,0,0,1, - // 1,0,1,1,1,1,0,1, - // 1,1,1,0,0,1,1,1, - // 1,1,1,0,0,1,1,1, - // 1,0,1,1,1,1,0,1, - // 1,0,0,1,1,0,0,1, - // 1,1,1,1,1,1,1,1 - //], block_size, height, 8); + //bitmap([ + // 1,1,1,1,1,1,1,1, + // 1,0,0,1,1,0,0,1, + // 1,0,1,1,1,1,0,1, + // 1,1,1,0,0,1,1,1, + // 1,1,1,0,0,1,1,1, + // 1,0,1,1,1,1,0,1, + // 1,0,0,1,1,0,0,1, + // 1,1,1,1,1,1,1,1 + //], block_size, height, 8); - //bitmap([ - // 1,1,1,1, - // 1,0,0,1, - // 1,0,0,1, - // 1,1,1,1 - , //], block_size, height, 4); - } - translate(v = [0,0,5/2]) { - color([0,0,1,1]) { - cube(size = [block_size * 8, block_size * 8, 5], center = true); - } - } + //bitmap([ + // 1,1,1,1, + // 1,0,0,1, + // 1,0,0,1, + // 1,1,1,1 + //], block_size, height, 4); + } + translate(v = [0,0,5/2]) { + color([0,0,1,1]) { + cube(size = [block_size * 8, block_size * 8, 5], center = true); + } + } } @@ -1084,14 +1066,13 @@ block_size = 1; height = 5; union() { - translate(v = [0,-block_size*8*char_count/2+block_size*8/2,5]) { - 8bit_str(chars, char_count, block_size, height); - } - translate(v = [0,0,5/2]) { - color([0,0,1,1]) { - cube(size = [block_size * 8, block_size * 8 * char_count, 5], center -= true); - } - } + translate(v = [0,-block_size*8*char_count/2+block_size*8/2,5]) { + 8bit_str(chars, char_count, block_size, height); + } + translate(v = [0,0,5/2]) { + color([0,0,1,1]) { + cube(size = [block_size * 8, block_size * 8 * char_count, 5], center = true); + } + } } */ diff --git a/text/fonts.scad b/text/fonts.scad index f234e119..91e2d17f 100644 --- a/text/fonts.scad +++ b/text/fonts.scad @@ -1,123 +1,71 @@ - // Font Functions // Encoding from http://en.wikipedia.org/wiki/ASCII // Author: Andrew Plumb // License: LGPL 2.1 -module outline_2d(outline, points, paths, width = 0.1, resolution = 8) -{ - if (outline && resolution > 4) { - for (j = [0:len(paths) - 1]) - union() - { - for (i = [1:len(paths[j]) - 1]) - hull() - { - translate(points[paths[j][i - 1]]) - circle($fn = resolution, r = width / 2); - translate(points[paths[j][i]]) - circle($fn = resolution, r = width / 2); - } - hull() - { - translate(points[paths[j][len(paths[j]) - 1]]) - circle($fn = resolution, r = width / 2); - translate(points[paths[j][0]]) - circle($fn = resolution, r = width / 2); - } - } - } else { - polygon(points = points, paths = paths); +module outline_2d(outline,points,paths,width=0.1,resolution=8) { + if(outline && resolution > 4) { + for(j=[0:len(paths)-1]) union() { + for(i=[1:len(paths[j])-1]) hull() { + translate(points[paths[j][i-1]]) circle($fn=resolution,r=width/2); + translate(points[paths[j][i]]) circle($fn=resolution,r=width/2); + } + hull() { + translate(points[paths[j][len(paths[j])-1]]) circle($fn=resolution,r=width/2); + translate(points[paths[j][0]]) circle($fn=resolution,r=width/2); + } } + } else { + polygon(points=points,paths=paths); + } } -module bold_2d(bold, width = 0.2, resolution = 8) -{ - for (j = [0:$children - 1]) { - if (bold) { - union() - { - child(j); - for (i = [0:resolution - 1]) - assign(dx = width * cos(360 * i / resolution), - dy = width * sin(360 * i / resolution)) - translate([ dx, dy ]) child(j); - } - } else { +module bold_2d(bold,width=0.2,resolution=8) { + for(j=[0:$children-1]) { + if(bold) { + union() { child(j); - } + for(i=[0:resolution-1]) assign(dx=width*cos(360*i/resolution),dy=width*sin(360*i/resolution)) + translate([dx,dy]) child(j); + } + } else { + child(j); } + } } -module polytext(charstring, - size, - font, - line = 0, - justify = 1, - align = -1, - bold = false, - bold_width = 0.2, - bold_resolution = 8, - underline = false, - underline_start = [ 0, 0 ], - underline_width = 1.0, - outline = false, - outline_width = 0.2, - outline_resolution = 8, - strike = false, - strike_start = [ -0.5, 0 ], - strike_width = 1.0) -{ - line_length = len(charstring) * font[0][0]; - line_shift_x = -line_length / 2 + justify * line_length / 2; - char_width = font[0][0]; - char_height = font[0][1]; - char_shift_height = -char_height / 2 - align * char_height / 2; - char_thickness = font[0][2]; - char_index_map = search(charstring, font[2], 1, 1); - for (i = [0:len(char_index_map) - 1]) - assign(thisCharIndex = char_index_map[i], - x_pos = i * size + line_shift_x * size / char_width) - { - translate( - [ x_pos, line * size + char_shift_height * size / char_height ]) - scale([ size / char_width, size / char_height ]) - { - if (char_thickness == 0) - bold_2d( - bold, width = bold_width, resolution = bold_resolution) - outline_2d(outline, - points = font[2][thisCharIndex][6][0], - paths = font[2][thisCharIndex][6][1], - width = outline_width, - resolution = outline_resolution); - if (charstring[i] != " ") { - if (underline) - translate(underline_start) - square(size = - [ - char_width - 2 * underline_start[0], - underline_width - ], - center = false); - if (strike) - translate([ - strike_start[0], - char_height / 2 + strike_start[1] - ]) square(size = - [ - char_width - 2 * strike_start[0], - strike_width - ], - center = false); - } - if (char_thickness > 0) - polyhedron(points = font[2][thisCharIndex][6][0], - triangles = font[2][thisCharIndex][6][1]); - } - } +module polytext(charstring,size,font,line=0,justify=1,align=-1 + ,bold=false,bold_width=0.2,bold_resolution=8 + ,underline=false,underline_start=[0,0],underline_width=1.0 + ,outline=false,outline_width=0.2,outline_resolution=8 + ,strike=false,strike_start=[-0.5,0],strike_width=1.0 + ) { + line_length=len(charstring)*font[0][0]; + line_shift_x=-line_length/2+justify*line_length/2; + char_width=font[0][0]; + char_height=font[0][1]; + char_shift_height=-char_height/2-align*char_height/2; + char_thickness=font[0][2]; + char_index_map=search(charstring,font[2],1,1); + for(i=[0:len(char_index_map)-1]) assign( thisCharIndex=char_index_map[i], x_pos=i*size+line_shift_x*size/char_width) { + translate([x_pos,line*size+char_shift_height*size/char_height]) scale([size/char_width,size/char_height]) { + if(char_thickness==0) + bold_2d(bold,width=bold_width,resolution=bold_resolution) + outline_2d(outline,points=font[2][thisCharIndex][6][0],paths=font[2][thisCharIndex][6][1] + ,width=outline_width,resolution=outline_resolution); + if( charstring[i] != " " ) { + if(underline) translate(underline_start) + square(size=[char_width-2*underline_start[0],underline_width],center=false); + if(strike) translate([strike_start[0],char_height/2+strike_start[1]]) + square(size=[char_width-2*strike_start[0],strike_width],center=false); + } + if(char_thickness>0) + polyhedron(points=font[2][thisCharIndex][6][0],triangles=font[2][thisCharIndex][6][1]); + } + } } + function 8bit_polyfont(dx=0.1,dy=0.1) = [ [8,8,0,"fixed"],["Decimal Byte","Caret Notation","Character Escape Code","Abbreviation","Name","Bound Box","[points,paths]"] ,[ @@ -602,89 +550,47 @@ function 8bit_polyfont(dx=0.1,dy=0.1) = [ // From http://www.brailleauthority.org/sizespacingofbraille/ // -// Section 3.2 of Specification 800 (Braille Books and Pamphlets) February -// 2008 reads as follows: +// Section 3.2 of Specification 800 (Braille Books and Pamphlets) February 2008 reads as follows: // Size and Spacing -// 3.2.1 The nominal height of braille dots shall be 0.019 inches [0.48 mm] -// and shall be uniform within any given transcription. 3.2.2 The nominal -// base diameter of braille dots shall be 0.057 inches [1.44 mm]. 3.2.3 Cell -// spacing of dots shall conform to the following: 3.2.3.1 The nominal -// distance from center to center of adjacent dots (horizontally or -// vertically, but not diagonally) +// 3.2.1 The nominal height of braille dots shall be 0.019 inches [0.48 mm] and shall be uniform within any given transcription. +// 3.2.2 The nominal base diameter of braille dots shall be 0.057 inches [1.44 mm]. +// 3.2.3 Cell spacing of dots shall conform to the following: +// 3.2.3.1 The nominal distance from center to center of adjacent dots (horizontally or vertically, but not diagonally) // in the same cell shall be 0.092 inches [2.340 mm]. -// 3.2.3.2 The nominal distance from center to center of corresponding dots -// in adjacent cells shall be 0.245 inches [6.2 mm]. 3.2.4 The nominal -// line spacing of braille cells from center to center of nearest -// corresponding dots in adjacent lines shall +// 3.2.3.2 The nominal distance from center to center of corresponding dots in adjacent cells shall be 0.245 inches [6.2 mm]. +// 3.2.4 The nominal line spacing of braille cells from center to center of nearest corresponding dots in adjacent lines shall // be 0.400 inches [1.000 cm]. // // Additional References: // http://www.loc.gov/nls/specs/800.pdf // http://www.tiresias.org/research/reports/braille_cell.htm -module braille_ascii_spec800(inString, - dot_backing = true, - cell_backing = false, - justify = 1, - align = -1, - dot_h = 0.48, - dot_d = 1.44, - dot_spacing = 2.340, - cell_d2d_spacing = 6.2, - line_d2d_spacing = 10.0, - echo_translate = true) -{ - // justify: - // -1 : left side - // 0 : center - // 1 : right side (default) - // align: - // -1 : bottom braille cell edge - shift up (default) - // 0 : center braille cell - // 1 : top braille cell edge - shift down - thisFont = braille_ascii_font(dot_h = dot_h, - dot_d = dot_d, - dot_spacing = dot_spacing, - cell_d2d_spacing = cell_d2d_spacing, - line_d2d_spacing = line_d2d_spacing); - x_shift = thisFont[0][0]; - y_shift = thisFont[0][1]; - theseIndicies = search(inString, thisFont[2], 1, 1); - for (i = [0:len(theseIndicies) - 1]) - translate([ - i * x_shift - (1 - justify) * x_shift * len(theseIndicies) / 2, - -y_shift * (align + 1) / 2 - ]) assign(dotPattern = thisFont[2][theseIndicies[i]][6]) - { - if (dot_backing) - translate([ - cell_d2d_spacing / 2 - dot_spacing / 2 - dot_d / 2, - line_d2d_spacing / 2 - dot_spacing - dot_d / 2, - -dot_h - ]) cube(size = - [ - dot_spacing + dot_d, - 2 * dot_spacing + dot_d, - dot_h - ], - center = false); - if (cell_backing) - translate([ 0, 0, -dot_h ]) - cube(size = [ x_shift, y_shift, dot_h ], center = false); - if (echo_translate) - echo(str(inStrin,g[i], - " maps to '", - thisFont[2][theseIndicies[i]][4], - "'")); - for (dotIndex = dotPattern) { - translate([ - cell_d2d_spacing / 2 - dot_spacing / 2 + - floor((dotIndex - 1) / 3) * dot_spacing, - line_d2d_spacing / 2 - dot_spacing + - (2 - (dotIndex - 1) % 3) * - dot_spacing - ]) scale([ dot_d, dot_d, 2 * dot_h ]) sphere($fn = 8, r = 0.5); - } - } +module braille_ascii_spec800(inString,dot_backing=true,cell_backing=false,justify=1,align=-1,dot_h=0.48,dot_d=1.44,dot_spacing=2.340,cell_d2d_spacing=6.2, line_d2d_spacing=10.0, echo_translate=true) { + // justify: + // -1 : left side + // 0 : center + // 1 : right side (default) + // align: + // -1 : bottom braille cell edge - shift up (default) + // 0 : center braille cell + // 1 : top braille cell edge - shift down + thisFont=braille_ascii_font(dot_h=dot_h,dot_d=dot_d,dot_spacing=dot_spacing + ,cell_d2d_spacing=cell_d2d_spacing,line_d2d_spacing=line_d2d_spacing); + x_shift=thisFont[0][0]; + y_shift=thisFont[0][1]; + theseIndicies=search(inString,thisFont[2],1,1); + for( i=[0:len(theseIndicies)-1]) translate([i*x_shift-(1-justify)*x_shift*len(theseIndicies)/2,-y_shift*(align+1)/2]) + assign(dotPattern=thisFont[2][theseIndicies[i]][6]) { + if(dot_backing) translate([cell_d2d_spacing/2-dot_spacing/2-dot_d/2,line_d2d_spacing/2-dot_spacing-dot_d/2,-dot_h]) + cube(size=[dot_spacing+dot_d,2*dot_spacing+dot_d,dot_h],center=false); + if(cell_backing) translate([0,0,-dot_h]) + cube(size=[x_shift,y_shift,dot_h],center=false); + if(echo_translate) echo(str(inString[i]," maps to '",thisFont[2][theseIndicies[i]][4],"'")); + for(dotIndex=dotPattern) { + translate([cell_d2d_spacing/2-dot_spacing/2+floor((dotIndex-1)/3)*dot_spacing + , line_d2d_spacing/2-dot_spacing+(2-(dotIndex-1)%3)*dot_spacing]) + scale([dot_d,dot_d,2*dot_h]) sphere($fn=8,r=0.5); + } + } } // Encoding from http://en.wikipedia.org/wiki/Braille_ASCII @@ -692,148 +598,141 @@ module braille_ascii_spec800(inString, // 1 4 // 2 5 // 3 6 -function braille_ascii_font(dot_h = 0.48, - dot_d = 1.44, - dot_spacing = 2.340, - cell_d2d_spacing = 6.2, - line_d2d_spacing = 10.0) = - [[cell_d2d_spacing, line_d2d_spacing, 0, "bump"], - ["Decimal Byte", - "Caret Notation", - "Character Escape Code", - "Abbreviation", - "Name", - "Bound Box", - "[bump_list]"], - [[0, "^@", "\0", "NUL", "Null character", [[0, 0], [2, 3]], []], - [1, "^A", "", "SOH", "Start of Header", [[0, 0], [2, 3]], []], - [2, "^B", "", "STX", "Start of Text", [[0, 0], [2, 3]], []], - [3, "^C", "", "ETX", "End of Text", [[0, 0], [2, 3]], []], - [4, "^D", "", "EOT", "End of Transmission", [[0, 0], [2, 3]], []], - [5, "^E", "", "ENQ", "Enquiry", [[0, 0], [2, 3]], []], - [6, "^F", "", "ACK", "Acknowledgment", [[0, 0], [2, 3]], []], - [7, "^G", "\a", "BEL", "Bell", [[0, 0], [2, 3]], []], - [8, "^H", "\b", "BS", "Backspace", [[0, 0], [2, 3]], []], - [9, "^I", "\t", "HT", "Horizontal Tab", [[0, 0], [2, 3]], []], - [10, "^J", "\n", "LF", "Line Feed", [[0, 0], [2, 3]], []], - [11, "^K", "\v", "VT", "Vertical Tab", [[0, 0], [2, 3]], []], - [12, "^L", "\f", "FF", "Form feed", [[0, 0], [2, 3]], []], - [13, "^M", "\r", "CR", "Carriage return", [[0, 0], [2, 3]], []], - [14, "^N", "", "SO", "Shift Out", [[0, 0], [2, 3]], []], - [15, "^O", "", "SI", "Shift In", [[0, 0], [2, 3]], []], - [16, "^P", "", "DLE", "Data Link Escape", [[0, 0], [2, 3]], []], - [17, "^Q", "", "DC1", "Device Control 1", [[0, 0], [2, 3]], []], - [18, "^R", "", "DC2", "Device Control 2", [[0, 0], [2, 3]], []], - [19, "^S", "", "DC3", "Device Control 3", [[0, 0], [2, 3]], []], - [20, "^T", "", "DC4", "Device Control 4", [[0, 0], [2, 3]], []], - [21, "^U", "", "NAK", "Negative Acknowledgement", [[0, 0], [2, 3]], []], - [22, "^V", "", "SYN", "Synchronous Idle", [[0, 0], [2, 3]], []], - [23, "^W", "", "ETB", "End of Transmission Block", [[0, 0], [2, 3]], []], - [24, "^X", "", "CAN", "Cancel", [[0, 0], [2, 3]], []], - [25, "^Y", "", "EM", "End of Medium", [[0, 0], [2, 3]], []], - [26, "^Z", "", "SUB", "Substitute", [[0, 0], [2, 3]], []], - [27, "^[", "\e", "ESC", "Escape", [[0, 0], [2, 3]], []], - [28, "^\\", "", "FS", "File Separator", [[0, 0], [2, 3]], []], - [29, "^]", "", "GS", "Group Separator", [[0, 0], [2, 3]], []], - [30, "^^", "", "RS", "Record Separator", [[0, 0], [2, 3]], []], - [31, "^_", "", "US", "Unit Separator", [[0, 0], [2, 3]], []], - [32, " ", " ", "", "Space", [[0, 0], [2, 3]], []], - [33, "!", "!", "", "the", [[0, 0], [2, 3]], [2, 3, 4, 6]], - [34, "\"", "\"", "", "(contraction)", [[0, 0], [2, 3]], [5]], - [35, "#", "#", "", "(number prefix)", [[0, 0], [2, 3]], [3, 4, 5, 6]], - [36, "$", "$", "", "ed", [[0, 0], [2, 3]], [1, 2, 4, 6]], - [37, "%", "%", "", "sh", [[0, 0], [2, 3]], [1, 4, 6]], - [38, "&", "&", "", "and", [[0, 0], [2, 3]], [1, 2, 3, 4, 6]], - [39, "'", "'", "", "", [[0, 0], [2, 3]], [3]], - [40, "(", "(", "", "of", [[0, 0], [2, 3]], [1, 2, 3, 5, 6]], - [41, ")", ")", "", "with", [[0, 0], [2, 3]], [2, 3, 4, 5, 6]], - [42, "*", "*", "", "ch", [[0, 0], [2, 3]], [1, 6]], - [43, "+", "+", "", "ing", [[0, 0], [2, 3]], [3, 4, 6]], - [44, ",", ",", "", "(uppercase prefix)", [[0, 0], [2, 3]], [6]], - [45, "-", "-", "", "", [[0, 0], [2, 3]], [3, 6]], - [46, ".", ".", "", "(italic prefix)", [[0, 0], [2, 3]], [4, 6]], - [47, "/", "/", "", "st", [[0, 0], [2, 3]], [3, 4]], - [48, "0", "0", "", "\"", [[0, 0], [2, 3]], [3, 5, 6]], - [49, "1", "1", "", ",", [[0, 0], [2, 3]], [2]], - [50, "2", "2", "", ";", [[0, 0], [2, 3]], [2, 3]], - [51, "3", "3", "", ":", [[0, 0], [2, 3]], [2, 5]], - [52, "4", "4", "", ".", [[0, 0], [2, 3]], [2, 5, 6]], - [53, "5", "5", "", "en", [[0, 0], [2, 3]], [2, 6]], - [54, "6", "6", "", "!", [[0, 0], [2, 3]], [2, 3, 5]], - [55, "7", "7", "", "( or )", [[0, 0], [2, 3]], [2, 3, 5, 6]], - [56, "8", "8", "", "\" or ?", [[0, 0], [2, 3]], [2, 3, 6]], - [57, "9", "9", "", "in", [[0, 0], [2, 3]], [3, 5]], - [58, ":", ":", "", "wh", [[0, 0], [2, 3]], [1, 5, 6]], - [59, ";", ";", "", "(letter prefix)", [[0, 0], [2, 3]], [5, 6]], - [60, "<", "<", "", "gh", [[0, 0], [2, 3]], [1, 2, 6]], - [61, "=", "=", "", "for", [[0, 0], [2, 3]], [1, 2, 3, 4, 5, 6]], - [62, ">", ">", "", "ar", [[0, 0], [2, 3]], [3, 4, 5]], - [63, "?", "?", "", "th", [[0, 0], [2, 3]], [1, 4, 5, 6]], - [64, "@", "@", "", "(accent prefix)", [[0, 0], [2, 3]], [4]], - [65, "A", "A", "", "a", [[0, 0], [2, 3]], [1]], - [66, "B", "B", "", "b", [[0, 0], [2, 3]], [1, 2]], - [67, "C", "C", "", "c", [[0, 0], [2, 3]], [1, 4]], - [68, "D", "D", "", "d", [[0, 0], [2, 3]], [1, 4, 5]], - [69, "E", "E", "", "e", [[0, 0], [2, 3]], [1, 5]], - [70, "F", "F", "", "f", [[0, 0], [2, 3]], [1, 2, 4]], - [71, "G", "G", "", "g", [[0, 0], [2, 3]], [1, 2, 4, 5]], - [72, "H", "H", "", "h", [[0, 0], [2, 3]], [1, 2, 5]], - [73, "I", "I", "", "i", [[0, 0], [2, 3]], [2, 4]], - [74, "J", "J", "", "j", [[0, 0], [2, 3]], [2, 4, 5]], - [75, "K", "K", "", "k", [[0, 0], [2, 3]], [1, 3]], - [76, "L", "L", "", "l", [[0, 0], [2, 3]], [1, 2, 3]], - [77, "M", "M", "", "m", [[0, 0], [2, 3]], [1, 3, 4]], - [78, "N", "N", "", "n", [[0, 0], [2, 3]], [1, 3, 4, 5]], - [79, "O", "O", "", "o", [[0, 0], [2, 3]], [1, 3, 5]], - [80, "P", "P", "", "p", [[0, 0], [2, 3]], [1, 2, 3, 4]], - [81, "Q", "Q", "", "q", [[0, 0], [2, 3]], [1, 2, 3, 4, 5]], - [82, "R", "R", "", "r", [[0, 0], [2, 3]], [1, 2, 3, 5]], - [83, "S", "S", "", "s", [[0, 0], [2, 3]], [2, 3, 4]], - [84, "T", "T", "", "t", [[0, 0], [2, 3]], [2, 3, 4, 5]], - [85, "U", "U", "", "u", [[0, 0], [2, 3]], [1, 3, 6]], - [86, "V", "V", "", "v", [[0, 0], [2, 3]], [1, 2, 3, 6]], - [87, "W", "W", "", "w", [[0, 0], [2, 3]], [2, 4, 5, 6]], - [88, "X", "X", "", "x", [[0, 0], [2, 3]], [1, 3, 4, 6]], - [89, "Y", "Y", "", "y", [[0, 0], [2, 3]], [1, 3, 4, 5, 6]], - [90, "Z", "Z", "", "z", [[0, 0], [2, 3]], [1, 3, 5, 6]], - [91, "[", "[", "", "ow", [[0, 0], [2, 3]], [2, 4, 6]] // ]] - , - [92, "\\", "\\", "", "ou", [[0, 0], [2, 3]], [1, 2, 5, 6]] // [[ - , - [93, "]", "]", "", "er", [[0, 0], [2, 3]], [1, 2, 4, 5, 6]], - [94, "^", "^", "", "(contraction)", [[0, 0], [2, 3]], [4, 5]], - [95, "_", "_", "", "(contraction)", [[0, 0], [2, 3]], [4, 5, 6]], - [96, "`", "`", "", "", [[0, 0], [2, 3]], []] - // Repeating upper-case patterns for lower-case letters. - , - [97, "a", "a", "", "a", [[0, 0], [2, 3]], [1]], - [98, "b", "b", "", "b", [[0, 0], [2, 3]], [1, 2]], - [99, "c", "c", "", "c", [[0, 0], [2, 3]], [1, 4]], - [100, "d", "d", "", "d", [[0, 0], [2, 3]], [1, 4, 5]], - [101, "e", "e", "", "e", [[0, 0], [2, 3]], [1, 5]], - [102, "f", "f", "", "f", [[0, 0], [2, 3]], [1, 2, 4]], - [103, "g", "g", "", "g", [[0, 0], [2, 3]], [1, 2, 4, 5]], - [104, "h", "h", "", "h", [[0, 0], [2, 3]], [1, 2, 5]], - [105, "i", "i", "", "i", [[0, 0], [2, 3]], [2, 4]], - [106, "j", "j", "", "j", [[0, 0], [2, 3]], [2, 4, 5]], - [107, "k", "k", "", "k", [[0, 0], [2, 3]], [1, 3]], - [108, "l", "l", "", "l", [[0, 0], [2, 3]], [1, 2, 3]], - [109, "m", "m", "", "m", [[0,, 0], [2, 3]], [1, 3, 4]], - [110, "n", "n", "", "n", [[0, 0], [2, 3]], [1, 3, 4, 5]], - [111, "o", "o", "", "o", [[0, 0], [2, 3]], [1, 3, 5]], - [112, "p", "p", "", "p", [[0, 0], [2, 3]], [1, 2, 3, 4]], - [113, "q", "q", "", "q", [[0, 0], [2, 3]], [1, 2, 3, 4, 5]], - [114, "r", "r", "", "r", [[0, 0], [2, 3]], [1, 2, 3, 5]], - [115, "s", "s", "", "s", [[0, 0], [2, 3]], [2, 3, 4]], - [116, "t", "t", "", "t", [[0, 0], [2, 3]], [2, 3, 4, 5]], - [117, "u", "u", "", "u", [[0, 0], [2, 3]], [1, 3, 6]], - [118, "v", "v", "", "v", [[0, 0], [2, 3]], [1, 2, 3, 6]], - [119, "w", "w", "", "w", [[0, 0], [2, 3]], [2, 4, 5, 6]], - [120, "x", "x", "", "x", [[0, 0], [2, 3]], [1, 3, 4, 6]], - [121, "y", "y", "", "y", [[0, 0], [2, 3]], [1, 3, 4, 5, 6]], - [122, "z", "z", "", "z", [[0, 0], [2, 3]], [1, 3, 5, 6]], - [123, "{", "{", "", "", [[0, 0], [2, 3]], []], - [124, "|", "|", "", "", [[0, 0], [2, 3]], []], - [125, "}", "}", "", "", [[0, 0], [2, 3]], []], - [126, "~", "~", "", "", [[0, 0], [2, 3]], []], - [127, "^?", "", "DEL", "Delete", [[0, 0], [2, 3]], []]]]; +function braille_ascii_font(dot_h=0.48,dot_d=1.44,dot_spacing=2.340,cell_d2d_spacing=6.2,line_d2d_spacing=10.0) = [ + [cell_d2d_spacing,line_d2d_spacing,0,"bump"],["Decimal Byte","Caret Notation","Character Escape Code","Abbreviation","Name","Bound Box","[bump_list]"] + ,[ + [ 0,"^@","\0","NUL","Null character",[[0,0],[2,3]],[]] + ,[ 1,"^A","", "SOH","Start of Header",[[0,0],[2,3]],[]] + ,[ 2,"^B","", "STX","Start of Text",[[0,0],[2,3]],[]] + ,[ 3,"^C","", "ETX","End of Text",[[0,0],[2,3]],[]] + ,[ 4,"^D","", "EOT","End of Transmission",[[0,0],[2,3]],[]] + ,[ 5,"^E","", "ENQ","Enquiry",[[0,0],[2,3]],[]] + ,[ 6,"^F","", "ACK","Acknowledgment",[[0,0],[2,3]],[]] + ,[ 7,"^G","\a","BEL","Bell",[[0,0],[2,3]],[]] + ,[ 8,"^H","\b","BS", "Backspace",[[0,0],[2,3]],[]] + ,[ 9,"^I","\t","HT", "Horizontal Tab",[[0,0],[2,3]],[]] + ,[ 10,"^J","\n","LF", "Line Feed",[[0,0],[2,3]],[]] + ,[ 11,"^K","\v","VT", "Vertical Tab",[[0,0],[2,3]],[]] + ,[ 12,"^L","\f","FF", "Form feed",[[0,0],[2,3]],[]] + ,[ 13,"^M","\r","CR", "Carriage return",[[0,0],[2,3]],[]] + ,[ 14,"^N","", "SO", "Shift Out",[[0,0],[2,3]],[]] + ,[ 15,"^O","", "SI", "Shift In",[[0,0],[2,3]],[]] + ,[ 16,"^P","", "DLE","Data Link Escape",[[0,0],[2,3]],[]] + ,[ 17,"^Q","", "DC1","Device Control 1",[[0,0],[2,3]],[]] + ,[ 18,"^R","", "DC2","Device Control 2",[[0,0],[2,3]],[]] + ,[ 19,"^S","", "DC3","Device Control 3",[[0,0],[2,3]],[]] + ,[ 20,"^T","", "DC4","Device Control 4",[[0,0],[2,3]],[]] + ,[ 21,"^U","", "NAK","Negative Acknowledgement",[[0,0],[2,3]],[]] + ,[ 22,"^V","", "SYN","Synchronous Idle",[[0,0],[2,3]],[]] + ,[ 23,"^W","", "ETB","End of Transmission Block",[[0,0],[2,3]],[]] + ,[ 24,"^X","", "CAN","Cancel",[[0,0],[2,3]],[]] + ,[ 25,"^Y","", "EM", "End of Medium",[[0,0],[2,3]],[]] + ,[ 26,"^Z","", "SUB","Substitute",[[0,0],[2,3]],[]] + ,[ 27,"^[","\e","ESC","Escape",[[0,0],[2,3]],[]] + ,[ 28,"^\\","", "FS", "File Separator",[[0,0],[2,3]],[]] + ,[ 29,"^]","", "GS", "Group Separator",[[0,0],[2,3]],[]] + ,[ 30,"^^","", "RS", "Record Separator",[[0,0],[2,3]],[]] + ,[ 31,"^_","", "US", "Unit Separator",[[0,0],[2,3]],[]] + ,[ 32," "," ", "", "Space",[[0,0],[2,3]],[]] + ,[ 33,"!","!", "", "the",[[0,0],[2,3]],[ 2,3,4,6 ]] + ,[ 34,"\"","\"","", "(contraction)",[[0,0],[2,3]],[ 5 ]] + ,[ 35,"#","#", "", "(number prefix)",[[0,0],[2,3]],[ 3,4,5,6 ]] + ,[ 36,"$","$", "", "ed",[[0,0],[2,3]],[ 1,2,4,6 ]] + ,[ 37,"%","%", "", "sh",[[0,0],[2,3]],[ 1,4,6 ]] + ,[ 38,"&","&", "", "and",[[0,0],[2,3]],[ 1,2,3,4,6 ]] + ,[ 39,"'","'", "", "",[[0,0],[2,3]],[ 3 ]] + ,[ 40,"(","(", "", "of",[[0,0],[2,3]],[ 1,2,3,5,6 ]] + ,[ 41,")",")", "", "with",[[0,0],[2,3]],[ 2,3,4,5,6 ]] + ,[ 42,"*","*", "", "ch",[[0,0],[2,3]],[ 1,6 ]] + ,[ 43,"+","+", "", "ing",[[0,0],[2,3]],[ 3,4,6 ]] + ,[ 44,",",",", "", "(uppercase prefix)",[[0,0],[2,3]],[ 6 ]] + ,[ 45,"-","-", "", "",[[0,0],[2,3]],[ 3,6 ]] + ,[ 46,".",".", "", "(italic prefix)",[[0,0],[2,3]],[ 4,6 ]] + ,[ 47,"/","/", "", "st",[[0,0],[2,3]],[ 3,4 ]] + ,[ 48,"0","0", "", "\"",[[0,0],[2,3]],[ 3,5,6 ]] + ,[ 49,"1","1", "", ",",[[0,0],[2,3]],[ 2 ]] + ,[ 50,"2","2", "", ";",[[0,0],[2,3]],[ 2,3 ]] + ,[ 51,"3","3", "", ":",[[0,0],[2,3]],[ 2,5 ]] + ,[ 52,"4","4", "", ".",[[0,0],[2,3]],[ 2,5,6 ]] + ,[ 53,"5","5", "", "en",[[0,0],[2,3]],[ 2,6 ]] + ,[ 54,"6","6", "", "!",[[0,0],[2,3]],[ 2,3,5 ]] + ,[ 55,"7","7", "", "( or )",[[0,0],[2,3]],[ 2,3,5,6 ]] + ,[ 56,"8","8", "", "\" or ?",[[0,0],[2,3]],[ 2,3,6 ]] + ,[ 57,"9","9", "", "in",[[0,0],[2,3]],[ 3,5 ]] + ,[ 58,":",":", "", "wh",[[0,0],[2,3]],[ 1,5,6 ]] + ,[ 59,";",";", "", "(letter prefix)",[[0,0],[2,3]],[ 5,6 ]] + ,[ 60,"<","<", "", "gh",[[0,0],[2,3]],[ 1,2,6 ]] + ,[ 61,"=","=", "", "for",[[0,0],[2,3]],[ 1,2,3,4,5,6 ]] + ,[ 62,">",">", "", "ar",[[0,0],[2,3]],[ 3,4,5 ]] + ,[ 63,"?","?", "", "th",[[0,0],[2,3]],[ 1,4,5,6 ]] + ,[ 64,"@","@", "", "(accent prefix)",[[0,0],[2,3]],[ 4 ]] + ,[ 65,"A","A", "", "a",[[0,0],[2,3]],[ 1 ]] + ,[ 66,"B","B", "", "b",[[0,0],[2,3]],[ 1,2 ]] + ,[ 67,"C","C", "", "c",[[0,0],[2,3]],[ 1,4 ]] + ,[ 68,"D","D", "", "d",[[0,0],[2,3]],[ 1,4,5 ]] + ,[ 69,"E","E", "", "e",[[0,0],[2,3]],[ 1,5 ]] + ,[ 70,"F","F", "", "f",[[0,0],[2,3]],[ 1,2,4 ]] + ,[ 71,"G","G", "", "g",[[0,0],[2,3]],[ 1,2,4,5 ]] + ,[ 72,"H","H", "", "h",[[0,0],[2,3]],[ 1,2,5 ]] + ,[ 73,"I","I", "", "i",[[0,0],[2,3]],[ 2,4 ]] + ,[ 74,"J","J", "", "j",[[0,0],[2,3]],[ 2,4,5 ]] + ,[ 75,"K","K", "", "k",[[0,0],[2,3]],[ 1,3 ]] + ,[ 76,"L","L", "", "l",[[0,0],[2,3]],[ 1,2,3 ]] + ,[ 77,"M","M", "", "m",[[0,0],[2,3]],[ 1,3,4 ]] + ,[ 78,"N","N", "", "n",[[0,0],[2,3]],[ 1,3,4,5 ]] + ,[ 79,"O","O", "", "o",[[0,0],[2,3]],[ 1,3,5 ]] + ,[ 80,"P","P", "", "p",[[0,0],[2,3]],[ 1,2,3,4 ]] + ,[ 81,"Q","Q", "", "q",[[0,0],[2,3]],[ 1,2,3,4,5 ]] + ,[ 82,"R","R", "", "r",[[0,0],[2,3]],[ 1,2,3,5 ]] + ,[ 83,"S","S", "", "s",[[0,0],[2,3]],[ 2,3,4 ]] + ,[ 84,"T","T", "", "t",[[0,0],[2,3]],[ 2,3,4,5 ]] + ,[ 85,"U","U", "", "u",[[0,0],[2,3]],[ 1,3,6 ]] + ,[ 86,"V","V", "", "v",[[0,0],[2,3]],[ 1,2,3,6 ]] + ,[ 87,"W","W", "", "w",[[0,0],[2,3]],[ 2,4,5,6 ]] + ,[ 88,"X","X", "", "x",[[0,0],[2,3]],[ 1,3,4,6 ]] + ,[ 89,"Y","Y", "", "y",[[0,0],[2,3]],[ 1,3,4,5,6 ]] + ,[ 90,"Z","Z", "", "z",[[0,0],[2,3]],[ 1,3,5,6 ]] + ,[ 91,"[","[", "", "ow",[[0,0],[2,3]],[ 2,4,6 ]] // ]] + ,[ 92,"\\","\\","", "ou",[[0,0],[2,3]],[ 1,2,5,6 ]] // [[ + ,[ 93,"]","]", "", "er",[[0,0],[2,3]],[ 1,2,4,5,6 ]] + ,[ 94,"^","^", "", "(contraction)",[[0,0],[2,3]],[ 4,5 ]] + ,[ 95,"_","_", "", "(contraction)",[[0,0],[2,3]],[ 4,5,6 ]] + ,[ 96,"`","`", "", "",[[0,0],[2,3]],[ + ]] +// Repeating upper-case patterns for lower-case letters. + ,[ 97,"a","a", "", "a",[[0,0],[2,3]],[ 1 ]] + ,[ 98,"b","b", "", "b",[[0,0],[2,3]],[ 1,2 ]] + ,[ 99,"c","c", "", "c",[[0,0],[2,3]],[ 1,4 ]] + ,[100,"d","d", "", "d",[[0,0],[2,3]],[ 1,4,5 ]] + ,[101,"e","e", "", "e",[[0,0],[2,3]],[ 1,5 ]] + ,[102,"f","f", "", "f",[[0,0],[2,3]],[ 1,2,4 ]] + ,[103,"g","g", "", "g",[[0,0],[2,3]],[ 1,2,4,5 ]] + ,[104,"h","h", "", "h",[[0,0],[2,3]],[ 1,2,5 ]] + ,[105,"i","i", "", "i",[[0,0],[2,3]],[ 2,4 ]] + ,[106,"j","j", "", "j",[[0,0],[2,3]],[ 2,4,5 ]] + ,[107,"k","k", "", "k",[[0,0],[2,3]],[ 1,3 ]] + ,[108,"l","l", "", "l",[[0,0],[2,3]],[ 1,2,3 ]] + ,[109,"m","m", "", "m",[[0,0],[2,3]],[ 1,3,4 ]] + ,[110,"n","n", "", "n",[[0,0],[2,3]],[ 1,3,4,5 ]] + ,[111,"o","o", "", "o",[[0,0],[2,3]],[ 1,3,5 ]] + ,[112,"p","p", "", "p",[[0,0],[2,3]],[ 1,2,3,4 ]] + ,[113,"q","q", "", "q",[[0,0],[2,3]],[ 1,2,3,4,5 ]] + ,[114,"r","r", "", "r",[[0,0],[2,3]],[ 1,2,3,5 ]] + ,[115,"s","s", "", "s",[[0,0],[2,3]],[ 2,3,4 ]] + ,[116,"t","t", "", "t",[[0,0],[2,3]],[ 2,3,4,5 ]] + ,[117,"u","u", "", "u",[[0,0],[2,3]],[ 1,3,6 ]] + ,[118,"v","v", "", "v",[[0,0],[2,3]],[ 1,2,3,6 ]] + ,[119,"w","w", "", "w",[[0,0],[2,3]],[ 2,4,5,6 ]] + ,[120,"x","x", "", "x",[[0,0],[2,3]],[ 1,3,4,6 ]] + ,[121,"y","y", "", "y",[[0,0],[2,3]],[ 1,3,4,5,6 ]] + ,[122,"z","z", "", "z",[[0,0],[2,3]],[ 1,3,5,6 ]] + ,[123,"{","{", "", "",[[0,0],[2,3]],[ + ]] + ,[124,"|","|", "", "",[[0,0],[2,3]],[ + ]] + ,[125,"}","}", "", "",[[0,0],[2,3]],[ + ]] + ,[126,"~","~", "", "",[[0,0],[2,3]],[ + ]] + ,[127,"^?","", "DEL","Delete",[[0,0],[2,3]],[]] + ] ]; diff --git a/text/height_map.scad b/text/height_map.scad index 6e20e719..0b75f569 100644 --- a/text/height_map.scad +++ b/text/height_map.scad @@ -1,4 +1,3 @@ -use /* Height Map Example Tony Buser @@ -7,19 +6,26 @@ http://creativecommons.org/licenses/by/3.0/ Can also dynamically run this by passing an array on the command line: -/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD -m make -D -bitmap=[2,2,2,0,1,3,2,2,2] -D row_size=3 -s height_map.stl height_map.scad +/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD -m make -D bitmap=[2,2,2,0,1,3,2,2,2] -D row_size=3 -s height_map.stl height_map.scad */ +use + block_size = 5; height = 5; row_size = 10; // 10x10 pixels bitmap = [ - 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 2, 1, - 1, 2, 2, 1, 0, 0, 1, 2, 1, 1, 1, 1, 2, 1, 0, 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, - 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, 0, 1, 2, 1, 1, 1, 1, 2, 1, 0, 0, 1, 2, 2, 1, - 1, 2, 2, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1 + 1,1,0,0,1,1,0,0,1,1, + 1,1,1,1,1,1,1,1,1,1, + 0,1,2,2,1,1,2,2,1,0, + 0,1,2,1,1,1,1,2,1,0, + 1,1,1,1,3,3,1,1,1,1, + 1,1,1,1,3,3,1,1,1,1, + 0,1,2,1,1,1,1,2,1,0, + 0,1,2,2,1,1,2,2,1,0, + 1,1,1,1,1,1,1,1,1,1, + 1,1,0,0,1,1,0,0,1,1 ]; bitmap(bitmap, block_size, height, row_size); diff --git a/text/letter_necklace.scad b/text/letter_necklace.scad index e894395a..8d357816 100644 --- a/text/letter_necklace.scad +++ b/text/letter_necklace.scad @@ -1,13 +1,14 @@ -use /* Parametric letters for for a necklace Elmo Mäntynen LGPL 2.1 */ +use + // change chars array and char_count // OpenSCAD has no string or length methods :( -chars = [ "M", "a", "k", "e", "r", "B", "o", "t" ]; +chars = ["M","a","k","e","r","B","o","t"]; char_count = 8; // block size 1 will result in 8mm per letter @@ -15,65 +16,44 @@ block_size = 2; // height is the Z height of each letter height = 3; -// Hole for the necklace +//Hole for the necklace hole_diameter = 5; -module 8bit_str(chars, char_count, block_size, height) -{ - echo(str("Total Width: ", block_size * 8 * char_count, "mm")); - union() - { - for (count = [0:char_count - 1]) { - translate(v = [ 0, count * block_size * 8, 0 ]) - { - 8bit_char(chars[count], block_size, height); - } - } - } +module 8bit_str(chars, char_count, block_size, height) { + echo(str("Total Width: ", block_size * 8 * char_count, "mm")); + union() { + for (count = [0:char_count-1]) { + translate(v = [0, count * block_size * 8, 0]) { + 8bit_char(chars[count], block_size, height); + } + } + } } -module -letter(char, block_size, height, hole_diameter) -{ - union() - { - translate(v = [ 0, 0, hole_diameter * 1.3 ]) - { - 8bit_char(char, block_size, height); - } - translate(v = [ 0, 0, (hole_diameter * 1.3) / 2 ]) - { - color([ 0, 0, 1, 1 ]) - { - difference() - { - cube(size = - [ - block_size * 8, - block_size * 8, - hole_diameter + 2 - ], - center = true); - rotate([ 90, 0, 0 ]) cylinder(h = block_size * 8 + 1, - r = hole_diameter / 2, - center = true); - } - } - } - } +module letter(char, block_size, height, hole_diameter) { + union() { + translate(v = [0,0, hole_diameter*1.3]) { + 8bit_char(char, block_size, height); + } + translate(v = [0,0,(hole_diameter*1.3)/2]) { + color([0,0,1,1]) { + difference() { + cube(size = [block_size * 8, block_size * 8, hole_diameter+2], center = true); + rotate([90, 0, 0]) cylinder(h = block_size * 8 + 1, r = hole_diameter/2, center = true); + } + } + } + } } -matrix = [ [ "O", "L", "E", "N", "S" ], [ "Y", "OE", "N", "Y", "T" ] ]; +matrix = [["O", "L", "E", "N", "S"], + [ "Y", "OE", "N", "Y", "T"]]; -union() -{ - for (column = [0:1]) { - for (row = [0:4]) { - translate(v = [ - column * (block_size * 1.1) * 8, - row * (block_size * 1.1) * 8, - 0 - ]) letter(matrix[column][row], block_size, height, hole_diameter); - } - } +union() { + for (column = [0:1]) { + for (row = [0:4]) { + translate(v=[column*(block_size*1.1)*8, row*(block_size*1.1)*8, 0]) + letter(matrix[column][row], block_size, height, hole_diameter); + } + } } diff --git a/text/name_tag.scad b/text/name_tag.scad index 0509ac90..4b392bb3 100644 --- a/text/name_tag.scad +++ b/text/name_tag.scad @@ -1,47 +1,36 @@ -use /* -Parametric Name Tag +Parametric Name Tag Tony Buser http://tonybuser.com http://creativecommons.org/licenses/by/3.0/ */ +use + /* chars = chars array block_size = letter size (block size 1 will result in 8mm per letter) height = the Z height of each letter in mm key_ring_hole = (boolean) Append a hole to a keyring, necklace etc. ? */ -module name_tag(chars = [ "R", "E", "P", "R", "A", "P" ], - block_size = 2, - height = 3, - key_ring_hole = true) -{ - char_count = len(chars); - union() - { - translate( - v = [ 0, -block_size * 8 * char_count / 2 + block_size * 8 / 2, 3 ]) - { - 8bit_str(chars, char_count, block_size, height); - } - translate(v = [ 0, 0, 3 / 2 ]) - { - color([ 0, 0, 1, 1 ]) - { - cube(size = [ block_size * 8, block_size * 8 * char_count, 3 ], - center = true); - } - } - if (key_ring_hole == true) { - translate([ 0, block_size * 8 * (char_count + 1) / 2, 3 / 2 ]) - difference() - { - cube(size = [ block_size * 8, block_size * 8, 3 ], - center = true); - cube(size = [ block_size * 4, block_size * 4, 5 ], - center = true); - } - } +module name_tag(chars = ["R", "E", "P", "R", "A", "P"], + block_size = 2, height = 3, key_ring_hole = true) { + char_count = len(chars); + union() { + translate(v = [0,-block_size*8*char_count/2+block_size*8/2,3]) { + 8bit_str(chars, char_count, block_size, height); + } + translate(v = [0,0,3/2]) { + color([0,0,1,1]) { + cube(size = [block_size * 8, block_size * 8 * char_count, 3], center = true); + } + } + if (key_ring_hole == true){ + translate([0, block_size * 8 * (char_count+1)/2, 3/2]) + difference(){ + cube(size = [block_size * 8, block_size * 8 , 3], center = true); + cube(size = [block_size * 4, block_size * 4 , 5], center = true); + } } + } } diff --git a/text/string.scad b/text/string.scad index b126ae8e..5c2292b5 100644 --- a/text/string.scad +++ b/text/string.scad @@ -1,34 +1,14 @@ -function strToInt(str, base = 10, i = 0, nb = 0) = - (str[0] == "-") ? -1 * _strToInt(str, base, 1) : _strToInt(str, base); -function _strToInt(str, base, i = 0, nb = 0) = - (i == len(str)) ? nb - : nb + _strToInt(str, - base, - i + 1, - search(str[i], "0123456789ABCDEF")[0] * - pow(base, len(str) - i - 1)); +function strToInt(str, base=10, i=0, nb=0) = (str[0] == "-") ? -1*_strToInt(str, base, 1) : _strToInt(str, base); +function _strToInt(str, base, i=0, nb=0) = (i == len(str)) ? nb : nb+_strToInt(str, base, i+1, search(str[i],"0123456789ABCDEF")[0]*pow(base,len(str)-i-1)); -function strcat(v, car = "") = _strcat(v, len(v) - 1, car, 0); -function _strcat(v, i, car, s) = (i == s ? v[i] - : str(_strcat(v, i - 1, car, s), - str(car, v[i]))); +function strcat(v, car="") = _strcat(v, len(v)-1, car, 0); +function _strcat(v, i, car, s) = (i==s ? v[i] : str(_strcat(v, i-1, car, s), str(car,v[i]) )); -function substr(data, i, length = 0) = (length == 0) - ? _substr(data, i, len(data)) - : _substr(data, i, length + i); -function _substr(str, i, j, out = "") = (i == j) - ? out - : str(str[i], - _substr(str, i + 1, j, out)); +function substr(data, i, length=0) = (length == 0) ? _substr(data, i, len(data)) : _substr(data, i, length+i); +function _substr(str, i, j, out="") = (i==j) ? out : str(str[i], _substr(str, i+1, j, out)); -function fill(car, nb_occ, out = "") = (nb_occ == 0) - ? out - : str(fill(car, nb_occ - 1, out), - car); +function fill(car, nb_occ, out="") = (nb_occ == 0) ? out : str(fill(car, nb_occ-1, out), car); -function getsplit(str, index = 0, char = " ") = - (index == 0) - ? substr(str, 0, search(char, str)[0]) - : getsplit(substr(str, search(" ", str)[0] + 1), index - 1, char); \ No newline at end of file +function getsplit(str, index=0, char=" ") = (index==0) ? substr(str, 0, search(char, str)[0]) : getsplit( substr(str, search(" ", str)[0]+1) , index-1, char); \ No newline at end of file diff --git a/text/test_name_tag.scad b/text/test_name_tag.scad index a7f56118..85e5c707 100644 --- a/text/test_name_tag.scad +++ b/text/test_name_tag.scad @@ -1,19 +1,19 @@ +include ; -include; +translate([0,0,0]) +name_tag("name_tag"); -translate([ 0, 0, 0 ]) name_tag("name_tag"); +translate([20,0,0]) // 0 + 16/2 + 16/2 + 4 +name_tag("NAME_TAG"); -translate([ 20, 0, 0 ]) // 0 + 16/2 + 16/2 + 4 - name_tag("NAME_TAG"); +translate([52,0,0]) // 20 + 16/2 + 40/2 + 4 +name_tag("name_tag", block_size=5); -translate([ 52, 0, 0 ]) // 20 + 16/2 + 40/2 + 4 - name_tag("name_tag", block_size = 5); +translate([96,0,0]) // 52 + 40/2 + 40/2 + 4 +name_tag("NAME_TAG", block_size=5); -translate([ 96, 0, 0 ]) // 52 + 40/2 + 40/2 + 4 - name_tag("NAME_TAG", block_size = 5); +translate([130,0,0]) // 92 + 40/2 + 16/2 + 4 +name_tag("name_tag", height=30); -translate([ 130, 0, 0 ]) // 92 + 40/2 + 16/2 + 4 - name_tag("name_tag", height = 30); - -translate([ 150, 0, 0 ]) // 130 + 16/2 + 16/2 + 4 - name_tag("NAME_TAG", height = 30); +translate([150,0,0]) // 130 + 16/2 + 16/2 + 4 +name_tag("NAME_TAG", height=30); diff --git a/units/default.scad b/units/default.scad index 51f970ff..91c03af7 100644 --- a/units/default.scad +++ b/units/default.scad @@ -1,4 +1,3 @@ - // Default units are mm. length_mm = 1; diff --git a/units/metric.scad b/units/metric.scad index 225e5211..0a457b22 100644 --- a/units/metric.scad +++ b/units/metric.scad @@ -1,9 +1,8 @@ -include // 1 2 3 4 5 6 7 -// 3456789012345678901234567890123456789012345678901234567890123456789012 +//3456789012345678901234567890123456789012345678901234567890123456789012 /* * Metric units. - * + * * Originally by Hans Häggström, 2010. With contributions from: * elmom (Elmo Mantynen ) * kr2 (Krallinger Sebastian ) @@ -22,8 +21,8 @@ function length_nm(quantity) = quantity * length_nm; //! Commented out until https://github.com/openscad/openscad/issues/737 //! is resolved. -// length_µm = 0.001 * length_mm; // micrometre -// function length_µm(quantity) = quantity * length_µm; +//length_µm = 0.001 * length_mm; // micrometre +//function length_µm(quantity) = quantity * length_µm; length_um = 0.001 * length_mm; // micrometre (alternate) function length_um(quantity) = quantity * length_um; @@ -61,9 +60,9 @@ function length_km(quantity) = quantity * length_km; //㎝ = length_cm; //㎞ = length_km; -X = [ 1, 0, 0 ]; -Y = [ 0, 1, 0 ]; -Z = [ 0, 0, 1 ]; +X = [1, 0, 0]; +Y = [0, 1, 0]; +Z = [0, 0, 1]; M3 = 3 * length_mm; M4 = 4 * length_mm; @@ -75,6 +74,8 @@ M8 = 8 * length_mm; // cutting, etc. //! Commented out until https://github.com/openscad/openscad/issues/737 //! is resolved. -// epsilon = 10.0 * length_µm; +//epsilon = 10.0 * length_µm; epsilon = 10.0 * length_um; -OS = epsilon; // Over size +OS = epsilon; // Over size + +include diff --git a/units/us.scad b/units/us.scad index 0d7e205f..586a7af5 100644 --- a/units/us.scad +++ b/units/us.scad @@ -1,9 +1,8 @@ -include // 1 2 3 4 5 6 7 -// 3456789012345678901234567890123456789012345678901234567890123456789012 +//3456789012345678901234567890123456789012345678901234567890123456789012 /* * United States customary units. - * + * * Originally by McNeight (Neil McNeight ) * * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and @@ -11,19 +10,18 @@ include */ /* - * From - * http://en.wikipedia.org/wiki/United_States_customary_units#Other_names_for_U.S._customary_units - * + * From http://en.wikipedia.org/wiki/United_States_customary_units#Other_names_for_U.S._customary_units + * * The United States Code refers to these units as "traditional systems * of weights and measures". - * + * * Other common ways of referring to these systems in the United States * are: "Standard", "Customary", or, somewhat erroneously when considering * volume/tonnage, "Imperial", or "English", which refers to the pre-1824 * reform measures used throughout the British Empire. Another term is the * "foot-pound-second" (FPS) system (as opposed to centimeter-gram-second * (CGS) system). - * + * * Tools and fasteners with sizes measured in inches are sometimes called * "SAE bolts" or "SAE wrenches" to differentiate them from their metric * counterparts. The Society of Automotive Engineers originally developed @@ -31,6 +29,8 @@ include * organization now uses metric units. */ +include + /* * Conversion to metric is defined by Roberts, R.W. (February 3, 1975). * Federal Register republished in Barbrow, L.E. and Judson, L. V. (1976) @@ -68,59 +68,42 @@ function length_thou(quantity) = quantity * length_thou; length_mil = 0.001 * length_inch; function length_mil(quantity) = quantity * length_mil; -module inch_ruler(inches){ difference(){ - // Body of ruler - color("Beige") cube( - size = [ length_inch(inches), length_inch(1.125), length_thou(150) ]); -// Inch markings -for (i = [0:length_inch(1):length_inch(inches) + epsilon]) { - translate([ i, length_inch(0.8875), length_thou(130) ]) color("Red") - cube(size = - [ - length_thou(20), - length_inch(0.475) + epsilon, - length_thou(40) + - epsilon - ], - center = true); -} -// Half inch markings -for (i = [length_inch(0.5):length_inch(1):length_inch(inches)]) { - translate([ i, length_inch(0.93125), length_thou(135) ]) color("Red") - cube(size = - [ - length_thou(20), - length_inch(0.3875) + epsilon, - length_thou(30) + - epsilon - ], - center = true); -} -// Quarter inch markings -for (i = [length_inch(0.25):length_inch(0.5):length_inch(inches)]) { - translate([ i, length_inch(1.0), length_thou(140) ]) color("Red") - cube(size = - [ - length_thou(20), - length_inch(0.25) + epsilon, - length_thou(20) + - epsilon - ], - center = true); -} -// Eighth inch markings -for (i = [length_inch(0.125):length_inch(0.25):length_inch(inches)]) { - translate([ i, length_inch(1.0375), length_thou(145) ]) color("Red") - cube(size = - [ - length_thou(20), - length_inch(0.175) + epsilon, - length_thou(10) + - epsilon - ], - center = true); -} -} +module inch_ruler(inches) +{ + difference() + { + // Body of ruler + color("Beige") + cube(size = [length_inch(inches), length_inch(1.125), length_thou(150)]); + // Inch markings + for (i = [0:length_inch(1):length_inch(inches) + epsilon]) + { + translate([i,length_inch(0.8875),length_thou(130)]) + color("Red") + cube(size = [length_thou(20), length_inch(0.475) + epsilon, length_thou(40) + epsilon], center = true); + } + // Half inch markings + for (i = [length_inch(0.5):length_inch(1):length_inch(inches)]) + { + translate([i,length_inch(0.93125),length_thou(135)]) + color("Red") + cube(size = [length_thou(20), length_inch(0.3875) + epsilon, length_thou(30) + epsilon], center = true); + } + // Quarter inch markings + for (i = [length_inch(0.25):length_inch(0.5):length_inch(inches)]) + { + translate([i,length_inch(1.0),length_thou(140)]) + color("Red") + cube(size = [length_thou(20), length_inch(0.25) + epsilon, length_thou(20) + epsilon], center = true); + } + // Eighth inch markings + for (i = [length_inch(0.125):length_inch(0.25):length_inch(inches)]) + { + translate([i,length_inch(1.0375),length_thou(145)]) + color("Red") + cube(size = [length_thou(20), length_inch(0.175) + epsilon, length_thou(10) + epsilon], center = true); + } + } } *inch_ruler(4); From 53a12dfd85f873f49a1ef8d8f724e82ce3b90643 Mon Sep 17 00:00:00 2001 From: Max O'Cull Date: Fri, 15 Mar 2019 01:45:00 -0400 Subject: [PATCH 3/3] Update formatter, add configuration, reformat to use 2 space indents --- .openscad-format | 8 + array/along_curve.scad | 19 +- array/generic-multiply.scad | 11 +- array/mirror.scad | 7 +- array/polar.scad | 65 +- array/rectangular.scad | 54 +- array/translations.scad | 57 +- boxes.scad | 4 +- curves.scad | 18 +- demos/array_along_curve_demo.scad | 32 +- demos/array_linear_demo.scad | 51 +- demos/array_polar_demo.scad | 37 +- demos/array_rectangular_demo.scad | 58 +- demos/bearing_demo.scad | 28 +- demos/constants_demo.scad | 8 +- demos/hardware_demo.scad | 16 +- demos/linear_bearing_demo.scad | 8 +- demos/materials_demo.scad | 37 +- demos/metric_demo.scad | 66 +- demos/polyhole_demo.scad | 29 +- demos/rack_and_pinion_demo.scad | 9 +- demos/stepper_demo.scad | 32 +- demos/string_demo.scad | 115 +- demos/teardrop_demo.scad | 14 +- demos/visibonecolors_demo.scad | 31 +- electronics/ATXpowerSupply.scad | 110 +- extrusions/8020.scad | 67 +- extrusions/extrusions.scad | 118 +- extrusions/makerbeam.scad | 14 +- extrusions/misumi_nfs5.scad | 58 +- extrusions/openbeam.scad | 36 +- fasteners/iso4017.scad | 240 ++-- fasteners/metric_fastners.scad | 123 +- fasteners/nuts_and_bolts.scad | 412 +++--- fasteners/threads.scad | 338 +++-- format.py | 8 + gears/gears.scad | 329 ++--- gears/involute_gears.scad | 1472 +++++++++++---------- gears/rack_and_pinion.scad | 395 +++--- general/constants.scad | 2 +- general/facets.scad | 27 +- general/math.scad | 7 +- general/sweep.scad | 92 +- general/utilities.scad | 162 ++- gridbeam.scad | 331 ++--- hardware/bearing.scad | 94 +- hardware/hardware.scad | 184 +-- hardware/linear_bearing.scad | 152 ++- layout/linear.scad | 18 +- lego_compatibility.scad | 320 +++-- materials/materials.scad | 27 +- materials/visibonecolors.scad | 871 ++++++------- motors/motors.scad | 177 +-- motors/servos.scad | 233 ++-- motors/stepper.scad | 446 ++++--- motors/stepper_mount.scad | 385 +++--- multiply.scad | 18 +- nuts_and_bolts.scad | 15 +- oshw.scad | 51 +- polyhole.scad | 3 +- screw.scad | 103 +- shapes/2Dshapes.scad | 422 +++--- shapes/3Dshapes.scad | 419 +++--- shapes/3d_triangle.scad | 304 +++-- shapes/cylinder.scad | 163 ++- shapes/polyhole.scad | 22 +- shapes/standard_shapes.scad | 61 +- shapes/triangles_pyramids.scad | 202 ++- shapes/trochoids.scad | 481 ++++--- text/alphabet_block.scad | 20 +- text/bitmap.scad | 2008 ++++++++++++++--------------- text/fonts.scad | 498 ++++--- text/height_map.scad | 17 +- text/letter_necklace.scad | 82 +- text/name_tag.scad | 36 +- text/string.scad | 37 +- text/test_name_tag.scad | 25 +- units/metric.scad | 18 +- units/us.scad | 102 +- 79 files changed, 6954 insertions(+), 6215 deletions(-) create mode 100644 .openscad-format create mode 100755 format.py diff --git a/.openscad-format b/.openscad-format new file mode 100644 index 00000000..8ac55619 --- /dev/null +++ b/.openscad-format @@ -0,0 +1,8 @@ +--- +BasedOnStyle: Mozilla +ColumnLimit: 80 +IndentWidth: 2 +AccessModifierOffset: -2 +ContinuationIndentWidth: 2 +TabWidth: 2 +UseTab: Never diff --git a/array/along_curve.scad b/array/along_curve.scad index c20959a6..598b0ce4 100644 --- a/array/along_curve.scad +++ b/array/along_curve.scad @@ -17,16 +17,15 @@ include * rotation (default: undef) * @param axis Axis to rotate around (default: Z) */ -module mcad_rotate_multiply (no, angle = undef, axis = Z) +module mcad_rotate_multiply(no, angle = undef, axis = Z) { - if (no > 0) { - angle = (angle == undef) ? 360 / no : angle; + if (no > 0) { + angle = (angle == undef) ? 360 / no : angle; - for (i = [0:no - 1]) { - rotate (angle * i, axis) - children (); - } + for (i = [0:no - 1]) { + rotate(angle * i, axis) children(); } + } } /** @@ -34,9 +33,7 @@ module mcad_rotate_multiply (no, angle = undef, axis = Z) * * @param axis Axis of rotation (default: Z) */ -module mcad_duplicate (axis = Z) +module mcad_duplicate(axis = Z) { - mcad_rotate_multiply (no = 2, axis = axis) - children (); + mcad_rotate_multiply(no = 2, axis = axis) children(); } - diff --git a/array/generic-multiply.scad b/array/generic-multiply.scad index deb32937..eaae14c2 100644 --- a/array/generic-multiply.scad +++ b/array/generic-multiply.scad @@ -24,12 +24,11 @@ * @param transformations List of transformations to apply to children() * @Param keep_original Whether or not to show the original child */ -module mcad_multiply (transformations, keep_original = true) +module mcad_multiply(transformations, keep_original = true) { - if (keep_original) - children (); + if (keep_original) + children(); - for (t = transformations) - multmatrix (t) - children (); + for (t = transformations) + multmatrix(t) children(); } diff --git a/array/mirror.scad b/array/mirror.scad index 42b84c82..3c7d7e35 100644 --- a/array/mirror.scad +++ b/array/mirror.scad @@ -3,10 +3,9 @@ * * @param axis Vector representing axis to mirror(). */ -module mcad_mirror_duplicate (axis) +module mcad_mirror_duplicate(axis) { - children (); + children(); - mirror (axis) - children (); + mirror(axis) children(); } diff --git a/array/polar.scad b/array/polar.scad index e02ac955..55440fb3 100644 --- a/array/polar.scad +++ b/array/polar.scad @@ -1,51 +1,42 @@ -include use use +include use /** - * Generate polar coordinates for polar-arrayed objects - * - * @param angle Angle increment between each coordinate (negative is clockwise) - * @param number Number of coordinates - * @param radius Radius of coordinates - */ -function mcad_generate_polar_coords (angle, number, radius) = ( - let (total = angle * number) - [ - for (i = [0:number-1]) - [radius, i * total / number] - ] -); + * Generate polar coordinates for polar-arrayed objects + * + * @param angle Angle increment between each coordinate (negative is clockwise) + * @param number Number of coordinates + * @param radius Radius of coordinates + */ +function mcad_generate_polar_coords(angle, number, radius) = (let( + total = angle * number)[for (i = [0:number - 1])[radius, i* total / number]]); /** - * Polar array, i.e. place objects in a circular arc - * - * @param angle Angle between each copy (negative is clockwise) - * @param number Number of copies - * @param radius Radius of array path - */ -module mcad_array_polar (angle, number, radius, preserve_orientation = false) + * Polar array, i.e. place objects in a circular arc + * + * @param angle Angle between each copy (negative is clockwise) + * @param number Number of copies + * @param radius Radius of array path + */ +module mcad_array_polar(angle, number, radius, preserve_orientation = false) { - polar_coords = mcad_generate_polar_coords (angle, number, radius); + polar_coords = mcad_generate_polar_coords(angle, number, radius); - if (preserve_orientation) - mcad_place_at ([for (coord = polar_coords) - conv2D_polar2cartesian (coord)]) - children (); + if (preserve_orientation) + mcad_place_at([for (coord = polar_coords) conv2D_polar2cartesian(coord)]) + children(); - else - for (coord = polar_coords) - rotate (coord[1], Z) - translate ([coord[0], 0]) - children (); + else + for (coord = polar_coords) + rotate(coord[1], Z) translate([ coord[0], 0 ]) children(); } -module test_mcad_array_polar () +module +test_mcad_array_polar() { - mcad_array_polar (angle = 30, - number = 3, - radius = 10, - preserve_orientation = true) - cube (2, center = true); + mcad_array_polar( + angle = 30, number = 3, radius = 10, preserve_orientation = true) + cube(2, center = true); } diff --git a/array/rectangular.scad b/array/rectangular.scad index b43184ac..71b06613 100644 --- a/array/rectangular.scad +++ b/array/rectangular.scad @@ -1,22 +1,21 @@ /** - * Copyright (C) 2016 Chow Loong Jin - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - + * Copyright (C) 2016 Chow Loong Jin + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ use include @@ -28,12 +27,11 @@ include * @param separation 2- or 3-vector indicating separation in respective axes * @param center Boolean or vector indicating which axes to center */ -module mcad_array_rectangular (grid_size, separation, center = true) +module mcad_array_rectangular(grid_size, separation, center = true) { - mcad_place_at (mcad_generate_grid (grid_size = grid_size, - separation = separation, - center = center)) - children (); + mcad_place_at(mcad_generate_grid( + grid_size = grid_size, separation = separation, center = center)) + children(); } /** @@ -44,12 +42,10 @@ module mcad_array_rectangular (grid_size, separation, center = true) * @param separation Separation between centers of adjacent copies * @param axis Direction to project toward */ -module mcad_linear_multiply (no, separation, axis = Z, center = false) +module mcad_linear_multiply(no, separation, axis = Z, center = false) { - centering_offset = -1 * axis * (no - 1) * separation / 2; + centering_offset = -1 * axis * (no - 1) * separation / 2; - translate (center ? centering_offset : [0, 0, 0]) - for (i = [0:no - 1]) - translate (i * separation * axis) - children (); + translate(center ? centering_offset : [ 0, 0, 0 ]) for (i = [0:no - 1]) + translate(i * separation * axis) children(); } diff --git a/array/translations.scad b/array/translations.scad index 9b6ec65f..26121900 100644 --- a/array/translations.scad +++ b/array/translations.scad @@ -26,10 +26,8 @@ use * @param points Vector of points * @returns Vector of translation matrices **/ -function mcad_points2translations (points) = [ - for (point = points) - translation (point) -]; +function mcad_points2translations(points) = [for (point = points) + translation(point)]; /** * Generate vector of points that represents grid @@ -38,48 +36,41 @@ function mcad_points2translations (points) = [ * @param separation 2- or 3-vector indicating separation in respective axes * @param center Boolean or vector indicating which axes to center */ -function mcad_generate_grid (grid_size, separation, center = false) = ( - let ( - sep = len (separation) > 0 ? separation : [1, 1, 1] * separation, - g = grid_size, - center = len(center) > 0 ? center : [center, center, center], +function mcad_generate_grid(grid_size, separation, center = false) = + (let(sep = len(separation) > 0 ? separation : [ 1, 1, 1 ] * separation, + g = grid_size, + center = len(center) > 0 ? center : [ center, center, center ], - center_offset = [ - for (i = [0:len(g)]) - (center[i]) ? (g[i] - 1) * sep[i] / 2 : 0 - ] - ) - - (len (grid_size) == 2) ? [ - for (x = [0 : g[0] - 1]) - for (y = [0 : g[1] - 1]) - [x * sep[0], y * sep[1]] - center_offset - ] : - (len (grid_size) == 3) ? [ - for (x = [0 : g[0] - 1]) - for (y = [0 : g[1] - 1]) - for (z = [0 : g[2] - 1]) - [x * sep[0], y * sep[1], z * sep[2]] - center_offset - ] : [] -); + center_offset = [for (i = [0:len(g)])(center[i]) + ? (g[i] - 1) * sep[i] / 2 + : 0]) + (len(grid_size) == 2) + ? [for (x = [0:g[0] - 1]) for (y = [0:g[1] - 1])[x * sep[0], y* sep[1]] - + center_offset] + : (len(grid_size) == 3) + ? [for (x = [0:g[0] - 1]) for (y = [0:g[1] - 1]) for ( + z = [0:g[2] - 1])[x * sep[0], y* sep[1], z* sep[2]] - + center_offset] + : []); /** * Place children at points * * @param List of points. */ -module mcad_place_at (points) +module mcad_place_at(points) { - mcad_multiply (mcad_points2translations (points), keep_original = false) - children (); + mcad_multiply(mcad_points2translations(points), keep_original = false) + children(); } /** * Test mcad_place_at module */ -module mcad_test_place_at () +module +mcad_test_place_at() { - mcad_place_at (mcad_generate_grid ([10, 10, 10], separation = $t * 10, - center = true)); + mcad_place_at( + mcad_generate_grid([ 10, 10, 10 ], separation = $t * 10, center = true)); } diff --git a/boxes.scad b/boxes.scad index 40d2e9e9..0f2ac17e 100644 --- a/boxes.scad +++ b/boxes.scad @@ -1,5 +1,5 @@ use // @deprecated -module roundedBox (size, radius, sidesonly, center = true) -mcad_rounded_box (size, radius, sidesonly, center); +module roundedBox(size, radius, sidesonly, center = true) + mcad_rounded_box(size, radius, sidesonly, center); diff --git a/curves.scad b/curves.scad index 0e20005f..33e22d06 100644 --- a/curves.scad +++ b/curves.scad @@ -1,21 +1,15 @@ // Parametric curves, to be used as paths // Licensed under the MIT license. // © 2010 by Elmo Mäntynen -use include +use - - -/* A circular helix of radius a and pitch 2πb is described by the following parametrisation: -x(t) = a*cos(t), -y(t) = a*sin(t), -z(t) = b*t +/* A circular helix of radius a and pitch 2πb is described by the following +parametrisation: x(t) = a*cos(t), y(t) = a*sin(t), z(t) = b*t */ - -function b(pitch) = pitch/(const_tau); -function t(pitch, z) = z/b(pitch); +function b(pitch) = pitch / (const_tau); +function t(pitch, z) = z / b(pitch); function helix_curve(pitch, radius, z) = - [radius*cos(deg(t(pitch, z))), radius*sin(deg(t(pitch, z))), z]; - + [ radius * cos(deg(t(pitch, z))), radius* sin(deg(t(pitch, z))), z ]; diff --git a/demos/array_along_curve_demo.scad b/demos/array_along_curve_demo.scad index eadaf023..3d2d0182 100644 --- a/demos/array_along_curve_demo.scad +++ b/demos/array_along_curve_demo.scad @@ -1,22 +1,22 @@ -include ; +include -//center reference point -translate([0,0,0]) -#cube([5,5,5],center=true); +// center reference point +translate([ 0, 0, 0 ]) +#cube([ 5, 5, 5 ], center = true); -spin(3,30,Z) + spin(3, 30, Z) { - translate([5,5,5]) -#cube([5,5,5],center=true); - // square([25,10]); - // square([25,10]); - // square([25,10]); - // square([25,10]); - // square([25,10]); + translate([ 5, 5, 5 ]) +#cube([ 5, 5, 5 ], center = true); + // square([25,10]); + // square([25,10]); + // square([25,10]); + // square([25,10]); + // square([25,10]); } -//cubic array of 5*5*5 objects spaced 10*10*10 center relative -//array_linear(20) +// cubic array of 5*5*5 objects spaced 10*10*10 center relative +// array_linear(20) //{ // sphere(2.5,center=true,$fn=60); // cylinder(h=10,r=.5,center=true); @@ -26,8 +26,8 @@ spin(3,30,Z) // cylinder(h=10,r=.5,center=true); //} // -//translate([0,0,10]) -//array_linear_grid(30,15,false,3) +// translate([0,0,10]) +// array_linear_grid(30,15,false,3) //{ // square([25,10]); // square([25,10]); diff --git a/demos/array_linear_demo.scad b/demos/array_linear_demo.scad index ca14dfa7..8626f1a6 100644 --- a/demos/array_linear_demo.scad +++ b/demos/array_linear_demo.scad @@ -1,38 +1,35 @@ -include ; +include -//center reference point -translate([0,0,0]) -#cube([5,5,5],center=true); +// center reference point +translate([ 0, 0, 0 ]) +#cube([ 5, 5, 5 ], center = true); -array_linear(25) + array_linear(25) { - square([25,10]); - square([25,10]); - square([25,10]); - square([25,10]); - square([25,10]); + square([ 25, 10 ]); + square([ 25, 10 ]); + square([ 25, 10 ]); + square([ 25, 10 ]); + square([ 25, 10 ]); } -//cubic array of 5*5*5 objects spaced 10*10*10 center relative +// cubic array of 5*5*5 objects spaced 10*10*10 center relative array_linear(20) { - sphere(2.5,center=true,$fn=60); - cylinder(h=10,r=.5,center=true); - rotate([90,0,0]) - cylinder(h=10,r=.5,center=true); - rotate([0,90,0]) - cylinder(h=10,r=.5,center=true); + sphere(2.5, center = true, $fn = 60); + cylinder(h = 10, r = .5, center = true); + rotate([ 90, 0, 0 ]) cylinder(h = 10, r = .5, center = true); + rotate([ 0, 90, 0 ]) cylinder(h = 10, r = .5, center = true); } - translate([0,0,10]) -array_linear_grid(30,15,false,3) +translate([ 0, 0, 10 ]) array_linear_grid(30, 15, false, 3) { - square([25,10]); - square([25,10]); - square([25,10]); - square([25,10]); - square([25,10]); - square([25,10]); - square([25,10]); - square([25,10]); + square([ 25, 10 ]); + square([ 25, 10 ]); + square([ 25, 10 ]); + square([ 25, 10 ]); + square([ 25, 10 ]); + square([ 25, 10 ]); + square([ 25, 10 ]); + square([ 25, 10 ]); } diff --git a/demos/array_polar_demo.scad b/demos/array_polar_demo.scad index bf3c6311..dc70bee6 100644 --- a/demos/array_polar_demo.scad +++ b/demos/array_polar_demo.scad @@ -1,29 +1,24 @@ -include ; -include ; +include +include -//center reference point -translate([0,0,0]) -#cube([5,5,5],center=true); +// center reference point +translate([ 0, 0, 0 ]) +#cube([ 5, 5, 5 ], center = true); - //radial array of 32 objects rotated though 10 degrees - translate([0,0,0]) -array_polar(10,32,40) + // radial array of 32 objects rotated though 10 degrees + translate([ 0, 0, 0 ]) array_polar(10, 32, 40) { - cube([2,4,6],center=true); + cube([ 2, 4, 6 ], center = true); } -// a radial array of linear arrays +// a radial array of linear arrays - rotate([45,45,45]) -array_polar(10,36,40) +rotate([ 45, 45, 45 ]) array_polar(10, 36, 40) { - translate([0,10,0]) - array_rectangular(0,10,0,1,5,1,center=false) - { - cube([2,3,4],center=true); - cylinder(h=10,r=.5,center=true); - rotate([90,0,0]) - cylinder(h=10,r=.5,center=true); - } + translate([ 0, 10, 0 ]) array_rectangular(0, 10, 0, 1, 5, 1, center = false) + { + cube([ 2, 3, 4 ], center = true); + cylinder(h = 10, r = .5, center = true); + rotate([ 90, 0, 0 ]) cylinder(h = 10, r = .5, center = true); + } } - diff --git a/demos/array_rectangular_demo.scad b/demos/array_rectangular_demo.scad index 0d3195c9..0df788e0 100644 --- a/demos/array_rectangular_demo.scad +++ b/demos/array_rectangular_demo.scad @@ -1,43 +1,37 @@ -include ; +include -//center reference point -translate([0,0,0]) -#cube([5,5,5],center=true); +// center reference point +translate([ 0, 0, 0 ]) +#cube([ 5, 5, 5 ], center = true); - //cubic array of 5*5*5 objects spaced 10*10*10 center relative -array_rectangular(10,10,10,5,5,5,center=true) + // cubic array of 5*5*5 objects spaced 10*10*10 center relative + array_rectangular(10, 10, 10, 5, 5, 5, center = true) { - sphere(2.5,center=true,$fn=60); - cylinder(h=10,r=.5,center=true); - rotate([90,0,0]) - cylinder(h=10,r=.5,center=true); - rotate([0,90,0]) - cylinder(h=10,r=.5,center=true); + sphere(2.5, center = true, $fn = 60); + cylinder(h = 10, r = .5, center = true); + rotate([ 90, 0, 0 ]) cylinder(h = 10, r = .5, center = true); + rotate([ 0, 90, 0 ]) cylinder(h = 10, r = .5, center = true); } -//a linear array allong x can be derived from the cubic array simply - translate([60,0,0]) -array_rectangular(10,0,0,5,1,1,center=false) +// a linear array allong x can be derived from the cubic array simply +translate([ 60, 0, 0 ]) array_rectangular(10, 0, 0, 5, 1, 1, center = false) { - cube([5,5,5],center=true); -} -//a linear array allong y can be derived from the cubic array simply - translate([0,60,0]) -array_rectangular(0,10,0,1,5,1,center=false) + cube([ 5, 5, 5 ], center = true); +} +// a linear array allong y can be derived from the cubic array simply +translate([ 0, 60, 0 ]) array_rectangular(0, 10, 0, 1, 5, 1, center = false) { - cube([5,5,5],center=true); -} + cube([ 5, 5, 5 ], center = true); +} -//a linear array allong z can be derived from the cubic array simply - translate([0,0,60]) -array_rectangular(0,0,10,1,1,5,center=false) +// a linear array allong z can be derived from the cubic array simply +translate([ 0, 0, 60 ]) array_rectangular(0, 0, 10, 1, 1, 5, center = false) { - cube([5,5,5],center=true); -} + cube([ 5, 5, 5 ], center = true); +} -//a grid array allong x,y can be derived from the cubic array simply - translate([0,0,-60]) -array_rectangular(10,10,0,5,5,1,center=true) +// a grid array allong x,y can be derived from the cubic array simply +translate([ 0, 0, -60 ]) array_rectangular(10, 10, 0, 5, 5, 1, center = true) { - cube([5,5,5],center=true); -} + cube([ 5, 5, 5 ], center = true); +} diff --git a/demos/bearing_demo.scad b/demos/bearing_demo.scad index e2933cec..856c298b 100644 --- a/demos/bearing_demo.scad +++ b/demos/bearing_demo.scad @@ -1,18 +1,24 @@ -include ; +include // Example, uncomment to view test_bearing(); -translate([0,40,0]) test_bearing_hole(); +translate([ 0, 40, 0 ]) test_bearing_hole(); -module test_bearing(){ - bearing(); - bearing(pos=[5*length_cm, 0,0], angle=[90,0,0]); - bearing(pos=[-2.5*length_cm, 0,0], model=624); +module +test_bearing() +{ + bearing(); + bearing(pos = [ 5 * length_cm, 0, 0 ], angle = [ 90, 0, 0 ]); + bearing(pos = [ -2.5 * length_cm, 0, 0 ], model = 624); } -module test_bearing_hole(){ - difference(){ - translate([0, 0, 3.5]) cube(size=[30, 30, 7-10*epsilon], center=true); - bearing(outline=true); - } +module +test_bearing_hole() +{ + difference() + { + translate([ 0, 0, 3.5 ]) + cube(size = [ 30, 30, 7 - 10 * epsilon ], center = true); + bearing(outline = true); + } } \ No newline at end of file diff --git a/demos/constants_demo.scad b/demos/constants_demo.scad index b581bb2d..05524e03 100644 --- a/demos/constants_demo.scad +++ b/demos/constants_demo.scad @@ -1,12 +1,12 @@ -include ; +include echo(const_e = const_e); echo(const_pi = const_pi); echo(const_tau = const_tau); echo(const_phi = const_phi); echo(const_sqrt2 = const_sqrt2); -echo(const_sqrt2 * const_sqrt2); +echo(const_sqrt2* const_sqrt2); echo(const_sqrt3 = const_sqrt3); -echo(const_sqrt3 * const_sqrt3); +echo(const_sqrt3* const_sqrt3); echo(const_sqrt5 = const_sqrt5); -echo(const_sqrt5 * const_sqrt5); +echo(const_sqrt5* const_sqrt5); diff --git a/demos/hardware_demo.scad b/demos/hardware_demo.scad index 7cc3be41..9488bfea 100644 --- a/demos/hardware_demo.scad +++ b/demos/hardware_demo.scad @@ -1,10 +1,10 @@ -include ; +include rod(20); -translate([rodsize * 2.5, 0, 0]) rod(20, true); -translate([rodsize * 5, 0, 0]) screw(10, true); -translate([rodsize * 7.5, 0, 0]) bearing(); -translate([rodsize * 10, 0, 0]) rodnut(); -translate([rodsize * 12.5, 0, 0]) rodwasher(); -translate([rodsize * 15, 0, 0]) nut(); -translate([rodsize * 17.5, 0, 0]) washer(); \ No newline at end of file +translate([ rodsize * 2.5, 0, 0 ]) rod(20, true); +translate([ rodsize * 5, 0, 0 ]) screw(10, true); +translate([ rodsize * 7.5, 0, 0 ]) bearing(); +translate([ rodsize * 10, 0, 0 ]) rodnut(); +translate([ rodsize * 12.5, 0, 0 ]) rodwasher(); +translate([ rodsize * 15, 0, 0 ]) nut(); +translate([ rodsize * 17.5, 0, 0 ]) washer(); \ No newline at end of file diff --git a/demos/linear_bearing_demo.scad b/demos/linear_bearing_demo.scad index 3b5bbc4c..7f867617 100644 --- a/demos/linear_bearing_demo.scad +++ b/demos/linear_bearing_demo.scad @@ -1,5 +1,5 @@ -include ; +include -//examples -linearBearing(model="LM8UU"); -translate([20,0,0]) linearBearing(model="LM10UU"); \ No newline at end of file +// examples +linearBearing(model = "LM8UU"); +translate([ 20, 0, 0 ]) linearBearing(model = "LM10UU"); \ No newline at end of file diff --git a/demos/materials_demo.scad b/demos/materials_demo.scad index 7a109c78..a63c4682 100644 --- a/demos/materials_demo.scad +++ b/demos/materials_demo.scad @@ -1,27 +1,30 @@ -include ; +include // Example, uncomment to view color_demo(); -module color_demo(){ - // Wood - colorTest(Oak, 0, 0); - colorTest(Pine, 1, 0); - colorTest(Birch, 2, 0); +module +color_demo() +{ + // Wood + colorTest(Oak, 0, 0); + colorTest(Pine, 1, 0); + colorTest(Birch, 2, 0); - // Metals - colorTest(Iron, 0, 1); - colorTest(Steel, 1, 1); - colorTest(Stainless, 2, 1); - colorTest(Aluminum, 3, 1); + // Metals + colorTest(Iron, 0, 1); + colorTest(Steel, 1, 1); + colorTest(Stainless, 2, 1); + colorTest(Aluminum, 3, 1); - // Mixboards - colorTest(FiberBoard, 0, 2); + // Mixboards + colorTest(FiberBoard, 0, 2); - // Paints - colorTest(BlackPaint, 0, 3); + // Paints + colorTest(BlackPaint, 0, 3); } -module colorTest(col, row=0, c=0) { - color(col) translate([row * 30,c*30,0]) sphere(r=10); +module colorTest(col, row = 0, c = 0) +{ + color(col) translate([ row * 30, c * 30, 0 ]) sphere(r = 10); } diff --git a/demos/metric_demo.scad b/demos/metric_demo.scad index fc2980bf..337e6186 100644 --- a/demos/metric_demo.scad +++ b/demos/metric_demo.scad @@ -1,34 +1,44 @@ -include ; +include module metric_ruler(millimeters) { - difference() - { - // Body of ruler - color("Beige") - cube(size = [length_mm(millimeters), length_cm(3), length_mm(1)]); - // Centimeter markings - for (i = [0:length_cm(1):length_mm(millimeters) + epsilon]) - { - translate([i,length_cm(2.5),length_mm(0.75)]) - color("Red") - cube(size = [length_mm(0.5), length_cm(1) + epsilon, length_mm(0.5) + epsilon], center = true); - } - // Half centimeter markings - for (i = [length_cm(0.5):length_cm(1):length_mm(millimeters) + epsilon]) - { - translate([i,length_cm(2.7),length_mm(0.875)]) - color("Red") - cube(size = [length_mm(0.5), length_cm(0.6) + epsilon, length_mm(0.25) + epsilon], center = true); - } - // Millimeter markings - for (i = [length_mm(1):length_mm(1):length_mm(millimeters) + epsilon]) - { - translate([i,length_cm(2.85),length_mm(0.9375)]) - color("Red") - cube(size = [length_mm(0.5), length_cm(0.3) + epsilon, length_mm(0.125) + epsilon], center = true); - } - } + difference() + { + // Body of ruler + color("Beige") + cube(size = [ length_mm(millimeters), length_cm(3), length_mm(1) ]); + // Centimeter markings + for (i = [0:length_cm(1):length_mm(millimeters) + epsilon]) { + translate([ i, length_cm(2.5), length_mm(0.75) ]) color("Red") cube( + size = + [ length_mm(0.5), length_cm(1) + epsilon, length_mm(0.5) + epsilon ], + center = true); + } + // Half centimeter markings + for (i = [length_cm(0.5):length_cm(1):length_mm(millimeters) + epsilon]) { + translate([ i, length_cm(2.7), length_mm(0.875) ]) color("Red") + cube(size = + [ + length_mm(0.5), + length_cm(0.6) + epsilon, + length_mm(0.25) + + epsilon + ], + center = true); + } + // Millimeter markings + for (i = [length_mm(1):length_mm(1):length_mm(millimeters) + epsilon]) { + translate([ i, length_cm(2.85), length_mm(0.9375) ]) color("Red") + cube(size = + [ + length_mm(0.5), + length_cm(0.3) + epsilon, + length_mm(0.125) + + epsilon + ], + center = true); + } + } } metric_ruler(100); diff --git a/demos/polyhole_demo.scad b/demos/polyhole_demo.scad index 37e15914..bd208dd6 100644 --- a/demos/polyhole_demo.scad +++ b/demos/polyhole_demo.scad @@ -1,19 +1,22 @@ include -module polyhole_demo(){ -difference() { - cube(size = [100,27,3]); - union() { - for(i = [1:10]) { - translate([(i * i + i)/2 + 3 * i , 8,-1]) - mcad_polyhole(h = 5, d = i); - - assign(d = i + 0.5) - translate([(d * d + d)/2 + 3 * d, 19,-1]) - mcad_polyhole(h = 5, d = d); - } +module +polyhole_demo() +{ + difference() + { + cube(size = [ 100, 27, 3 ]); + union() + { + for (i = [1:10]) { + translate([ (i * i + i) / 2 + 3 * i, 8, -1 ]) + mcad_polyhole(h = 5, d = i); + + assign(d = i + 0.5) translate([ (d * d + d) / 2 + 3 * d, 19, -1 ]) + mcad_polyhole(h = 5, d = d); + } } -} + } } polyhole_demo(); diff --git a/demos/rack_and_pinion_demo.scad b/demos/rack_and_pinion_demo.scad index ddb03434..5d76733f 100644 --- a/demos/rack_and_pinion_demo.scad +++ b/demos/rack_and_pinion_demo.scad @@ -1,10 +1,13 @@ -include ; +include // examples of usage // include this in your code: // use // then: // a simple rack -rack(4,20,10,1);//CP (mm/tooth), width (mm), thickness(of base) (mm), # teeth +rack(4, + 20, + 10, + 1); // CP (mm/tooth), width (mm), thickness(of base) (mm), # teeth // a simple pinion and translation / rotation to make it mesh the rack -translate([0,-8.5,0])rotate([0,0,360/10/2]) pinion(4,10,10,5); \ No newline at end of file +translate([ 0, -8.5, 0 ]) rotate([ 0, 0, 360 / 10 / 2 ]) pinion(4, 10, 10, 5); \ No newline at end of file diff --git a/demos/stepper_demo.scad b/demos/stepper_demo.scad index 08bd6425..fc4a1d79 100644 --- a/demos/stepper_demo.scad +++ b/demos/stepper_demo.scad @@ -1,24 +1,26 @@ -include ; +include // Demo, uncomment to show: nema_demo(); -module test_nema14() +module +test_nema14() { - motor(Nema14, NemaLong, dualAxis=false); - //motor(); + motor(Nema14, NemaLong, dualAxis = false); + // motor(); } - -module nema_demo(){ - for (size = [NemaShort, NemaMedium, NemaLong]) { - translate([-100,size*100,0]) motor(Nema34, size, dualAxis=true); - translate([0,size*100,0]) motor(Nema23, size, dualAxis=true); - translate([100,size*100,0]) motor(Nema17, size, dualAxis=true); - translate([200,size*100,0]) motor(Nema14, size, dualAxis=true); - translate([300,size*100,0]) motor(Nema11, size, dualAxis=true); - translate([400,size*100,0]) motor(Nema08, size, dualAxis=true); - } +module +nema_demo() +{ + for (size = [ NemaShort, NemaMedium, NemaLong ]) { + translate([ -100, size * 100, 0 ]) motor(Nema34, size, dualAxis = true); + translate([ 0, size * 100, 0 ]) motor(Nema23, size, dualAxis = true); + translate([ 100, size * 100, 0 ]) motor(Nema17, size, dualAxis = true); + translate([ 200, size * 100, 0 ]) motor(Nema14, size, dualAxis = true); + translate([ 300, size * 100, 0 ]) motor(Nema11, size, dualAxis = true); + translate([ 400, size * 100, 0 ]) motor(Nema08, size, dualAxis = true); + } } -//test_nema14(); +// test_nema14(); diff --git a/demos/string_demo.scad b/demos/string_demo.scad index c3e6560a..ee171464 100644 --- a/demos/string_demo.scad +++ b/demos/string_demo.scad @@ -1,59 +1,62 @@ -include ; +include // Uncomment this bloc to see how to use this library. - // strToInt(string [,base]) - - // Resume : Converts a number in string. - // string : The string you wants to converts. - // base (optional) : The base conversion of the number : 2 for binay, 10 for decimal (default), 16 for hexadecimal. - echo("*** strToInt() ***"); - echo(strToInt("491585")); - echo(strToInt("01110", 2)); - echo(strToInt("D5A4", 16)); - echo(strToInt("-15")); - echo(strToInt("-5") + strToInt("10") + 5); - - // strcat(vector [,insert]) - - // Resume : Concatenates a vector of words into a string. - // vector : A vector of string. - // insert (optional) : A string which will added between each words. - echo("*** strcat() ***"); - v_data = ["OpenScad", "is", "a", "free", "CAD", "software."]; - echo(strcat(v_data)); // ECHO: "OpenScadisafreeCADsoftware." - echo(strcat(v_data, " ")); // ECHO: "OpenScad is a free CAD software." - - // substr(str, pos [,length]) - - // Resume : Substract a substring from a bigger string. - // str : The original string - // pos : The index of the position where the substring will begin. - // length (optional) : The length of the substring. If not specified, the substring will continue until the end of the string. - echo("*** substr() ***"); - str = "OpenScad is a free CAD software."; - echo(str); // ECHO: "OpenScad is a free CAD software." - echo(substr(str, 0, 11)); // ECHO: "OpenScad is" - echo(substr(str, 12)); // ECHO: "a free CAD software." - echo(substr(str, 12, 10)); // ECHO: "a free CAD" - - // fill(string, occurrences) - - // Resume : Fill a string with several characters (or strings). - // string : the character or string which will be copied. - // occurrences : The number of occurences of the string. - echo("*** Fill() ***"); - echo(fill("0", 4)); // ECHO: "0000" - echo(fill("hey", 3)); // ECHO: "heyheyhey" - - // getsplit(string, index [,separator]) - - // Resume : Split a string in several words. - // string : The original string. - // index : The index of the word to get. - // separator : The separator which cut the string (default is " "). - // Note : Nowadays it's impossible to get a vector of words because we can't append data in a vector. - echo("*** getsplit() ***"); - echo(getsplit(str)); - echo(getsplit(str, 3)); - echo(getsplit("123, 456, 789", 1, ", ")); \ No newline at end of file +// strToInt(string [,base]) + +// Resume : Converts a number in string. +// string : The string you wants to converts. +// base (optional) : The base conversion of the number : 2 for binay, 10 for +// decimal (default), 16 for hexadecimal. +echo("*** strToInt() ***"); +echo(strToInt("491585")); +echo(strToInt("01110", 2)); +echo(strToInt("D5A4", 16)); +echo(strToInt("-15")); +echo(strToInt("-5") + strToInt("10") + 5); + +// strcat(vector [,insert]) + +// Resume : Concatenates a vector of words into a string. +// vector : A vector of string. +// insert (optional) : A string which will added between each words. +echo("*** strcat() ***"); +v_data = [ "OpenScad", "is", "a", "free", "CAD", "software." ]; +echo(strcat(v_data)); // ECHO: "OpenScadisafreeCADsoftware." +echo(strcat(v_data, " ")); // ECHO: "OpenScad is a free CAD software." + +// substr(str, pos [,length]) + +// Resume : Substract a substring from a bigger string. +// str : The original string +// pos : The index of the position where the substring will begin. +// length (optional) : The length of the substring. If not specified, the +// substring will continue until the end of the string. +echo("*** substr() ***"); +str = "OpenScad is a free CAD software."; +echo(str); // ECHO: "OpenScad is a free CAD software." +echo(substr(str, 0, 11)); // ECHO: "OpenScad is" +echo(substr(str, 12)); // ECHO: "a free CAD software." +echo(substr(str, 12, 10)); // ECHO: "a free CAD" + +// fill(string, occurrences) + +// Resume : Fill a string with several characters (or strings). +// string : the character or string which will be copied. +// occurrences : The number of occurences of the string. +echo("*** Fill() ***"); +echo(fill("0", 4)); // ECHO: "0000" +echo(fill("hey", 3)); // ECHO: "heyheyhey" + +// getsplit(string, index [,separator]) + +// Resume : Split a string in several words. +// string : The original string. +// index : The index of the word to get. +// separator : The separator which cut the string (default is " "). +// Note : Nowadays it's impossible to get a vector of words because we can't +// append data in a vector. +echo("*** getsplit() ***"); +echo(getsplit(str)); +echo(getsplit(str, 3)); +echo(getsplit("123, 456, 789", 1, ", ")); \ No newline at end of file diff --git a/demos/teardrop_demo.scad b/demos/teardrop_demo.scad index cc737512..50f8ca13 100644 --- a/demos/teardrop_demo.scad +++ b/demos/teardrop_demo.scad @@ -1,10 +1,12 @@ -include ; +include -module teardrop_demo(){ - translate([0, -30, 0]) flat_teardrop(5, 20, 90); - translate([0, -15, 0]) teardrop(5, 20, 90); - translate([0, 0, 0]) teardrop(5, 20, 60); - translate([0, 15, 0]) teardrop(5, 20, 45); +module +teardrop_demo() +{ + translate([ 0, -30, 0 ]) flat_teardrop(5, 20, 90); + translate([ 0, -15, 0 ]) teardrop(5, 20, 90); + translate([ 0, 0, 0 ]) teardrop(5, 20, 60); + translate([ 0, 15, 0 ]) teardrop(5, 20, 45); } teardrop_demo(); diff --git a/demos/visibonecolors_demo.scad b/demos/visibonecolors_demo.scad index 29351590..84d59533 100644 --- a/demos/visibonecolors_demo.scad +++ b/demos/visibonecolors_demo.scad @@ -1,14 +1,15 @@ -include ; +include -module visibonecolorstest() +module +visibonecolorstest() { - /* - 216 colors: 12 x 18 matrix - Not all colors are tested because OpenSCAD has limited support - for variable re-assignment :( - 'nuff said! - */ - colors = + /* + 216 colors: 12 x 18 matrix + Not all colors are tested because OpenSCAD has limited support + for variable re-assignment :( + 'nuff said! + */ + colors = [PPR, PPM, RRP, MMP, DRP, DMP, LRP, LMP, DPR, DPM, LPR, LPM, MPR, MPM, OOY, OOR, YYO, RRO, DYO, DRO, LYO, LRO, DOY, DOR, LOY, LOR, MOY, MOR, SSG, SSY, GGS, YYS, DGS, DYS, LGS, LYS, @@ -28,13 +29,11 @@ module visibonecolorstest() ODT, DDT, LDT, PDT, DHT, LHT, ODA, DDA, LDA, PDA, DHA, LHA, ODV, DDV, LDV, PDV, DHV, LHV, K, OG, DG, LG, PG, W]; - for (i=[1:12]) - { - for (j=[1:18]) - { - color(colors[i*j]) translate([(i-1)*4,(j-1)*4,0]) sphere(2); - } - } + for (i = [1:12]) { + for (j = [1:18]) { + color(colors[i * j]) translate([ (i - 1) * 4, (j - 1) * 4, 0 ]) sphere(2); + } + } } visibonecolorstest(); diff --git a/electronics/ATXpowerSupply.scad b/electronics/ATXpowerSupply.scad index c99108a0..c763066e 100644 --- a/electronics/ATXpowerSupply.scad +++ b/electronics/ATXpowerSupply.scad @@ -15,63 +15,81 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -*/ + */ include +ATX_outlines = [ 86, 140, 150 ]; //!< metal box outline -ATX_outlines = [86,140,150]; //!< metal box outline - -ATX_threadedHoles = [[6,30],[16,144],[80,6],[80,144]]; //!< thread hols M4 in the x,z Coordinates 0:@powerconector corner +ATX_threadedHoles = [ + [ 6, 30 ], + [ 16, 144 ], + [ 80, 6 ], + [ 80, 144 ] +]; //!< thread hols M4 in the x,z Coordinates 0:@powerconector corner ATX_threadedHoleDiameter = 4; -ATX_threadedHoleDepth = 10; +ATX_threadedHoleDepth = 10; -ATX_fanPos = [43,100]; -ATX_fanDiameter = 74; -ATX_fanDepth = 5; +ATX_fanPos = [ 43, 100 ]; +ATX_fanDiameter = 74; +ATX_fanDepth = 5; -ATX_powConPos = [24,30]; -ATX_powConSize = [22,40]; -ATX_powHeight = 5; +ATX_powConPos = [ 24, 30 ]; +ATX_powConSize = [ 22, 40 ]; +ATX_powHeight = 5; -ATX_wireHarnesPos = [53,16]; -ATX_wireHarnesDiameter = 14; -ATX_wireHarnesLenght = 10; +ATX_wireHarnesPos = [ 53, 16 ]; +ATX_wireHarnesDiameter = 14; +ATX_wireHarnesLenght = 10; /** -* @brief ATX power Suply. -* -* http://www.formfactors.org/developer/specs/ATX12V_PSDG_2_2_public_br2.pdf. -* @param[in,out] VALUE DESCRIPTION -* @return DESCRIPTION -**/ -module powerSuplyATX() { - difference() { - union(){ - // box - color("Gainsboro") cube(size=ATX_outlines, center=false); + * @brief ATX power Suply. + * + * http://www.formfactors.org/developer/specs/ATX12V_PSDG_2_2_public_br2.pdf. + * @param[in,out] VALUE DESCRIPTION + * @return DESCRIPTION + **/ +module +powerSuplyATX() +{ + difference() + { + union() + { + // box + color("Gainsboro") cube(size = ATX_outlines, center = false); - // wireHarnest - color("DarkOrange") translate([ATX_wireHarnesPos[0], ATX_outlines[1]+ATX_wireHarnesLenght-OS, ATX_wireHarnesPos[1]]) rotate(a=90,v=X) - cylinder(r=ATX_wireHarnesDiameter/2, h=ATX_wireHarnesLenght+OS, center=false); + // wireHarnest + color("DarkOrange") translate([ + ATX_wireHarnesPos[0], + ATX_outlines[1] + ATX_wireHarnesLenght - OS, + ATX_wireHarnesPos[1] + ]) rotate(a = 90, v = X) cylinder(r = ATX_wireHarnesDiameter / 2, + h = ATX_wireHarnesLenght + OS, + center = false); - // power - color("DarkSlateGray") translate([ATX_powConPos[0], -OS, ATX_powConPos[1]]) - cube(size=[ATX_powConSize[0], ATX_powHeight, ATX_powConSize[1]], center=true); - } - union(){ - // thread holse - for (i=ATX_threadedHoles) { - color("Black") translate([i[0], +ATX_threadedHoleDepth-OS, i[1]]) rotate(a=90,v=X) - cylinder(r=ATX_threadedHoleDiameter/2, h=ATX_threadedHoleDepth+OS, center=false); - } + // power + color("DarkSlateGray") + translate([ ATX_powConPos[0], -OS, ATX_powConPos[1] ]) + cube(size = [ ATX_powConSize[0], ATX_powHeight, ATX_powConSize[1] ], + center = true); + } + union() + { + // thread holse + for (i = ATX_threadedHoles) { + color("Black") translate([ i[0], +ATX_threadedHoleDepth - OS, i[1] ]) + rotate(a = 90, v = X) cylinder(r = ATX_threadedHoleDiameter / 2, + h = ATX_threadedHoleDepth + OS, + center = false); + } - // fan - color("Black") translate([ATX_fanPos[0], +ATX_fanDepth-OS, ATX_fanPos[1]]) rotate(a=90,v=X) - cylinder(r=ATX_fanDiameter/2, h=ATX_fanDepth+OS, center=false); - - - } - } + // fan + color("Black") + translate([ ATX_fanPos[0], +ATX_fanDepth - OS, ATX_fanPos[1] ]) + rotate(a = 90, v = X) cylinder( + r = ATX_fanDiameter / 2, h = ATX_fanDepth + OS, center = false); + } + } } -//powerSuplyATX(); +// powerSuplyATX(); diff --git a/extrusions/8020.scad b/extrusions/8020.scad index 40b2d681..2dd1e450 100644 --- a/extrusions/8020.scad +++ b/extrusions/8020.scad @@ -1,50 +1,73 @@ -module profile_8020_fractional_1010 () { - profile_tslot_generic (pitch = 1, slot = 0.26, lip = 0.1, web = 0.13, core = 0.45, hole = 0.28); +module +profile_8020_fractional_1010() +{ + profile_tslot_generic( + pitch = 1, slot = 0.26, lip = 0.1, web = 0.13, core = 0.45, hole = 0.28); } // module extrusion_8020_1001(h) { - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("8020/8020-1001.dxf"); - } + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0) + { + import("8020/8020-1001.dxf"); + } } // module extrusion_8020_1002(h) { - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("8020/8020-1002.dxf"); - } + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0) + { + import("8020/8020-1002.dxf"); + } } // module extrusion_8020_1003(h) { - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("8020/8020-1003.dxf"); - } + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0) + { + import("8020/8020-1003.dxf"); + } } // module extrusion_8020_1004(h) { - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("8020/8020-1004.dxf"); - } + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0) + { + import("8020/8020-1004.dxf"); + } } module 8020_line_up_and_wait() { - extrusion_8020_1001(20, $fn=36); - translate([30,0,0]) extrusion_8020_1002(20, $fn=36); - translate([60,0,0]) extrusion_8020_1003(20, $fn=36); - translate([90,0,0]) extrusion_8020_1004(20, $fn=36); + extrusion_8020_1001(20, $fn = 36); + translate([ 30, 0, 0 ]) extrusion_8020_1002(20, $fn = 36); + translate([ 60, 0, 0 ]) extrusion_8020_1003(20, $fn = 36); + translate([ 90, 0, 0 ]) extrusion_8020_1004(20, $fn = 36); } 8020_line_up_and_wait(); \ No newline at end of file diff --git a/extrusions/extrusions.scad b/extrusions/extrusions.scad index 2c269218..3988cd8f 100644 --- a/extrusions/extrusions.scad +++ b/extrusions/extrusions.scad @@ -21,71 +21,91 @@ // linear_extrude (height = 3.5) profile_square_tube(1.5, 1/8); // -include ; -include ; -include ; -include ; +include +include +include +include $fn = 24; -module profile_angle_equal(side, wall) { - difference () { - square (side); - translate([wall, wall, 0]) square (side - wall); - } +module profile_angle_equal(side, wall) +{ + difference() + { + square(side); + translate([ wall, wall, 0 ]) square(side - wall); + } } -module profile_angle_unequal(side_x, side_y, wall) { - difference () { - square ([side_x, side_y]); - translate ([wall, wall, 0]) square ([side_x - wall, side_y - wall]); - } +module profile_angle_unequal(side_x, side_y, wall) +{ + difference() + { + square([ side_x, side_y ]); + translate([ wall, wall, 0 ]) square([ side_x - wall, side_y - wall ]); + } } -module profile_square_tube(side, wall) { - difference () { - square (side, center = true); - square (side-wall*2, center = true); - } +module profile_square_tube(side, wall) +{ + difference() + { + square(side, center = true); + square(side - wall * 2, center = true); + } } -module profile_rect_tube(side_x, side_y, wall) { - difference () { - square ([side_x, side_y], center = true); - square ([side_x - wall*2, side_y - wall*2], center = true); - } +module profile_rect_tube(side_x, side_y, wall) +{ + difference() + { + square([ side_x, side_y ], center = true); + square([ side_x - wall * 2, side_y - wall * 2 ], center = true); + } } -module profile_channel(base, side, wall) { - translate ([0, side/2, 0]) difference () { - square ([base, side], center = true); - translate ([0, wall/2, 0]) square ([base - wall*2, side - wall], center = true); - } +module profile_channel(base, side, wall) +{ + translate([ 0, side / 2, 0 ]) difference() + { + square([ base, side ], center = true); + translate([ 0, wall / 2, 0 ]) + square([ base - wall * 2, side - wall ], center = true); + } } -module profile_tslot_generic (pitch, slot, lip, web, hole) { - // pitch = side width, slot = slot width, lip = thickness of the lip, web = thickness of the web, core = side of the center square, hole = center hole diameter - difference () { - union() { - difference () { - square (pitch, center=true); - square (pitch - lip*2, center=true); - square ([pitch, slot], center=true); - square ([slot, pitch], center=true); - } - rotate ([0, 0, 45]) square ([pitch*1.15, web], center=true); - rotate ([0, 0, -45]) square ([pitch*1.15, web], center=true); - square (core, center=true); - } - circle (hole/2, center = true); - } +module profile_tslot_generic(pitch, slot, lip, web, hole) +{ + // pitch = side width, slot = slot width, lip = thickness of the lip, web = + // thickness of the web, core = side of the center square, hole = center hole + // diameter + difference() + { + union() + { + difference() + { + square(pitch, center = true); + square(pitch - lip * 2, center = true); + square([ pitch, slot ], center = true); + square([ slot, pitch ], center = true); + } + rotate([ 0, 0, 45 ]) square([ pitch * 1.15, web ], center = true); + rotate([ 0, 0, -45 ]) square([ pitch * 1.15, web ], center = true); + square(core, center = true); + } + circle(hole / 2, center = true); + } } -module profile_misumi_metric_2020 () { - profile_tslot_generic (pitch = 20, slot = 5.2, lip = 2, web = 2.6, core = 9, hole = 5.6); +module +profile_misumi_metric_2020() +{ + profile_tslot_generic( + pitch = 20, slot = 5.2, lip = 2, web = 2.6, core = 9, hole = 5.6); } // Line up and wait extrusion_makerbeam(30); -translate([17.5, 0, 0]) extrusion_openbeam_v1(30); -translate([37.5, 0, 0]) extrusion_openbeam_v2(30, $fn=36); +translate([ 17.5, 0, 0 ]) extrusion_openbeam_v1(30); +translate([ 37.5, 0, 0 ]) extrusion_openbeam_v2(30, $fn = 36); diff --git a/extrusions/makerbeam.scad b/extrusions/makerbeam.scad index 7b573763..330f24a8 100644 --- a/extrusions/makerbeam.scad +++ b/extrusions/makerbeam.scad @@ -1,9 +1,11 @@ -module extrusion_makerbeam(h) -{ - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("MakerBeam_Cross_Section_Metric.DXF"); - } +module extrusion_makerbeam(h){ + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0){ import("MakerBeam_Cross_Section_Metric.DXF"); +} } *extrusion_makerbeam(30); diff --git a/extrusions/misumi_nfs5.scad b/extrusions/misumi_nfs5.scad index 4ccf859b..8004575b 100644 --- a/extrusions/misumi_nfs5.scad +++ b/extrusions/misumi_nfs5.scad @@ -1,40 +1,60 @@ // module extrusion_misumi_nfs5_2525(h) { - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("MISUMI/nfs5-2525.dxf"); - } + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0) + { + import("MISUMI/nfs5-2525.dxf"); + } } // module extrusion_misumi_nfs5_2550(h) { - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("MISUMI/nfs5-2550.dxf"); - } + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0) + { + import("MISUMI/nfs5-2550.dxf"); + } } // module extrusion_misumi_nfs5_4060(h) { - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("MISUMI/nfs5-4060.dxf"); - } + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0) + { + import("MISUMI/nfs5-4060.dxf"); + } } // module extrusion_misumi_nfs5_4080(h) { - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("MISUMI/nfs5-4080.dxf"); - } + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0) + { + import("MISUMI/nfs5-4080.dxf"); + } } extrusion_misumi_nfs5_2525(25); -translate([40,0,0]) extrusion_misumi_nfs5_2550(25); -translate([100,0,0]) extrusion_misumi_nfs5_4060(25); -translate([175,0,0]) extrusion_misumi_nfs5_4080(25); \ No newline at end of file +translate([ 40, 0, 0 ]) extrusion_misumi_nfs5_2550(25); +translate([ 100, 0, 0 ]) extrusion_misumi_nfs5_4060(25); +translate([ 175, 0, 0 ]) extrusion_misumi_nfs5_4080(25); \ No newline at end of file diff --git a/extrusions/openbeam.scad b/extrusions/openbeam.scad index 53a6fe60..6877e3ad 100644 --- a/extrusions/openbeam.scad +++ b/extrusions/openbeam.scad @@ -1,27 +1,35 @@ -//module extrusion_openbeam_v1_generate_dxf() +// module extrusion_openbeam_v1_generate_dxf() //{ // // Original STL has origin in lower left // translate([-7.5, -7.5, 0]) -// projection(cut = true) import("TL-400-0101-001CLR_-_OpenBeam_1515_Extrusion_Clear_Anodized.STL"); +// projection(cut = true) +// import("TL-400-0101-001CLR_-_OpenBeam_1515_Extrusion_Clear_Anodized.STL"); // export("TL-400-0101-001.DXF"); //} module extrusion_openbeam_v1(h) { - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("TL-400-0101-001.DXF"); - } + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0) + { + import("TL-400-0101-001.DXF"); + } } -module extrusion_openbeam_v2(h) -{ - linear_extrude(height = h, center = false, convexity = 1, twist = 0, slices = 1, scale = 1.0) - { - import("TL-400-0101-002.DXF"); - } +module extrusion_openbeam_v2(h){ + linear_extrude(height = h, + center = false, + convexity = 1, + twist = 0, + slices = 1, + scale = 1.0){ import("TL-400-0101-002.DXF"); +} } -//extrusion_openbeam_v1_generate_dxf(); +// extrusion_openbeam_v1_generate_dxf(); *extrusion_openbeam_v1(30); -*translate([20, 0, 0]) extrusion_openbeam_v2(30, $fn=36); +*translate([ 20, 0, 0 ]) extrusion_openbeam_v2(30, $fn = 36); diff --git a/fasteners/iso4017.scad b/fasteners/iso4017.scad index 8873e9a1..65b52085 100644 --- a/fasteners/iso4017.scad +++ b/fasteners/iso4017.scad @@ -5,125 +5,119 @@ // // β = angle of the chamfer (hexagon head) -include -include include +include +include $fn = 36; module iso_hexagon_head_screw(diameter, length, grade = "A", tolerance = false) { - dimensions = iso_hexagon_head_screw_dimensions(diameter); - hex_side_nom = dimensions[18] / const_sqrt3; - hex_side_grade_a = dimensions[19] / const_sqrt3; - hex_side_grade_b = dimensions[20] / const_sqrt3; + dimensions = iso_hexagon_head_screw_dimensions(diameter); + hex_side_nom = dimensions[18] / const_sqrt3; + hex_side_grade_a = dimensions[19] / const_sqrt3; + hex_side_grade_b = dimensions[20] / const_sqrt3; - echo(dimensions); - echo(dimensions[8] / 2, hex_side_nom); + echo(dimensions); + echo(dimensions[8] / 2, hex_side_nom); - if (grade == "A") - { - if (tolerance) - { - // Use minimum dimensions - linear_extrude(height = dimensions[12]) - { - polygon(points = [ - [0, dimensions[8] / 2], - [dimensions[19] / 2, hex_side_grade_a / 2], - [dimensions[19] / 2, -hex_side_grade_a / 2], - [0, -dimensions[8] / 2], - [-dimensions[19] / 2, -hex_side_grade_a / 2], - [-dimensions[19] / 2, hex_side_grade_a / 2] - ], - paths = [[0,1,2,3,4,5]] - ); - } - // Ghost in maximum dimensions - %linear_extrude(height = dimensions[11]) - { - polygon(points = [ - [0, hex_side_nom], - [dimensions[18] / 2, hex_side_nom / 2], - [dimensions[18] / 2, -hex_side_nom / 2], - [0, -hex_side_nom], - [-dimensions[18] / 2, -hex_side_nom / 2], - [-dimensions[18] / 2, hex_side_nom / 2] - ], - paths = [[0,1,2,3,4,5]] - ); - } - } - // Use nominal dimensions - else - { - linear_extrude(height = dimensions[10]) - { - polygon(points = [ - [0, hex_side_nom], - [dimensions[18] / 2, hex_side_nom / 2], - [dimensions[18] / 2, -hex_side_nom / 2], - [0, -hex_side_nom], - [-dimensions[18] / 2, -hex_side_nom / 2], - [-dimensions[18] / 2, hex_side_nom / 2] - ], - paths = [[0,1,2,3,4,5]] - ); - } - } - } - else if (grade == "B") - { - if (tolerance) - { - // Use minimum dimensions - linear_extrude(height = dimensions[14]) - { - polygon(points = [ - [0, dimensions[9] / 2], - [dimensions[20] / 2, hex_side_grade_b / 2], - [dimensions[20] / 2, -hex_side_grade_b / 2], - [0, -dimensions[9] / 2], - [-dimensions[20] / 2, -hex_side_grade_b / 2], - [-dimensions[20] / 2, hex_side_grade_b / 2] - ], - paths = [[0,1,2,3,4,5]] - ); - } - // Ghost in nominal/maximum dimensions - %linear_extrude(height = dimensions[13]) - { - polygon(points = [ - [0, hex_side_nom], - [dimensions[18] / 2, hex_side_nom / 2], - [dimensions[18] / 2, -hex_side_nom / 2], - [0, -hex_side_nom], - [-dimensions[18] / 2, -hex_side_nom / 2], - [-dimensions[18] / 2, hex_side_nom / 2] - ], - paths = [[0,1,2,3,4,5]] - ); - } - } - // Use nominal dimensions - else - { - linear_extrude(height = dimensions[10]) - { - polygon(points = [ - [0, hex_side_nom], - [dimensions[18] / 2, hex_side_nom / 2], - [dimensions[18] / 2, -hex_side_nom / 2], - [0, -hex_side_nom], - [-dimensions[18] / 2, -hex_side_nom / 2], - [-dimensions[18] / 2, hex_side_nom / 2] - ], - paths = [[0,1,2,3,4,5]] - ); - } - rotate([180,0,0]) cylinder(h = length, d = dimensions[21], center = false); - } - } + if (grade == "A") { + if (tolerance) { + // Use minimum dimensions + linear_extrude(height = dimensions[12]) + { + polygon(points = + [ + [ 0, dimensions[8] / 2 ], + [ dimensions[19] / 2, hex_side_grade_a / 2 ], + [ dimensions[19] / 2, -hex_side_grade_a / 2 ], + [ 0, -dimensions[8] / 2 ], + [ -dimensions[19] / 2, -hex_side_grade_a / 2 ], + [ -dimensions[19] / 2, hex_side_grade_a / 2 ] + ], + paths = [[ 0, 1, 2, 3, 4, 5 ]]); + } + // Ghost in maximum dimensions + % linear_extrude(height = dimensions[11]) + { + polygon(points = + [ + [ 0, hex_side_nom ], + [ dimensions[18] / 2, hex_side_nom / 2 ], + [ dimensions[18] / 2, -hex_side_nom / 2 ], + [ 0, -hex_side_nom ], + [ -dimensions[18] / 2, -hex_side_nom / 2 ], + [ -dimensions[18] / 2, hex_side_nom / 2 ] + ], + paths = [[ 0, 1, 2, 3, 4, 5 ]]); + } + } + // Use nominal dimensions + else { + linear_extrude(height = dimensions[10]) + { + polygon(points = + [ + [ 0, hex_side_nom ], + [ dimensions[18] / 2, hex_side_nom / 2 ], + [ dimensions[18] / 2, -hex_side_nom / 2 ], + [ 0, -hex_side_nom ], + [ -dimensions[18] / 2, -hex_side_nom / 2 ], + [ -dimensions[18] / 2, hex_side_nom / 2 ] + ], + paths = [[ 0, 1, 2, 3, 4, 5 ]]); + } + } + } else if (grade == "B") { + if (tolerance) { + // Use minimum dimensions + linear_extrude(height = dimensions[14]) + { + polygon(points = + [ + [ 0, dimensions[9] / 2 ], + [ dimensions[20] / 2, hex_side_grade_b / 2 ], + [ dimensions[20] / 2, -hex_side_grade_b / 2 ], + [ 0, -dimensions[9] / 2 ], + [ -dimensions[20] / 2, -hex_side_grade_b / 2 ], + [ -dimensions[20] / 2, hex_side_grade_b / 2 ] + ], + paths = [[ 0, 1, 2, 3, 4, 5 ]]); + } + // Ghost in nominal/maximum dimensions + % linear_extrude(height = dimensions[13]) + { + polygon(points = + [ + [ 0, hex_side_nom ], + [ dimensions[18] / 2, hex_side_nom / 2 ], + [ dimensions[18] / 2, -hex_side_nom / 2 ], + [ 0, -hex_side_nom ], + [ -dimensions[18] / 2, -hex_side_nom / 2 ], + [ -dimensions[18] / 2, hex_side_nom / 2 ] + ], + paths = [[ 0, 1, 2, 3, 4, 5 ]]); + } + } + // Use nominal dimensions + else { + linear_extrude(height = dimensions[10]) + { + polygon(points = + [ + [ 0, hex_side_nom ], + [ dimensions[18] / 2, hex_side_nom / 2 ], + [ dimensions[18] / 2, -hex_side_nom / 2 ], + [ 0, -hex_side_nom ], + [ -dimensions[18] / 2, -hex_side_nom / 2 ], + [ -dimensions[18] / 2, hex_side_nom / 2 ] + ], + paths = [[ 0, 1, 2, 3, 4, 5 ]]); + } + rotate([ 180, 0, 0 ]) + cylinder(h = length, d = dimensions[21], center = false); + } + } } // Definitions from ISO 225 — Fasteners — Bolts, screws, studs and @@ -131,15 +125,15 @@ module iso_hexagon_head_screw(diameter, length, grade = "A", tolerance = false) // // For a given d: // 0:P: pitch of the thread -// 1:a max: maximum distance from the bearing face to the first full form (full profile) thread (screw) -// 2:a min: minimum distance from the bearing face to the first full form (full profile) thread (screw) -// 3:c max: maximum height of the washer-faced portion or thickness of the flange or collar -// 4:c min: minimum height of the washer-faced portion or thickness of the flange or collar -// 5:da max: maximum inner diameter of the bearing face -// 6:dw grade a min: minimum outer diameter of the washer face (bearing face) -// 7:dw grade b min: minimum outer diameter of the washer face (bearing face) -// 8:e grade a min: minimum width across corners -// 9:e grade b min: minimum width across corners +// 1:a max: maximum distance from the bearing face to the first full form (full +// profile) thread (screw) 2:a min: minimum distance from the bearing face to +// the first full form (full profile) thread (screw) 3:c max: maximum height of +// the washer-faced portion or thickness of the flange or collar 4:c min: +// minimum height of the washer-faced portion or thickness of the flange or +// collar 5:da max: maximum inner diameter of the bearing face 6:dw grade a min: +// minimum outer diameter of the washer face (bearing face) 7:dw grade b min: +// minimum outer diameter of the washer face (bearing face) 8:e grade a min: +// minimum width across corners 9:e grade b min: minimum width across corners // 10:k nom: nominal height of the head // 11:k grade a max: maximum height of the head // 12:k grade a min: minimum height of the head @@ -167,6 +161,6 @@ function iso_hexagon_head_screw_dimensions(diameter) = [8*length_mm, 22*length_mm, 7*length_mm]; // this is the default iso_hexagon_head_screw("M1.6", 20, "A", true); -translate([5,0,0]) iso_hexagon_head_screw("M1.6", 20, "A", false); -translate([0,5,0]) iso_hexagon_head_screw("M1.6", 20, "B", true); -translate([5,5,0]) iso_hexagon_head_screw("M1.6", 20, "B", false); \ No newline at end of file +translate([ 5, 0, 0 ]) iso_hexagon_head_screw("M1.6", 20, "A", false); +translate([ 0, 5, 0 ]) iso_hexagon_head_screw("M1.6", 20, "B", true); +translate([ 5, 5, 0 ]) iso_hexagon_head_screw("M1.6", 20, "B", false); \ No newline at end of file diff --git a/fasteners/metric_fastners.scad b/fasteners/metric_fastners.scad index 7134c743..ef7257a9 100644 --- a/fasteners/metric_fastners.scad +++ b/fasteners/metric_fastners.scad @@ -16,96 +16,93 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * -*/ + */ // $fn=50; -apply_chamfer=true; +apply_chamfer = true; -module cap_bolt(dia,len) +module cap_bolt(dia, len) { - e=1.5*dia; - h1=1.25*dia; - cylinder(r=dia/2,h=len); - translate([0,0,-h1]) cylinder(r=e/2,h=h1); + e = 1.5 * dia; + h1 = 1.25 * dia; + cylinder(r = dia / 2, h = len); + translate([ 0, 0, -h1 ]) cylinder(r = e / 2, h = h1); } -module csk_bolt(dia,len) +module csk_bolt(dia, len) { - h1=0.6*dia; - h2=len-h1; - cylinder(r=dia/2,h=h2); - cylinder(r1=dia,r2=dia/2,h=h1); + h1 = 0.6 * dia; + h2 = len - h1; + cylinder(r = dia / 2, h = h2); + cylinder(r1 = dia, r2 = dia / 2, h = h1); } module washer(dia) { - t=0.1*dia; - difference() - { - cylinder(r=dia,h=t); - translate([0,0,-t/2])cylinder(r=dia/2,h=t*2); - } + t = 0.1 * dia; + difference() + { + cylinder(r = dia, h = t); + translate([ 0, 0, -t / 2 ]) cylinder(r = dia / 2, h = t * 2); + } } module flat_nut(dia) { - m=0.8*dia; - e=1.8*dia; - c=0.2*dia; - difference() - { - cylinder(r=e/2,h=m,$fn=6); - translate([0,0,-m/2])cylinder(r=dia/2,h=m*2); - if(apply_chamfer) - translate([0,0,c])cylinder_chamfer(e/2,c); - } + m = 0.8 * dia; + e = 1.8 * dia; + c = 0.2 * dia; + difference() + { + cylinder(r = e / 2, h = m, $fn = 6); + translate([ 0, 0, -m / 2 ]) cylinder(r = dia / 2, h = m * 2); + if (apply_chamfer) + translate([ 0, 0, c ]) cylinder_chamfer(e / 2, c); + } } -module bolt(dia,len) +module bolt(dia, len) { - e=1.8*dia; - k=0.7*dia; - c=0.2*dia; - difference() - { - cylinder(r=e/2,h=k,$fn=6); - if(apply_chamfer) - translate([0,0,c])cylinder_chamfer(e/2,c); - } - - cylinder(r=dia/2,h=len); + e = 1.8 * dia; + k = 0.7 * dia; + c = 0.2 * dia; + difference() + { + cylinder(r = e / 2, h = k, $fn = 6); + if (apply_chamfer) + translate([ 0, 0, c ]) cylinder_chamfer(e / 2, c); + } + cylinder(r = dia / 2, h = len); } -module cylinder_chamfer(r1,r2) +module cylinder_chamfer(r1, r2) { - t=r1-r2; - p=r2*2; - rotate_extrude() - difference() - { - translate([t,-p])square([p,p]); - translate([t,0])circle(r2); - } + t = r1 - r2; + p = r2 * 2; + rotate_extrude() difference() + { + translate([ t, -p ]) square([ p, p ]); + translate([ t, 0 ]) circle(r2); + } } -module chamfer(len,r) +module chamfer(len, r) { - p=r*2; - linear_extrude(height=len) - difference() - { - square([p,p]); - circle(r); - } + p = r * 2; + linear_extrude(height = len) difference() + { + square([ p, p ]); + circle(r); + } } union() { -//csk_bolt(3,14); -//washer(3); -//flat_nut(3); -//bolt(4,14); -//cylinder_chamfer(8,1); -//chamfer(10,2); + // csk_bolt(3,14); + // washer(3); + // flat_nut(3); + // bolt(4,14); + // cylinder_chamfer(8,1); + // chamfer(10,2); } diff --git a/fasteners/nuts_and_bolts.scad b/fasteners/nuts_and_bolts.scad index a4cf8d54..252ace20 100644 --- a/fasteners/nuts_and_bolts.scad +++ b/fasteners/nuts_and_bolts.scad @@ -6,213 +6,183 @@ include // This library is dual licensed under the GPL 3.0 and the GNU Lesser General // Public License as per http://creativecommons.org/licenses/LGPL/2.1/ . -module mcad_test_nuts_and_bolts_1 () +module +mcad_test_nuts_and_bolts_1() { - $fn = 360; + $fn = 360; - translate ([0, 15]) - mcad_nut_hole (3, proj = -1); - - mcad_bolt_hole (3, length = 30,tolerance =10, proj = -1); + translate([ 0, 15 ]) mcad_nut_hole(3, proj = -1); + mcad_bolt_hole(3, length = 30, tolerance = 10, proj = -1); } -//mcad_test_nuts_and_bolts_1 (); +// mcad_test_nuts_and_bolts_1 (); -module mcad_test_nuts_and_bolts_2 () +module +mcad_test_nuts_and_bolts_2() { - $fn = 360; - - difference(){ - cube(size = [10, 20, 10], center = true); - union(){ - translate ([0, 15]) - mcad_nut_hole (3, proj = 2); - - linear_extrude (height = 20, center = true, convexity = 10, - twist = 0) - mcad_bolt_hole (3, length = 30, proj = 2); - } - } + $fn = 360; + + difference() + { + cube(size = [ 10, 20, 10 ], center = true); + union() + { + translate([ 0, 15 ]) mcad_nut_hole(3, proj = 2); + + linear_extrude(height = 20, center = true, convexity = 10, twist = 0) + mcad_bolt_hole(3, length = 30, proj = 2); + } + } } -//mcad_test_nuts_and_bolts_2 (); +// mcad_test_nuts_and_bolts_2 (); -module mcad_test_nuts_and_bolts_3 () +module +mcad_test_nuts_and_bolts_3() { - $fn = 360; + $fn = 360; - mcad_bolt_hole_with_nut ( - size = 3, - length = 10 - ); + mcad_bolt_hole_with_nut(size = 3, length = 10); } -//mcad_test_nuts_and_bolts_3 (); - -//Based on: http://www.roymech.co.uk/Useful_Tables/Screws/Hex_Screws.htm -METRIC_NUT_AC_WIDTHS = -[ - -1, //0 index is not used but reduces computation - -1, - 4.32, //m2 - 6.40,//m3 - 8.10,//m4 - 9.20,//m5 - 11.50,//m6 - -1, - 15.00,//m8 - -1, - 19.60,//m10 - -1, - 22.10,//m12 - -1, - -1, - -1, - 27.70,//m16 - -1, - -1, - -1, - 34.60,//m20 - -1, - -1, - -1, - 41.60,//m24 - -1, - -1, - -1, - -1, - -1, - 53.1,//m30 - -1, - -1, - -1, - -1, - -1, - 63.5//m36 +// mcad_test_nuts_and_bolts_3 (); + +// Based on: http://www.roymech.co.uk/Useful_Tables/Screws/Hex_Screws.htm +METRIC_NUT_AC_WIDTHS = [ + -1, // 0 index is not used but reduces computation + -1, + 4.32, // m2 + 6.40, // m3 + 8.10, // m4 + 9.20, // m5 + 11.50, // m6 + -1, + 15.00, // m8 + -1, + 19.60, // m10 + -1, + 22.10, // m12 + -1, -1, -1, + 27.70, // m16 + -1, -1, -1, + 34.60, // m20 + -1, -1, -1, + 41.60, // m24 + -1, -1, -1, -1, -1, + 53.1, // m30 + -1, -1, -1, -1, -1, + 63.5 // m36 ]; -METRIC_NUT_THICKNESS = -[ - -1, //0 index is not used but reduces computation - -1, - 1.6,//m2 - 2.40,//m3 - 3.20,//m4 - 4.00,//m5 - 5.00,//m6 - -1, - 6.50,//m8 - -1, - 8.00,//m10 - -1, - 10.00,//m12 - -1, - -1, - -1, - 13.00,//m16 - -1, - -1, - -1, - 16.00//m20 - -1, - -1, - -1, - 19.00,//m24 - -1, - -1, - -1, - -1, - -1, - 24.00,//m30 - -1, - -1, - -1, - -1, - -1, - 29.00//m36 +METRIC_NUT_THICKNESS = [ + -1, // 0 index is not used but reduces computation + -1, + 1.6, // m2 + 2.40, // m3 + 3.20, // m4 + 4.00, // m5 + 5.00, // m6 + -1, + 6.50, // m8 + -1, + 8.00, // m10 + -1, + 10.00, // m12 + -1, + -1, + -1, + 13.00, // m16 + -1, + -1, + -1, + 16.00 // m20 + - 1, + -1, + -1, + 19.00, // m24 + -1, + -1, + -1, + -1, + -1, + 24.00, // m30 + -1, + -1, + -1, + -1, + -1, + 29.00 // m36 ]; METRIC_BOLT_CAP_DIAMETERS = [ - -1, - -1, - -1, - 5.5, // m3 - 7, // m4 - 8.5, // m5 - 10, // m6 - -1, - 13, // m8 - -1, - 16, // m10 - -1, - 18, // m12 - -1, - -1, - -1, - 24, // m16 - -1, - -1, - -1, - 30, // m20 - -1, - -1, - -1, - 36 // m24 + -1, -1, -1, + 5.5, // m3 + 7, // m4 + 8.5, // m5 + 10, // m6 + -1, + 13, // m8 + -1, + 16, // m10 + -1, + 18, // m12 + -1, -1, -1, + 24, // m16 + -1, -1, -1, + 30, // m20 + -1, -1, -1, + 36 // m24 ]; -function mcad_metric_nut_ac_width (size) = METRIC_NUT_AC_WIDTHS[size]; -function mcad_metric_nut_thickness (size) = METRIC_NUT_THICKNESS[size]; -function mcad_metric_bolt_major_diameter (size) = size; -function mcad_metric_bolt_cap_height (size) = size; -function mcad_metric_bolt_cap_diameter (size) = ( - METRIC_BOLT_CAP_DIAMETERS[size] -); +function mcad_metric_nut_ac_width(size) = METRIC_NUT_AC_WIDTHS[size]; +function mcad_metric_nut_thickness(size) = METRIC_NUT_THICKNESS[size]; +function mcad_metric_bolt_major_diameter(size) = size; +function mcad_metric_bolt_cap_height(size) = size; +function mcad_metric_bolt_cap_diameter(size) = + (METRIC_BOLT_CAP_DIAMETERS[size]); -module mcad_nut_hole (size, tolerance = +0.0001, proj = -1) +module mcad_nut_hole(size, tolerance = +0.0001, proj = -1) { - //takes a metric screw/nut size and looksup nut dimensions - radius = mcad_metric_nut_ac_width (size) / 2 + tolerance; - height = mcad_metric_nut_thickness (size) + tolerance; + // takes a metric screw/nut size and looksup nut dimensions + radius = mcad_metric_nut_ac_width(size) / 2 + tolerance; + height = mcad_metric_nut_thickness(size) + tolerance; - if (proj == -1) { - cylinder (r = radius, h = height, $fn = 6, center = [0, 0]); - } + if (proj == -1) { + cylinder(r = radius, h = height, $fn = 6, center = [ 0, 0 ]); + } - else if (proj == 1) { - circle(r = radius, $fn = 6); - } + else if (proj == 1) { + circle(r = radius, $fn = 6); + } - else if (proj == 2) - { - translate ([-radius/2, 0]) - square ([radius*2, height]); - } + else if (proj == 2) { + translate([ -radius / 2, 0 ]) square([ radius * 2, height ]); + } } -module mcad_bolt_hole (size, length, cap_extra_length, tolerance = +0.0001, - proj = -1) +module mcad_bolt_hole(size, + length, + cap_extra_length, + tolerance = +0.0001, + proj = -1) { - radius = mcad_metric_bolt_major_diameter (size) / 2 + tolerance; - - cap_height = mcad_metric_bolt_cap_height (size) + tolerance; - cap_radius = mcad_metric_bolt_cap_diameter (size) / 2 + tolerance; - - if (proj == -1) - { - translate([0, 0, -cap_height - cap_extra_length]) - cylinder(r = cap_radius, h = cap_height + cap_extra_length); - cylinder(r = radius, h = length); - } - if (proj == 1) - { - circle(r = radius); - } - if (proj == 2) - { - translate([-cap_radius, - cap_height]) - square([cap_radius * 2, cap_height]); - translate([-radius, 0]) - square([radius * 2, length]); - } + radius = mcad_metric_bolt_major_diameter(size) / 2 + tolerance; + + cap_height = mcad_metric_bolt_cap_height(size) + tolerance; + cap_radius = mcad_metric_bolt_cap_diameter(size) / 2 + tolerance; + + if (proj == -1) { + translate([ 0, 0, -cap_height - cap_extra_length ]) + cylinder(r = cap_radius, h = cap_height + cap_extra_length); + cylinder(r = radius, h = length); + } + if (proj == 1) { + circle(r = radius); + } + if (proj == 2) { + translate([ -cap_radius, -cap_height ]) + square([ cap_radius * 2, cap_height ]); + translate([ -radius, 0 ]) square([ radius * 2, length ]); + } } /** @@ -224,42 +194,50 @@ module mcad_bolt_hole (size, length, cap_extra_length, tolerance = +0.0001, * @param align_with Alignment of whole set (above_head, below_head, center, * below_nut, above_nut) */ -module mcad_bolt_hole_with_nut (size, length, nut_projection = "axial", - align_with = "above_head", - screw_extra_length = 9999, - head_extra_length = 9999, - nut_projection_length = 100, - bolt_tolerance = 0.15, - nut_tolerance = 0.001) +module mcad_bolt_hole_with_nut(size, + length, + nut_projection = "axial", + align_with = "above_head", + screw_extra_length = 9999, + head_extra_length = 9999, + nut_projection_length = 100, + bolt_tolerance = 0.15, + nut_tolerance = 0.001) { - cap_head_d = mcad_metric_bolt_cap_diameter (size); - cap_head_h = size; - - nut_thickness = mcad_metric_nut_thickness (size); - - elevation = ( - (align_with == "above_head") ? 0 : - (align_with == "below_head") ? cap_head_h : - (align_with == "center") ? cap_head_h + length / 2 : - (align_with == "below_nut") ? cap_head_h + length : - (align_with == "above_nut") ? cap_head_h + length + nut_thickness : 0 - ); - - translate ([0, 0, -elevation]) { - /* screw head */ - translate ([0, 0, cap_head_h]) - mcad_bolt_hole (size = size, length = length + screw_extra_length, - cap_extra_length = head_extra_length, - tolerance = bolt_tolerance); - - /* nut */ - translate ([0, 0, cap_head_h + length - epsilon]) - hull () { - axis = (nut_projection == "axial") ? +Z : +X; - - mcad_linear_multiply (no = 2, separation = nut_projection_length, - axis = axis) - mcad_nut_hole (size = size, tolerance = nut_tolerance); - } - } + cap_head_d = mcad_metric_bolt_cap_diameter(size); + cap_head_h = size; + + nut_thickness = mcad_metric_nut_thickness(size); + + elevation = ((align_with == "above_head") + ? 0 + : (align_with == "below_head") + ? cap_head_h + : (align_with == "center") + ? cap_head_h + length / 2 + : (align_with == "below_nut") + ? cap_head_h + length + : (align_with == "above_nut") + ? cap_head_h + length + nut_thickness + : 0); + + translate([ 0, 0, -elevation ]) + { + /* screw head */ + translate([ 0, 0, cap_head_h ]) + mcad_bolt_hole(size = size, + length = length + screw_extra_length, + cap_extra_length = head_extra_length, + tolerance = bolt_tolerance); + + /* nut */ + translate([ 0, 0, cap_head_h + length - epsilon ]) hull() + { + axis = (nut_projection == "axial") ? +Z : +X; + + mcad_linear_multiply( + no = 2, separation = nut_projection_length, axis = axis) + mcad_nut_hole(size = size, tolerance = nut_tolerance); + } + } } diff --git a/fasteners/threads.scad b/fasteners/threads.scad index 29527f84..1d127f4c 100644 --- a/fasteners/threads.scad +++ b/fasteners/threads.scad @@ -5,44 +5,39 @@ * You are welcome to make free use of this software. Retention of my * authorship credit would be appreciated. * - * Version 1.3. 2013-12-01 Correct loop over turns -- don't have early cut-off - * Version 1.2. 2012-09-09 Use discrete polyhedra rather than linear_extrude() - * Version 1.1. 2012-09-07 Corrected to right-hand threads! + * Version 1.3. 2013-12-01 Correct loop over turns -- don't have early + * cut-off Version 1.2. 2012-09-09 Use discrete polyhedra rather than + * linear_extrude() Version 1.1. 2012-09-07 Corrected to right-hand threads! */ // Examples: -test_threads (); +test_threads(); -module test_threads ($fa=5, $fs=0.1) +module test_threads($fa = 5, $fs = 0.1) { - // M8 - metric_thread(8, 1.5, 10); + // M8 + metric_thread(8, 1.5, 10); - translate ([10, 0, 0]) - square_thread(8, 1.5, 10); + translate([ 10, 0, 0 ]) square_thread(8, 1.5, 10); - translate ([20, 0, 0]) - acme_thread(8, 1.5, 10); + translate([ 20, 0, 0 ]) acme_thread(8, 1.5, 10); - translate ([30, 0, 0]) - buttress_thread(8, 1.5, 10); + translate([ 30, 0, 0 ]) buttress_thread(8, 1.5, 10); - translate ([40, 0, 0]) - english_thread(1/4, 20, 1); + translate([ 40, 0, 0 ]) english_thread(1 / 4, 20, 1); - // Rohloff hub thread: - translate ([65, 0, 0]) - metric_thread(34, 1, 10, internal=true, n_starts=6); + // Rohloff hub thread: + translate([ 65, 0, 0 ]) + metric_thread(34, 1, 10, internal = true, n_starts = 6); } // ---------------------------------------------------------------------------- -use -use use +use +use use - // ---------------------------------------------------------------------------- // internal - true = clearances for internal thread (e.g., a nut). // false = clearances for external thread (e.g., a bolt). @@ -50,87 +45,77 @@ use // difference()). // n_starts - Number of thread starts (e.g., DNA, a "double helix," has // n_starts=2). See wikipedia Screw_thread. -module metric_thread ( - diameter = 8, - pitch = 1, - length = 1, - internal = false, - n_starts = 1 -) +module metric_thread(diameter = 8, + pitch = 1, + length = 1, + internal = false, + n_starts = 1) { - trapezoidal_thread ( - pitch = pitch, - length = length, - upper_angle = 30, lower_angle = 30, - outer_flat_length = pitch / 8, - major_radius = diameter / 2, - minor_radius = diameter / 2 - 5/8 * cos(30) * pitch, - internal = internal, - n_starts = n_starts - ); + trapezoidal_thread(pitch = pitch, + length = length, + upper_angle = 30, + lower_angle = 30, + outer_flat_length = pitch / 8, + major_radius = diameter / 2, + minor_radius = diameter / 2 - 5 / 8 * cos(30) * pitch, + internal = internal, + n_starts = n_starts); } -module square_thread ( - diameter = 8, - pitch = 1, - length = 1, - internal = false, - n_starts = 1 -) +module square_thread(diameter = 8, + pitch = 1, + length = 1, + internal = false, + n_starts = 1) { - trapezoidal_thread ( - pitch = pitch, - length = length, - upper_angle = 0, lower_angle = 0, - outer_flat_length = pitch / 2, - major_radius = diameter / 2, - minor_radius = diameter / 2 - pitch / 2, - internal = internal, - n_starts = n_starts - ); + trapezoidal_thread(pitch = pitch, + length = length, + upper_angle = 0, + lower_angle = 0, + outer_flat_length = pitch / 2, + major_radius = diameter / 2, + minor_radius = diameter / 2 - pitch / 2, + internal = internal, + n_starts = n_starts); } -module acme_thread ( - diameter = 8, - pitch = 1, - length = 1, - internal = false, - n_starts = 1 -) +module acme_thread(diameter = 8, + pitch = 1, + length = 1, + internal = false, + n_starts = 1) { - trapezoidal_thread ( - pitch = pitch, - length = length, - upper_angle = 29/2, lower_angle = 29/2, - outer_flat_length = 0.3707 * pitch, - major_radius = diameter / 2, - minor_radius = diameter / 2 - pitch / 2, - internal = internal, - n_starts = n_starts - ); + trapezoidal_thread(pitch = pitch, + length = length, + upper_angle = 29 / 2, + lower_angle = 29 / 2, + outer_flat_length = 0.3707 * pitch, + major_radius = diameter / 2, + minor_radius = diameter / 2 - pitch / 2, + internal = internal, + n_starts = n_starts); } -module buttress_thread ( - diameter = 8, - pitch = 1, - length = 1, - internal = false, - n_starts = 1, - buttress_angles = [3, 33], - pitch_flat_ratio = 6, // ratio of pitch to flat length - pitch_depth_ratio = 3/2 // ratio of pitch to thread depth +module buttress_thread(diameter = 8, + pitch = 1, + length = 1, + internal = false, + n_starts = 1, + buttress_angles = [ 3, 33 ], + pitch_flat_ratio = 6, // ratio of pitch to flat length + pitch_depth_ratio = 3 / + 2 // ratio of pitch to thread depth ) { - trapezoidal_thread ( - pitch = pitch, - length = length, - upper_angle = buttress_angles[0], lower_angle = buttress_angles[1], - outer_flat_length = pitch / pitch_flat_ratio, - major_radius = diameter / 2, - minor_radius = diameter / 2 - pitch / pitch_depth_ratio, - internal = internal, - n_starts = n_starts - ); + trapezoidal_thread(pitch = pitch, + length = length, + upper_angle = buttress_angles[0], + lower_angle = buttress_angles[1], + outer_flat_length = pitch / pitch_flat_ratio, + major_radius = diameter / 2, + minor_radius = diameter / 2 - pitch / pitch_depth_ratio, + internal = internal, + n_starts = n_starts); } /** @@ -147,99 +132,94 @@ module buttress_thread ( * internal = if true, generates a thread suitable for difference() to make nuts * n_starts = number of threads winding the screw */ -module trapezoidal_thread ( - pitch, - length, - upper_angle, - lower_angle, - outer_flat_length, - major_radius, - minor_radius, - internal = false, - n_starts = 1 -) +module trapezoidal_thread(pitch, + length, + upper_angle, + lower_angle, + outer_flat_length, + major_radius, + minor_radius, + internal = false, + n_starts = 1) { - // trapezoid calculation: - /* - upper flat - ___________________ - /| |\ - / | | \ - left /__|_________________|__\ right - angle| | lower flat | |angle - | | | | - |left |right - flat |flat - */ - // looking at the tooth profile along the upper part of a screw held - // horizontally, which is a trapezoid longer at the bottom flat - tooth_height = major_radius - minor_radius; - left_angle = 90 - upper_angle; - right_angle = 90 - lower_angle; - upper_flat = outer_flat_length; - left_flat = tooth_height / tan (left_angle); - right_flat = tooth_height / tan (right_angle); - lower_flat = upper_flat + left_flat + right_flat; - clearance = 0.3/8 * tooth_height; - - tooth_profile = [ - [0, 0], - [tooth_height + 0.001, right_flat], - [tooth_height + 0.001, right_flat + upper_flat], - [0, lower_flat] - ]; - - // convert length along the tooth profile to angle of twist of the screw - function length2twist (length) = length / pitch * (360 / n_starts); - function twist2length (angle) = angle / (360 / n_starts) * pitch; - - // facet calculation - facets = get_fragments_from_r (minor_radius); - fa = 360 / facets; - - slices = length2twist (length) / fa; - - path_transforms = [ - for (i=[0:slices + length2twist (pitch) / fa]) - let (a=i * fa) - ( - rotation (axis=[0, 0, a]) * - translation ([0, 0, twist2length (a) - pitch]) * - translation ([minor_radius - 0.001, 0, 0]) * - rotation (axis=[90, 0, 0]) - ) - ]; - - cylinder (r=minor_radius, h=length); - - difference () { - for (i=[0:n_starts]) - rotate ([0, 0, i / n_starts * 360]) - sweep (tooth_profile, path_transforms); - - translate ([0, 0, length + pitch / 2]) - cube ([major_radius * 2 + .1, major_radius * 2+ .1, pitch], - center=true); - - translate ([0, 0, -pitch / 2]) - cube ([major_radius * 2 + .1, major_radius * 2+ .1, pitch], - center=true); - } + // trapezoid calculation: + /* + upper flat + ___________________ + /| |\ + / | | \ + left /__|_________________|__\ right + angle| | lower flat | |angle + | | | | + |left |right + flat |flat + */ + // looking at the tooth profile along the upper part of a screw held + // horizontally, which is a trapezoid longer at the bottom flat + tooth_height = major_radius - minor_radius; + left_angle = 90 - upper_angle; + right_angle = 90 - lower_angle; + upper_flat = outer_flat_length; + left_flat = tooth_height / tan(left_angle); + right_flat = tooth_height / tan(right_angle); + lower_flat = upper_flat + left_flat + right_flat; + clearance = 0.3 / 8 * tooth_height; + + tooth_profile = [ + [ 0, 0 ], + [ tooth_height + 0.001, right_flat ], + [ tooth_height + 0.001, right_flat + upper_flat ], + [ 0, lower_flat ] + ]; + + // convert length along the tooth profile to angle of twist of the screw + function length2twist(length) = length / pitch * (360 / n_starts); + function twist2length(angle) = angle / (360 / n_starts) * pitch; + + // facet calculation + facets = get_fragments_from_r(minor_radius); + fa = 360 / facets; + + slices = length2twist(length) / fa; + + path_transforms = [for (i = [0:slices + length2twist(pitch) / fa]) + let(a = i * fa)(rotation(axis = [ 0, 0, a ]) * + translation([ 0, 0, twist2length(a) - pitch ]) * + translation([ minor_radius - 0.001, 0, 0 ]) * + rotation(axis = [ 90, 0, 0 ]))]; + + cylinder(r = minor_radius, h = length); + + difference() + { + for (i = [0:n_starts]) + rotate([ 0, 0, i / n_starts * 360 ]) + sweep(tooth_profile, path_transforms); + + translate([ 0, 0, length + pitch / 2 ]) cube( + [ major_radius * 2 + .1, major_radius * 2 + .1, pitch ], center = true); + + translate([ 0, 0, -pitch / 2 ]) cube( + [ major_radius * 2 + .1, major_radius * 2 + .1, pitch ], center = true); + } } // ---------------------------------------------------------------------------- // Input units in inches. // Note: units of measure in drawing are mm! -module english_thread(diameter=0.25, threads_per_inch=20, length=1, - internal=false, n_starts=1) +module english_thread(diameter = 0.25, + threads_per_inch = 20, + length = 1, + internal = false, + n_starts = 1) { - // Convert to mm. - mm_diameter = diameter*25.4; - mm_pitch = (1.0/threads_per_inch)*25.4; - mm_length = length*25.4; - - echo(str("mm_diameter: ", mm_diameter)); - echo(str("mm_pitch: ", mm_pitch)); - echo(str("mm_length: ", mm_length)); - metric_thread(mm_diameter, mm_pitch, mm_length, internal, n_starts); + // Convert to mm. + mm_diameter = diameter * 25.4; + mm_pitch = (1.0 / threads_per_inch) * 25.4; + mm_length = length * 25.4; + + echo(str("mm_diameter: ", mm_diameter)); + echo(str("mm_pitch: ", mm_pitch)); + echo(str("mm_length: ", mm_length)); + metric_thread(mm_diameter, mm_pitch, mm_length, internal, n_starts); } diff --git a/format.py b/format.py new file mode 100755 index 00000000..54b9aca3 --- /dev/null +++ b/format.py @@ -0,0 +1,8 @@ +#!/usr/bin/python3 + +import os +import shutil + +if shutil.which("openscad-format") is None: + os.system("npm install -g openscad-format") +os.system("openscad-format -f -i './**/*.scad' -c ./.openscad-format") diff --git a/gears/gears.scad b/gears/gears.scad index eb2a7d9b..5f3f4ae0 100644 --- a/gears/gears.scad +++ b/gears/gears.scad @@ -1,10 +1,9 @@ // Copyright 2010 D1plo1d // LGPL 2.1 - -//test_involute_curve(); -//test_gears(); -//demo_3d_gears(); +// test_involute_curve(); +// test_gears(); +// demo_3d_gears(); // Geometry Sources: // http://www.cartertools.com/involute.html @@ -12,187 +11,197 @@ // Usage: // Diametral pitch: Number of teeth per unit length. // Circular pitch: Length of the arc from one tooth to the next -// Clearance: Radial distance between top of tooth on one gear to bottom of gap on another. +// Clearance: Radial distance between top of tooth on one gear to bottom of gap +// on another. -function pitch_circular2diameter(number_of_teeth,circular_pitch) = number_of_teeth * circular_pitch / 180; -function pitch_diametral2diameter(number_of_teeth,diametral_pitch) = number_of_teeth / diametral_pitch; +function pitch_circular2diameter(number_of_teeth, circular_pitch) = + number_of_teeth * circular_pitch / 180; +function pitch_diametral2diameter(number_of_teeth, diametral_pitch) = + number_of_teeth / diametral_pitch; module gear(number_of_teeth, - circular_pitch=false, diametral_pitch=false, - pressure_angle=20, clearance = 0, - verbose=false) + circular_pitch = false, + diametral_pitch = false, + pressure_angle = 20, + clearance = 0, + verbose = false) { - if(verbose) { - echo("gear arguments:"); - echo(str(" number_of_teeth: ", number_of_teeth)); - echo(str(" circular_pitch: ", circular_pitch)); - echo(str(" diametral_pitch: ", diametral_pitch)); - echo(str(" pressure_angle: ", pressure_angle)); - echo(str(" clearance: ", clearance)); - } - if (circular_pitch==false && diametral_pitch==false) echo("MCAD ERROR: gear module needs either a diametral_pitch or circular_pitch"); - if(verbose) echo("gear calculations:"); - - //Convert diametrial pitch to our native circular pitch - circular_pitch = (circular_pitch!=false?circular_pitch:180/diametral_pitch); - - // Pitch diameter: Diameter of pitch circle. - pitch_diameter = pitch_circular2diameter(number_of_teeth,circular_pitch); - if(verbose) echo (str(" pitch_diameter: ", pitch_diameter)); - pitch_radius = pitch_diameter/2; - - // Base Circle - base_diameter = pitch_diameter*cos(pressure_angle); - if(verbose) echo (str(" base_diameter: ", base_diameter)); - base_radius = base_diameter/2; - - // Diametrial pitch: Number of teeth per unit length. - pitch_diametrial = number_of_teeth / pitch_diameter; - if(verbose) echo (str(" pitch_diametrial: ", pitch_diametrial)); - - // Addendum: Radial distance from pitch circle to outside circle. - addendum = 1/pitch_diametrial; - if(verbose) echo (str(" addendum: ", addendum)); - - //Outer Circle - outer_radius = pitch_radius+addendum; - outer_diameter = outer_radius*2; - if(verbose) echo (str(" outer_diameter: ", outer_diameter)); - - // Dedendum: Radial distance from pitch circle to root diameter - dedendum = addendum + clearance; - if(verbose) echo (str(" dedendum: ", dedendum)); - - // Root diameter: Diameter of bottom of tooth spaces. - root_radius = pitch_radius-dedendum; - root_diameter = root_radius * 2; - if(verbose) echo (str(" root_diameter: ", root_diameter)); - - half_thick_angle = 360 / (4 * number_of_teeth); - if(verbose) echo (str(" half_thick_angle: ", half_thick_angle)); - - union() - { - rotate(half_thick_angle) circle($fn=number_of_teeth*2, r=root_radius*1.001); - - for (i= [1:number_of_teeth]) - //for (i = [0]) - { - rotate([0,0,i*360/number_of_teeth]) - { - involute_gear_tooth( - pitch_radius = pitch_radius, - root_radius = root_radius, - base_radius = base_radius, - outer_radius = outer_radius, - half_thick_angle = half_thick_angle); - } - } - } + if (verbose) { + echo("gear arguments:"); + echo(str(" number_of_teeth: ", number_of_teeth)); + echo(str(" circular_pitch: ", circular_pitch)); + echo(str(" diametral_pitch: ", diametral_pitch)); + echo(str(" pressure_angle: ", pressure_angle)); + echo(str(" clearance: ", clearance)); + } + if (circular_pitch == false && diametral_pitch == false) + echo("MCAD ERROR: gear module needs either a diametral_pitch or " + "circular_pitch"); + if (verbose) + echo("gear calculations:"); + + // Convert diametrial pitch to our native circular pitch + circular_pitch = + (circular_pitch != false ? circular_pitch : 180 / diametral_pitch); + + // Pitch diameter: Diameter of pitch circle. + pitch_diameter = pitch_circular2diameter(number_of_teeth, circular_pitch); + if (verbose) + echo(str(" pitch_diameter: ", pitch_diameter)); + pitch_radius = pitch_diameter / 2; + + // Base Circle + base_diameter = pitch_diameter * cos(pressure_angle); + if (verbose) + echo(str(" base_diameter: ", base_diameter)); + base_radius = base_diameter / 2; + + // Diametrial pitch: Number of teeth per unit length. + pitch_diametrial = number_of_teeth / pitch_diameter; + if (verbose) + echo(str(" pitch_diametrial: ", pitch_diametrial)); + + // Addendum: Radial distance from pitch circle to outside circle. + addendum = 1 / pitch_diametrial; + if (verbose) + echo(str(" addendum: ", addendum)); + + // Outer Circle + outer_radius = pitch_radius + addendum; + outer_diameter = outer_radius * 2; + if (verbose) + echo(str(" outer_diameter: ", outer_diameter)); + + // Dedendum: Radial distance from pitch circle to root diameter + dedendum = addendum + clearance; + if (verbose) + echo(str(" dedendum: ", dedendum)); + + // Root diameter: Diameter of bottom of tooth spaces. + root_radius = pitch_radius - dedendum; + root_diameter = root_radius * 2; + if (verbose) + echo(str(" root_diameter: ", root_diameter)); + + half_thick_angle = 360 / (4 * number_of_teeth); + if (verbose) + echo(str(" half_thick_angle: ", half_thick_angle)); + + union() + { + rotate(half_thick_angle) + circle($fn = number_of_teeth * 2, r = root_radius * 1.001); + + for (i = [1:number_of_teeth]) + // for (i = [0]) + { + rotate([ 0, 0, i * 360 / number_of_teeth ]) + { + involute_gear_tooth(pitch_radius = pitch_radius, + root_radius = root_radius, + base_radius = base_radius, + outer_radius = outer_radius, + half_thick_angle = half_thick_angle); + } + } + } } - -module involute_gear_tooth( - pitch_radius, - root_radius, - base_radius, - outer_radius, - half_thick_angle - ) +module involute_gear_tooth(pitch_radius, + root_radius, + base_radius, + outer_radius, + half_thick_angle) { - pitch_to_base_angle = involute_intersect_angle( base_radius, pitch_radius ); - - outer_to_base_angle = involute_intersect_angle( base_radius, outer_radius ); - - base1 = 0 - pitch_to_base_angle - half_thick_angle; - pitch1 = 0 - half_thick_angle; - outer1 = outer_to_base_angle - pitch_to_base_angle - half_thick_angle; - - b1 = polar_to_cartesian([ base1, base_radius ]); - p1 = polar_to_cartesian([ pitch1, pitch_radius ]); - o1 = polar_to_cartesian([ outer1, outer_radius ]); - - b2 = polar_to_cartesian([ -base1, base_radius ]); - p2 = polar_to_cartesian([ -pitch1, pitch_radius ]); - o2 = polar_to_cartesian([ -outer1, outer_radius ]); - - // ( root_radius > base_radius variables ) - pitch_to_root_angle = pitch_to_base_angle - involute_intersect_angle(base_radius, root_radius ); - root1 = pitch1 - pitch_to_root_angle; - root2 = -pitch1 + pitch_to_root_angle; - r1_t = polar_to_cartesian([ root1, root_radius ]); - r2_t = polar_to_cartesian([ -root1, root_radius ]); - - // ( else ) - r1_f = polar_to_cartesian([ base1, root_radius ]); - r2_f = polar_to_cartesian([ -base1, root_radius ]); - - if (root_radius > base_radius) - { - //echo("true"); - polygon( points = [ - r1_t,p1,o1,o2,p2,r2_t - ], convexity = 3); - } - else - { - polygon( points = [ - r1_f, b1,p1,o1,o2,p2,b2,r2_f - ], convexity = 3); - } - + pitch_to_base_angle = involute_intersect_angle(base_radius, pitch_radius); + + outer_to_base_angle = involute_intersect_angle(base_radius, outer_radius); + + base1 = 0 - pitch_to_base_angle - half_thick_angle; + pitch1 = 0 - half_thick_angle; + outer1 = outer_to_base_angle - pitch_to_base_angle - half_thick_angle; + + b1 = polar_to_cartesian([ base1, base_radius ]); + p1 = polar_to_cartesian([ pitch1, pitch_radius ]); + o1 = polar_to_cartesian([ outer1, outer_radius ]); + + b2 = polar_to_cartesian([ -base1, base_radius ]); + p2 = polar_to_cartesian([ -pitch1, pitch_radius ]); + o2 = polar_to_cartesian([ -outer1, outer_radius ]); + + // ( root_radius > base_radius variables ) + pitch_to_root_angle = + pitch_to_base_angle - involute_intersect_angle(base_radius, root_radius); + root1 = pitch1 - pitch_to_root_angle; + root2 = -pitch1 + pitch_to_root_angle; + r1_t = polar_to_cartesian([ root1, root_radius ]); + r2_t = polar_to_cartesian([ -root1, root_radius ]); + + // ( else ) + r1_f = polar_to_cartesian([ base1, root_radius ]); + r2_f = polar_to_cartesian([ -base1, root_radius ]); + + if (root_radius > base_radius) { + // echo("true"); + polygon(points = [ r1_t, p1, o1, o2, p2, r2_t ], convexity = 3); + } else { + polygon(points = [ r1_f, b1, p1, o1, o2, p2, b2, r2_f ], convexity = 3); + } } // Mathematical Functions //=============== -// Finds the angle of the involute about the base radius at the given distance (radius) from it's center. -//source: http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html - -function involute_intersect_angle(base_radius, radius) = sqrt( pow(radius/base_radius,2) - 1); - +// Finds the angle of the involute about the base radius at the given distance +// (radius) from it's center. +// source: +// http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html +function involute_intersect_angle(base_radius, + radius) = sqrt(pow(radius / base_radius, 2) - + 1); // Polar coord [angle, radius] to cartesian coord [x,y] -function polar_to_cartesian(polar) = [ - polar[1]*cos(polar[0]), - polar[1]*sin(polar[0]) -]; - +function polar_to_cartesian(polar) = + [ polar[1] * cos(polar[0]), polar[1] * sin(polar[0]) ]; // Test Cases //=============== -module test_gears() +module +test_gears() { - gear(number_of_teeth=51,circular_pitch=200); - translate([0, 50])gear(number_of_teeth=17,circular_pitch=200); - translate([-50,0]) gear(number_of_teeth=17,diametral_pitch=1); + gear(number_of_teeth = 51, circular_pitch = 200); + translate([ 0, 50 ]) gear(number_of_teeth = 17, circular_pitch = 200); + translate([ -50, 0 ]) gear(number_of_teeth = 17, diametral_pitch = 1); } -module demo_3d_gears() +module +demo_3d_gears() { - //double helical gear - // (helics don't line up perfectly - for display purposes only ;) - translate([50,0]) - { - linear_extrude(height = 10, center = true, convexity = 10, twist = -45) - gear(number_of_teeth=17,diametral_pitch=1); - translate([0,0,10]) linear_extrude(height = 10, center = true, convexity = 10, twist = 45) - gear(number_of_teeth=17,diametral_pitch=1); - } - - //spur gear - translate([0,-50]) linear_extrude(height = 10, center = true, convexity = 10, twist = 0) - gear(number_of_teeth=17,diametral_pitch=1); - + // double helical gear + // (helics don't line up perfectly - for display purposes only ;) + translate([ 50, 0 ]) + { + linear_extrude(height = 10, center = true, convexity = 10, twist = -45) + gear(number_of_teeth = 17, diametral_pitch = 1); + translate([ 0, 0, 10 ]) + linear_extrude(height = 10, center = true, convexity = 10, twist = 45) + gear(number_of_teeth = 17, diametral_pitch = 1); + } + + // spur gear + translate([ 0, -50 ]) + linear_extrude(height = 10, center = true, convexity = 10, twist = 0) + gear(number_of_teeth = 17, diametral_pitch = 1); } -module test_involute_curve() +module +test_involute_curve() { - for (i=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]) - { - translate(polar_to_cartesian([involute_intersect_angle( 0.1,i) , i ])) circle($fn=15, r=0.5); - } + for (i = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ]) { + translate(polar_to_cartesian([ involute_intersect_angle(0.1, i), i ])) + circle($fn = 15, r = 0.5); + } } diff --git a/gears/involute_gears.scad b/gears/involute_gears.scad index 73e19f6a..750ea7c8 100644 --- a/gears/involute_gears.scad +++ b/gears/involute_gears.scad @@ -1,738 +1,712 @@ // Parametric Involute Bevel and Spur Gears by GregFrost // It is licensed under the Creative Commons - GNU LGPL 2.1 license. // © 2010 by GregFrost, thingiverse.com/Amp -// http://www.thingiverse.com/thing:3575 and http://www.thingiverse.com/thing:3752 +// http://www.thingiverse.com/thing:3575 and +// http://www.thingiverse.com/thing:3752 use // Simple Test: -gear ( - number_of_teeth = 30, - circular_pitch=700, - gear_thickness = 12, - rim_thickness = 15, - hub_thickness = 17, - circles=8, - roundsize = 0 - ); - -translate ([700 * PI / 180 * 30 / 2 / PI * 2,0,0]) -rotate (180 + 360 / 30 / 2) -gear ( - number_of_teeth = 30, - circular_pitch=700, - gear_thickness = 12, - rim_thickness = 15, - hub_thickness = 17, - circles=8, - roundsize = 1 - ); - -//Complex Spur Gear Test: -//test_gears (); +gear(number_of_teeth = 30, + circular_pitch = 700, + gear_thickness = 12, + rim_thickness = 15, + hub_thickness = 17, + circles = 8, + roundsize = 0); + +translate([ 700 * PI / 180 * 30 / 2 / PI * 2, 0, 0 ]) rotate(180 + 360 / 30 / 2) + gear(number_of_teeth = 30, + circular_pitch = 700, + gear_thickness = 12, + rim_thickness = 15, + hub_thickness = 17, + circles = 8, + roundsize = 1); + +// Complex Spur Gear Test: +// test_gears (); // Meshing Double Helix: -//test_meshing_double_helix (); +// test_meshing_double_helix (); -module test_meshing_double_helix(){ - meshing_double_helix (); +module +test_meshing_double_helix() +{ + meshing_double_helix(); } // Demonstrate the backlash option for Spur gears. -//test_backlash (); +// test_backlash (); // Demonstrate how to make meshing bevel gears. -//test_bevel_gear_pair(); +// test_bevel_gear_pair(); -module test_bevel_gear_pair(){ - bevel_gear_pair (); +module +test_bevel_gear_pair() +{ + bevel_gear_pair(); } -module test_bevel_gear(){bevel_gear();} +module +test_bevel_gear() +{ + bevel_gear(); +} -//bevel_gear(); +// bevel_gear(); -pi=3.1415926535897932384626433832795; +pi = 3.1415926535897932384626433832795; //================================================== // Bevel Gears: -// Two gears with the same cone distance, circular pitch (measured at the cone distance) -// and pressure angle will mesh. - -module bevel_gear_pair ( - gear1_teeth = 41, - gear2_teeth = 7, - axis_angle = 90, - outside_circular_pitch=1000) +// Two gears with the same cone distance, circular pitch (measured at the cone +// distance) and pressure angle will mesh. + +module bevel_gear_pair(gear1_teeth = 41, + gear2_teeth = 7, + axis_angle = 90, + outside_circular_pitch = 1000) { - outside_pitch_radius1 = gear1_teeth * outside_circular_pitch / 360; - outside_pitch_radius2 = gear2_teeth * outside_circular_pitch / 360; - pitch_apex1=outside_pitch_radius2 * sin (axis_angle) + - (outside_pitch_radius2 * cos (axis_angle) + outside_pitch_radius1) / tan (axis_angle); - cone_distance = sqrt (pow (pitch_apex1, 2) + pow (outside_pitch_radius1, 2)); - pitch_apex2 = sqrt (pow (cone_distance, 2) - pow (outside_pitch_radius2, 2)); - echo ("cone_distance", cone_distance); - pitch_angle1 = asin (outside_pitch_radius1 / cone_distance); - pitch_angle2 = asin (outside_pitch_radius2 / cone_distance); - echo ("pitch_angle1, pitch_angle2", pitch_angle1, pitch_angle2); - echo ("pitch_angle1 + pitch_angle2", pitch_angle1 + pitch_angle2); - - rotate([0,0,90]) - translate ([0,0,pitch_apex1+20]) - { - translate([0,0,-pitch_apex1]) - bevel_gear ( - number_of_teeth=gear1_teeth, - cone_distance=cone_distance, - pressure_angle=30, - outside_circular_pitch=outside_circular_pitch); - - rotate([0,-(pitch_angle1+pitch_angle2),0]) - translate([0,0,-pitch_apex2]) - bevel_gear ( - number_of_teeth=gear2_teeth, - cone_distance=cone_distance, - pressure_angle=30, - outside_circular_pitch=outside_circular_pitch); - } + outside_pitch_radius1 = gear1_teeth * outside_circular_pitch / 360; + outside_pitch_radius2 = gear2_teeth * outside_circular_pitch / 360; + pitch_apex1 = + outside_pitch_radius2 * sin(axis_angle) + + (outside_pitch_radius2 * cos(axis_angle) + outside_pitch_radius1) / + tan(axis_angle); + cone_distance = sqrt(pow(pitch_apex1, 2) + pow(outside_pitch_radius1, 2)); + pitch_apex2 = sqrt(pow(cone_distance, 2) - pow(outside_pitch_radius2, 2)); + echo("cone_distance", cone_distance); + pitch_angle1 = asin(outside_pitch_radius1 / cone_distance); + pitch_angle2 = asin(outside_pitch_radius2 / cone_distance); + echo("pitch_angle1, pitch_angle2", pitch_angle1, pitch_angle2); + echo("pitch_angle1 + pitch_angle2", pitch_angle1 + pitch_angle2); + + rotate([ 0, 0, 90 ]) translate([ 0, 0, pitch_apex1 + 20 ]) + { + translate([ 0, 0, -pitch_apex1 ]) + bevel_gear(number_of_teeth = gear1_teeth, + cone_distance = cone_distance, + pressure_angle = 30, + outside_circular_pitch = outside_circular_pitch); + + rotate([ 0, -(pitch_angle1 + pitch_angle2), 0 ]) + translate([ 0, 0, -pitch_apex2 ]) + bevel_gear(number_of_teeth = gear2_teeth, + cone_distance = cone_distance, + pressure_angle = 30, + outside_circular_pitch = outside_circular_pitch); + } } -//Bevel Gear Finishing Options: +// Bevel Gear Finishing Options: bevel_gear_flat = 0; bevel_gear_back_cone = 1; -module bevel_gear ( - number_of_teeth=11, - cone_distance=100, - face_width=20, - outside_circular_pitch=1000, - pressure_angle=30, - clearance = 0.2, - bore_diameter=5, - gear_thickness = 15, - backlash = 0, - involute_facets=0, - finish = -1) +module bevel_gear(number_of_teeth = 11, + cone_distance = 100, + face_width = 20, + outside_circular_pitch = 1000, + pressure_angle = 30, + clearance = 0.2, + bore_diameter = 5, + gear_thickness = 15, + backlash = 0, + involute_facets = 0, + finish = -1) { - echo ("bevel_gear", - "teeth", number_of_teeth, - "cone distance", cone_distance, - face_width, - outside_circular_pitch, - pressure_angle, - clearance, - bore_diameter, - involute_facets, - finish); - - // Pitch diameter: Diameter of pitch circle at the fat end of the gear. - outside_pitch_diameter = number_of_teeth * outside_circular_pitch / 180; - outside_pitch_radius = outside_pitch_diameter / 2; - - // The height of the pitch apex. - pitch_apex = sqrt (pow (cone_distance, 2) - pow (outside_pitch_radius, 2)); - pitch_angle = asin (outside_pitch_radius/cone_distance); - - echo ("Num Teeth:", number_of_teeth, " Pitch Angle:", pitch_angle); - - finish = (finish != -1) ? finish : (pitch_angle < 45) ? bevel_gear_flat : bevel_gear_back_cone; - - apex_to_apex=cone_distance / cos (pitch_angle); - back_cone_radius = apex_to_apex * sin (pitch_angle); - - // Calculate and display the pitch angle. This is needed to determine the angle to mount two meshing cone gears. - - // Base Circle for forming the involute teeth shape. - base_radius = back_cone_radius * cos (pressure_angle); - - // Diametrial pitch: Number of teeth per unit length. - pitch_diametrial = number_of_teeth / outside_pitch_diameter; - - // Addendum: Radial distance from pitch circle to outside circle. - addendum = 1 / pitch_diametrial; - // Outer Circle - outer_radius = back_cone_radius + addendum; - - // Dedendum: Radial distance from pitch circle to root diameter - dedendum = addendum + clearance; - dedendum_angle = atan (dedendum / cone_distance); - root_angle = pitch_angle - dedendum_angle; - - root_cone_full_radius = tan (root_angle)*apex_to_apex; - back_cone_full_radius=apex_to_apex / tan (pitch_angle); - - back_cone_end_radius = - outside_pitch_radius - - dedendum * cos (pitch_angle) - - gear_thickness / tan (pitch_angle); - back_cone_descent = dedendum * sin (pitch_angle) + gear_thickness; - - // Root diameter: Diameter of bottom of tooth spaces. - root_radius = back_cone_radius - dedendum; - - half_tooth_thickness = outside_pitch_radius * sin (360 / (4 * number_of_teeth)) - backlash / 4; - half_thick_angle = asin (half_tooth_thickness / back_cone_radius); - - face_cone_height = apex_to_apex-face_width / cos (pitch_angle); - face_cone_full_radius = face_cone_height / tan (pitch_angle); - face_cone_descent = dedendum * sin (pitch_angle); - face_cone_end_radius = - outside_pitch_radius - - face_width / sin (pitch_angle) - - face_cone_descent / tan (pitch_angle); - - // For the bevel_gear_flat finish option, calculate the height of a cube to select the portion of the gear that includes the full pitch face. - bevel_gear_flat_height = pitch_apex - (cone_distance - face_width) * cos (pitch_angle); - -// translate([0,0,-pitch_apex]) - difference () - { - intersection () - { - union() - { - rotate (half_thick_angle) - translate ([0,0,pitch_apex-apex_to_apex]) - cylinder ($fn=number_of_teeth*2, r1=root_cone_full_radius,r2=0,h=apex_to_apex); - for (i = [1:number_of_teeth]) -// for (i = [1:1]) - { - rotate ([0,0,i*360/number_of_teeth]) - { - involute_bevel_gear_tooth ( - back_cone_radius = back_cone_radius, - root_radius = root_radius, - base_radius = base_radius, - outer_radius = outer_radius, - pitch_apex = pitch_apex, - cone_distance = cone_distance, - half_thick_angle = half_thick_angle, - involute_facets = involute_facets); - } - } - } - - if (finish == bevel_gear_back_cone) - { - translate ([0,0,-back_cone_descent]) - cylinder ( - $fn=number_of_teeth*2, - r1=back_cone_end_radius, - r2=back_cone_full_radius*2, - h=apex_to_apex + back_cone_descent); - } - else - { - translate ([-1.5*outside_pitch_radius,-1.5*outside_pitch_radius,0]) - cube ([3*outside_pitch_radius, - 3*outside_pitch_radius, - bevel_gear_flat_height]); - } - } - - if (finish == bevel_gear_back_cone) - { - translate ([0,0,-face_cone_descent]) - cylinder ( - r1=face_cone_end_radius, - r2=face_cone_full_radius * 2, - h=face_cone_height + face_cone_descent+pitch_apex); - } - - translate ([0,0,pitch_apex - apex_to_apex]) - cylinder (r=bore_diameter/2,h=apex_to_apex); - } + echo("bevel_gear", + "teeth", + number_of_teeth, + "cone distance", + cone_distance, + face_width, + outside_circular_pitch, + pressure_angle, + clearance, + bore_diameter, + involute_facets, + finish); + + // Pitch diameter: Diameter of pitch circle at the fat end of the gear. + outside_pitch_diameter = number_of_teeth * outside_circular_pitch / 180; + outside_pitch_radius = outside_pitch_diameter / 2; + + // The height of the pitch apex. + pitch_apex = sqrt(pow(cone_distance, 2) - pow(outside_pitch_radius, 2)); + pitch_angle = asin(outside_pitch_radius / cone_distance); + + echo("Num Teeth:", number_of_teeth, " Pitch Angle:", pitch_angle); + + finish = (finish != -1) + ? finish + : (pitch_angle < 45) ? bevel_gear_flat : bevel_gear_back_cone; + + apex_to_apex = cone_distance / cos(pitch_angle); + back_cone_radius = apex_to_apex * sin(pitch_angle); + + // Calculate and display the pitch angle. This is needed to determine the + // angle to mount two meshing cone gears. + + // Base Circle for forming the involute teeth shape. + base_radius = back_cone_radius * cos(pressure_angle); + + // Diametrial pitch: Number of teeth per unit length. + pitch_diametrial = number_of_teeth / outside_pitch_diameter; + + // Addendum: Radial distance from pitch circle to outside circle. + addendum = 1 / pitch_diametrial; + // Outer Circle + outer_radius = back_cone_radius + addendum; + + // Dedendum: Radial distance from pitch circle to root diameter + dedendum = addendum + clearance; + dedendum_angle = atan(dedendum / cone_distance); + root_angle = pitch_angle - dedendum_angle; + + root_cone_full_radius = tan(root_angle) * apex_to_apex; + back_cone_full_radius = apex_to_apex / tan(pitch_angle); + + back_cone_end_radius = outside_pitch_radius - dedendum * cos(pitch_angle) - + gear_thickness / tan(pitch_angle); + back_cone_descent = dedendum * sin(pitch_angle) + gear_thickness; + + // Root diameter: Diameter of bottom of tooth spaces. + root_radius = back_cone_radius - dedendum; + + half_tooth_thickness = + outside_pitch_radius * sin(360 / (4 * number_of_teeth)) - backlash / 4; + half_thick_angle = asin(half_tooth_thickness / back_cone_radius); + + face_cone_height = apex_to_apex - face_width / cos(pitch_angle); + face_cone_full_radius = face_cone_height / tan(pitch_angle); + face_cone_descent = dedendum * sin(pitch_angle); + face_cone_end_radius = outside_pitch_radius - face_width / sin(pitch_angle) - + face_cone_descent / tan(pitch_angle); + + // For the bevel_gear_flat finish option, calculate the height of a cube to + // select the portion of the gear that includes the full pitch face. + bevel_gear_flat_height = + pitch_apex - (cone_distance - face_width) * cos(pitch_angle); + + // translate([0,0,-pitch_apex]) + difference() + { + intersection() + { + union() + { + rotate(half_thick_angle) translate([ 0, 0, pitch_apex - apex_to_apex ]) + cylinder($fn = number_of_teeth * 2, + r1 = root_cone_full_radius, + r2 = 0, + h = apex_to_apex); + for (i = [1:number_of_teeth]) + // for (i = [1:1]) + { + rotate([ 0, 0, i * 360 / number_of_teeth ]) + { + involute_bevel_gear_tooth(back_cone_radius = back_cone_radius, + root_radius = root_radius, + base_radius = base_radius, + outer_radius = outer_radius, + pitch_apex = pitch_apex, + cone_distance = cone_distance, + half_thick_angle = half_thick_angle, + involute_facets = involute_facets); + } + } + } + + if (finish == bevel_gear_back_cone) { + translate([ 0, 0, -back_cone_descent ]) + cylinder($fn = number_of_teeth * 2, + r1 = back_cone_end_radius, + r2 = back_cone_full_radius * 2, + h = apex_to_apex + back_cone_descent); + } else { + translate( + [ -1.5 * outside_pitch_radius, -1.5 * outside_pitch_radius, 0 ]) + cube([ + 3 * outside_pitch_radius, + 3 * outside_pitch_radius, + bevel_gear_flat_height + ]); + } + } + + if (finish == bevel_gear_back_cone) { + translate([ 0, 0, -face_cone_descent ]) + cylinder(r1 = face_cone_end_radius, + r2 = face_cone_full_radius * 2, + h = face_cone_height + face_cone_descent + pitch_apex); + } + + translate([ 0, 0, pitch_apex - apex_to_apex ]) + cylinder(r = bore_diameter / 2, h = apex_to_apex); + } } -module involute_bevel_gear_tooth ( - back_cone_radius, - root_radius, - base_radius, - outer_radius, - pitch_apex, - cone_distance, - half_thick_angle, - involute_facets) +module involute_bevel_gear_tooth(back_cone_radius, + root_radius, + base_radius, + outer_radius, + pitch_apex, + cone_distance, + half_thick_angle, + involute_facets) { -// echo ("involute_bevel_gear_tooth", -// back_cone_radius, -// root_radius, -// base_radius, -// outer_radius, -// pitch_apex, -// cone_distance, -// half_thick_angle); - - min_radius = max (base_radius*2,root_radius*2); - - pitch_point = - involute ( - base_radius*2, - involute_intersect_angle (base_radius*2, back_cone_radius*2)); - pitch_angle = atan2 (pitch_point[1], pitch_point[0]); - centre_angle = pitch_angle + half_thick_angle; - - start_angle = involute_intersect_angle (base_radius*2, min_radius); - stop_angle = involute_intersect_angle (base_radius*2, outer_radius*2); - - res=(involute_facets!=0)?involute_facets:($fn==0)?5:$fn/4; - - translate ([0,0,pitch_apex]) - rotate ([0,-atan(back_cone_radius/cone_distance),0]) - translate ([-back_cone_radius*2,0,-cone_distance*2]) - union () - { - for (i=[1:res]) - { - assign ( - point1= - involute (base_radius*2,start_angle+(stop_angle - start_angle)*(i-1)/res), - point2= - involute (base_radius*2,start_angle+(stop_angle - start_angle)*(i)/res)) - { - assign ( - side1_point1 = rotate_2dvector (centre_angle, point1), - side1_point2 = rotate_2dvector (centre_angle, point2), - side2_point1 = mirror_2dvector (rotate_2dvector (centre_angle, point1)), - side2_point2 = mirror_2dvector (rotate_2dvector (centre_angle, point2))) - { - polyhedron ( - points=[ - [back_cone_radius*2+0.1,0,cone_distance*2], - [side1_point1[0],side1_point1[1],0], - [side1_point2[0],side1_point2[1],0], - [side2_point2[0],side2_point2[1],0], - [side2_point1[0],side2_point1[1],0], - [0.1,0,0]], - triangles=[[0,2,1],[0,3,2],[0,4,3],[0,1,5],[1,2,5],[2,3,5],[3,4,5],[0,5,4]]); - } - } - } - } + // echo ("involute_bevel_gear_tooth", + // back_cone_radius, + // root_radius, + // base_radius, + // outer_radius, + // pitch_apex, + // cone_distance, + // half_thick_angle); + + min_radius = max(base_radius * 2, root_radius * 2); + + pitch_point = + involute(base_radius * 2, + involute_intersect_angle(base_radius * 2, back_cone_radius * 2)); + pitch_angle = atan2(pitch_point[1], pitch_point[0]); + centre_angle = pitch_angle + half_thick_angle; + + start_angle = involute_intersect_angle(base_radius * 2, min_radius); + stop_angle = involute_intersect_angle(base_radius * 2, outer_radius * 2); + + res = (involute_facets != 0) ? involute_facets : ($fn == 0) ? 5 : $fn / 4; + + translate([ 0, 0, pitch_apex ]) + rotate([ 0, -atan(back_cone_radius / cone_distance), 0 ]) + translate([ -back_cone_radius * 2, 0, -cone_distance * 2 ]) union() + { + for (i = [1:res]) { + assign( + point1 = + involute(base_radius * 2, + start_angle + (stop_angle - start_angle) * (i - 1) / res), + point2 = involute(base_radius * 2, + start_angle + (stop_angle - start_angle) * (i) / res)) + { + assign( + side1_point1 = rotate_2dvector(centre_angle, point1), + side1_point2 = rotate_2dvector(centre_angle, point2), + side2_point1 = mirror_2dvector(rotate_2dvector(centre_angle, point1)), + side2_point2 = mirror_2dvector(rotate_2dvector(centre_angle, point2))) + { + polyhedron(points = + [[back_cone_radius * 2 + 0.1, 0, cone_distance * 2], + [side1_point1 [0], side1_point1 [1], 0], + [side1_point2 [0], side1_point2 [1], 0], + [side2_point2 [0], side2_point2 [1], 0], + [side2_point1 [0], side2_point1 [1], 0], + [0.1, 0, 0]], + triangles = [ + [ 0, 2, 1 ], + [ 0, 3, 2 ], + [ 0, 4, 3 ], + [ 0, 1, 5 ], + [ 1, 2, 5 ], + [ 2, 3, 5 ], + [ 3, 4, 5 ], + [ 0, 5, 4 ] + ]); + } + } + } + } } - - -module gear ( - number_of_teeth=15, - circular_pitch=false, diametral_pitch=false, - pressure_angle=28, - clearance = 0.2, - gear_thickness=5, - rim_thickness=8, - rim_width=5, - hub_thickness=10, - hub_diameter=15, - bore_diameter=5, - circles=0, - backlash=0, - twist=0, - helix_angle=0, - herringbone=false, - involute_facets=0, - flat=false, - roundsize=1, - internal = false) +module gear(number_of_teeth = 15, + circular_pitch = false, + diametral_pitch = false, + pressure_angle = 28, + clearance = 0.2, + gear_thickness = 5, + rim_thickness = 8, + rim_width = 5, + hub_thickness = 10, + hub_diameter = 15, + bore_diameter = 5, + circles = 0, + backlash = 0, + twist = 0, + helix_angle = 0, + herringbone = false, + involute_facets = 0, + flat = false, + roundsize = 1, + internal = false) { - if (circular_pitch==false && diametral_pitch==false) - echo("MCAD ERROR: gear module needs either a diametral_pitch or circular_pitch"); - - //Convert diametrial pitch to our native circular pitch - circular_pitch = (circular_pitch!=false?circular_pitch:180/diametral_pitch); - - // Pitch diameter: Diameter of pitch circle. - pitch_diameter = number_of_teeth * circular_pitch / 180; - pitch_radius = pitch_diameter/2; - pitch_circumference = PI * pitch_diameter; - echo ("Teeth:", number_of_teeth, " Pitch radius:", pitch_radius); - - twist = ( - (twist != 0) ? twist : - (tan (helix_angle) * rim_thickness / - pitch_circumference * 360) - ); - echo ("Twist: ", twist); - - // Base Circle - base_radius = pitch_radius*cos(pressure_angle); - - // Diametrial pitch: Number of teeth per unit length. - pitch_diametrial = number_of_teeth / pitch_diameter; - - // Addendum: Radial distance from pitch circle to outside circle. - addendum = 1/pitch_diametrial + (internal ? clearance : 0); - - //Outer Circle - outer_radius = pitch_radius+addendum; - - // Dedendum: Radial distance from pitch circle to root diameter - dedendum = addendum + (internal ? -clearance : clearance); - - // Root diameter: Diameter of bottom of tooth spaces. - root_radius = pitch_radius-dedendum; - backlash_angle = (internal ? -backlash : backlash) / pitch_radius * 180 / pi; - half_thick_angle = (360 / number_of_teeth - backlash_angle) / 4; - - // Variables controlling the rim. - rim_radius = internal ? outer_radius + rim_width : root_radius - rim_width; - - // Variables controlling the circular holes in the gear. - circle_orbit_diameter=hub_diameter/2+min(rim_radius, root_radius); - circle_orbit_curcumference=pi*circle_orbit_diameter; - - max_thickness = max (rim_thickness, hub_thickness, gear_thickness); - - // Limit the circle size to 90% of the gear face. - circle_diameter= - min ( - 0.70*circle_orbit_curcumference/circles, - (min(rim_radius, root_radius)-hub_diameter/2)*0.9); - - module flat_gear () - { - module _gear_shape () - { - gear_shape ( - number_of_teeth, - pitch_radius = pitch_radius, - root_radius = root_radius, - base_radius = base_radius, - outer_radius = outer_radius, - half_thick_angle = half_thick_angle, - involute_facets=involute_facets); - } - - module rounding_circles () - { - path_radius = internal ? outer_radius : root_radius; - circle_positions = (internal ? - [0:1:number_of_teeth] : - [0.5:1:number_of_teeth - 0.5]); - - if (roundsize > 0) - for (i=circle_positions) { - rotate([0, 0, (i*360/number_of_teeth)]) - translate([path_radius, 0]) - circle(r=((360/number_of_teeth - half_thick_angle)/360) * pi*root_radius/2 * roundsize, $fa = 18, $fs = 0.5); - } - } - - if (internal) - union () { - _gear_shape (); - rounding_circles (); - } else - difference() { - _gear_shape (); - rounding_circles (); - } - } - - // render the extruded gear shape (or cutout for internal gear) - module extruded_gear () - { - lower_rim_thickness = ( - rim_thickness / 2 + - ((internal && gear_thickness == 0) ? 0.1 : 0) - ); - lower_twist = twist / rim_thickness * lower_rim_thickness; - - upper_rim_thickness = ( - rim_thickness / 2 + - ((internal) ? 0.1 : 0) - ); - upper_twist = twist / rim_thickness * upper_rim_thickness; - - if (flat) { - flat_gear (); - - } else if (herringbone) { - translate ([0, 0, rim_thickness / 2]) { - linear_extrude ( - height = upper_rim_thickness, - convexity = 10, - twist = upper_twist - ) - flat_gear (); - - mirror ([0, 0, 1]) - linear_extrude ( - height = lower_rim_thickness, - convexity = 10, - twist = lower_twist - ) - flat_gear (); - } - - } else { - linear_extrude( - height = rim_thickness + (internal ? 0.2 : 0), - convexity = 10, - twist = twist - ) - flat_gear (); - } - } - - module ensure_rim () - { - if (flat) { - children (); - - } else if (internal) { - difference () { - linear_extrude (height = rim_thickness) - circle (r = rim_radius); - - translate ([0, 0, gear_thickness]) - children (); - } - - } else if (gear_thickness > rim_thickness) { - union () { - children (); - - linear_extrude_flat_option ( - flat = flat, - height = gear_thickness - ) - circle (r = rim_radius); - } - } else { - difference () { - children (); - - translate ([0, 0, gear_thickness]) - linear_extrude_flat_option ( - flat = flat, - height = (rim_thickness - gear_thickness - + 0.1) - ) - circle (r = rim_radius); - } - } - } - - module hub () - { - if (internal) - cylinder (d=hub_diameter, h=hub_thickness); - - else if (!flat) - translate ([0, 0, gear_thickness]) - cylinder (d=hub_diameter, h=hub_thickness - gear_thickness); - } - - module _circles () - { - if (circles > 1) - for (i=[0:circles-1]) - rotate ([0, 0, i*360/circles]) - translate ([circle_orbit_diameter / 2, 0, 0]) - circle (r=circle_diameter / 2); - } - - module bore () - { - circle (d = bore_diameter); - } - - difference () { - union () { - ensure_rim () - extruded_gear (); - - hub (); - } - - linear_extrude_flat_option ( - flat = flat, - center = true, - height = (max_thickness + 0.1) * 2 - ) - union () { - _circles (); - bore (); - } - } + if (circular_pitch == false && diametral_pitch == false) + echo("MCAD ERROR: gear module needs either a diametral_pitch or " + "circular_pitch"); + + // Convert diametrial pitch to our native circular pitch + circular_pitch = + (circular_pitch != false ? circular_pitch : 180 / diametral_pitch); + + // Pitch diameter: Diameter of pitch circle. + pitch_diameter = number_of_teeth * circular_pitch / 180; + pitch_radius = pitch_diameter / 2; + pitch_circumference = PI * pitch_diameter; + echo("Teeth:", number_of_teeth, " Pitch radius:", pitch_radius); + + twist = ((twist != 0) + ? twist + : (tan(helix_angle) * rim_thickness / pitch_circumference * 360)); + echo("Twist: ", twist); + + // Base Circle + base_radius = pitch_radius * cos(pressure_angle); + + // Diametrial pitch: Number of teeth per unit length. + pitch_diametrial = number_of_teeth / pitch_diameter; + + // Addendum: Radial distance from pitch circle to outside circle. + addendum = 1 / pitch_diametrial + (internal ? clearance : 0); + + // Outer Circle + outer_radius = pitch_radius + addendum; + + // Dedendum: Radial distance from pitch circle to root diameter + dedendum = addendum + (internal ? -clearance : clearance); + + // Root diameter: Diameter of bottom of tooth spaces. + root_radius = pitch_radius - dedendum; + backlash_angle = (internal ? -backlash : backlash) / pitch_radius * 180 / pi; + half_thick_angle = (360 / number_of_teeth - backlash_angle) / 4; + + // Variables controlling the rim. + rim_radius = internal ? outer_radius + rim_width : root_radius - rim_width; + + // Variables controlling the circular holes in the gear. + circle_orbit_diameter = hub_diameter / 2 + min(rim_radius, root_radius); + circle_orbit_curcumference = pi * circle_orbit_diameter; + + max_thickness = max(rim_thickness, hub_thickness, gear_thickness); + + // Limit, the circle size to 90% of the gear face. + circle_diameter = + min(0.70 * circle_orbit_curcumference / circles, + (min(rim_radius, root_radius) - hub_diameter / 2) * 0.9); + + module flat_gear() + { + module _gear_shape() + { + gear_shape(number_of_teeth, + pitch_radius = pitch_radius, + root_radius = root_radius, + base_radius = base_radius, + outer_radius = outer_radius, + half_thick_angle = half_thick_angle, + involute_facets = involute_facets); + } + + module rounding_circles() + { + path_radius = internal ? outer_radius : root_radius; + circle_positions = + (internal ? [0:1:number_of_teeth] : [0.5:1:number_of_teeth - 0.5]); + + if (roundsize > 0) + for (i = circle_positions) { + rotate([ 0, 0, (i * 360 / number_of_teeth) ]) + translate([ path_radius, 0 ]) + circle(r = ((360 / number_of_teeth - half_thick_angle) / 360) * + pi * root_radius / 2 * roundsize, + $fa = 18, + $fs = 0.5); + } + } + + if (internal) + union() + { + _gear_shape(); + rounding_circles(); + } + else + difference() + { + _gear_shape(); + rounding_circles(); + } + } + + // render the extruded gear shape (or cutout for internal gear) + module extruded_gear() + { + lower_rim_thickness = + (rim_thickness / 2 + ((internal && gear_thickness == 0) ? 0.1 : 0)); + lower_twist = twist / rim_thickness * lower_rim_thickness; + + upper_rim_thickness = (rim_thickness / 2 + ((internal) ? 0.1 : 0)); + upper_twist = twist / rim_thickness * upper_rim_thickness; + + if (flat) { + flat_gear(); + + } else if (herringbone) { + translate([ 0, 0, rim_thickness / 2 ]) + { + linear_extrude(height = upper_rim_thickness, + convexity = 10, + twist = upper_twist) flat_gear(); + + mirror([ 0, 0, 1 ]) linear_extrude(height = lower_rim_thickness, + convexity = 10, + twist = lower_twist) flat_gear(); + } + + } else { + linear_extrude(height = rim_thickness + (internal ? 0.2 : 0), + convexity = 10, + twist = twist) flat_gear(); + } + } + + module ensure_rim() + { + if (flat) { + children(); + + } else if (internal) { + difference() + { + linear_extrude(height = rim_thickness) circle(r = rim_radius); + + translate([ 0, 0, gear_thickness ]) children(); + } + + } else if (gear_thickness > rim_thickness) { + union() + { + children(); + + linear_extrude_flat_option(flat = flat, height = gear_thickness) + circle(r = rim_radius); + } + } else { + difference() + { + children(); + + translate([ 0, 0, gear_thickness ]) linear_extrude_flat_option( + flat = flat, height = (rim_thickness - gear_thickness + 0.1)) + circle(r = rim_radius); + } + } + } + + module hub() + { + if (internal) + cylinder(d = hub_diameter, h = hub_thickness); + + else if (!flat) + translate([ 0, 0, gear_thickness ]) + cylinder(d = hub_diameter, h = hub_thickness - gear_thickness); + } + + module _circles() + { + if (circles > 1) + for (i = [0:circles - 1]) + rotate([ 0, 0, i * 360 / circles ]) + translate([ circle_orbit_diameter / 2, 0, 0 ]) + circle(r = circle_diameter / 2); + } + + module bore() { circle(d = bore_diameter); } + + difference() + { + union() + { + ensure_rim() extruded_gear(); + + hub(); + } + + linear_extrude_flat_option( + flat = flat, center = true, height = (max_thickness + 0.1) * 2) union() + { + _circles(); + bore(); + } + } } -module linear_extrude_flat_option(flat =false, height = 10, center = false, convexity = 2, twist = 0) +module linear_extrude_flat_option(flat = false, + height = 10, + center = false, + convexity = 2, + twist = 0) { - if(flat==false) - { - linear_extrude(height = height, center = center, convexity = convexity, twist= twist) - children (); - } - else - { - children (); - } - + if (flat == false) { + linear_extrude( + height = height, center = center, convexity = convexity, twist = twist) + children(); + } else { + children(); + } } - -module gear_shape ( - number_of_teeth, - pitch_radius, - root_radius, - base_radius, - outer_radius, - half_thick_angle, - involute_facets) +module gear_shape(number_of_teeth, + pitch_radius, + root_radius, + base_radius, + outer_radius, + half_thick_angle, + involute_facets) { - - union() - { - rotate (half_thick_angle) circle ($fn=number_of_teeth*2, r=root_radius); - - for (i = [1:number_of_teeth]) - { - - rotate ([0,0,i*360/number_of_teeth]) - { - involute_gear_tooth ( - pitch_radius = pitch_radius, - root_radius = root_radius, - base_radius = base_radius, - outer_radius = outer_radius, - half_thick_angle = half_thick_angle, - involute_facets=involute_facets); - } - } - } + union() + { + rotate(half_thick_angle) circle($fn = number_of_teeth * 2, r = root_radius); + + for (i = [1:number_of_teeth]) { + + rotate([ 0, 0, i * 360 / number_of_teeth ]) + { + involute_gear_tooth(pitch_radius = pitch_radius, + root_radius = root_radius, + base_radius = base_radius, + outer_radius = outer_radius, + half_thick_angle = half_thick_angle, + involute_facets = involute_facets); + } + } + } } - -module involute_gear_tooth ( - pitch_radius, - root_radius, - base_radius, - outer_radius, - half_thick_angle, - involute_facets) +module involute_gear_tooth(pitch_radius, + root_radius, + base_radius, + outer_radius, + half_thick_angle, + involute_facets) { - min_radius = max (base_radius,root_radius); + min_radius = max(base_radius, root_radius); - pitch_point = involute (base_radius, involute_intersect_angle (base_radius, pitch_radius)); - pitch_angle = atan2 (pitch_point[1], pitch_point[0]); - centre_angle = pitch_angle + half_thick_angle; + pitch_point = + involute(base_radius, involute_intersect_angle(base_radius, pitch_radius)); + pitch_angle = atan2(pitch_point[1], pitch_point[0]); + centre_angle = pitch_angle + half_thick_angle; - start_angle = involute_intersect_angle (base_radius, min_radius); - stop_angle = involute_intersect_angle (base_radius, outer_radius); + start_angle = involute_intersect_angle(base_radius, min_radius); + stop_angle = involute_intersect_angle(base_radius, outer_radius); - res=(involute_facets!=0)?involute_facets:($fn==0)?5:$fn/4; + res = (involute_facets != 0) ? involute_facets : ($fn == 0) ? 5 : $fn / 4; - function reverse (v) = [ - for (i = [1:len (v)]) - v[len (v) - i] - ]; + function reverse(v) = [for (i = [1:len(v)]) v[len(v) - i]]; - side1_points = [ - for (i = [0:res]) - rotate_2dvector (centre_angle, involute (base_radius, start_angle + (stop_angle - start_angle) * i / res)) - ]; + side1_points = [for (i = [0:res]) rotate_2dvector( + centre_angle, + involute(base_radius, start_angle + (stop_angle - start_angle) * i / res))]; - side2_points = [ - for (i = reverse (side1_points)) - mirror_2dvector (i) - ]; + side2_points = [for (i = reverse(side1_points)) mirror_2dvector(i)]; - polygon (points = concat ([[0, 0]], side1_points, side2_points)); + polygon(points = concat([[ 0, 0 ]], side1_points, side2_points)); } // Mathematical Functions //=============== -// Finds the angle of the involute about the base radius at the given distance (radius) from it's center. -//source: http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html +// Finds the angle of the involute about the base radius at the given distance +// (radius) from it's center. +// source: +// http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html -function involute_intersect_angle (base_radius, radius) = sqrt (pow (radius/base_radius, 2) - 1) * 180 / pi; +function involute_intersect_angle(base_radius, radius) = + sqrt(pow(radius / base_radius, 2) - 1) * 180 / pi; // Calculate the involute position for a given base radius and involute angle. -function rotated_involute (rotate, base_radius, involute_angle) = -[ - cos (rotate) * involute (base_radius, involute_angle)[0] + sin (rotate) * involute (base_radius, involute_angle)[1], - cos (rotate) * involute (base_radius, involute_angle)[1] - sin (rotate) * involute (base_radius, involute_angle)[0] +function rotated_involute(rotate, base_radius, involute_angle) = [ + cos(rotate) * involute(base_radius, involute_angle)[0] + + sin(rotate) * involute(base_radius, involute_angle)[1], + cos(rotate) * involute(base_radius, involute_angle)[1] - + sin(rotate) * involute(base_radius, involute_angle)[0] ]; -function involute (base_radius, involute_angle) = -[ - base_radius*(cos (involute_angle) + involute_angle*pi/180*sin (involute_angle)), - base_radius*(sin (involute_angle) - involute_angle*pi/180*cos (involute_angle)) +function involute(base_radius, involute_angle) = [ + base_radius * + (cos(involute_angle) + involute_angle * pi / 180 * sin(involute_angle)), + base_radius*(sin(involute_angle) - + involute_angle * pi / 180 * cos(involute_angle)) ]; // For ease of conversion from proper circular pitch to this broken library's // values -function convertcp (circular_pitch) = circular_pitch / PI * 180; -function circumference2radius (circumference) = circumference / (2 * PI); -function gear_spacing (cp, nt1, nt2) = circumference2radius (cp * nt1) + - circumference2radius (cp * nt2); - +function convertcp(circular_pitch) = circular_pitch / PI * 180; +function circumference2radius(circumference) = circumference / (2 * PI); +function gear_spacing(cp, nt1, nt2) = circumference2radius(cp * nt1) + + circumference2radius(cp * nt2); // Test Cases //=============== -module test_gears() +module +test_gears() { - translate([17,-15]) - { - #gear (number_of_teeth=17, - circular_pitch=500, + translate([ 17, -15 ]) + { +#gear(number_of_teeth = 17, + circular_pitch=500, circles=8); - rotate ([0,0,360*4/17]) - translate ([39.088888,0,0]) - { - #gear (number_of_teeth=11, - circular_pitch=500, + rotate([ 0, 0, 360 * 4 / 17 ]) translate([ 39.088888, 0, 0 ]) + { +#gear(number_of_teeth = 11, + circular_pitch=500, hub_diameter=0, rim_width=65); - translate ([0,0,8]) - { - gear (number_of_teeth=6, - circular_pitch=300, - hub_diameter=0, - rim_width=5, - rim_thickness=6, - pressure_angle=31); - #rotate ([0,0,360*5/6]) - translate ([22.5,0,1]) - gear (number_of_teeth=21, - circular_pitch=300, - bore_diameter=2, - hub_diameter=4, - rim_width=1, - hub_thickness=4, - rim_thickness=4, - gear_thickness=3, - pressure_angle=31); - } - } - - translate ([-61.1111111,0,0]) - { - #gear (number_of_teeth=27, - circular_pitch=500, + translate([ 0, 0, 8 ]) + { + gear(number_of_teeth = 6, + circular_pitch = 300, + hub_diameter = 0, + rim_width = 5, + rim_thickness = 6, + pressure_angle = 31); +#rotate([ 0, 0, 360 * 5 / 6 ]) + translate([ 22.5, 0, 1 ]) gear(number_of_teeth = 21, + circular_pitch = 300, + bore_diameter = 2, + hub_diameter = 4, + rim_width = 1, + hub_thickness = 4, + rim_thickness = 4, + gear_thickness = 3, + pressure_angle = 31); + } + } + + translate([ -61.1111111, 0, 0 ]) + { +#gear(number_of_teeth = 27, + circular_pitch=500, circles=5, hub_diameter=2*8.88888889); - translate ([0,0,10]) - { - gear ( - number_of_teeth=14, - circular_pitch=200, - pressure_angle=5, - clearance = 0.2, - gear_thickness = 10, - rim_thickness = 10, - rim_width = 15, - bore_diameter=5, - circles=0); - translate ([13.8888888,0,1]) - #gear ( + translate([ 0, 0, 10 ]) + { + gear(number_of_teeth = 14, + circular_pitch = 200, + pressure_angle = 5, + clearance = 0.2, + gear_thickness = 10, + rim_thickness = 10, + rim_width = 15, + bore_diameter = 5, + circles = 0); + translate ([13.8888888,0,1]) +#gear( number_of_teeth=11, circular_pitch=200, pressure_angle=5, @@ -744,12 +718,12 @@ module test_gears() hub_diameter=2*7.222222, bore_diameter=5, circles=0); - } - } + } + } - rotate ([0,0,360*-5/17]) + rotate ([0,0,360*-5/17]) translate ([44.444444444,0,0]) - #gear (number_of_teeth=15, +#gear(number_of_teeth = 15, circular_pitch=500, hub_diameter=10, rim_width=5, @@ -758,117 +732,109 @@ module test_gears() hub_thickness=6, circles=9); - rotate ([0,0,360*-1/17]) + rotate ([0,0,360*-1/17]) translate ([30.5555555,0,-1]) - #gear (number_of_teeth=5, +#gear(number_of_teeth = 5, circular_pitch=500, hub_diameter=0, rim_width=5, rim_thickness=10); - } + } } -module meshing_double_helix () +module +meshing_double_helix() { - test_double_helix_gear (); + test_double_helix_gear(); - mirror ([0,1,0]) - translate ([58.33333333,0,0]) - test_double_helix_gear (teeth=13,circles=6); + mirror([ 0, 1, 0 ]) translate([ 58.33333333, 0, 0 ]) + test_double_helix_gear(teeth = 13, circles = 6); } -module test_double_helix_gear ( - teeth=17, - circles=8) +module test_double_helix_gear(teeth = 17, circles = 8) { - //double helical gear - { - twist=200; - height=20; - pressure_angle=30; - - gear (number_of_teeth=teeth, - circular_pitch=700, - pressure_angle=pressure_angle, - clearance = 0.2, - gear_thickness = height/2*0.5, - rim_thickness = height/2, - rim_width = 5, - hub_thickness = height/2*1.2, - hub_diameter=15, - bore_diameter=5, - circles=circles, - helix_angle=45, - herringbone=true); - *mirror([0,0,1]) - gear (number_of_teeth=teeth, - circular_pitch=700, - pressure_angle=pressure_angle, - clearance = 0.2, - gear_thickness = height/2, - rim_thickness = height/2, - rim_width = 5, - hub_thickness = height/2, - hub_diameter=15, - bore_diameter=5, - circles=circles, - twist=twist/teeth); - } + // double helical gear + { + twist = 200; + height = 20; + pressure_angle = 30; + + gear(number_of_teeth = teeth, + circular_pitch = 700, + pressure_angle = pressure_angle, + clearance = 0.2, + gear_thickness = height / 2 * 0.5, + rim_thickness = height / 2, + rim_width = 5, + hub_thickness = height / 2 * 1.2, + hub_diameter = 15, + bore_diameter = 5, + circles = circles, + helix_angle = 45, + herringbone = true); + *mirror([ 0, 0, 1 ]) gear(number_of_teeth = teeth, + circular_pitch = 700, + pressure_angle = pressure_angle, + clearance = 0.2, + gear_thickness = height / 2, + rim_thickness = height / 2, + rim_width = 5, + hub_thickness = height / 2, + hub_diameter = 15, + bore_diameter = 5, + circles = circles, + twist = twist / teeth); + } } -module test_backlash () +module +test_backlash() { - backlash = 2; - teeth = 15; - - translate ([-29.166666,0,0]) - { - translate ([58.3333333,0,0]) - rotate ([0,0,-360/teeth/4]) - gear ( - number_of_teeth = teeth, - circular_pitch=700, - gear_thickness = 12, - rim_thickness = 15, - rim_width = 5, - hub_thickness = 17, - hub_diameter=15, - bore_diameter=5, - backlash = 2, - circles=8); - - rotate ([0,0,360/teeth/4]) - gear ( - number_of_teeth = teeth, - circular_pitch=700, - gear_thickness = 12, - rim_thickness = 15, - rim_width = 5, - hub_thickness = 17, - hub_diameter=15, - bore_diameter=5, - backlash = 2, - circles=8); - } - - color([0,0,128,0.5]) - translate([0,0,-5]) - cylinder ($fn=20,r=backlash / 4,h=25); + backlash = 2; + teeth = 15; + + translate([ -29.166666, 0, 0 ]) + { + translate([ 58.3333333, 0, 0 ]) rotate([ 0, 0, -360 / teeth / 4 ]) + gear(number_of_teeth = teeth, + circular_pitch = 700, + gear_thickness = 12, + rim_thickness = 15, + rim_width = 5, + hub_thickness = 17, + hub_diameter = 15, + bore_diameter = 5, + backlash = 2, + circles = 8); + + rotate([ 0, 0, 360 / teeth / 4 ]) gear(number_of_teeth = teeth, + circular_pitch = 700, + gear_thickness = 12, + rim_thickness = 15, + rim_width = 5, + hub_thickness = 17, + hub_diameter = 15, + bore_diameter = 5, + backlash = 2, + circles = 8); + } + + color([ 0, 0, 128, 0.5 ]) translate([ 0, 0, -5 ]) + cylinder($fn = 20, r = backlash / 4, h = 25); } -module test_internal_gear () +module +test_internal_gear() { - gear ( - number_of_teeth = 30, - circular_pitch = 5 * 180 / PI, - hub_thickness = 0, - rim_thickness = 10, - rim_width = 5, - gear_thickness = 0, - internal = true, - helix_angle = 45, - herringbone = true - ); + gear(number_of_teeth = 30, + circular_pitch = 5 * 180 / PI, + hub_thickness = 0, + rim_thickness = 10, + rim_width = 5, + gear_thickness = 0, + internal = true, + helix_angle = 45, + herringbone = true); } -*test_internal_gear (); +*test_internal_gear(); diff --git a/gears/rack_and_pinion.scad b/gears/rack_and_pinion.scad index 8ed01a64..8034932e 100644 --- a/gears/rack_and_pinion.scad +++ b/gears/rack_and_pinion.scad @@ -14,12 +14,12 @@ // Modular Rack by Mark "Ckaos" Moissette GNU GPL license. (Rack based on the // work of MattMoses and Fdavies // http://forums.reprap.org/read.php?1,51452,52099#msg-52099 and Forrest Higgs: -// +// // The originals have many fine additions such as helical gears which I've // dropped in favour of simplicity (as befits my needs) - it wouldn't be a big // jobs to nobble my changes backwards or their features forwards. -$fn=50; +$fn = 50; // examples of usage // include this in your code: @@ -30,171 +30,242 @@ $fn=50; // a simple pinion and translation / rotation to make it mesh the rack // translate([0,-8.5,0])rotate([0,0,360/10/2]) pinion(4,10,10,5); -include ; - - - -module rack(cp, N, width, thickness){ -// cp = circular pitch - for rack = pitch in mm/per tooth -// N = number of teeth -// width = width of rack -// thickness = thickness of support under teeth (0 for no support) - - a = 1.0*cp/const_pi; // addendum (also known as "module") - d = 1.1*cp/const_pi; // dedendum (this is set by a standard) - height=(d+a); - - // find the tangent of pressure angle once - tanPA = tan(20); - // length of bottom and top horizontal segments of tooth profile - botL = (cp/2 - 2*d*tanPA); - topL = (cp/2 - 2*a*tanPA); - - slantLng=tanPA*height; - realBase=2*slantLng+topL; - - offset=topL+botL+2*slantLng; - length=(realBase+botL)*N; - - supportSize=width; - translate([botL/2,0,0]) - rotate([90,0,0]){ - translate([0,supportSize/2,0]){ - union(){ - cube(size=[length,width,thickness],center=true); - for (i = [0:N-1]){ - translate([i*offset-length/2+realBase/2,0,thickness/2]){ - trapezoid([topL,supportSize],[realBase,supportSize],height); - } - } - } - } - } - } - -module pinion (cp, N, width, shaft_diameter, backlash=0){ -// cp= circular pitch - for pinion pitch in mm/per as measured along the ptich radius (~1/2 way up tooth) -// N= number of teeth -// width= width of the gear -// shaft_diameter= diameter of hole for shaft -// backlash - I think this is just a bodge for making things fit when printed but I never tested it - - if (cp==false && diametral_pitch==false) - echo("MCAD ERROR: pinion module needs either a diametral_pitch or cp"); - - //Convert diametrial pitch to our native circular pitch - cp = (cp!=false?cp:180/diametral_pitch); - - // Pitch diameter: Diameter of pitch circle. - pitch_diameter = N * cp / const_pi; - pitch_radius = pitch_diameter/2; - echo ("Teeth:", N, " Pitch radius:", pitch_radius); - // Base Circle - base_radius = pitch_radius*cos(20); - - // Addendum: Radial distance from pitch circle to outside circle. - addendum = cp/const_pi; - - //Outer Circle - outer_radius = pitch_radius+addendum; - - // Dedendum: Radial distance from pitch circle to root diameter - dedendum = addendum*1.1; - - // Root diameter: Diameter of bottom of tooth spaces. - root_radius = pitch_radius-dedendum; - - backlash_angle = backlash / pitch_radius * 180 / const_pi; - half_thick_angle = (360 / N - backlash_angle) / 4; - - difference(){ - linear_extrude (height=width, convexity=10, twist=0) - pinion_shape(N, pitch_radius = pitch_radius, root_radius = root_radius, - base_radius = base_radius, outer_radius = outer_radius, - half_thick_angle = half_thick_angle, involute_facets=0); - - translate([0,0,-1]) cylinder(r=shaft_diameter/2,h=2+width); - } - - echo("Root radius =",root_radius,"\nPitch radius=",pitch_radius,"\n Tip radius=",outer_radius,"\n"); - } - -module pinion_shape ( N, pitch_radius, root_radius, base_radius, outer_radius, half_thick_angle, involute_facets) { - union(){ - rotate (half_thick_angle) circle ($fn=N*2, r=root_radius); - for (i = [1:N]) { - rotate ([0,0,i*360/N]) { - involute_pinion_tooth ( - pitch_radius = pitch_radius, - root_radius = root_radius, - base_radius = base_radius, - outer_radius = outer_radius, - half_thick_angle = half_thick_angle, - involute_facets=involute_facets); - } - } - } - } - -module involute_pinion_tooth ( pitch_radius, root_radius, base_radius, outer_radius, half_thick_angle, involute_facets) { - min_radius = max (base_radius,root_radius); - - pitch_point = involute (base_radius, involute_intersect_angle (base_radius, pitch_radius)); - pitch_angle = atan2 (pitch_point[1], pitch_point[0]); - centre_angle = pitch_angle + half_thick_angle; - - start_angle = involute_intersect_angle (base_radius, min_radius); - stop_angle = involute_intersect_angle (base_radius, outer_radius); - - res=(involute_facets!=0)?involute_facets:($fn==0)?5:$fn/4; - - union () { - for (i=[1:res]) - assign ( point1=involute (base_radius,start_angle+(stop_angle - start_angle)*(i-1)/res), point2=involute (base_radius,start_angle+(stop_angle - start_angle)*i/res)) { - assign ( - side1_point1=rotate_point (centre_angle, point1), - side1_point2=rotate_point (centre_angle, point2), - side2_point1=mirror_point (rotate_point (centre_angle, point1)), - side2_point2=mirror_point (rotate_point (centre_angle, point2))) { - polygon ( points=[[0,0],side1_point1,side1_point2,side2_point2,side2_point1], paths=[[0,1,2,3,4,0]]); - } - } - } - } +include + +module rack(cp, N, width, thickness) +{ + // cp = circular pitch - for rack = pitch in mm/per tooth + // N = number of teeth + // width = width of rack + // thickness = thickness of support under teeth (0 for no support) + + a = 1.0 * cp / const_pi; // addendum (also known as "module") + d = 1.1 * cp / const_pi; // dedendum (this is set by a standard) + height = (d + a); + + // find the tangent of pressure angle once + tanPA = tan(20); + // length of bottom and top horizontal segments of tooth profile + botL = (cp / 2 - 2 * d * tanPA); + topL = (cp / 2 - 2 * a * tanPA); + + slantLng = tanPA * height; + realBase = 2 * slantLng + topL; + + offset = topL + botL + 2 * slantLng; + length = (realBase + botL) * N; + + supportSize = width; + translate([ botL / 2, 0, 0 ]) rotate([ 90, 0, 0 ]) + { + translate([ 0, supportSize / 2, 0 ]) + { + union() + { + cube(size = [ length, width, thickness ], center = true); + for (i = [0:N - 1]) { + translate( + [ i * offset - length / 2 + realBase / 2, 0, thickness / 2 ]) + { + trapezoid([ topL, supportSize ], [ realBase, supportSize ], height); + } + } + } + } + } +} + +module pinion(cp, N, width, shaft_diameter, backlash = 0) +{ + // cp= circular pitch - for pinion pitch in mm/per as measured along the ptich + // radius (~1/2 way up tooth) N= number of teeth width= width of the gear + // shaft_diameter= diameter of hole for shaft + // backlash - I think this is just a bodge for making things fit when printed + // but I never tested it + + if (cp == false && diametral_pitch == false) + echo("MCAD ERROR: pinion module needs either a diametral_pitch or cp"); + + // Convert diametrial pitch to our native circular pitch + cp = (cp != false ? cp : 180 / diametral_pitch); + + // Pitch diameter: Diameter of pitch circle. + pitch_diameter = N * cp / const_pi; + pitch_radius = pitch_diameter / 2; + echo("Teeth:", N, " Pitch radius:", pitch_radius); + // Base Circle + base_radius = pitch_radius * cos(20); + + // Addendum: Radial distance from pitch circle to outside circle. + addendum = cp / const_pi; + + // Outer Circle + outer_radius = pitch_radius + addendum; + + // Dedendum: Radial distance from pitch circle to root diameter + dedendum = addendum * 1.1; + + // Root diameter: Diameter of bottom of tooth spaces. + root_radius = pitch_radius - dedendum; + + backlash_angle = backlash / pitch_radius * 180 / const_pi; + half_thick_angle = (360 / N - backlash_angle) / 4; + + difference() + { + linear_extrude(height = width, convexity = 10, twist = 0) + pinion_shape(N, + pitch_radius = pitch_radius, + root_radius = root_radius, + base_radius = base_radius, + outer_radius = outer_radius, + half_thick_angle = half_thick_angle, + involute_facets = 0); + + translate([ 0, 0, -1 ]) cylinder(r = shaft_diameter / 2, h = 2 + width); + } + + echo("Root radius =", + root_radius, + "\nPitch radius=", + pitch_radius, + "\n Tip radius=", + outer_radius, + "\n"); +} + +module pinion_shape(N, + pitch_radius, + root_radius, + base_radius, + outer_radius, + half_thick_angle, + involute_facets) +{ + union() + { + rotate(half_thick_angle) circle($fn = N * 2, r = root_radius); + for (i = [1:N]) { + rotate([ 0, 0, i * 360 / N ]) + { + involute_pinion_tooth(pitch_radius = pitch_radius, + root_radius = root_radius, + base_radius = base_radius, + outer_radius = outer_radius, + half_thick_angle = half_thick_angle, + involute_facets = involute_facets); + } + } + } +} + +module involute_pinion_tooth(pitch_radius, + root_radius, + base_radius, + outer_radius, + half_thick_angle, + involute_facets) +{ + min_radius = max(base_radius, root_radius); + + pitch_point = + involute(base_radius, involute_intersect_angle(base_radius, pitch_radius)); + pitch_angle = atan2(pitch_point[1], pitch_point[0]); + centre_angle = pitch_angle + half_thick_angle; + + start_angle = involute_intersect_angle(base_radius, min_radius); + stop_angle = involute_intersect_angle(base_radius, outer_radius); + + res = (involute_facets != 0) ? involute_facets : ($fn == 0) ? 5 : $fn / 4; + + union() + { + for (i = [1:res]) + assign(point1 = involute(base_radius, + start_angle + + (stop_angle - start_angle) * (i - 1) / res), + point2 = involute( + base_radius, start_angle + (stop_angle - start_angle) * i / res)) + { + assign(side1_point1 = rotate_point(centre_angle, point1), + side1_point2 = rotate_point(centre_angle, point2), + side2_point1 = mirror_point(rotate_point(centre_angle, point1)), + side2_point2 = mirror_point(rotate_point(centre_angle, point2))) + { + polygon(points = + [ + [ 0, 0 ], + side1_point1, + side1_point2, + side2_point2, + side2_point1 + ], + paths = [[ 0, 1, 2, 3, 4, 0 ]]); + } + } + } +} // Mathematical Functions //=============== -// Finds the angle of the involute about the base radius at the given distance (radius) from it's center. -//source: http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html +// Finds the angle of the involute about the base radius at the given distance +// (radius) from it's center. +// source: +// http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html -function involute_intersect_angle (base_radius, radius) = sqrt (pow (radius/base_radius, 2) - 1) * 180 / const_pi; +function involute_intersect_angle(base_radius, radius) = + sqrt(pow(radius / base_radius, 2) - 1) * 180 / const_pi; // Calculate the involute position for a given base radius and involute angle. -function rotated_involute(rotate,base_radius,involute_angle)=[cos(rotate)*involute(base_radius, involute_angle)[0]+sin(rotate)*involute(base_radius, involute_angle)[1],cos(rotate)*involute(base_radius, involute_angle)[1]-sin(rotate)*involute(base_radius, involute_angle)[0]]; - -function mirror_point(coord)=[coord[0],-coord[1]]; - -function rotate_point(rotate,coord)=[cos(rotate)*coord[0]+sin(rotate)*coord[1],cos(rotate)*coord[1]-sin(rotate)*coord[0]]; - -function involute (base_radius, involute_angle)=[base_radius*(cos(involute_angle)+involute_angle*const_pi/180*sin(involute_angle)),base_radius*(sin(involute_angle)-involute_angle*const_pi/180*cos(involute_angle))]; - - - - -module trapezoid(top,base,height){ - //echo ("test",base[0]); - basePT1=[ -base[0]/2, base[1]/2, 0]; - basePT2=[ base[0]/2, base[1]/2, 0]; - basePT3=[ base[0]/2, -base[1]/2, 0]; - basePT4=[ -base[0]/2, -base[1]/2, 0]; - topPT1=[ -top[0]/2, top[1]/2, height]; - topPT2=[ top[0]/2, top[1]/2, height]; - topPT3=[ top[0]/2, -top[1]/2, height]; - topPT4=[ -top[0]/2, -top[1]/2, height]; - polyhedron(points=[ basePT1, basePT2, basePT3, basePT4, topPT1, topPT2, topPT3, topPT4],faces=[[0,1,2], [0,2,3],[3,7,0], [7,4,0],[1,6,2], [1,5,6],[2,6,3], [3,6,7],[5,1,0],[4,5,0],[7,5,4],[5,7,6]]); - } - - - +function rotated_involute(rotate, base_radius, involute_angle) = [ + cos(rotate) * involute(base_radius, involute_angle)[0] + + sin(rotate) * involute(base_radius, involute_angle)[1], + cos(rotate) * involute(base_radius, involute_angle)[1] - + sin(rotate) * involute(base_radius, involute_angle)[0] +]; + +function mirror_point(coord) = [ coord[0], -coord[1] ]; + +function rotate_point(rotate, coord) = [ + cos(rotate) * coord[0] + sin(rotate) * coord[1], + cos(rotate) * coord[1] - sin(rotate) * coord[0] +]; + +function involute(base_radius, involute_angle) = [ + base_radius * (cos(involute_angle) + + involute_angle * const_pi / 180 * sin(involute_angle)), + base_radius*(sin(involute_angle) - + involute_angle * const_pi / 180 * cos(involute_angle)) +]; + +module trapezoid(top, base, height) +{ + // echo ("test",base[0]); + basePT1 = [ -base[0] / 2, base[1] / 2, 0 ]; + basePT2 = [ base[0] / 2, base[1] / 2, 0 ]; + basePT3 = [ base[0] / 2, -base[1] / 2, 0 ]; + basePT4 = [ -base[0] / 2, -base[1] / 2, 0 ]; + topPT1 = [ -top[0] / 2, top[1] / 2, height ]; + topPT2 = [ top[0] / 2, top[1] / 2, height ]; + topPT3 = [ top[0] / 2, -top[1] / 2, height ]; + topPT4 = [ -top[0] / 2, -top[1] / 2, height ]; + polyhedron( + points = + [ basePT1, basePT2, basePT3, basePT4, topPT1, topPT2, topPT3, topPT4 ], + faces = [ + [ 0, 1, 2 ], + [ 0, 2, 3 ], + [ 3, 7, 0 ], + [ 7, 4, 0 ], + [ 1, 6, 2 ], + [ 1, 5, 6 ], + [ 2, 6, 3 ], + [ 3, 6, 7 ], + [ 5, 1, 0 ], + [ 4, 5, 0 ], + [ 7, 5, 4 ], + [ 5, 7, 6 ] + ]); +} diff --git a/general/constants.scad b/general/constants.scad index cb053d2a..4e2f6122 100644 --- a/general/constants.scad +++ b/general/constants.scad @@ -5,7 +5,7 @@ const_e = 2.71828182845904523536028747135266249775724709369995; // http://oeis.org/A000796 const_pi = 3.14159265358979323846264338327950288419716939937510; -// +// const_pi_div_180 = 0.01745329251994329576923690768489; // const_180_div_pi = 57.295779513082320876798154814105; diff --git a/general/facets.scad b/general/facets.scad index 66d2d260..da6ecb42 100644 --- a/general/facets.scad +++ b/general/facets.scad @@ -4,11 +4,11 @@ * * @param r Radius of circle */ -function get_fragments_from_r (r) = ( - ($fn > 0) ? $fn : - (r < 0.00000095367431640625) ? 3 : - ceil (max (min (360 / $fa, r * 2 * PI / $fs), 5)) -); +function get_fragments_from_r(r) = + (($fn > 0) ? $fn + : (r < 0.00000095367431640625) + ? 3 + : ceil(max(min(360 / $fa, r * 2 * PI / $fs), 5))); /** * This is a function that generates a series of values ala $t for use as facet @@ -16,19 +16,10 @@ function get_fragments_from_r (r) = ( * * @param r Radius of circle */ -function gen_facet_series (r) = [0 : 1.0 / get_fragments_from_r (r) : 1.0001]; +function gen_facet_series(r) = [0:1.0 / get_fragments_from_r(r):1.0001]; // example -translate ([0, 0, 10]) -linear_extrude (1) -circle (10, $fn = 10); +translate([ 0, 0, 10 ]) linear_extrude(1) circle(10, $fn = 10); -linear_extrude (1) -polygon ( - [ - let (r = 10) - for (t = gen_facet_series (r, $fn = 10)) - let (angle = t * 360) - [cos (angle) * r, sin (angle) * r] - ] -); +linear_extrude(1) polygon([let(r = 10) for (t = gen_facet_series(r, $fn = 10)) + let(angle = t * 360)[cos(angle) * r, sin(angle) * r]]); diff --git a/general/math.scad b/general/math.scad index 4dea9b0b..2cbbbae6 100644 --- a/general/math.scad +++ b/general/math.scad @@ -2,12 +2,13 @@ include -function deg(angle) = 360*angle/const_tau; +function deg(angle) = 360 * angle / const_tau; // transformations.scad // License: GNU LGPL 2.1 or later. // © 2010 by Elmo Mäntynen -module local_scale(v, reference=[0, 0, 0]) { - translate(-reference) scale(v) translate(reference) children(0); +module local_scale(v, reference = [ 0, 0, 0 ]) +{ + translate(-reference) scale(v) translate(reference) children(0); } diff --git a/general/sweep.scad b/general/sweep.scad index e7e3647e..a12a6f2e 100644 --- a/general/sweep.scad +++ b/general/sweep.scad @@ -1,51 +1,71 @@ use -use use +use -function rotation_from_axis(x,y,z) = [[x[0],y[0],z[0]],[x[1],y[1],z[1]],[x[2],y[2],z[2]]]; +function rotation_from_axis(x, y, z) = [[x [0], y [0], z [0]], + [x [1], y [1], z [1]], + [x [2], y [2], z [2]]]; -function rotate_from_to(a,b,_axis=[]) = - len(_axis) == 0 - ? rotate_from_to(a,b,unit(cross(a,b))) - : _axis*_axis >= 0.99 ? rotation_from_axis(unit(b),_axis,cross(_axis,unit(b))) * - transpose_3(rotation_from_axis(unit(a),_axis,cross(_axis,unit(a)))) : identity3(); +function rotate_from_to(a, b, _axis = []) = + len(_axis) == 0 + ? rotate_from_to(a, b, unit(cross(a, b))) + : _axis * _axis >= 0.99 + ? rotation_from_axis(unit(b), _axis, cross(_axis, unit(b))) * + transpose_3(rotation_from_axis(unit(a), + _axis, + cross(_axis, unit(a)))) + : identity3(); -function make_orthogonal(u,v) = unit(u - unit(v) * (unit(v) * u)); +function make_orthogonal(u, v) = unit(u - unit(v) * (unit(v) * u)); -// Prevent creeping nonorthogonality -function coerce(m) = [unit(m[0]), make_orthogonal(m[1],m[0]), make_orthogonal(make_orthogonal(m[2],m[0]),m[1])]; +// Prevent creeping nonorthogonality +function coerce(m) = [ + unit(m[0]), + make_orthogonal(m[1], m[0]), + make_orthogonal(make_orthogonal(m[2], m[0]), m[1]) +]; -function tangent_path(path, i) = -i == 0 ? - unit(path[1] - path[0]) : - (i == len(path)-1 ? - unit(path[i] - path[i-1]) : - unit(path[i+1]-path[i-1])); +function tangent_path(path, i) = i == 0 ? unit(path[1] - path[0]) + : (i == len(path) - 1 + ? unit(path[i] - path[i - 1]) + : unit(path[i + 1] - path[i - 1])); -function construct_rt(r,t) = [concat(r[0],t[0]),concat(r[1],t[1]),concat(r[2],t[2]),[0,0,0,1]]; +function construct_rt(r, t) = [ + concat(r[0], t[0]), + concat(r[1], t[1]), + concat(r[2], t[2]), + [ 0, 0, 0, 1 ] +]; -function construct_transform_path(path) = - [let (l=len(path)) - for (i=[0:l-1]) - construct_rt(rotate_from_to([0,0,1], tangent_path(path, i)), path[i])]; +function construct_transform_path(path) = [let(l = len(path)) for (i = [0:l - + 1]) + construct_rt(rotate_from_to([ 0, 0, 1 ], tangent_path(path, i)), path[i])]; -module sweep(shape, path_transforms, closed=false) { +module sweep(shape, path_transforms, closed = false) +{ - pathlen = len(path_transforms); - segments = pathlen + (closed ? 0 : -1); - shape3d = to_3d(shape); + pathlen = len(path_transforms); + segments = pathlen + (closed ? 0 : -1); + shape3d = to_3d(shape); - function sweep_points() = - flatten([for (i=[0:pathlen-1]) transform(path_transforms[i], shape3d)]); + function sweep_points() = + flatten([for (i = [0:pathlen - 1]) transform(path_transforms[i], shape3d)]); - function loop_faces() = [let (facets=len(shape3d)) - for(s=[0:segments-1], i=[0:facets-1]) - [(s%pathlen) * facets + i, - (s%pathlen) * facets + (i + 1) % facets, - ((s + 1) % pathlen) * facets + (i + 1) % facets, - ((s + 1) % pathlen) * facets + i]]; + function loop_faces() = [let( + facets = len( + shape3d)) for (s = [0:segments - 1], + i = [0:facets - + 1])[(s % pathlen) * facets + i, + (s % pathlen) * facets + (i + 1) % facets, + ((s + 1) % pathlen) * facets + (i + 1) % facets, + ((s + 1) % pathlen) * facets + i]]; - bottom_cap = closed ? [] : [[for (i=[len(shape3d)-1:-1:0]) i]]; - top_cap = closed ? [] : [[for (i=[0:len(shape3d)-1]) i+len(shape3d)*(pathlen-1)]]; - polyhedron(points = sweep_points(), faces = concat(loop_faces(), bottom_cap, top_cap), convexity=5); + bottom_cap = closed ? [] : [[for (i = [len(shape3d) - 1:-1:0]) i]]; + top_cap = + closed + ? [] + : [[for (i = [0:len(shape3d) - 1]) i + len(shape3d) * (pathlen - 1)]]; + polyhedron(points = sweep_points(), + faces = concat(loop_faces(), bottom_cap, top_cap), + convexity = 5); } diff --git a/general/utilities.scad b/general/utilities.scad index 897151c7..b1b5d259 100644 --- a/general/utilities.scad +++ b/general/utilities.scad @@ -2,80 +2,76 @@ * Utility functions. * * Originally by Hans Häggström, 2010. - * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later + * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or + * later */ include - /******************** Disance Poins ******************************/ -function distance3D(a,b) =sqrt( (a[0] - b[0])*(a[0] - b[0]) + - (a[1] - b[1])*(a[1] - b[1]) + - (a[2] - b[2])*(a[2] - b[2]) ); -//Obsolet -function distance(a, b) = distance3D(a,b); +function distance3D(a, b) = sqrt((a[0] - b[0]) * (a[0] - b[0]) + + (a[1] - b[1]) * (a[1] - b[1]) + + (a[2] - b[2]) * (a[2] - b[2])); +// Obsolet +function distance(a, b) = distance3D(a, b); -function distance2D(a,b) = sqrt( (a[0] - b[0])*(a[0] - b[0]) + - (a[1] - b[1])*(a[1] - b[1])); - -function distance1D(a,b) = sqrt(a*a+b*b); -//Obsolet -function length2(a) = distance1D(a[0],a[1]); +function distance2D(a, b) = sqrt((a[0] - b[0]) * (a[0] - b[0]) + + (a[1] - b[1]) * (a[1] - b[1])); +function distance1D(a, b) = sqrt(a * a + b * b); +// Obsolet +function length2(a) = distance1D(a[0], a[1]); /************************ vector *************************/ -function normalized(a) = a / (max(distance3D([0,0,0], a), 0.00001)); +function normalized(a) = a / (max(distance3D([ 0, 0, 0 ], a), 0.00001)); -function normalized_axis(a) = a == "x" ? [1, 0, 0]: - a == "y" ? [0, 1, 0]: - a == "z" ? [0, 0, 1]: normalized(a); +function normalized_axis(a) = a == "x" ? [ 1, 0, 0 ] + : a == "y" ? [ 0, 1, 0 ] + : a == "z" ? [ 0, 0, 1 ] + : normalized(a); -function angleOfNormalizedVector(n) = [0, -atan2(n[2], distance1D([n[0], n[1]])), atan2(n[1], n[0]) ]; +function angleOfNormalizedVector(n) = + [ 0, -atan2(n[2], distance1D([ n[0], n[1] ])), atan2(n[1], n[0]) ]; function angle(v) = angleOfNormalizedVector(normalized(v)); -function angleBetweenTwoPoints(a, b) = angle(normalized(b-a)); +function angleBetweenTwoPoints(a, b) = angle(normalized(b - a)); -function _angleVectore2D(a) = atan2(a[0],a[1]); -function angle_betweentTwoPoints2D (a,b) = _angleVectore2D(b-a); +function _angleVectore2D(a) = atan2(a[0], a[1]); +function angle_betweentTwoPoints2D(a, b) = _angleVectore2D(b - a); -function mirror_2dvector (coord) = -[ - coord[0], - -coord[1] -]; +function mirror_2dvector(coord) = [ coord[0], -coord[1] ]; -function rotate_2dvector (rotate, coord) = -[ - cos (rotate) * coord[0] + sin (rotate) * coord[1], - cos (rotate) * coord[1] - sin (rotate) * coord[0] +function rotate_2dvector(rotate, coord) = [ + cos(rotate) * coord[0] + sin(rotate) * coord[1], + cos(rotate) * coord[1] - sin(rotate) * coord[0] ]; - - - /********************** Circel ***************************/ function circel_area(r) = const_pi * r * r; -function circel_radius3Points(a,b,c) = (distance2D(a,b) * distance2D(b,c) * distance2D(c,a)) / (4 * triangle_area3Points(a,b,c)); - -function circel_radius3lengths(a,b,c) = (a*b*c) / (4 * triangle_area3lengths(a,b,c)); +function circel_radius3Points(a, b, c) = (distance2D(a, b) * distance2D(b, c) * + distance2D(c, a)) / + (4 * triangle_area3Points(a, b, c)); +function circel_radius3lengths(a, b, c) = (a * b * c) / + (4 * triangle_area3lengths(a, b, c)); /********************** triangle **************************/ -//Satz des Heron -function triangle_area3lengths(a,b,c) = sqrt((a+b+c)*(a+b-c)*(b+c-a)*(c+a-b))/4; - -function triangle_area3Points(a,b,c) = triangle_area3lengths(distance2D(a,b),distance2D(b,c),distance2D(c,a)); - +// Satz des Heron +function triangle_area3lengths(a, b, c) = sqrt((a + b + c) * (a + b - c) * + (b + c - a) * (c + a - b)) / + 4; +function triangle_area3Points(a, b, c) = + triangle_area3lengths(distance2D(a, b), distance2D(b, c), distance2D(c, a)); /************************** coordinate systems translation ****/ //[radius,phi] <=> [x,y] -function conv2D_cartesian2polar(x) = [ distance1D(x[0],x[1]) , atan2(x[1],x[0]) ]; -function conv2D_polar2cartesian(x) = [ x[0]*cos(x[1]) , x[0]*sin(x[1]) ]; - +function conv2D_cartesian2polar(x) = + [ distance1D(x[0], x[1]), atan2(x[1], x[0]) ]; +function conv2D_polar2cartesian(x) = [ x[0] * cos(x[1]), x[0] * sin(x[1]) ]; CENTER = 0; LEFT = -0.5; @@ -83,49 +79,73 @@ RIGHT = 0.5; TOP = 0.5; BOTTOM = -0.5; -FlatCap =0; -ExtendedCap =0.5; -CutCap =-0.5; - - -module fromTo(from=[0,0,0], to=[1,0,0], size=[1, 1], align=[CENTER, CENTER], material=[0.5, 0.5, 0.5], name="", endExtras=[0,0], endCaps=[FlatCap, FlatCap], rotation=[0,0,0], printString=true) { +FlatCap = 0; +ExtendedCap = 0.5; +CutCap = -0.5; + +module fromTo(from = [ 0, 0, 0 ], + to = [ 1, 0, 0 ], + size = [ 1, 1 ], + align = [ CENTER, CENTER ], + material = [ 0.5, 0.5, 0.5 ], + name = "", + endExtras = [ 0, 0 ], + endCaps = [ FlatCap, FlatCap ], + rotation = [ 0, 0, 0 ], + printString = true) +{ angle = angleBetweenTwoPoints(from, to); - length = distance(from, to) + endCaps[0]*size[0] + endCaps[1]*size[0] + endExtras[0] + endExtras[1]; + length = distance(from, to) + endCaps[0] * size[0] + endCaps[1] * size[0] + + endExtras[0] + endExtras[1]; if (length > 0) { - if (printString) echo(str( " " ,name, " ", size[0], "mm x ", size[1], "mm, length ", length, "mm")); - - color(material) - translate(from) - rotate(angle) - translate( [ -endCaps[0]*size[0] - endExtras[0], size[0]*(-0.5-align[0]), size[1]*(-0.5+align[1]) ] ) - rotate(rotation) - scale([length, size[0], size[1]]) child(); + if (printString) + echo(str(" ", + name, + " ", + size[0], + "mm x ", + size[1], + "mm, length ", + length, + "mm")); + + color(material) translate(from) rotate(angle) translate([ + -endCaps[0] * size[0] - endExtras[0], + size[0] * (-0.5 - align[0]), + size[1] * (-0.5 + align[1]) + ]) rotate(rotation) scale([ length, size[0], size[1] ]) child(); } } -module part(name) { +module part(name) +{ echo(""); echo(str(name, ":")); } -module mirror_duplicate (plane = [0, 0, 1]) -union () { - child (); +module mirror_duplicate(plane = [ 0, 0, 1 ]) union() +{ + child(); - mirror (plane) - child (); + mirror(plane) child(); } -module linear_extrude_if (condition, height, center = undef, convexity = undef, - twist = undef, slices = undef) +module linear_extrude_if(condition, + height, + center = undef, + convexity = undef, + twist = undef, + slices = undef) { if (condition) - linear_extrude (height = height, center = center, convexity = convexity, - twist = twist, slices = slices) - children (); + linear_extrude(height = height, + center = center, + convexity = convexity, + twist = twist, + slices = slices) children(); else - children (); + children(); } diff --git a/gridbeam.scad b/gridbeam.scad index 66366fb4..90bd2ac9 100644 --- a/gridbeam.scad +++ b/gridbeam.scad @@ -1,13 +1,14 @@ /********************************* -* OpenSCAD GridBeam Library * -* (c) Timothy Schmidt 2013 * -* http://www.github.com/gridbeam * -* License: LGPL 2.1 or later * -*********************************/ + * OpenSCAD GridBeam Library * + * (c) Timothy Schmidt 2013 * + * http://www.github.com/gridbeam * + * License: LGPL 2.1 or later * + *********************************/ /* Todo: - implement "dxf" mode - - implement hole cutout pattern - interference based on hole size, compatible with two sizes above and below the currently set size. + - implement hole cutout pattern - interference based on hole size, compatible + with two sizes above and below the currently set size. */ // zBeam(segments) - create a vertical gridbeam strut 'segments' long @@ -16,174 +17,178 @@ // zBolt(segments) - create a bolt 'segments' in length // xBolt(segments) // yBolt(segments) -// topShelf(width, depth, corners) - create a shelf suitable for use in gridbeam structures width and depth in 'segments', corners == 1 notches corners -// bottomShelf(width, depth, corners) - like topShelf, but aligns shelf to underside of beams -// backBoard(width, height, corners) - create a backing board suitable for use in gridbeam structures width and height in 'segments', corners == 1 notches corners -// frontBoard(width, height, corners) - like backBoard, but aligns board to front side of beams -// translateBeam([x, y, z]) - translate gridbeam struts or shelves in X, Y, or Z axes in units 'segments' +// topShelf(width, depth, corners) - create a shelf suitable for use in gridbeam +// structures width and depth in 'segments', corners == 1 notches corners +// bottomShelf(width, depth, corners) - like topShelf, but aligns shelf to +// underside of beams backBoard(width, height, corners) - create a backing board +// suitable for use in gridbeam structures width and height in 'segments', +// corners == 1 notches corners frontBoard(width, height, corners) - like +// backBoard, but aligns board to front side of beams translateBeam([x, y, z]) - +// translate gridbeam struts or shelves in X, Y, or Z axes in units 'segments' // To render the DXF file from the command line: // openscad -x connector.dxf -D'mode="dxf"' connector.scad mode = "model"; -//mode = "dxf"; +// mode = "dxf"; include beam_width = length_inch * 1.5; -beam_hole_diameter = length_inch * 5/16; +beam_hole_diameter = length_inch * 5 / 16; beam_hole_radius = beam_hole_diameter / 2; beam_is_hollow = 1; -beam_wall_thickness = length_inch * 1/8; -beam_shelf_thickness = length_inch * 1/4; - -module zBeam(segments) { -if (mode == "model") { - difference() { - cube([beam_width, beam_width, beam_width * segments]); - for(i = [0 : segments - 1]) { - translate([beam_width / 2, beam_width + 1, beam_width * i + beam_width / 2]) - rotate([90,0,0]) - cylinder(r=beam_hole_radius, h=beam_width + 2); - - translate([-1, beam_width / 2, beam_width * i + beam_width / 2]) - rotate([0,90,0]) - cylinder(r=beam_hole_radius, h=beam_width + 2); - } - if (beam_is_hollow == 1) { - translate([beam_wall_thickness, beam_wall_thickness, -1]) - cube([beam_width - beam_wall_thickness * 2, beam_width - beam_wall_thickness * 2, beam_width * segments + 2]); - } -} -} - -if (mode == "dxf") { - -} -} - -module xBeam(segments) { -if (mode == "model") { - translate([0,0,beam_width]) - rotate([0,90,0]) - zBeam(segments); -} - -if (mode == "dxf") { - -} -} - -module yBeam(segments) { -if (mode == "model") { - translate([0,0,beam_width]) - rotate([-90,0,0]) - zBeam(segments); -} - -if (mode == "dxf") { +beam_wall_thickness = length_inch * 1 / 8; +beam_shelf_thickness = length_inch * 1 / 4; + +module zBeam(segments) +{ + if (mode == "model") { + difference() + { + cube([ beam_width, beam_width, beam_width * segments ]); + for (i = [0:segments - 1]) { + translate( + [ beam_width / 2, beam_width + 1, beam_width * i + beam_width / 2 ]) + rotate([ 90, 0, 0 ]) + cylinder(r = beam_hole_radius, h = beam_width + 2); + + translate([ -1, beam_width / 2, beam_width * i + beam_width / 2 ]) + rotate([ 0, 90, 0 ]) + cylinder(r = beam_hole_radius, h = beam_width + 2); + } + if (beam_is_hollow == 1) { + translate([ beam_wall_thickness, beam_wall_thickness, -1 ]) cube([ + beam_width - beam_wall_thickness * 2, + beam_width - beam_wall_thickness * 2, + beam_width * segments + 2 + ]); + } + } + } + + if (mode == "dxf") { + } +} + +module xBeam(segments) +{ + if (mode == "model") { + translate([ 0, 0, beam_width ]) rotate([ 0, 90, 0 ]) zBeam(segments); + } + + if (mode == "dxf") { + } +} + +module yBeam(segments) +{ + if (mode == "model") { + translate([ 0, 0, beam_width ]) rotate([ -90, 0, 0 ]) zBeam(segments); + } + + if (mode == "dxf") { + } +} + +module zBolt(segments) +{ + if (mode == "model") { + } + + if (mode == "dxf") { + } +} + +module xBolt(segments) +{ + if (mode == "model") { + } + + if (mode == "dxf") { + } +} + +module yBolt(segments) +{ + if (mode == "model") { + } + + if (mode == "dxf") { + } +} + +module translateBeam(v) +{ + for (i = [0:$children - 1]) { + translate(v * beam_width) child(i); + } +} + +module topShelf(width, depth, corners) +{ + if (mode == "model") { + difference() + { + cube([ width * beam_width, depth * beam_width, beam_shelf_thickness ]); + + if (corners == 1) { + translate([ -1, -1, -1 ]) + cube([ beam_width + 2, beam_width + 2, beam_shelf_thickness + 2 ]); + translate([ -1, (depth - 1) * beam_width, -1 ]) + cube([ beam_width + 2, beam_width + 2, beam_shelf_thickness + 2 ]); + translate([ (width - 1) * beam_width, -1, -1 ]) + cube([ beam_width + 2, beam_width + 2, beam_shelf_thickness + 2 ]); + translate([ (width - 1) * beam_width, (depth - 1) * beam_width, -1 ]) + cube([ beam_width + 2, beam_width + 2, beam_shelf_thickness + 2 ]); + } + } + } + + if (mode == "dxf") { + } +} + +module bottomShelf(width, depth, corners) +{ + if (mode == "model") { + translate([ 0, 0, -beam_shelf_thickness ]) topShelf(width, depth, corners); + } + + if (mode == "dxf") { + } +} + +module backBoard(width, height, corners) +{ + if (mode == "model") { + translate([ beam_width, 0, 0 ]) difference() + { + cube([ beam_shelf_thickness, width * beam_width, height * beam_width ]); -} -} - -module zBolt(segments) { -if (mode == "model") { - -} - -if (mode == "dxf") { + if (corners == 1) { + translate([ -1, -1, -1 ]) + cube([ beam_shelf_thickness + 2, beam_width + 2, beam_width + 2 ]); + translate([ -1, -1, (height - 1) * beam_width ]) + cube([ beam_shelf_thickness + 2, beam_width + 2, beam_width + 2 ]); + translate([ -1, (width - 1) * beam_width, -1 ]) + cube([ beam_shelf_thickness + 2, beam_width + 2, beam_width + 2 ]); + translate([ -1, (width - 1) * beam_width, (height - 1) * beam_width ]) + cube([ beam_shelf_thickness + 2, beam_width + 2, beam_width + 2 ]); + } + } + } -} -} + if (mode == "dxf") { + } +} + +module frontBoard(width, height, corners) +{ + if (mode == "model") { + translate([ -beam_width - beam_shelf_thickness, 0, 0 ]) + backBoard(width, height, corners); + } -module xBolt(segments) { -if (mode == "model") { -} - -if (mode == "dxf") { - -} -} - -module yBolt(segments) { -if (mode == "model") { -} - -if (mode == "dxf") { - -} -} - -module translateBeam(v) { - for (i = [0 : $children - 1]) { - translate(v * beam_width) child(i); - } -} - -module topShelf(width, depth, corners) { -if (mode == "model") { - difference() { - cube([width * beam_width, depth * beam_width, beam_shelf_thickness]); - - if (corners == 1) { - translate([-1, -1, -1]) - cube([beam_width + 2, beam_width + 2, beam_shelf_thickness + 2]); - translate([-1, (depth - 1) * beam_width, -1]) - cube([beam_width + 2, beam_width + 2, beam_shelf_thickness + 2]); - translate([(width - 1) * beam_width, -1, -1]) - cube([beam_width + 2, beam_width + 2, beam_shelf_thickness + 2]); - translate([(width - 1) * beam_width, (depth - 1) * beam_width, -1]) - cube([beam_width + 2, beam_width + 2, beam_shelf_thickness + 2]); - } - } -} - -if (mode == "dxf") { - -} -} - -module bottomShelf(width, depth, corners) { -if (mode == "model") { - translate([0,0,-beam_shelf_thickness]) - topShelf(width, depth, corners); -} - -if (mode == "dxf") { - -} -} - -module backBoard(width, height, corners) { -if (mode == "model") { - translate([beam_width, 0, 0]) - difference() { - cube([beam_shelf_thickness, width * beam_width, height * beam_width]); - - if (corners == 1) { - translate([-1, -1, -1]) - cube([beam_shelf_thickness + 2, beam_width + 2, beam_width + 2]); - translate([-1, -1, (height - 1) * beam_width]) - cube([beam_shelf_thickness + 2, beam_width + 2, beam_width + 2]); - translate([-1, (width - 1) * beam_width, -1]) - cube([beam_shelf_thickness + 2, beam_width + 2, beam_width + 2]); - translate([-1, (width - 1) * beam_width, (height - 1) * beam_width]) - cube([beam_shelf_thickness + 2, beam_width + 2, beam_width + 2]); - } - } -} - -if (mode == "dxf") { - -} -} - -module frontBoard(width, height, corners) { -if (mode == "model") { - translate([-beam_width - beam_shelf_thickness, 0, 0]) - backBoard(width, height, corners); -} - -if (mode == "dxf") { - -} + if (mode == "dxf") { + } } diff --git a/hardware/bearing.scad b/hardware/bearing.scad index 2d9019de..6aeaa69b 100644 --- a/hardware/bearing.scad +++ b/hardware/bearing.scad @@ -2,16 +2,17 @@ * Bearing model. * * Originally by Hans Häggström, 2010. - * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later + * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or + * later */ /* change list 13/6/2013 - added ,604,606,607,628,629,6200,6201,6202,6203,6205,6206 bearing sizes + added ,604,606,607,628,629,6200,6201,6202,6203,6205,6206 bearing sizes */ -include include +include BEARING_INNER_DIAMETER = 0; BEARING_OUTER_DIAMETER = 1; @@ -23,7 +24,8 @@ SkateBearing = 608; // Bearing dimensions // model == XXX ? [inner dia, outer dia, width]: // http://www.gizmology.net/bearings.htm has some valuable information on that -// https://www.bearingworks.com/bearing-sizes has a very exhaustive table of dimensions +// https://www.bearingworks.com/bearing-sizes has a very exhaustive table of +// dimensions function bearingDimensions(model) = model == 603 ? [3*mm, 9*mm, 5*mm]: model == 604 ? [4*mm, 12*mm, 4*mm]: @@ -83,54 +85,68 @@ function bearingDimensions(model) = [8*length_mm, 22*length_mm, 7*length_mm]; // this is the default - function bearingWidth(model) = bearingDimensions(model)[BEARING_WIDTH]; -function bearingInnerDiameter(model) = bearingDimensions(model)[BEARING_INNER_DIAMETER]; -function bearingOuterDiameter(model) = bearingDimensions(model)[BEARING_OUTER_DIAMETER]; - -module bearing(pos=[0,0,0], angle=[0,0,0], model=SkateBearing, outline=false, - material=Steel, sideMaterial=Brass, center=false) { +function bearingInnerDiameter(model) = + bearingDimensions(model)[BEARING_INNER_DIAMETER]; +function bearingOuterDiameter(model) = + bearingDimensions(model)[BEARING_OUTER_DIAMETER]; + +module bearing(pos = [ 0, 0, 0 ], + angle = [ 0, 0, 0 ], + model = SkateBearing, + outline = false, + material = Steel, + sideMaterial = Brass, + center = false) +{ // Common bearing names - model = - model == "Skate" ? 608 : - model; + model = model == "Skate" ? 608 : model; w = bearingWidth(model); - innerD = outline==false ? bearingInnerDiameter(model) : 0; + innerD = outline == false ? bearingInnerDiameter(model) : 0; outerD = bearingOuterDiameter(model); innerRim = innerD + (outerD - innerD) * 0.2; outerRim = outerD - (outerD - innerD) * 0.2; midSink = w * 0.1; - centering_pos = (center) ? [0, 0, -w/2] : [0, 0, 0]; - - translate(pos) rotate(angle) translate (centering_pos) union() { - color(material) - difference() { - // Basic ring - Ring([0,0,0], outerD, innerD, w, material, material); - - if (outline==false) { - // Side shields - Ring([0,0,-epsilon], outerRim, innerRim, epsilon+midSink, sideMaterial, material); - Ring([0,0,w-midSink], outerRim, innerRim, epsilon+midSink, sideMaterial, material); - } + centering_pos = (center) ? [ 0, 0, -w / 2 ] : [ 0, 0, 0 ]; + + translate(pos) rotate(angle) translate(centering_pos) union() + { + color(material) difference() + { + // Basic ring + Ring([ 0, 0, 0 ], outerD, innerD, w, material, material); + + if (outline == false) { + // Side shields + Ring([ 0, 0, -epsilon ], + outerRim, + innerRim, + epsilon + midSink, + sideMaterial, + material); + Ring([ 0, 0, w - midSink ], + outerRim, + innerRim, + epsilon + midSink, + sideMaterial, + material); } + } } - module Ring(pos, od, id, h, material, holeMaterial) { - color(material) { - translate(pos) - difference() { - cylinder(r=od/2, h=h, $fs = 0.01); - color(holeMaterial) - translate([0,0,-10*epsilon]) - cylinder(r=(id/2)+epsilon, h=h+20*epsilon, $fs = 0.01); - } + module Ring(pos, od, id, h, material, holeMaterial) + { + color(material) + { + translate(pos) difference() + { + cylinder(r = od / 2, h = h, $fs = 0.01); + color(holeMaterial) translate([ 0, 0, -10 * epsilon ]) + cylinder(r = (id / 2) + epsilon, h = h + 20 * epsilon, $fs = 0.01); + } } } - } - - diff --git a/hardware/hardware.scad b/hardware/hardware.scad index aeda29a2..9271caa7 100644 --- a/hardware/hardware.scad +++ b/hardware/hardware.scad @@ -1,14 +1,12 @@ // License: LGPL 2.1 -rodsize = 6; //threaded/smooth rod diameter in mm -xaxis = 182.5; //width of base in mm -yaxis = 266.5; //length of base in mm - - -screwsize = 3; //bearing bore/screw diameter in mm -bearingsize = 10; //outer diameter of bearings in mm -bearingwidth = 4; //width of bearings in mm +rodsize = 6; // threaded/smooth rod diameter in mm +xaxis = 182.5; // width of base in mm +yaxis = 266.5; // length of base in mm +screwsize = 3; // bearing bore/screw diameter in mm +bearingsize = 10; // outer diameter of bearings in mm +bearingwidth = 4; // width of bearings in mm rodpitch = rodsize / 6; rodnutsize = 0.8 * rodsize; @@ -23,90 +21,122 @@ washerdiameter = 2 * screwsize; partthick = 2 * rodsize; vertexrodspace = 2 * rodsize; - -c = [0.3, 0.3, 0.3]; +c = [ 0.3, 0.3, 0.3 ]; rodendoffset = rodnutsize + rodwashersize * 2 + partthick / 2; vertexoffset = vertexrodspace + rodendoffset; - renderrodthreads = false; renderscrewthreads = false; fn = 36; - - -module rod(length, threaded) if (threaded && renderrodthreads) { - linear_extrude(height = length, center = true, convexity = 10, twist = -360 * length / rodpitch, $fn = fn) - translate([rodsize * 0.1 / 2, 0, 0]) - circle(r = rodsize * 0.9 / 2, $fn = fn); -} else cylinder(h = length, r = rodsize / 2, center = true, $fn = fn); - - -module screw(length, nutpos, washer, bearingpos = -1) union(){ - translate([0, 0, -length / 2]) if (renderscrewthreads) { - linear_extrude(height = length, center = true, convexity = 10, twist = -360 * length / screwpitch, $fn = fn) - translate([screwsize * 0.1 / 2, 0, 0]) - circle(r = screwsize * 0.9 / 2, $fn = fn); - } else cylinder(h = length, r = screwsize / 2, center = true, $fn = fn); - render() difference() { - translate([0, 0, screwsize / 2]) cylinder(h = screwsize, r = screwsize, center = true, $fn = fn); - translate([0, 0, screwsize]) cylinder(h = screwsize, r = screwsize / 2, center = true, $fn = 6); - } - if (washer > 0 && nutpos > 0) { - washer(nutpos); - nut(nutpos + washersize); - } else if (nutpos > 0) nut(nutpos); - if (bearingpos >= 0) bearing(bearingpos); +module rod(length, threaded) if (threaded && renderrodthreads) +{ + linear_extrude(height = length, + center = true, + convexity = 10, + twist = -360 * length / rodpitch, + $fn = fn) translate([ rodsize * 0.1 / 2, 0, 0 ]) + circle(r = rodsize * 0.9 / 2, $fn = fn); } - - -module bearing(position) render() translate([0, 0, -position - bearingwidth / 2]) union() { - difference() { - cylinder(h = bearingwidth, r = bearingsize / 2, center = true, $fn = fn); - cylinder(h = bearingwidth * 2, r = bearingsize / 2 - 1, center = true, $fn = fn); - } - difference() { - cylinder(h = bearingwidth - 0.5, r = bearingsize / 2 - 0.5, center = true, $fn = fn); - cylinder(h = bearingwidth * 2, r = screwsize / 2 + 0.5, center = true, $fn = fn); - } - difference() { - cylinder(h = bearingwidth, r = screwsize / 2 + 1, center = true, $fn = fn); - cylinder(h = bearingwidth + 0.1, r = screwsize / 2, center = true, $fn = fn); - } +else cylinder(h = length, r = rodsize / 2, center = true, $fn = fn); + +module screw(length, nutpos, washer, bearingpos = -1) union() +{ + translate([ 0, 0, -length / 2 ]) if (renderscrewthreads) + { + linear_extrude(height = length, + center = true, + convexity = 10, + twist = -360 * length / screwpitch, + $fn = fn) translate([ screwsize * 0.1 / 2, 0, 0 ]) + circle(r = screwsize * 0.9 / 2, $fn = fn); + } + else cylinder(h = length, r = screwsize / 2, center = true, $fn = fn); + render() difference() + { + translate([ 0, 0, screwsize / 2 ]) + cylinder(h = screwsize, r = screwsize, center = true, $fn = fn); + translate([ 0, 0, screwsize ]) + cylinder(h = screwsize, r = screwsize / 2, center = true, $fn = 6); + } + if (washer > 0 && nutpos > 0) { + washer(nutpos); + nut(nutpos + washersize); + } else if (nutpos > 0) + nut(nutpos); + if (bearingpos >= 0) + bearing(bearingpos); } - -module nut(position, washer) render() translate([0, 0, -position - nutsize / 2]) { - intersection() { - scale([1, 1, 0.5]) sphere(r = 1.05 * screwsize, center = true); - difference() { - cylinder (h = nutsize, r = nutdiameter / 2, center = true, $fn = 6); - cylinder(r = screwsize / 2, h = nutsize + 0.1, center = true, $fn = fn); - } - } - if (washer > 0) washer(0); +module bearing(position) render() + translate([ 0, 0, -position - bearingwidth / 2 ]) union() +{ + difference() + { + cylinder(h = bearingwidth, r = bearingsize / 2, center = true, $fn = fn); + cylinder( + h = bearingwidth * 2, r = bearingsize / 2 - 1, center = true, $fn = fn); + } + difference() + { + cylinder(h = bearingwidth - 0.5, + r = bearingsize / 2 - 0.5, + center = true, + $fn = fn); + cylinder( + h = bearingwidth * 2, r = screwsize / 2 + 0.5, center = true, $fn = fn); + } + difference() + { + cylinder(h = bearingwidth, r = screwsize / 2 + 1, center = true, $fn = fn); + cylinder( + h = bearingwidth + 0.1, r = screwsize / 2, center = true, $fn = fn); + } } - -module washer(position) render() translate ([0, 0, -position - washersize / 2]) difference() { - cylinder(r = washerdiameter / 2, h = washersize, center = true, $fn = fn); - cylinder(r = screwsize / 2, h = washersize + 0.1, center = true, $fn = fn); +module nut(position, washer) render() + translate([ 0, 0, -position - nutsize / 2 ]) +{ + intersection() + { + scale([ 1, 1, 0.5 ]) sphere(r = 1.05 * screwsize, center = true); + difference() + { + cylinder(h = nutsize, r = nutdiameter / 2, center = true, $fn = 6); + cylinder(r = screwsize / 2, h = nutsize + 0.1, center = true, $fn = fn); + } + } + if (washer > 0) + washer(0); } -module rodnut(position, washer) render() translate([0, 0, position]) { - intersection() { - scale([1, 1, 0.5]) sphere(r = 1.05 * rodsize, center = true); - difference() { - cylinder (h = rodnutsize, r = rodnutdiameter / 2, center = true, $fn = 6); - rod(rodnutsize + 0.1); - } - } - if (washer == 1 || washer == 4) rodwasher(((position > 0) ? -1 : 1) * (rodnutsize + rodwashersize) / 2); - if (washer == 2 || washer == 4) rodwasher(((position > 0) ? 1 : -1) * (rodnutsize + rodwashersize) / 2); +module washer(position) render() translate([ 0, 0, -position - washersize / 2 ]) + difference() +{ + cylinder(r = washerdiameter / 2, h = washersize, center = true, $fn = fn); + cylinder(r = screwsize / 2, h = washersize + 0.1, center = true, $fn = fn); } +module rodnut(position, washer) render() translate([ 0, 0, position ]) +{ + intersection() + { + scale([ 1, 1, 0.5 ]) sphere(r = 1.05 * rodsize, center = true); + difference() + { + cylinder(h = rodnutsize, r = rodnutdiameter / 2, center = true, $fn = 6); + rod(rodnutsize + 0.1); + } + } + if (washer == 1 || washer == 4) + rodwasher(((position > 0) ? -1 : 1) * (rodnutsize + rodwashersize) / 2); + if (washer == 2 || washer == 4) + rodwasher(((position > 0) ? 1 : -1) * (rodnutsize + rodwashersize) / 2); +} -module rodwasher(position) render() translate ([0, 0, position]) difference() { - cylinder(r = rodwasherdiameter / 2, h = rodwashersize, center = true, $fn = fn); - rod(rodwashersize + 0.1); +module rodwasher(position) render() translate([ 0, 0, position ]) difference() +{ + cylinder( + r = rodwasherdiameter / 2, h = rodwashersize, center = true, $fn = fn); + rod(rodwashersize + 0.1); } diff --git a/hardware/linear_bearing.scad b/hardware/linear_bearing.scad index aa88c915..f14778be 100644 --- a/hardware/linear_bearing.scad +++ b/hardware/linear_bearing.scad @@ -1,16 +1,16 @@ -//By Glen Chung, 2013. -//Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later +// By Glen Chung, 2013. +// Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or +// later -include ; -include ; - -LINEAR_BEARING_dr = 0; //Inscribed circle -LINEAR_BEARING_D = 1; //Outer diameter -LINEAR_BEARING_L = 2; //Length -LINEAR_BEARING_B = 3; //Outer locking groove B -LINEAR_BEARING_D1 = 4; //Outer locking groove D1 -LINEAR_BEARING_W = 5; //W +include +include +LINEAR_BEARING_dr = 0; // Inscribed circle +LINEAR_BEARING_D = 1; // Outer diameter +LINEAR_BEARING_L = 2; // Length +LINEAR_BEARING_B = 3; // Outer locking groove B +LINEAR_BEARING_D1 = 4; // Outer locking groove D1 +LINEAR_BEARING_W = 5; // W // Common bearing names LinearBearing = "LM8UU"; @@ -38,57 +38,91 @@ model == "LM80UU" ? [ 80*length_mm, 120*length_mm, 140*length_mm, 105.5*lengt model == "LM100UU" ? [100*length_mm, 150*length_mm, 150*length_mm, 125.5*length_mm, 145.0*length_mm, 4.15*length_mm]: /*model == "LM8UU" ?*/ [ 8*length_mm, 15*length_mm, 24*length_mm, 17.5*length_mm, 14.3*length_mm, 1.10*length_mm]; +function linearBearing_dr(model) = + linearBearingDimensions(model)[LINEAR_BEARING_dr]; +function linearBearing_D(model) = + linearBearingDimensions(model)[LINEAR_BEARING_D]; +function linearBearing_L(model) = + linearBearingDimensions(model)[LINEAR_BEARING_L]; +function linearBearing_B(model) = + linearBearingDimensions(model)[LINEAR_BEARING_B]; +function linearBearing_D1(model) = + linearBearingDimensions(model)[LINEAR_BEARING_D1]; +function linearBearing_W(model) = + linearBearingDimensions(model)[LINEAR_BEARING_W]; -function linearBearing_dr(model) = linearBearingDimensions(model)[LINEAR_BEARING_dr]; -function linearBearing_D(model) = linearBearingDimensions(model)[LINEAR_BEARING_D]; -function linearBearing_L(model) = linearBearingDimensions(model)[LINEAR_BEARING_L]; -function linearBearing_B(model) = linearBearingDimensions(model)[LINEAR_BEARING_B]; -function linearBearing_D1(model) = linearBearingDimensions(model)[LINEAR_BEARING_D1]; -function linearBearing_W(model) = linearBearingDimensions(model)[LINEAR_BEARING_W]; - -module linearBearing(pos=[0,0,0], angle=[0,0,0], model=LinearBearing, - material=Steel, sideMaterial=BlackPaint) { - dr = linearBearing_dr(model); - D = linearBearing_D(model); - L = linearBearing_L(model); - B = linearBearing_B(model); - D1 = linearBearing_D1(model); - W = linearBearing_W(model); +module linearBearing(pos = [ 0, 0, 0 ], + angle = [ 0, 0, 0 ], + model = LinearBearing, + material = Steel, + sideMaterial = BlackPaint) +{ + dr = linearBearing_dr(model); + D = linearBearing_D(model); + L = linearBearing_L(model); + B = linearBearing_B(model); + D1 = linearBearing_D1(model); + W = linearBearing_W(model); - innerRim = dr + (D - dr) * 0.2; - outerRim = D - (D - dr) * 0.2; - midSink = W/4; + innerRim = dr + (D - dr) * 0.2; + outerRim = D - (D - dr) * 0.2; + midSink = W / 4; - translate(pos) rotate(angle) union() { - color(material) - difference() { - // Basic ring - Ring([0,0,0], D, dr, L, material, material); + translate(pos) rotate(angle) union() + { + color(material) difference() + { + // Basic ring + Ring([ 0, 0, 0 ], D, dr, L, material, material); - if(W) { - // Side shields - Ring([0,0,-epsilon], outerRim, innerRim, L*epsilon+midSink, sideMaterial, material); - Ring([0,0,L-midSink-epsilon], outerRim, innerRim, L*epsilon+midSink, sideMaterial, material); - //Outer locking groove - Ring([0,0,(L-B)/2], D+epsilon, outerRim+W/2, W, material, material); - Ring([0,0,L-(L-B)/2], D+epsilon, outerRim+W/2, W, material, material); - } - } - if(W) - Ring([0,0,midSink], D-L*epsilon, dr+L*epsilon, L-midSink*2, sideMaterial, sideMaterial); - } - - module Ring(pos, od, id, h, material, holeMaterial) { - color(material) { - translate(pos) - difference() { - cylinder(r=od/2, h=h, $fn = 100); - color(holeMaterial) - translate([0,0,-10*epsilon]) - cylinder(r=id/2, h=h+20*epsilon, $fn = 100); - } - } - } + if (W) { + // Side shields + Ring([ 0, 0, -epsilon ], + outerRim, + innerRim, + L * epsilon + midSink, + sideMaterial, + material); + Ring([ 0, 0, L - midSink - epsilon ], + outerRim, + innerRim, + L * epsilon + midSink, + sideMaterial, + material); + // Outer locking groove + Ring([ 0, 0, (L - B) / 2 ], + D + epsilon, + outerRim + W / 2, + W, + material, + material); + Ring([ 0, 0, L - (L - B) / 2 ], + D + epsilon, + outerRim + W / 2, + W, + material, + material); + } + } + if (W) + Ring([ 0, 0, midSink ], + D - L * epsilon, + dr + L * epsilon, + L - midSink * 2, + sideMaterial, + sideMaterial); + } + module Ring(pos, od, id, h, material, holeMaterial) + { + color(material) + { + translate(pos) difference() + { + cylinder(r = od / 2, h = h, $fn = 100); + color(holeMaterial) translate([ 0, 0, -10 * epsilon ]) + cylinder(r = id / 2, h = h + 20 * epsilon, $fn = 100); + } + } + } } - diff --git a/layout/linear.scad b/layout/linear.scad index 53795705..1bacc793 100644 --- a/layout/linear.scad +++ b/layout/linear.scad @@ -7,16 +7,16 @@ module array_linear(iHeight) { - for (i = [0 : $children-1]) - translate([0,i*iHeight]) children(i); + for (i = [0:$children - 1]) + translate([ 0, i * iHeight ]) children(i); } -module array_linear_grid(iWidth,iHeight,inYDir = true,limit=3) +module array_linear_grid(iWidth, iHeight, inYDir = true, limit = 3) { - for (i = [0 : $children-1]) - { - translate([(inYDir)? (iWidth)*(i%limit) : (iWidth)*floor(i/limit), - (inYDir)? (iHeight)*floor(i/limit) : (iHeight)*(i%limit)]) - children(i); - } + for (i = [0:$children - 1]) { + translate([ + (inYDir) ? (iWidth) * (i % limit) : (iWidth)*floor(i / limit), + (inYDir) ? (iHeight)*floor(i / limit) : (iHeight) * (i % limit) + ]) children(i); + } } diff --git a/lego_compatibility.scad b/lego_compatibility.scad index 4e402d9b..bcdeaff6 100644 --- a/lego_compatibility.scad +++ b/lego_compatibility.scad @@ -15,143 +15,239 @@ // standard LEGO 2x1x5 brick has no pin and has hollow knobs // block(1,2,5,reinforcement=false,hollow_knob=true); - -knob_diameter=4.8; //knobs on top of blocks -knob_height=2; -knob_spacing=8.0; -wall_thickness=1.45; -roof_thickness=1.05; -block_height=9.5; -pin_diameter=3; //pin for bottom blocks with width or length of 1 -post_diameter=6.5; -reinforcing_width=1.5; -axle_spline_width=2.0; -axle_diameter=5; -cylinder_precision=0.5; +knob_diameter = 4.8; // knobs on top of blocks +knob_height = 2; +knob_spacing = 8.0; +wall_thickness = 1.45; +roof_thickness = 1.05; +block_height = 9.5; +pin_diameter = 3; // pin for bottom blocks with width or length of 1 +post_diameter = 6.5; +reinforcing_width = 1.5; +axle_spline_width = 2.0; +axle_diameter = 5; +cylinder_precision = 0.5; /* EXAMPLES: block(2,1,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true); translate([50,-10,0]) - block(1,2,1/3,axle_hole=false,circular_hole=true,reinforcement=false,hollow_knob=true,flat_top=true); + block(1,2,1/3,axle_hole=false,circular_hole=true,reinforcement=false,hollow_knob=true,flat_top=true); translate([10,0,0]) - block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true); + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true); translate([30,0,0]) - block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=false,flat_top=false); + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=false,flat_top=false); translate([50,0,0]) - block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false); + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false); translate([0,20,0]) - block(3,2,2/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false); + block(3,2,2/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false); translate([20,20,0]) - block(3,2,1,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false); + block(3,2,1,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false); translate([40,20,0]) - block(3,2,1/3,axle_hole=false,circular_hole=false,reinforcement=false,hollow_knob=false,flat_top=false); + block(3,2,1/3,axle_hole=false,circular_hole=false,reinforcement=false,hollow_knob=false,flat_top=false); translate([0,-10,0]) - block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false); + block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false); translate([0,-20,0]) - block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=false); + block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=false); translate([0,-30,0]) - block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=true); + block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=true); //*/ -module block(width,length,height,axle_hole=false,reinforcement=false, hollow_knob=false, flat_top=false, circular_hole=false, solid_bottom=true, center=false) { - overall_length=(length-1)*knob_spacing+knob_diameter+wall_thickness*2; - overall_width=(width-1)*knob_spacing+knob_diameter+wall_thickness*2; - center= center==true ? 1 : 0; - translate(center*[-overall_length/2, -overall_width/2, 0]) - union() { - difference() { - union() { - // body: - cube([overall_length,overall_width,height*block_height]); - // knobs: - if (flat_top != true) - translate([knob_diameter/2+wall_thickness,knob_diameter/2+wall_thickness,0]) - for (ycount=[0:width-1]) - for (xcount=[0:length-1]) { - translate([xcount*knob_spacing,ycount*knob_spacing,0]) - difference() { - cylinder(r=knob_diameter/2,h=block_height*height+knob_height,$fs=cylinder_precision); - if (hollow_knob==true) - translate([0,0,-roof_thickness]) - cylinder(r=pin_diameter/2,h=block_height*height+knob_height+2*roof_thickness,$fs=cylinder_precision); - } - } - } - // hollow bottom: - if (solid_bottom == false) - translate([wall_thickness,wall_thickness,-roof_thickness]) cube([overall_length-wall_thickness*2,overall_width-wall_thickness*2,block_height*height]); - // flat_top -> groove around bottom - if (flat_top == true) { - translate([-wall_thickness/2,-wall_thickness*2/3,-wall_thickness/2]) - cube([overall_length+wall_thickness,wall_thickness,wall_thickness]); - translate([-wall_thickness/2,overall_width-wall_thickness/3,-wall_thickness/2]) - cube([overall_length+wall_thickness,wall_thickness,wall_thickness]); - - translate([-wall_thickness*2/3,-wall_thickness/2,-wall_thickness/2]) - cube([wall_thickness,overall_width+wall_thickness,wall_thickness]); - translate([overall_length-wall_thickness/3,0,-wall_thickness/2]) - cube([wall_thickness,overall_width+wall_thickness,wall_thickness]); - } - if (axle_hole==true) - if (width>1 && length>1) for (ycount=[1:width-1]) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,ycount*knob_spacing,roof_thickness]) axle(height); - if (circular_hole==true) - if (width>1 && length>1) for (ycount=[1:width-1]) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,ycount*knob_spacing,roof_thickness]) - cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision); - } +module block(width, + length, + height, + axle_hole = false, + reinforcement = false, + hollow_knob = false, + flat_top = false, + circular_hole = false, + solid_bottom = true, + center = false) +{ + overall_length = + (length - 1) * knob_spacing + knob_diameter + wall_thickness * 2; + overall_width = + (width - 1) * knob_spacing + knob_diameter + wall_thickness * 2; + center = center == true ? 1 : 0; + translate(center * [ -overall_length / 2, -overall_width / 2, 0 ]) union() + { + difference() + { + union() + { + // body: + cube([ overall_length, overall_width, height * block_height ]); + // knobs: + if (flat_top != true) + translate([ + knob_diameter / 2 + wall_thickness, + knob_diameter / 2 + wall_thickness, + 0 + ]) for (ycount = [0:width - 1]) for (xcount = [0:length - 1]) + { + translate([ xcount * knob_spacing, ycount * knob_spacing, 0 ]) + difference() + { + cylinder(r = knob_diameter / 2, + h = block_height * height + knob_height, + $fs = cylinder_precision); + if (hollow_knob == true) + translate([ 0, 0, -roof_thickness ]) cylinder( + r = pin_diameter / 2, + h = block_height * height + knob_height + 2 * roof_thickness, + $fs = cylinder_precision); + } + } + } + // hollow bottom: + if (solid_bottom == false) + translate([ wall_thickness, wall_thickness, -roof_thickness ]) cube([ + overall_length - wall_thickness * 2, + overall_width - wall_thickness * 2, + block_height * + height + ]); + // flat_top -> groove around bottom + if (flat_top == true) { + translate( + [ -wall_thickness / 2, -wall_thickness * 2 / 3, -wall_thickness / 2 ]) + cube([ + overall_length + wall_thickness, + wall_thickness, + wall_thickness + ]); + translate([ + -wall_thickness / 2, + overall_width - wall_thickness / 3, + -wall_thickness / 2 + ]) + cube([ + overall_length + wall_thickness, + wall_thickness, + wall_thickness + ]); + + translate( + [ -wall_thickness * 2 / 3, -wall_thickness / 2, -wall_thickness / 2 ]) + cube( + [ wall_thickness, overall_width + wall_thickness, wall_thickness ]); + translate( + [ overall_length - wall_thickness / 3, 0, -wall_thickness / 2 ]) + cube( + [ wall_thickness, overall_width + wall_thickness, wall_thickness ]); + } + if (axle_hole == true) + if (width > 1 && length > 1) + for (ycount = [1:width - 1]) + for (xcount = [1:length - 1]) + translate([ + xcount * knob_spacing, + ycount * knob_spacing, + roof_thickness + ]) axle(height); + if (circular_hole == true) + if (width > 1 && length > 1) + for (ycount = [1:width - 1]) + for (xcount = [1:length - 1]) + translate([ + xcount * knob_spacing, + ycount * knob_spacing, + roof_thickness + ]) cylinder(r = knob_diameter / 2, + h = height * block_height + roof_thickness / 4, + $fs = cylinder_precision); + } - if (reinforcement==true && width>1 && length>1) - difference() { - for (ycount=[1:width-1]) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,ycount*knob_spacing,0]) reinforcement(height); - for (ycount=[1:width-1]) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,ycount*knob_spacing,-roof_thickness/2]) cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness, $fs=cylinder_precision); - } - // posts: - if (solid_bottom == false) - if (width>1 && length>1) for (ycount=[1:width-1]) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,ycount*knob_spacing,0]) post(height); + if (reinforcement == true && width > 1 && length > 1) + difference() + { + for (ycount = [1:width - 1]) + for (xcount = [1:length - 1]) + translate([ xcount * knob_spacing, ycount * knob_spacing, 0 ]) + reinforcement(height); + for (ycount = [1:width - 1]) + for (xcount = [1:length - 1]) + translate([ + xcount * knob_spacing, + ycount * knob_spacing, + -roof_thickness / 2 + ]) cylinder(r = knob_diameter / 2, + h = height * block_height + roof_thickness, + $fs = cylinder_precision); + } + // posts: + if (solid_bottom == false) + if (width > 1 && length > 1) + for (ycount = [1:width - 1]) + for (xcount = [1:length - 1]) + translate([ xcount * knob_spacing, ycount * knob_spacing, 0 ]) + post(height); - if (reinforcement == true && width==1 && length!=1) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,overall_width/2,0]) cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision); + if (reinforcement == true && width == 1 && length != 1) + for (xcount = [1:length - 1]) + translate([ xcount * knob_spacing, overall_width / 2, 0 ]) + cylinder(r = pin_diameter / 2, + h = block_height * height, + $fs = cylinder_precision); - if (reinforcement == true && length==1 && width!=1) - for (ycount=[1:width-1]) - translate([overall_length/2,ycount*knob_spacing,0]) cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision); - } + if (reinforcement == true && length == 1 && width != 1) + for (ycount = [1:width - 1]) + translate([ overall_length / 2, ycount * knob_spacing, 0 ]) + cylinder(r = pin_diameter / 2, + h = block_height * height, + $fs = cylinder_precision); + } } -module post(height) { - difference() { - cylinder(r=post_diameter/2, h=height*block_height-roof_thickness/2,$fs=cylinder_precision); - translate([0,0,-roof_thickness/2]) - cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision); - } +module post(height) +{ + difference() + { + cylinder(r = post_diameter / 2, + h = height * block_height - roof_thickness / 2, + $fs = cylinder_precision); + translate([ 0, 0, -roof_thickness / 2 ]) + cylinder(r = knob_diameter / 2, + h = height * block_height + roof_thickness / 4, + $fs = cylinder_precision); + } } -module reinforcement(height) { - union() { - translate([0,0,height*block_height/2]) union() { - cube([reinforcing_width,knob_spacing+knob_diameter+wall_thickness/2,height*block_height],center=true); - rotate(v=[0,0,1],a=90) cube([reinforcing_width,knob_spacing+knob_diameter+wall_thickness/2,height*block_height], center=true); - } - } +module reinforcement(height) +{ + union() + { + translate([ 0, 0, height * block_height / 2 ]) union() + { + cube( + [ + reinforcing_width, + knob_spacing + knob_diameter + wall_thickness / 2, + height * + block_height + ], + center = true); + rotate(v = [ 0, 0, 1 ], a = 90) cube( + [ + reinforcing_width, + knob_spacing + knob_diameter + wall_thickness / 2, + height * + block_height + ], + center = true); + } + } } -module axle(height) { - translate([0,0,height*block_height/2]) union() { - cube([axle_diameter,axle_spline_width,height*block_height],center=true); - cube([axle_spline_width,axle_diameter,height*block_height],center=true); - } +module axle(height) +{ + translate([ 0, 0, height * block_height / 2 ]) union() + { + cube([ axle_diameter, axle_spline_width, height * block_height ], + center = true); + cube([ axle_spline_width, axle_diameter, height * block_height ], + center = true); + } } - diff --git a/materials/materials.scad b/materials/materials.scad index 5afc293b..6e136071 100644 --- a/materials/materials.scad +++ b/materials/materials.scad @@ -1,19 +1,20 @@ /* * Material colors. - * + * * Originally by Hans Häggström, 2010. - * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later + * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or + * later */ // Material colors -Oak = [0.65, 0.5, 0.4]; -Pine = [0.85, 0.7, 0.45]; -Birch = [0.9, 0.8, 0.6]; -FiberBoard = [0.7, 0.67, 0.6]; -BlackPaint = [0.2, 0.2, 0.2]; -Iron = [0.36, 0.33, 0.33]; -Steel = [0.65, 0.67, 0.72]; -Stainless = [0.45, 0.43, 0.5]; -Aluminum = [0.77, 0.77, 0.8]; -Brass = [0.88, 0.78, 0.5]; -Transparent = [1, 1, 1, 0.2]; +Oak = [ 0.65, 0.5, 0.4 ]; +Pine = [ 0.85, 0.7, 0.45 ]; +Birch = [ 0.9, 0.8, 0.6 ]; +FiberBoard = [ 0.7, 0.67, 0.6 ]; +BlackPaint = [ 0.2, 0.2, 0.2 ]; +Iron = [ 0.36, 0.33, 0.33 ]; +Steel = [ 0.65, 0.67, 0.72 ]; +Stainless = [ 0.45, 0.43, 0.5 ]; +Aluminum = [ 0.77, 0.77, 0.8 ]; +Brass = [ 0.88, 0.78, 0.5 ]; +Transparent = [ 1, 1, 1, 0.2 ]; diff --git a/materials/visibonecolors.scad b/materials/visibonecolors.scad index 701f4d41..8e37e95b 100644 --- a/materials/visibonecolors.scad +++ b/materials/visibonecolors.scad @@ -12,7 +12,7 @@ * This program is free software; you can redistribute it and/or modify * it under the terms of the Creative Commons - LGPL License (cc-lgpl) as * published by the Creative Commons Corporation. - * + * * See http://creativecommons.org/licenses/LGPL/2.1/ for details. * * This program is distributed in the hope that it will be useful, @@ -21,440 +21,441 @@ **************************************************************************/ /* Visibone Colors http://www.visibone.com/colorlab/ */ -PPR = [255/255, 0/255, 102/255]; /* Pink Pink Red */ -PPM = [255/255, 0/255, 153/255]; /* Pink Pink Magenta */ -RRP = [255/255, 0/255, 51/255]; /* Red Red Pink */ -MMP = [255/255, 0/255, 204/255]; /* Magenta Magenta Pink */ -DRP = [204/255, 0/255, 51/255]; /* Dark Red Pink */ -DMP = [204/255, 0/255, 153/255]; /* Dark Magenta Pink */ -LRP = [255/255, 51/255, 102/255]; /* Light Red Pink */ -LMP = [255/255, 51/255, 204/255]; /* Light Magenta Pink */ -DPR = [153/255, 0/255, 51/255]; /* Dark Pink Red */ -DPM = [153/255, 0/255, 102/255]; /* Dark Pink Magenta */ -LPR = [255/255, 102/255, 153/255]; /* Light Pink Red */ -LPM = [255/255, 102/255, 204/255]; /* Light Pink Magenta */ -MPR = [204/255, 51/255, 102/255]; /* Medium Pink Red */ -MPM = [204/255, 51/255, 153/255]; /* Medium Pink Magenta */ -OOY = [255/255, 153/255, 0/255]; /* Orange Orange Yellow */ -OOR = [255/255, 102/255, 0/255]; /* Orange Orange Red */ -YYO = [255/255, 204/255, 0/255]; /* Yellow Yellow Orange */ -RRO = [255/255, 51/255, 0/255]; /* Red Red Orange */ -DYO = [204/255, 153/255, 0/255]; /* Dark Yellow Orange */ -DRO = [204/255, 51/255, 0/255]; /* Dark Red Orange */ -LYO = [255/255, 204/255, 51/255]; /* Light Yellow Orange */ -LRO = [255/255, 102/255, 51/255]; /* Light Red Orange */ -DOY = [153/255, 102/255, 0/255]; /* Dark Orange Yellow */ -DOR = [153/255, 51/255, 0/255]; /* Dark Orange Red */ -LOY = [255/255, 204/255, 102/255]; /* Light Orange Yellow */ -LOR = [255/255, 153/255, 102/255]; /* Light Orange Red */ -MOY = [204/255, 153/255, 51/255]; /* Medium Orange Yellow */ -MOR = [204/255, 102/255, 51/255]; /* Medium Orange Red */ -SSG = [102/255, 255/255, 0/255]; /* Spring Spring Green */ -SSY = [153/255, 255/255, 0/255]; /* Spring Spring Yellow */ -GGS = [ 51/255, 255/255, 0/255]; /* Green Green Spring */ -YYS = [204/255, 255/255, 0/255]; /* Yellow Yellow Spring */ -DGS = [ 51/255, 204/255, 0/255]; /* Dark Green Spring */ -DYS = [153/255, 204/255, 0/255]; /* Dark Yellow Spring */ -LGS = [102/255, 255/255, 51/255]; /* Light Green Spring */ -LYS = [204/255, 255/255, 51/255]; /* Light Yellow Spring */ -DSG = [ 51/255, 153/255, 0/255]; /* Dark Spring Green */ -DSY = [102/255, 153/255, 0/255]; /* Dark Spring Yellow */ -LSG = [153/255, 255/255, 102/255]; /* Light Spring Green */ -LSY = [204/255, 255/255, 102/255]; /* Light Spring Yellow */ -MSG = [102/255, 204/255, 51/255]; /* Medium Spring Green */ -MSY = [153/255, 204/255, 51/255]; /* Medium Spring Yellow */ -TTC = [ 0/255, 255/255, 153/255]; /* Teal Teal Cyan */ -TTG = [ 0/255, 255/255, 102/255]; /* Teal Teal Green */ -CCT = [ 0/255, 255/255, 204/255]; /* Cyan Cyan Teal */ -GGT = [ 0/255, 255/255, 51/255]; /* Green Green Teal */ -DCT = [ 0/255, 204/255, 153/255]; /* Dark Cyan Teal */ -DGT = [ 0/255, 204/255, 51/255]; /* Dark Green Teal */ -LCT = [ 51/255, 255/255, 204/255]; /* Light Cyan Teal */ -LGT = [ 51/255, 255/255, 102/255]; /* Light Green Teal */ -DTC = [ 0/255, 153/255, 102/255]; /* Dark Teal Cyan */ -DTG = [ 0/255, 153/255, 51/255]; /* Dark Teal Green */ -LTC = [102/255, 255/255, 204/255]; /* Light Teal Cyan */ -LTG = [102/255, 255/255, 153/255]; /* Light Teal Green */ -MTC = [ 51/255, 204/255, 153/255]; /* Medium Teal Cyan */ -MTG = [ 51/255, 204/255, 102/255]; /* Medium Teal Green */ -AAB = [ 0/255, 102/255, 255/255]; /* Azure Azure Blue */ -AAC = [ 0/255, 153/255, 255/255]; /* Azure Azure Cyan */ -BBA = [ 0/255, 51/255, 255/255]; /* Blue Blue Azure */ -CCA = [ 0/255, 204/255, 255/255]; /* Cyan Cyan Azure */ -DBA = [ 0/255, 51/255, 204/255]; /* Dark Blue Azure */ -DCA = [ 0/255, 153/255, 204/255]; /* Dark Cyan Azure */ -LBA = [ 51/255, 102/255, 255/255]; /* Light Blue Azure */ -LCA = [ 51/255, 204/255, 255/255]; /* Light Cyan Azure */ -DAB = [ 0/255, 51/255, 153/255]; /* Dark Azure Blue */ -DAC = [ 0/255, 102/255, 153/255]; /* Dark Azure Cyan */ -LAB = [102/255, 153/255, 255/255]; /* Light Azure Blue */ -LAC = [102/255, 204/255, 255/255]; /* Light Azure Cyan */ -MAB = [ 51/255, 102/255, 204/255]; /* Medium Azure Blue */ -MAC = [ 51/255, 153/255, 204/255]; /* Medium Azure Cyan */ -VVM = [153/255, 0/255, 255/255]; /* Violet Violet Magenta */ -VVB = [102/255, 0/255, 255/255]; /* Violet Violet Blue */ -MMV = [204/255, 0/255, 255/255]; /* Magenta Magenta Violet */ -BBV = [ 51/255, 0/255, 255/255]; /* Blue Blue Violet */ -DMV = [153/255, 0/255, 204/255]; /* Dark Magenta Violet */ -DBV = [ 51/255, 0/255, 204/255]; /* Dark Blue Violet */ -LMV = [204/255, 51/255, 255/255]; /* Light Magenta Violet */ -LBV = [102/255, 51/255, 255/255]; /* Light Blue Violet */ -DVM = [102/255, 0/255, 153/255]; /* Dark Violet Magenta */ -DVB = [ 51/255, 0/255, 153/255]; /* Dark Violet Blue */ -LVM = [204/255, 102/255, 255/255]; /* Light Violet Magenta */ -LVB = [153/255, 102/255, 255/255]; /* Light Violet Blue */ -MVM = [153/255, 51/255, 204/255]; /* Medium Violet Magenta */ -MVB = [102/255, 51/255, 204/255]; /* Medium Violet Blue */ -OWM = [ 51/255, 0/255, 51/255]; /* Obscure Weak Magenta */ -ODM = [102/255, 0/255, 102/255]; /* Obscure Dull Magenta */ -DFM = [153/255, 0/255, 153/255]; /* Dark Faded Magenta */ -DHM = [204/255, 0/255, 204/255]; /* Dark Hard Magenta */ -M = [255/255, 0/255, 255/255]; /* Magenta */ -DWM = [102/255, 51/255, 102/255]; /* Dark Weak Magenta */ -DDM = [153/255, 51/255, 153/255]; /* Dark Dull Magenta */ -MFM = [204/255, 51/255, 204/255]; /* Medium Faded Magenta */ -LHM = [255/255, 51/255, 255/255]; /* Light Hard Magenta */ -MWM = [153/255, 102/255, 153/255]; /* Medium Weak Magenta */ -LDM = [204/255, 102/255, 204/255]; /* Light Dull Magenta */ -LFM = [255/255, 102/255, 255/255]; /* Light Faded Magenta */ -LWM = [204/255, 153/255, 204/255]; /* Light Weak Magenta */ -PDM = [255/255, 153/255, 255/255]; /* Pale Dull Magenta */ -PWM = [255/255, 204/255, 255/255]; /* Pale Weak Magenta */ -OWR = [ 51/255, 0/255, 0/255]; /* Obscure Weak Red */ -ODR = [102/255, 0/255, 0/255]; /* Obscure Dull Red */ -DFR = [153/255, 0/255, 0/255]; /* Dark Faded Red */ -DHR = [204/255, 0/255, 0/255]; /* Dark Hard Red */ -R = [255/255, 0/255, 0/255]; /* Red */ -DWR = [102/255, 51/255, 51/255]; /* Dark Weak Red */ -DDR = [153/255, 51/255, 51/255]; /* Dark Dull Red */ -MFR = [204/255, 51/255, 51/255]; /* Medium Faded Red */ -LHR = [255/255, 51/255, 51/255]; /* Light Hard Red */ -MWR = [153/255, 102/255, 102/255]; /* Medium Weak Red */ -LDR = [204/255, 102/255, 102/255]; /* Light Dull Red */ -LFR = [255/255, 102/255, 102/255]; /* Light Faded Red */ -LWR = [204/255, 153/255, 153/255]; /* Light Weak Red */ -PDR = [255/255, 153/255, 153/255]; /* Pale Dull Red */ -PWR = [255/255, 204/255, 204/255]; /* Pale Weak Red */ -OWY = [ 51/255, 51/255, 0/255]; /* Obscure Weak Yellow */ -ODY = [102/255, 102/255, 0/255]; /* Obscure Dull Yellow */ -DFY = [153/255, 153/255, 0/255]; /* Dark Faded Yellow */ -DHY = [204/255, 204/255, 0/255]; /* Dark Hard Yellow */ -Y = [255/255, 255/255, 0/255]; /* Yellow */ -DWY = [102/255, 102/255, 51/255]; /* Dark Weak Yellow */ -DDY = [153/255, 153/255, 51/255]; /* Dark Dull Yellow */ -MFY = [204/255, 204/255, 51/255]; /* Medium Faded Yellow */ -LHY = [255/255, 255/255, 51/255]; /* Light Hard Yellow */ -MWY = [153/255, 153/255, 102/255]; /* Medium Weak Yellow */ -LDY = [204/255, 204/255, 102/255]; /* Light Dull Yellow */ -LFY = [255/255, 255/255, 102/255]; /* Light Faded Yellow */ -LWY = [204/255, 204/255, 153/255]; /* Light Weak Yellow */ -PDY = [255/255, 255/255, 153/255]; /* Pale Dull Yellow */ -PWY = [255/255, 255/255, 204/255]; /* Pale Weak Yellow */ -OWG = [ 0/255, 51/255, 0/255]; /* Obscure Weak Green */ -ODG = [ 0/255, 102/255, 0/255]; /* Obscure Dull Green */ -DFG = [ 0/255, 153/255, 0/255]; /* Dark Faded Green */ -DHG = [ 0/255, 204/255, 0/255]; /* Dark Hard Green */ -G = [ 0/255, 255/255, 0/255]; /* Green */ -DWG = [ 51/255, 102/255, 51/255]; /* Dark Weak Green */ -DDG = [ 51/255, 153/255, 51/255]; /* Dark Dull Green */ -MFG = [ 51/255, 204/255, 51/255]; /* Medium Faded Green */ -LHG = [ 51/255, 255/255, 51/255]; /* Light Hard Green */ -MWG = [102/255, 153/255, 102/255]; /* Medium Weak Green */ -LDG = [102/255, 204/255, 102/255]; /* Light Dull Green */ -LFG = [102/255, 255/255, 102/255]; /* Light Faded Green */ -LWG = [153/255, 204/255, 153/255]; /* Light Weak Green */ -PDG = [153/255, 255/255, 153/255]; /* Pale Dull Green */ -PWG = [204/255, 255/255, 204/255]; /* Pale Weak Green */ -OWC = [ 0/255, 51/255, 51/255]; /* Obscure Weak Cyan */ -ODC = [ 0/255, 102/255, 102/255]; /* Obscure Dull Cyan */ -DFC = [ 0/255, 153/255, 153/255]; /* Dark Faded Cyan */ -DHC = [ 0/255, 204/255, 204/255]; /* Dark Hard Cyan */ -C = [ 0/255, 255/255, 255/255]; /* Cyan */ -DWC = [ 51/255, 102/255, 102/255]; /* Dark Weak Cyan */ -DDC = [ 51/255, 153/255, 153/255]; /* Dark Dull Cyan */ -MFC = [ 51/255, 204/255, 204/255]; /* Medium Faded Cyan */ -LHC = [ 51/255, 255/255, 255/255]; /* Light Hard Cyan */ -MWC = [102/255, 153/255, 153/255]; /* Medium Weak Cyan */ -LDC = [102/255, 204/255, 204/255]; /* Light Dull Cyan */ -LFC = [102/255, 255/255, 255/255]; /* Light Faded Cyan */ -LWC = [153/255, 204/255, 204/255]; /* Light Weak Cyan */ -PDC = [153/255, 255/255, 255/255]; /* Pale Dull Cyan */ -PWC = [204/255, 255/255, 255/255]; /* Pale Weak Cyan */ -OWB = [ 0/255, 0/255, 51/255]; /* Obscure Weak Blue */ -ODB = [ 0/255, 0/255, 102/255]; /* Obscure Dull Blue */ -DFB = [ 0/255, 0/255, 153/255]; /* Dark Faded Blue */ -DHB = [ 0/255, 0/255, 204/255]; /* Dark Hard Blue */ -B = [ 0/255, 0/255, 255/255]; /* Blue */ -DWB = [ 51/255, 51/255, 102/255]; /* Dark Weak Blue */ -DDB = [ 51/255, 51/255, 153/255]; /* Dark Dull Blue */ -MFB = [ 51/255, 51/255, 204/255]; /* Medium Faded Blue */ -LHB = [ 51/255, 51/255, 255/255]; /* Light Hard Blue */ -MWB = [102/255, 102/255, 153/255]; /* Medium Weak Blue */ -LDB = [102/255, 102/255, 204/255]; /* Light Dull Blue */ -LFB = [102/255, 102/255, 255/255]; /* Light Faded Blue */ -LWB = [153/255, 153/255, 204/255]; /* Light Weak Blue */ -PDB = [153/255, 153/255, 255/255]; /* Pale Dull Blue */ -PWB = [204/255, 204/255, 255/255]; /* Pale Weak Blue */ -ODP = [102/255, 0/255, 51/255]; /* Obscure Dull Pink */ -DDP = [153/255, 51/255, 102/255]; /* Dark Dull Pink */ -LDP = [204/255, 102/255, 153/255]; /* Light Dull Pink */ -PDP = [255/255, 153/255, 204/255]; /* Pale Dull Pink */ -DHP = [204/255, 0/255, 102/255]; /* Dark Hard Pink */ -LHP = [255/255, 51/255, 153/255]; /* Light Hard Pink */ -ODO = [102/255, 51/255, 0/255]; /* Obscure Dull Orange */ -DDO = [153/255, 102/255, 51/255]; /* Dark Dull Orange */ -LDO = [204/255, 153/255, 102/255]; /* Light Dull Orange */ -PDO = [255/255, 204/255, 153/255]; /* Pale Dull Orange */ -DHO = [204/255, 102/255, 0/255]; /* Dark Hard Orange */ -LHO = [255/255, 153/255, 51/255]; /* Light Hard Orange */ -ODS = [ 51/255, 102/255, 0/255]; /* Obscure Dull Spring */ -DDS = [102/255, 153/255, 51/255]; /* Dark Dull Spring */ -LDS = [153/255, 204/255, 102/255]; /* Light Dull Spring */ -PDS = [204/255, 255/255, 153/255]; /* Pale Dull Spring */ -DHS = [102/255, 204/255, 0/255]; /* Dark Hard Spring */ -LHS = [153/255, 255/255, 51/255]; /* Light Hard Spring */ -ODT = [ 0/255, 102/255, 51/255]; /* Obscure Dull Teal */ -DDT = [ 51/255, 153/255, 102/255]; /* Dark Dull Teal */ -LDT = [102/255, 204/255, 153/255]; /* Light Dull Teal */ -PDT = [153/255, 255/255, 204/255]; /* Pale Dull Teal */ -DHT = [ 0/255, 204/255, 102/255]; /* Dark Hard Teal */ -LHT = [ 51/255, 255/255, 153/255]; /* Light Hard Teal */ -ODA = [ 0/255, 51/255, 102/255]; /* Obscure Dull Azure */ -DDA = [ 51/255, 102/255, 153/255]; /* Dark Dull Azure */ -LDA = [102/255, 153/255, 204/255]; /* Light Dull Azure */ -PDA = [153/255, 204/255, 255/255]; /* Pale Dull Azure */ -DHA = [ 0/255, 102/255, 204/255]; /* Dark Hard Azure */ -LHA = [ 51/255, 153/255, 255/255]; /* Light Hard Azure */ -ODV = [ 51/255, 0/255, 102/255]; /* Obscure Dull Violet */ -DDV = [102/255, 51/255, 153/255]; /* Dark Dull Violet */ -LDV = [153/255, 102/255, 204/255]; /* Light Dull Violet */ -PDV = [204/255, 153/255, 255/255]; /* Pale Dull Violet */ -DHV = [102/255, 0/255, 204/255]; /* Dark Hard Violet */ -LHV = [153/255, 51/255, 255/255]; /* Light Hard Violet */ -K = [ 0/255, 0/255, 0/255]; /* Black */ -OG = [ 51/255, 51/255, 51/255]; /* Obscure Gray */ -DG = [102/255, 102/255, 102/255]; /* Dark Gray */ -LG = [153/255, 153/255, 153/255]; /* Light Gray */ -PG = [204/255, 204/255, 204/255]; /* Pale Gray */ -W = [255/255, 255/255, 255/255]; /* White */ +PPR = [ 255 / 255, 0 / 255, 102 / 255 ]; /* Pink Pink Red */ +PPM = [ 255 / 255, 0 / 255, 153 / 255 ]; /* Pink Pink Magenta */ +RRP = [ 255 / 255, 0 / 255, 51 / 255 ]; /* Red Red Pink */ +MMP = [ 255 / 255, 0 / 255, 204 / 255 ]; /* Magenta Magenta Pink */ +DRP = [ 204 / 255, 0 / 255, 51 / 255 ]; /* Dark Red Pink */ +DMP = [ 204 / 255, 0 / 255, 153 / 255 ]; /* Dark Magenta Pink */ +LRP = [ 255 / 255, 51 / 255, 102 / 255 ]; /* Light Red Pink */ +LMP = [ 255 / 255, 51 / 255, 204 / 255 ]; /* Light Magenta Pink */ +DPR = [ 153 / 255, 0 / 255, 51 / 255 ]; /* Dark Pink Red */ +DPM = [ 153 / 255, 0 / 255, 102 / 255 ]; /* Dark Pink Magenta */ +LPR = [ 255 / 255, 102 / 255, 153 / 255 ]; /* Light Pink Red */ +LPM = [ 255 / 255, 102 / 255, 204 / 255 ]; /* Light Pink Magenta */ +MPR = [ 204 / 255, 51 / 255, 102 / 255 ]; /* Medium Pink Red */ +MPM = [ 204 / 255, 51 / 255, 153 / 255 ]; /* Medium Pink Magenta */ +OOY = [ 255 / 255, 153 / 255, 0 / 255 ]; /* Orange Orange Yellow */ +OOR = [ 255 / 255, 102 / 255, 0 / 255 ]; /* Orange Orange Red */ +YYO = [ 255 / 255, 204 / 255, 0 / 255 ]; /* Yellow Yellow Orange */ +RRO = [ 255 / 255, 51 / 255, 0 / 255 ]; /* Red Red Orange */ +DYO = [ 204 / 255, 153 / 255, 0 / 255 ]; /* Dark Yellow Orange */ +DRO = [ 204 / 255, 51 / 255, 0 / 255 ]; /* Dark Red Orange */ +LYO = [ 255 / 255, 204 / 255, 51 / 255 ]; /* Light Yellow Orange */ +LRO = [ 255 / 255, 102 / 255, 51 / 255 ]; /* Light Red Orange */ +DOY = [ 153 / 255, 102 / 255, 0 / 255 ]; /* Dark Orange Yellow */ +DOR = [ 153 / 255, 51 / 255, 0 / 255 ]; /* Dark Orange Red */ +LOY = [ 255 / 255, 204 / 255, 102 / 255 ]; /* Light Orange Yellow */ +LOR = [ 255 / 255, 153 / 255, 102 / 255 ]; /* Light Orange Red */ +MOY = [ 204 / 255, 153 / 255, 51 / 255 ]; /* Medium Orange Yellow */ +MOR = [ 204 / 255, 102 / 255, 51 / 255 ]; /* Medium Orange Red */ +SSG = [ 102 / 255, 255 / 255, 0 / 255 ]; /* Spring Spring Green */ +SSY = [ 153 / 255, 255 / 255, 0 / 255 ]; /* Spring Spring Yellow */ +GGS = [ 51 / 255, 255 / 255, 0 / 255 ]; /* Green Green Spring */ +YYS = [ 204 / 255, 255 / 255, 0 / 255 ]; /* Yellow Yellow Spring */ +DGS = [ 51 / 255, 204 / 255, 0 / 255 ]; /* Dark Green Spring */ +DYS = [ 153 / 255, 204 / 255, 0 / 255 ]; /* Dark Yellow Spring */ +LGS = [ 102 / 255, 255 / 255, 51 / 255 ]; /* Light Green Spring */ +LYS = [ 204 / 255, 255 / 255, 51 / 255 ]; /* Light Yellow Spring */ +DSG = [ 51 / 255, 153 / 255, 0 / 255 ]; /* Dark Spring Green */ +DSY = [ 102 / 255, 153 / 255, 0 / 255 ]; /* Dark Spring Yellow */ +LSG = [ 153 / 255, 255 / 255, 102 / 255 ]; /* Light Spring Green */ +LSY = [ 204 / 255, 255 / 255, 102 / 255 ]; /* Light Spring Yellow */ +MSG = [ 102 / 255, 204 / 255, 51 / 255 ]; /* Medium Spring Green */ +MSY = [ 153 / 255, 204 / 255, 51 / 255 ]; /* Medium Spring Yellow */ +TTC = [ 0 / 255, 255 / 255, 153 / 255 ]; /* Teal Teal Cyan */ +TTG = [ 0 / 255, 255 / 255, 102 / 255 ]; /* Teal Teal Green */ +CCT = [ 0 / 255, 255 / 255, 204 / 255 ]; /* Cyan Cyan Teal */ +GGT = [ 0 / 255, 255 / 255, 51 / 255 ]; /* Green Green Teal */ +DCT = [ 0 / 255, 204 / 255, 153 / 255 ]; /* Dark Cyan Teal */ +DGT = [ 0 / 255, 204 / 255, 51 / 255 ]; /* Dark Green Teal */ +LCT = [ 51 / 255, 255 / 255, 204 / 255 ]; /* Light Cyan Teal */ +LGT = [ 51 / 255, 255 / 255, 102 / 255 ]; /* Light Green Teal */ +DTC = [ 0 / 255, 153 / 255, 102 / 255 ]; /* Dark Teal Cyan */ +DTG = [ 0 / 255, 153 / 255, 51 / 255 ]; /* Dark Teal Green */ +LTC = [ 102 / 255, 255 / 255, 204 / 255 ]; /* Light Teal Cyan */ +LTG = [ 102 / 255, 255 / 255, 153 / 255 ]; /* Light Teal Green */ +MTC = [ 51 / 255, 204 / 255, 153 / 255 ]; /* Medium Teal Cyan */ +MTG = [ 51 / 255, 204 / 255, 102 / 255 ]; /* Medium Teal Green */ +AAB = [ 0 / 255, 102 / 255, 255 / 255 ]; /* Azure Azure Blue */ +AAC = [ 0 / 255, 153 / 255, 255 / 255 ]; /* Azure Azure Cyan */ +BBA = [ 0 / 255, 51 / 255, 255 / 255 ]; /* Blue Blue Azure */ +CCA = [ 0 / 255, 204 / 255, 255 / 255 ]; /* Cyan Cyan Azure */ +DBA = [ 0 / 255, 51 / 255, 204 / 255 ]; /* Dark Blue Azure */ +DCA = [ 0 / 255, 153 / 255, 204 / 255 ]; /* Dark Cyan Azure */ +LBA = [ 51 / 255, 102 / 255, 255 / 255 ]; /* Light Blue Azure */ +LCA = [ 51 / 255, 204 / 255, 255 / 255 ]; /* Light Cyan Azure */ +DAB = [ 0 / 255, 51 / 255, 153 / 255 ]; /* Dark Azure Blue */ +DAC = [ 0 / 255, 102 / 255, 153 / 255 ]; /* Dark Azure Cyan */ +LAB = [ 102 / 255, 153 / 255, 255 / 255 ]; /* Light Azure Blue */ +LAC = [ 102 / 255, 204 / 255, 255 / 255 ]; /* Light Azure Cyan */ +MAB = [ 51 / 255, 102 / 255, 204 / 255 ]; /* Medium Azure Blue */ +MAC = [ 51 / 255, 153 / 255, 204 / 255 ]; /* Medium Azure Cyan */ +VVM = [ 153 / 255, 0 / 255, 255 / 255 ]; /* Violet Violet Magenta */ +VVB = [ 102 / 255, 0 / 255, 255 / 255 ]; /* Violet Violet Blue */ +MMV = [ 204 / 255, 0 / 255, 255 / 255 ]; /* Magenta Magenta Violet */ +BBV = [ 51 / 255, 0 / 255, 255 / 255 ]; /* Blue Blue Violet */ +DMV = [ 153 / 255, 0 / 255, 204 / 255 ]; /* Dark Magenta Violet */ +DBV = [ 51 / 255, 0 / 255, 204 / 255 ]; /* Dark Blue Violet */ +LMV = [ 204 / 255, 51 / 255, 255 / 255 ]; /* Light Magenta Violet */ +LBV = [ 102 / 255, 51 / 255, 255 / 255 ]; /* Light Blue Violet */ +DVM = [ 102 / 255, 0 / 255, 153 / 255 ]; /* Dark Violet Magenta */ +DVB = [ 51 / 255, 0 / 255, 153 / 255 ]; /* Dark Violet Blue */ +LVM = [ 204 / 255, 102 / 255, 255 / 255 ]; /* Light Violet Magenta */ +LVB = [ 153 / 255, 102 / 255, 255 / 255 ]; /* Light Violet Blue */ +MVM = [ 153 / 255, 51 / 255, 204 / 255 ]; /* Medium Violet Magenta */ +MVB = [ 102 / 255, 51 / 255, 204 / 255 ]; /* Medium Violet Blue */ +OWM = [ 51 / 255, 0 / 255, 51 / 255 ]; /* Obscure Weak Magenta */ +ODM = [ 102 / 255, 0 / 255, 102 / 255 ]; /* Obscure Dull Magenta */ +DFM = [ 153 / 255, 0 / 255, 153 / 255 ]; /* Dark Faded Magenta */ +DHM = [ 204 / 255, 0 / 255, 204 / 255 ]; /* Dark Hard Magenta */ +M = [ 255 / 255, 0 / 255, 255 / 255 ]; /* Magenta */ +DWM = [ 102 / 255, 51 / 255, 102 / 255 ]; /* Dark Weak Magenta */ +DDM = [ 153 / 255, 51 / 255, 153 / 255 ]; /* Dark Dull Magenta */ +MFM = [ 204 / 255, 51 / 255, 204 / 255 ]; /* Medium Faded Magenta */ +LHM = [ 255 / 255, 51 / 255, 255 / 255 ]; /* Light Hard Magenta */ +MWM = [ 153 / 255, 102 / 255, 153 / 255 ]; /* Medium Weak Magenta */ +LDM = [ 204 / 255, 102 / 255, 204 / 255 ]; /* Light Dull Magenta */ +LFM = [ 255 / 255, 102 / 255, 255 / 255 ]; /* Light Faded Magenta */ +LWM = [ 204 / 255, 153 / 255, 204 / 255 ]; /* Light Weak Magenta */ +PDM = [ 255 / 255, 153 / 255, 255 / 255 ]; /* Pale Dull Magenta */ +PWM = [ 255 / 255, 204 / 255, 255 / 255 ]; /* Pale Weak Magenta */ +OWR = [ 51 / 255, 0 / 255, 0 / 255 ]; /* Obscure Weak Red */ +ODR = [ 102 / 255, 0 / 255, 0 / 255 ]; /* Obscure Dull Red */ +DFR = [ 153 / 255, 0 / 255, 0 / 255 ]; /* Dark Faded Red */ +DHR = [ 204 / 255, 0 / 255, 0 / 255 ]; /* Dark Hard Red */ +R = [ 255 / 255, 0 / 255, 0 / 255 ]; /* Red */ +DWR = [ 102 / 255, 51 / 255, 51 / 255 ]; /* Dark Weak Red */ +DDR = [ 153 / 255, 51 / 255, 51 / 255 ]; /* Dark Dull Red */ +MFR = [ 204 / 255, 51 / 255, 51 / 255 ]; /* Medium Faded Red */ +LHR = [ 255 / 255, 51 / 255, 51 / 255 ]; /* Light Hard Red */ +MWR = [ 153 / 255, 102 / 255, 102 / 255 ]; /* Me,dium Weak Red */ +LDR = [ 204 / 255, 102 / 255, 102 / 255 ]; /* Light Dull Red */ +LFR = [ 255 / 255, 102 / 255, 102 / 255 ]; /* Light Faded Red */ +LWR = [ 204 / 255, 153 / 255, 153 / 255 ]; /* Light Weak Red */ +PDR = [ 255 / 255, 153 / 255, 153 / 255 ]; /* Pale Dull Red */ +PWR = [ 255 / 255, 204 / 255, 204 / 255 ]; /* Pale Weak Red */ +OWY = [ 51 / 255, 51 / 255, 0 / 255 ]; /* Obscure Weak Yellow */ +ODY = [ 102 / 255, 102 / 255, 0 / 255 ]; /* Obscure Dull Yellow */ +DFY = [ 153 / 255, 153 / 255, 0 / 255 ]; /* Dark Faded Yellow */ +DHY = [ 204 / 255, 204 / 255, 0 / 255 ]; /* Dark Hard Yellow */ +Y = [ 255 / 255, 255 / 255, 0 / 255 ]; /* Yellow */ +DWY = [ 102 / 255, 102 / 255, 51 / 255 ]; /* Dark Weak Yellow */ +DDY = [ 153 / 255, 153 / 255, 51 / 255 ]; /* Dark Dull Yellow */ +MFY = [ 204 / 255, 204 / 255, 51 / 255 ]; /* Medium Faded Yellow */ +LHY = [ 255 / 255, 255 / 255, 51 / 255 ]; /* Light Hard Yellow */ +MWY = [ 153 / 255, 153 / 255, 102 / 255 ]; /* Medium Weak Yellow */ +LDY = [ 204 / 255, 204 / 255, 102 / 255 ]; /* Light Dull Yellow */ +LFY = [ 255 / 255, 255 / 255, 102 / 255 ]; /* Light Faded Yellow */ +LWY = [ 204 / 255, 204 / 255, 153 / 255 ]; /* Light Weak Yellow */ +PDY = [ 255 / 255, 255 / 255, 153 / 255 ]; /* Pale Dull Yellow */ +PWY = [ 255 / 255, 255 / 255, 204 / 255 ]; /* Pale Weak Yellow */ +OWG = [ 0 / 255, 51 / 255, 0 / 255 ]; /* Obscure Weak Green */ +ODG = [ 0 / 255, 102 / 255, 0 / 255 ]; /* Obscure Dull Green */ +DFG = [ 0 / 255, 153 / 255, 0 / 255 ]; /* Dark Faded Green */ +DHG = [ 0 / 255, 204 / 255, 0 / 255 ]; /* Dark Hard Green */ +G = [ 0 / 255, 255 / 255, 0 / 255 ]; /* Green */ +DWG = [ 51 / 255, 102 / 255, 51 / 255 ]; /* Dark Weak Green */ +DDG = [ 51 / 255, 153 / 255, 51 / 255 ]; /* Dark Dull Green */ +MFG = [ 51 / 255, 204 / 255, 51 / 255 ]; /* Medium Faded Green */ +LHG = [ 51 / 255, 255 / 255, 51 / 255 ]; /* Light Hard Green */ +MWG = [ 102 / 255, 153 / 255, 102 / 255 ]; /* Medium Weak Green */ +LDG = [ 102 / 255, 204 / 255, 102 / 255 ]; /* Light Dull Green */ +LFG = [ 102 / 255, 255 / 255, 102 / 255 ]; /* Light Faded Green */ +LWG = [ 153 / 255, 204 / 255, 153 / 255 ]; /* Light Weak Green */ +PDG = [ 153 / 255, 255 / 255, 153 / 255 ]; /* Pale Dull Green */ +PWG = [ 204 / 255, 255 / 255, 204 / 255 ]; /* Pale Weak Green */ +OWC = [ 0 / 255, 51 / 255, 51 / 255 ]; /* Obscure Weak Cyan */ +ODC = [ 0 / 255, 102 / 255, 102 / 255 ]; /* Obscure Dull Cyan */ +DFC = [ 0 / 255, 153 / 255, 153 / 255 ]; /* Dark Faded Cyan */ +DHC = [ 0 / 255, 204 / 255, 204 / 255 ]; /* Dark Hard Cyan */ +C = [ 0 / 255, 255 / 255, 255 / 255 ]; /* Cyan */ +DWC = [ 51 / 255, 102 / 255, 102 / 255 ]; /* Dark Weak Cyan */ +DDC = [ 51 / 255, 153 / 255, 153 / 255 ]; /* Dark Dull Cyan */ +MFC = [ 51 / 255, 204 / 255, 204 / 255 ]; /* Medium Faded Cyan */ +LHC = [ 51 / 255, 255 / 255, 255 / 255 ]; /* Light Hard Cyan */ +MWC = [ 102 / 255, 153 / 255, 153 / 255 ]; /* Medium Weak Cyan */ +LDC = [ 102 / 255, 204 / 255, 204 / 255 ]; /* Light Dull Cyan */ +LFC = [ 102 / 255, 255 / 255, 255 / 255 ]; /* Light Faded Cyan */ +LWC = [ 153 / 255, 204 / 255, 204 / 255 ]; /* Light Weak Cyan */ +PDC = [ 153 / 255, 255 / 255, 255 / 255 ]; /* Pale Dull Cyan */ +PWC = [ 204 / 255, 255 / 255, 255 / 255 ]; /* Pale Weak Cyan */ +OWB = [ 0 / 255, 0 / 255, 51 / 255 ]; /* Obscure Weak Blue */ +ODB = [ 0 / 255, 0 / 255, 102 / 255 ]; /* Obscure Dull Blue */ +DFB = [ 0 / 255, 0 / 255, 153 / 255 ]; /* Dark Faded Blue */ +DHB = [ 0 / 255, 0 / 255, 204 / 255 ]; /* Dark Hard Blue */ +B = [ 0 / 255, 0 / 255, 255 / 255 ]; /* Blue */ +DWB = [ 51 / 255, 51 / 255, 102 / 255 ]; /* Dark Weak Blue */ +DDB = [ 51 / 255, 51 / 255, 153 / 255 ]; /* Dark Dull Blue */ +MFB = [ 51 / 255, 51 / 255, 204 / 255 ]; /* Medium Faded Blue */ +LHB = [ 51 / 255, 51 / 255, 255 / 255 ]; /* Light Hard Blue */ +MWB = [ 102 / 255, 102 / 255, 153 / 255 ]; /* Medium Weak Blue */ +LDB = [ 102 / 255, 102 / 255, 204 / 255 ]; /* Light Dull Blue */ +LFB = [ 102 / 255, 102 / 255, 255 / 255 ]; /* Light Faded Blue */ +LWB = [ 153 / 255, 153 / 255, 204 / 255 ]; /* Light Weak Blue */ +PDB = [ 153 / 255, 153 / 255, 255 / 255 ]; /* Pale Dull Blue */ +PWB = [ 204 / 255, 204 / 255, 255 / 255 ]; /* Pale Weak Blue */ +ODP = [ 102 / 255, 0 / 255, 51 / 255 ]; /* Obscure Dull Pink */ +DDP = [ 153 / 255, 51 / 255, 102 / 255 ]; /* Dark Dull Pink */ +LDP = [ 204 / 255, 102 / 255, 153 / 255 ]; /* Light Dull Pink */ +PDP = [ 255 / 255, 153 / 255, 204 / 255 ]; /* Pale Dull Pink */ +DHP = [ 204 / 255, 0 / 255, 102 / 255 ]; /* Dark Hard Pink */ +LHP = [ 255 / 255, 51 / 255, 153 / 255 ]; /* Light Hard Pink */ +ODO = [ 102 / 255, 51 / 255, 0 / 255 ]; /* Obscure Dull Orange */ +DDO = [ 153 / 255, 102 / 255, 51 / 255 ]; /* Dark Dull Orange */ +LDO = [ 204 / 255, 153 / 255, 102 / 255 ]; /* Light Dull Orange */ +PDO = [ 255 / 255, 204 / 255, 153 / 255 ]; /* Pale Dull Orange */ +DHO = [ 204 / 255, 102 / 255, 0 / 255 ]; /* Dark Hard Orange */ +LHO = [ 255 / 255, 153 / 255, 51 / 255 ]; /* Light Hard Orange */ +ODS = [ 51 / 255, 102 / 255, 0 / 255 ]; /* Obscure Dull Spring */ +DDS = [ 102 / 255, 153 / 255, 51 / 255 ]; /* Dark Dull Spring */ +LDS = [ 153 / 255, 204 / 255, 102 / 255 ]; /* Light Dull Spring */ +PDS = [ 204 / 255, 255 / 255, 153 / 255 ]; /* Pale Dull Spring */ +DHS = [ 102 / 255, 204 / 255, 0 / 255 ]; /* Dark Hard Spring */ +LHS = [ 153 / 255, 255 / 255, 51 / 255 ]; /* Light Hard Spring */ +ODT = [ 0 / 255, 102 / 255, 51 / 255 ]; /* Obscure Dull Teal */ +DDT = [ 51 / 255, 153 / 255, 102 / 255 ]; /* Dark Dull Teal */ +LDT = [ 102 / 255, 204 / 255, 153 / 255 ]; /* Light Dull Teal */ +PDT = [ 153 / 255, 255 / 255, 204 / 255 ]; /* Pale Dull Teal */ +DHT = [ 0 / 255, 204 / 255, 102 / 255 ]; /* Dark Hard Teal */ +LHT = [ 51 / 255, 255 / 255, 153 / 255 ]; /* Light Hard Teal */ +ODA = [ 0 / 255, 51 / 255, 102 / 255 ]; /* Obscure Dull Azure */ +DDA = [ 51 / 255, 102 / 255, 153 / 255 ]; /* Dark Dull Azure */ +LDA = [ 102 / 255, 153 / 255, 204 / 255 ]; /* Light Dull Azure */ +PDA = [ 153 / 255, 204 / 255, 255 / 255 ]; /* Pale Dull Azure */ +DHA = [ 0 / 255, 102 / 255, 204 / 255 ]; /* Dark Hard Azure */ +LHA = [ 51 / 255, 153 / 255, 255 / 255 ]; /* Light Hard Azure */ +ODV = [ 51 / 255, 0 / 255, 102 / 255 ]; /* Obscure Dull Violet */ +DDV = [ 102 / 255, 51 / 255, 153 / 255 ]; /* Dark Dull Violet */ +LDV = [ 153 / 255, 102 / 255, 204 / 255 ]; /* Light Dull Violet */ +PDV = [ 204 / 255, 153 / 255, 255 / 255 ]; /* Pale Dull Violet */ +DHV = [ 102 / 255, 0 / 255, 204 / 255 ]; /* Dark Hard Violet */ +LHV = [ 153 / 255, 51 / 255, 255 / 255 ]; /* Light Hard Violet */ +K = [ 0 / 255, 0 / 255, 0 / 255 ]; /* Black */ +OG = [ 51 / 255, 51 / 255, 51 / 255 ]; /* Obscure Gray */ +DG = [ 102 / 255, 102 / 255, 102 / 255 ]; /* Dark Gray */ +LG = [ 153 / 255, 153 / 255, 153 / 255 ]; /* Light Gray */ +PG = [ 204 / 255, 204 / 255, 204 / 255 ]; /* Pale Gray */ +W = [ 255 / 255, 255 / 255, 255 / 255 ]; /* White */ -module colorshelp() +module +colorshelp() { - echo("--- visibonecolorshelp ---"); - echo("color(PPR); /* Pink Pink Red */"); - echo("color(PPM); /* Pink Pink Magenta */"); - echo("color(RRP); /* Red Red Pink */"); - echo("color(MMP); /* Magenta Magenta Pink */"); - echo("color(DRP); /* Dark Red Pink */"); - echo("color(DMP); /* Dark Magenta Pink */"); - echo("color(LRP); /* Light Red Pink */"); - echo("color(LMP); /* Light Magenta Pink */"); - echo("color(DPR); /* Dark Pink Red */"); - echo("color(DPM); /* Dark Pink Magenta */"); - echo("color(LPR); /* Light Pink Red */"); - echo("color(LPM); /* Light Pink Magenta */"); - echo("color(MPR); /* Medium Pink Red */"); - echo("color(MPM); /* Medium Pink Magenta */"); - echo("color(OOY); /* Orange Orange Yellow */"); - echo("color(OOR); /* Orange Orange Red */"); - echo("color(YYO); /* Yellow Yellow Orange */"); - echo("color(RRO); /* Red Red Orange */"); - echo("color(DYO); /* Dark Yellow Orange */"); - echo("color(DRO); /* Dark Red Orange */"); - echo("color(LYO); /* Light Yellow Orange */"); - echo("color(LRO); /* Light Red Orange */"); - echo("color(DOY); /* Dark Orange Yellow */"); - echo("color(DOR); /* Dark Orange Red */"); - echo("color(LOY); /* Light Orange Yellow */"); - echo("color(LOR); /* Light Orange Red */"); - echo("color(MOY); /* Medium Orange Yellow */"); - echo("color(MOR); /* Medium Orange Red */"); - echo("color(SSG); /* Spring Spring Green */"); - echo("color(SSY); /* Spring Spring Yellow */"); - echo("color(GGS); /* Green Green Spring */"); - echo("color(YYS); /* Yellow Yellow Spring */"); - echo("color(DGS); /* Dark Green Spring */"); - echo("color(DYS); /* Dark Yellow Spring */"); - echo("color(LGS); /* Light Green Spring */"); - echo("color(LYS); /* Light Yellow Spring */"); - echo("color(DSG); /* Dark Spring Green */"); - echo("color(DSY); /* Dark Spring Yellow */"); - echo("color(LSG); /* Light Spring Green */"); - echo("color(LSY); /* Light Spring Yellow */"); - echo("color(MSG); /* Medium Spring Green */"); - echo("color(MSY); /* Medium Spring Yellow */"); - echo("color(TTC); /* Teal Teal Cyan */"); - echo("color(TTG); /* Teal Teal Green */"); - echo("color(CCT); /* Cyan Cyan Teal */"); - echo("color(GGT); /* Green Green Teal */"); - echo("color(DCT); /* Dark Cyan Teal */"); - echo("color(DGT); /* Dark Green Teal */"); - echo("color(LCT); /* Light Cyan Teal */"); - echo("color(LGT); /* Light Green Teal */"); - echo("color(DTC); /* Dark Teal Cyan */"); - echo("color(DTG); /* Dark Teal Green */"); - echo("color(LTC); /* Light Teal Cyan */"); - echo("color(LTG); /* Light Teal Green */"); - echo("color(MTC); /* Medium Teal Cyan */"); - echo("color(MTG); /* Medium Teal Green */"); - echo("color(AAB); /* Azure Azure Blue */"); - echo("color(AAC); /* Azure Azure Cyan */"); - echo("color(BBA); /* Blue Blue Azure */"); - echo("color(CCA); /* Cyan Cyan Azure */"); - echo("color(DBA); /* Dark Blue Azure */"); - echo("color(DCA); /* Dark Cyan Azure */"); - echo("color(LBA); /* Light Blue Azure */"); - echo("color(LCA); /* Light Cyan Azure */"); - echo("color(DAB); /* Dark Azure Blue */"); - echo("color(DAC); /* Dark Azure Cyan */"); - echo("color(LAB); /* Light Azure Blue */"); - echo("color(LAC); /* Light Azure Cyan */"); - echo("color(MAB); /* Medium Azure Blue */"); - echo("color(MAC); /* Medium Azure Cyan */"); - echo("color(VVM); /* Violet Violet Magenta */"); - echo("color(VVB); /* Violet Violet Blue */"); - echo("color(MMV); /* Magenta Magenta Violet */"); - echo("color(BBV); /* Blue Blue Violet */"); - echo("color(DMV); /* Dark Magenta Violet */"); - echo("color(DBV); /* Dark Blue Violet */"); - echo("color(LMV); /* Light Magenta Violet */"); - echo("color(LBV); /* Light Blue Violet */"); - echo("color(DVM); /* Dark Violet Magenta */"); - echo("color(DVB); /* Dark Violet Blue */"); - echo("color(LVM); /* Light Violet Magenta */"); - echo("color(LVB); /* Light Violet Blue */"); - echo("color(MVM); /* Medium Violet Magenta */"); - echo("color(MVB); /* Medium Violet Blue */"); - echo("color(OWM); /* Obscure Weak Magenta */"); - echo("color(ODM); /* Obscure Dull Magenta */"); - echo("color(DFM); /* Dark Faded Magenta */"); - echo("color(DHM); /* Dark Hard Magenta */"); - echo("color(M); /* Magenta */"); - echo("color(DWM); /* Dark Weak Magenta */"); - echo("color(DDM); /* Dark Dull Magenta */"); - echo("color(MFM); /* Medium Faded Magenta */"); - echo("color(LHM); /* Light Hard Magenta */"); - echo("color(MWM); /* Medium Weak Magenta */"); - echo("color(LDM); /* Light Dull Magenta */"); - echo("color(LFM); /* Light Faded Magenta */"); - echo("color(LWM); /* Light Weak Magenta */"); - echo("color(PDM); /* Pale Dull Magenta */"); - echo("color(PWM); /* Pale Weak Magenta */"); - echo("color(OWR); /* Obscure Weak Red */"); - echo("color(ODR); /* Obscure Dull Red */"); - echo("color(DFR); /* Dark Faded Red */"); - echo("color(DHR); /* Dark Hard Red */"); - echo("color(R); /* Red */"); - echo("color(DWR); /* Dark Weak Red */"); - echo("color(DDR); /* Dark Dull Red */"); - echo("color(MFR); /* Medium Faded Red */"); - echo("color(LHR); /* Light Hard Red */"); - echo("color(MWR); /* Medium Weak Red */"); - echo("color(LDR); /* Light Dull Red */"); - echo("color(LFR); /* Light Faded Red */"); - echo("color(LWR); /* Light Weak Red */"); - echo("color(PDR); /* Pale Dull Red */"); - echo("color(PWR); /* Pale Weak Red */"); - echo("color(OWY); /* Obscure Weak Yellow */"); - echo("color(ODY); /* Obscure Dull Yellow */"); - echo("color(DFY); /* Dark Faded Yellow */"); - echo("color(DHY); /* Dark Hard Yellow */"); - echo("color(Y); /* Yellow */"); - echo("color(DWY); /* Dark Weak Yellow */"); - echo("color(DDY); /* Dark Dull Yellow */"); - echo("color(MFY); /* Medium Faded Yellow */"); - echo("color(LHY); /* Light Hard Yellow */"); - echo("color(MWY); /* Medium Weak Yellow */"); - echo("color(LDY); /* Light Dull Yellow */"); - echo("color(LFY); /* Light Faded Yellow */"); - echo("color(LWY); /* Light Weak Yellow */"); - echo("color(PDY); /* Pale Dull Yellow */"); - echo("color(PWY); /* Pale Weak Yellow */"); - echo("color(OWG); /* Obscure Weak Green */"); - echo("color(ODG); /* Obscure Dull Green */"); - echo("color(DFG); /* Dark Faded Green */"); - echo("color(DHG); /* Dark Hard Green */"); - echo("color(G); /* Green */"); - echo("color(DWG); /* Dark Weak Green */"); - echo("color(DDG); /* Dark Dull Green */"); - echo("color(MFG); /* Medium Faded Green */"); - echo("color(LHG); /* Light Hard Green */"); - echo("color(MWG); /* Medium Weak Green */"); - echo("color(LDG); /* Light Dull Green */"); - echo("color(LFG); /* Light Faded Green */"); - echo("color(LWG); /* Light Weak Green */"); - echo("color(PDG); /* Pale Dull Green */"); - echo("color(PWG); /* Pale Weak Green */"); - echo("color(OWC); /* Obscure Weak Cyan */"); - echo("color(ODC); /* Obscure Dull Cyan */"); - echo("color(DFC); /* Dark Faded Cyan */"); - echo("color(DHC); /* Dark Hard Cyan */"); - echo("color(C); /* Cyan */"); - echo("color(DWC); /* Dark Weak Cyan */"); - echo("color(DDC); /* Dark Dull Cyan */"); - echo("color(MFC); /* Medium Faded Cyan */"); - echo("color(LHC); /* Light Hard Cyan */"); - echo("color(MWC); /* Medium Weak Cyan */"); - echo("color(LDC); /* Light Dull Cyan */"); - echo("color(LFC); /* Light Faded Cyan */"); - echo("color(LWC); /* Light Weak Cyan */"); - echo("color(PDC); /* Pale Dull Cyan */"); - echo("color(PWC); /* Pale Weak Cyan */"); - echo("color(OWB); /* Obscure Weak Blue */"); - echo("color(ODB); /* Obscure Dull Blue */"); - echo("color(DFB); /* Dark Faded Blue */"); - echo("color(DHB); /* Dark Hard Blue */"); - echo("color(B); /* Blue */"); - echo("color(DWB); /* Dark Weak Blue */"); - echo("color(DDB); /* Dark Dull Blue */"); - echo("color(MFB); /* Medium Faded Blue */"); - echo("color(LHB); /* Light Hard Blue */"); - echo("color(MWB); /* Medium Weak Blue */"); - echo("color(LDB); /* Light Dull Blue */"); - echo("color(LFB); /* Light Faded Blue */"); - echo("color(LWB); /* Light Weak Blue */"); - echo("color(PDB); /* Pale Dull Blue */"); - echo("color(PWB); /* Pale Weak Blue */"); - echo("color(ODP); /* Obscure Dull Pink */"); - echo("color(DDP); /* Dark Dull Pink */"); - echo("color(LDP); /* Light Dull Pink */"); - echo("color(PDP); /* Pale Dull Pink */"); - echo("color(DHP); /* Dark Hard Pink */"); - echo("color(LHP); /* Light Hard Pink */"); - echo("color(ODO); /* Obscure Dull Orange */"); - echo("color(DDO); /* Dark Dull Orange */"); - echo("color(LDO); /* Light Dull Orange */"); - echo("color(PDO); /* Pale Dull Orange */"); - echo("color(DHO); /* Dark Hard Orange */"); - echo("color(LHO); /* Light Hard Orange */"); - echo("color(ODS); /* Obscure Dull Spring */"); - echo("color(DDS); /* Dark Dull Spring */"); - echo("color(LDS); /* Light Dull Spring */"); - echo("color(PDS); /* Pale Dull Spring */"); - echo("color(DHS); /* Dark Hard Spring */"); - echo("color(LHS); /* Light Hard Spring */"); - echo("color(ODT); /* Obscure Dull Teal */"); - echo("color(DDT); /* Dark Dull Teal */"); - echo("color(LDT); /* Light Dull Teal */"); - echo("color(PDT); /* Pale Dull Teal */"); - echo("color(DHT); /* Dark Hard Teal */"); - echo("color(LHT); /* Light Hard Teal */"); - echo("color(ODA); /* Obscure Dull Azure */"); - echo("color(DDA); /* Dark Dull Azure */"); - echo("color(LDA); /* Light Dull Azure */"); - echo("color(PDA); /* Pale Dull Azure */"); - echo("color(DHA); /* Dark Hard Azure */"); - echo("color(LHA); /* Light Hard Azure */"); - echo("color(ODV); /* Obscure Dull Violet */"); - echo("color(DDV); /* Dark Dull Violet */"); - echo("color(LDV); /* Light Dull Violet */"); - echo("color(PDV); /* Pale Dull Violet */"); - echo("color(DHV); /* Dark Hard Violet */"); - echo("color(LHV); /* Light Hard Violet */"); - echo("color(K); /* Black */"); - echo("color(OG); /* Obscure Gray */"); - echo("color(DG); /* Dark Gray */"); - echo("color(LG); /* Light Gray */"); - echo("color(PG); /* Pale Gray */"); - echo("color(W); /* White */"); + echo("--- visibonecolorshelp ---"); + echo("color(PPR); /* Pink Pink Red */"); + echo("color(PPM); /* Pink Pink Magenta */"); + echo("color(RRP); /* Red Red Pink */"); + echo("color(MMP); /* Magenta Magenta Pink */"); + echo("color(DRP); /* Dark Red Pink */"); + echo("color(DMP); /* Dark Magenta Pink */"); + echo("color(LRP); /* Light Red Pink */"); + echo("color(LMP); /* Light Magenta Pink */"); + echo("color(DPR); /* Dark Pink Red */"); + echo("color(DPM); /* Dark Pink Magenta */"); + echo("color(LPR); /* Light Pink Red */"); + echo("color(LPM); /* Light Pink Magenta */"); + echo("color(MPR); /* Medium Pink Red */"); + echo("color(MPM); /* Medium Pink Magenta */"); + echo("color(OOY); /* Orange Orange Yellow */"); + echo("color(OOR); /* Orange Orange Red */"); + echo("color(YYO); /* Yellow Yellow Orange */"); + echo("color(RRO); /* Red Red Orange */"); + echo("color(DYO); /* Dark Yellow Orange */"); + echo("color(DRO); /* Dark Red Orange */"); + echo("color(LYO); /* Light Yellow Orange */"); + echo("color(LRO); /* Light Red Orange */"); + echo("color(DOY); /* Dark Orange Yellow */"); + echo("color(DOR); /* Dark Orange Red */"); + echo("color(LOY); /* Light Orange Yellow */"); + echo("color(LOR); /* Light Orange Red */"); + echo("color(MOY); /* Medium Orange Yellow */"); + echo("color(MOR); /* Medium Orange Red */"); + echo("color(SSG); /* Spring Spring Green */"); + echo("color(SSY); /* Spring Spring Yellow */"); + echo("color(GGS); /* Green Green Spring */"); + echo("color(YYS); /* Yellow Yellow Spring */"); + echo("color(DGS); /* Dark Green Spring */"); + echo("color(DYS); /* Dark Yellow Spring */"); + echo("color(LGS); /* Light Green Spring */"); + echo("color(LYS); /* Light Yellow Spring */"); + echo("color(DSG); /* Dark Spring Green */"); + echo("color(DSY); /* Dark Spring Yellow */"); + echo("color(LSG); /* Light Spring Green */"); + echo("color(LSY); /* Light Spring Yellow */"); + echo("color(MSG); /* Medium Spring Green */"); + echo("color(MSY); /* Medium Spring Yellow */"); + echo("color(TTC); /* Teal Teal Cyan */"); + echo("color(TTG); /* Teal Teal Green */"); + echo("color(CCT); /* Cyan Cyan Teal */"); + echo("color(GGT); /* Green Green Teal */"); + echo("color(DCT); /* Dark Cyan Teal */"); + echo("color(DGT); /* Dark Green Teal */"); + echo("color(LCT); /* Light Cyan Teal */"); + echo("color(LGT); /* Light Green Teal */"); + echo("color(DTC); /* Dark Teal Cyan */"); + echo("color(DTG); /* Dark Teal Green */"); + echo("color(LTC); /* Light Teal Cyan */"); + echo("color(LTG); /* Light Teal Green */"); + echo("color(MTC); /* Medium Teal Cyan */"); + echo("color(MTG); /* Medium Teal Green */"); + echo("color(AAB); /* Azure Azure Blue */"); + echo("color(AAC); /* Azure Azure Cyan */"); + echo("color(BBA); /* Blue Blue Azure */"); + echo("color(CCA); /* Cyan Cyan Azure */"); + echo("color(DBA); /* Dark Blue Azure */"); + echo("color(DCA); /* Dark Cyan Azure */"); + echo("color(LBA); /* Light Blue Azure */"); + echo("color(LCA); /* Light Cyan Azure */"); + echo("color(DAB); /* Dark Azure Blue */"); + echo("color(DAC); /* Dark Azure Cyan */"); + echo("color(LAB); /* Light Azure Blue */"); + echo("color(LAC); /* Light Azure Cyan */"); + echo("color(MAB); /* Medium Azure Blue */"); + echo("color(MAC); /* Medium Azure Cyan */"); + echo("color(VVM); /* Violet Violet Magenta */"); + echo("color(VVB); /* Violet Violet Blue */"); + echo("color(MMV); /* Magenta Magenta Violet */"); + echo("color(BBV); /* Blue Blue Violet */"); + echo("color(DMV); /* Dark Magenta Violet */"); + echo("color(DBV); /* Dark Blue Violet */"); + echo("color(LMV); /* Light Magenta Violet */"); + echo("color(LBV); /* Light Blue Violet */"); + echo("color(DVM); /* Dark Violet Magenta */"); + echo("color(DVB); /* Dark Violet Blue */"); + echo("color(LVM); /* Light Violet Magenta */"); + echo("color(LVB); /* Light Violet Blue */"); + echo("color(MVM); /* Medium Violet Magenta */"); + echo("color(MVB); /* Medium Violet Blue */"); + echo("color(OWM); /* Obscure Weak Magenta */"); + echo("color(ODM); /* Obscure Dull Magenta */"); + echo("color(DFM); /* Dark Faded Magenta */"); + echo("color(DHM); /* Dark Hard Magenta */"); + echo("color(M); /* Magenta */"); + echo("color(DWM); /* Dark Weak Magenta */"); + echo("color(DDM); /* Dark Dull Magenta */"); + echo("color(MFM); /* Medium Faded Magenta */"); + echo("color(LHM); /* Light Hard Magenta */"); + echo("color(MWM); /* Medium Weak Magenta */"); + echo("color(LDM); /* Light Dull Magenta */"); + echo("color(LFM); /* Light Faded Magenta */"); + echo("color(LWM); /* Light Weak Magenta */"); + echo("color(PDM); /* Pale Dull Magenta */"); + echo("color(PWM); /* Pale Weak Magenta */"); + echo("color(OWR); /* Obscure Weak Red */"); + echo("color(ODR); /* Obscure Dull Red */"); + echo("color(DFR); /* Dark Faded Red */"); + echo("color(DHR); /* Dark Hard Red */"); + echo("color(R); /* Red */"); + echo("color(DWR); /* Dark Weak Red */"); + echo("color(DDR); /* Dark Dull Red */"); + echo("color(MFR); /* Medium Faded Red */"); + echo("color(LHR); /* Light Hard Red */"); + echo("color(MWR); /* Medium Weak Red */"); + echo("color(LDR); /* Light Dull Red */"); + echo("color(LFR); /* Light Faded Red */"); + echo("color(LWR); /* Light Weak Red */"); + echo("color(PDR); /* Pale Dull Red */"); + echo("color(PWR); /* Pale Weak Red */"); + echo("color(OWY); /* Obscure Weak Yellow */"); + echo("color(ODY); /* Obscure Dull Yellow */"); + echo("color(DFY); /* Dark Faded Yellow */"); + echo("color(DHY); /* Dark Hard Yellow */"); + echo("color(Y); /* Yellow */"); + echo("color(DWY); /* Dark Weak Yellow */"); + echo("color(DDY); /* Dark Dull Yellow */"); + echo("color(MFY); /* Medium Faded Yellow */"); + echo("color(LHY); /* Light Hard Yellow */"); + echo("color(MWY); /* Medium Weak Yellow */"); + echo("color(LDY); /* Light Dull Yellow */"); + echo("color(LFY); /* Light Faded Yellow */"); + echo("color(LWY); /* Light Weak Yellow */"); + echo("color(PDY); /* Pale Dull Yellow */"); + echo("color(PWY); /* Pale Weak Yellow */"); + echo("color(OWG); /* Obscure Weak Green */"); + echo("color(ODG); /* Obscure Dull Green */"); + echo("color(DFG); /* Dark Faded Green */"); + echo("color(DHG); /* Dark Hard Green */"); + echo("color(G); /* Green */"); + echo("color(DWG); /* Dark Weak Green */"); + echo("color(DDG); /* Dark Dull Green */"); + echo("color(MFG); /* Medium Faded Green */"); + echo("color(LHG); /* Light Hard Green */"); + echo("color(MWG); /* Medium Weak Green */"); + echo("color(LDG); /* Light Dull Green */"); + echo("color(LFG); /* Light Faded Green */"); + echo("color(LWG); /* Light Weak Green */"); + echo("color(PDG); /* Pale Dull Green */"); + echo("color(PWG); /* Pale Weak Green */"); + echo("color(OWC); /* Obscure Weak Cyan */"); + echo("color(ODC); /* Obscure Dull Cyan */"); + echo("color(DFC); /* Dark Faded Cyan */"); + echo("color(DHC); /* Dark Hard Cyan */"); + echo("color(C); /* Cyan */"); + echo("color(DWC); /* Dark Weak Cyan */"); + echo("color(DDC); /* Dark Dull Cyan */"); + echo("color(MFC); /* Medium Faded Cyan */"); + echo("color(LHC); /* Light Hard Cyan */"); + echo("color(MWC); /* Medium Weak Cyan */"); + echo("color(LDC); /* Light Dull Cyan */"); + echo("color(LFC); /* Light Faded Cyan */"); + echo("color(LWC); /* Light Weak Cyan */"); + echo("color(PDC); /* Pale Dull Cyan */"); + echo("color(PWC); /* Pale Weak Cyan */"); + echo("color(OWB); /* Obscure Weak Blue */"); + echo("color(ODB); /* Obscure Dull Blue */"); + echo("color(DFB); /* Dark Faded Blue */"); + echo("color(DHB); /* Dark Hard Blue */"); + echo("color(B); /* Blue */"); + echo("color(DWB); /* Dark Weak Blue */"); + echo("color(DDB); /* Dark Dull Blue */"); + echo("color(MFB); /* Medium Faded Blue */"); + echo("color(LHB); /* Light Hard Blue */"); + echo("color(MWB); /* Medium Weak Blue */"); + echo("color(LDB); /* Light Dull Blue */"); + echo("color(LFB); /* Light Faded Blue */"); + echo("color(LWB); /* Light Weak Blue */"); + echo("color(PDB); /* Pale Dull Blue */"); + echo("color(PWB); /* Pale Weak Blue */"); + echo("color(ODP); /* Obscure Dull Pink */"); + echo("color(DDP); /* Dark Dull Pink */"); + echo("color(LDP); /* Light Dull Pink */"); + echo("color(PDP); /* Pale Dull Pink */"); + echo("color(DHP); /* Dark Hard Pink */"); + echo("color(LHP); /* Light Hard Pink */"); + echo("color(ODO); /* Obscure Dull Orange */"); + echo("color(DDO); /* Dark Dull Orange */"); + echo("color(LDO); /* Light Dull Orange */"); + echo("color(PDO); /* Pale Dull Orange */"); + echo("color(DHO); /* Dark Hard Orange */"); + echo("color(LHO); /* Light Hard Orange */"); + echo("color(ODS); /* Obscure Dull Spring */"); + echo("color(DDS); /* Dark Dull Spring */"); + echo("color(LDS); /* Light Dull Spring */"); + echo("color(PDS); /* Pale Dull Spring */"); + echo("color(DHS); /* Dark Hard Spring */"); + echo("color(LHS); /* Light Hard Spring */"); + echo("color(ODT); /* Obscure Dull Teal */"); + echo("color(DDT); /* Dark Dull Teal */"); + echo("color(LDT); /* Light Dull Teal */"); + echo("color(PDT); /* Pale Dull Teal */"); + echo("color(DHT); /* Dark Hard Teal */"); + echo("color(LHT); /* Light Hard Teal */"); + echo("color(ODA); /* Obscure Dull Azure */"); + echo("color(DDA); /* Dark Dull Azure */"); + echo("color(LDA); /* Light Dull Azure */"); + echo("color(PDA); /* Pale Dull Azure */"); + echo("color(DHA); /* Dark Hard Azure */"); + echo, ("color(LHA); /* Light Hard Azure */"); + echo("color(ODV); /* Obscure Dull Violet */"); + echo("color(DDV); /* Dark Dull Violet */"); + echo("color(LDV); /* Light Dull Violet */"); + echo("color(PDV); /* Pale Dull Violet */"); + echo("color(DHV); /* Dark Hard Violet */"); + echo("color(LHV); /* Light Hard Violet */"); + echo("color(K); /* Black */"); + echo("color(OG); /* Obscure Gray */"); + echo("color(DG); /* Dark Gray */"); + echo("color(LG); /* Light Gray */"); + echo("color(PG); /* Pale Gray */"); + echo("color(W); /* White */"); } diff --git a/motors/motors.scad b/motors/motors.scad index bff35023..d5cc0b67 100644 --- a/motors/motors.scad +++ b/motors/motors.scad @@ -1,96 +1,105 @@ // Copyright 2010 D1plo1d -// This library is dual licensed under the GPL 3.0 and the GNU Lesser General Public License as per http://creativecommons.org/licenses/LGPL/2.1/ . +// This library is dual licensed under the GPL 3.0 and the GNU Lesser General +// Public License as per http://creativecommons.org/licenses/LGPL/2.1/ . include include include -//generates a motor mount for the specified nema standard #. -module stepper_motor_mount(nema_standard,slide_distance=0, mochup=true, tolerance=0) { - //dimensions from: - // http://www.numberfactory.com/NEMA%20Motor%20Dimensions.htm - if (nema_standard == 17) - { - _stepper_motor_mount( - motor_shaft_diameter = 0.1968*length_in, - motor_shaft_length = 0.945*length_in, - pilot_diameter = 0.866*length_in, - pilot_length = 0.80*length_in, - mounting_bolt_circle = 1.725*length_in, - bolt_hole_size = 3.5, - bolt_hole_distance = 1.220*length_in, - slide_distance = slide_distance, - mochup = mochup, - tolerance=tolerance); - } - if (nema_standard == 23) - { - _stepper_motor_mount( - motor_shaft_diameter = 0.250*length_in, - motor_shaft_length = 0.81*length_in, - pilot_diameter = 1.500*length_in, - pilot_length = 0.062*length_in, - mounting_bolt_circle = 2.625*length_in, - bolt_hole_size = 0.195*length_in, - bolt_hole_distance = 1.856*length_in, - slide_distance = slide_distance, - mochup = mochup, - tolerance=tolerance); - } - +// generates a motor mount for the specified nema standard #. +module stepper_motor_mount(nema_standard, + slide_distance = 0, + mochup = true, + tolerance = 0) +{ + // dimensions from: + // http://www.numberfactory.com/NEMA%20Motor%20Dimensions.htm + if (nema_standard == 17) { + _stepper_motor_mount(motor_shaft_diameter = 0.1968 * length_in, + motor_shaft_length = 0.945 * length_in, + pilot_diameter = 0.866 * length_in, + pilot_length = 0.80 * length_in, + mounting_bolt_circle = 1.725 * length_in, + bolt_hole_size = 3.5, + bolt_hole_distance = 1.220 * length_in, + slide_distance = slide_distance, + mochup = mochup, + tolerance = tolerance); + } + if (nema_standard == 23) { + _stepper_motor_mount(motor_shaft_diameter = 0.250 * length_in, + motor_shaft_length = 0.81 * length_in, + pilot_diameter = 1.500 * length_in, + pilot_length = 0.062 * length_in, + mounting_bolt_circle = 2.625 * length_in, + bolt_hole_size = 0.195 * length_in, + bolt_hole_distance = 1.856 * length_in, + slide_distance = slide_distance, + mochup = mochup, + tolerance = tolerance); + } } - -//inner mehod for creating a stepper motor mount of any dimensions -module _stepper_motor_mount( - motor_shaft_diameter, - motor_shaft_length, - pilot_diameter, - pilot_length, - mounting_bolt_circle, - bolt_hole_size, - bolt_hole_distance, - slide_distance = 0, - motor_length = 40, //arbitray - not standardized - mochup, - tolerance = 0 -) +// inner mehod for creating a stepper motor mount of any dimensions +module _stepper_motor_mount(motor_shaft_diameter, + motor_shaft_length, + pilot_diameter, + pilot_length, + mounting_bolt_circle, + bolt_hole_size, + bolt_hole_distance, + slide_distance = 0, + motor_length = 40, // arbitray - not standardized + mochup, + tolerance = 0) { - union() - { - // == centered mount points == - //mounting circle inset - translate([0,slide_distance/2,0]) circle(r = pilot_diameter/2 + tolerance); - square([pilot_diameter,slide_distance],center=true); - translate([0,-slide_distance/2,0]) circle(r = pilot_diameter/2 + tolerance); + union() + { + // == centered mount points == + // mounting circle inset + translate([ 0, slide_distance / 2, 0 ]) + circle(r = pilot_diameter / 2 + tolerance); + square([ pilot_diameter, slide_distance ], center = true); + translate([ 0, -slide_distance / 2, 0 ]) + circle(r = pilot_diameter / 2 + tolerance); + + // todo: motor shaft hole - //todo: motor shaft hole - - //mounting screw holes - for (x = [-1,1]) for (y = [-1,1]) - { - translate([x*bolt_hole_distance/2,y*bolt_hole_distance/2,0]) - { - translate([0,slide_distance/2,0]) circle(bolt_hole_size/2 + tolerance); - translate([0,-slide_distance/2,0]) circle(bolt_hole_size/2 + tolerance); - square([bolt_hole_size+2*tolerance,slide_distance],center=true); - } - } - // == motor mock-up == - //motor box - if (mochup == true) - { - %translate([0,0,-5]) cylinder(h = 5, r = pilot_diameter/2); - %translate(v=[0,0,-motor_length/2]) - { - cube(size=[bolt_hole_distance+bolt_hole_size+5,bolt_hole_distance+bolt_hole_size+5,motor_length], center = true); - } - //shaft - %translate(v=[0,0,-(motor_length-motor_shaft_length-2)/2]) - { - %cylinder(r=motor_shaft_diameter/2,h=motor_length+motor_shaft_length--1, center = true); - } - } - } + // mounting screw holes + for (x = [ -1, 1 ]) + for (y = [ -1, 1 ]) { + translate([ x * bolt_hole_distance / 2, y * bolt_hole_distance / 2, 0 ]) + { + translate([ 0, slide_distance / 2, 0 ]) + circle(bolt_hole_size / 2 + tolerance); + translate([ 0, -slide_distance / 2, 0 ]) + circle(bolt_hole_size / 2 + tolerance); + square([ bolt_hole_size + 2 * tolerance, slide_distance ], + center = true); + } + } + // == motor mock-up == + // motor box + if (mochup == true) { + % translate([ 0, 0, -5 ]) cylinder(h = 5, r = pilot_diameter / 2); + % translate(v = [ 0, 0, -motor_length / 2 ]) + { + cube(size = + [ + bolt_hole_distance + bolt_hole_size + 5, + bolt_hole_distance + bolt_hole_size + 5, + motor_length + ], + center = true); + } + // shaft + % translate(v = [ 0, 0, -(motor_length - motor_shaft_length - 2) / 2 ]) + { + % cylinder(r = motor_shaft_diameter / 2, + h = motor_length + motor_shaft_length-- 1, + center = true); + } + } + } } diff --git a/motors/servos.scad b/motors/servos.scad index 0f3f39c2..cf0b5176 100644 --- a/motors/servos.scad +++ b/motors/servos.scad @@ -14,94 +14,81 @@ use * * @param vector position The position vector * @param vector rotation The rotation vector - * @param boolean screws If defined then "screws" will be added and when the module is differenced() from something if will have holes for the screws - * @param number axle_lenght If defined this will draw "backgound" indicator for the main axle + * @param boolean screws If defined then "screws" will be added and when the + * module is differenced() from something if will have holes for the screws + * @param number axle_lenght If defined this will draw "backgound" indicator for + * the main axle */ module alignds420(position, rotation, screws = 0, axle_lenght = 0) { - translate(position) - { - rotate(rotation) - { - union() - { - // Main axle - translate([0,0,17]) - { - cylinder(r=6, h=8, $fn=30); - cylinder(r=2.5, h=10.5, $fn=20); - } - // Box and ears - translate([-6,-6,0]) - { - cube([12, 22.8,19.5], false); - translate([0,-5, 17]) - { - cube([12, 7, 2.5]); - } - translate([0, 20.8, 17]) - { - cube([12, 7, 2.5]); - } - } - if (screws > 0) - { - translate([0,(-10.2 + 1.8),11.5]) - { - # cylinder(r=1.8/2, h=6, $fn=6); - } - translate([0,(21.0 - 1.8),11.5]) - { - # cylinder(r=1.8/2, h=6, $fn=6); - } + translate(position) + { + rotate(rotation) + { + union() + { + // Main axle + translate([ 0, 0, 17 ]) + { + cylinder(r = 6, h = 8, $fn = 30); + cylinder(r = 2.5, h = 10.5, $fn = 20); + } + // Box and ears + translate([ -6, -6, 0 ]) + { + cube([ 12, 22.8, 19.5 ], false); + translate([ 0, -5, 17 ]) { cube([ 12, 7, 2.5 ]); } + translate([ 0, 20.8, 17 ]) { cube([ 12, 7, 2.5 ]); } + } + if (screws > 0) { + translate([ 0, (-10.2 + 1.8), 11.5 ]) + { +#cylinder(r = 1.8 / 2, h = 6, $fn = 6); + } + translate([ 0, (21.0 - 1.8), 11.5 ]) + { +#cylinder(r = 1.8 / 2, h = 6, $fn = 6); + } + } + // The large slope + translate([ -6, 0, 19 ]) + { + rotate([ 90, 0, 90 ]) { triangle(4, 18, 12); } + } - } - // The large slope - translate([-6,0,19]) - { - rotate([90,0,90]) - { - triangle(4, 18, 12); - } - } + /** + * This seems to get too complex fast + // Small additional axes + translate([0,6,17]) + { + cylinder(r=2.5, h=6, $fn=10); + cylinder(r=1.25, h=8, $fn=10); + } + // Small slope + difference() + { + translate([-6,-6,19.0]) + { + cube([12,6.5,4]); + } + translate([7,-7,24.0]) + { + rotate([-90,0,90]) + { + triangle(3, 8, 14); + } + } - /** - * This seems to get too complex fast - // Small additional axes - translate([0,6,17]) - { - cylinder(r=2.5, h=6, $fn=10); - cylinder(r=1.25, h=8, $fn=10); - } - // Small slope - difference() - { - translate([-6,-6,19.0]) - { - cube([12,6.5,4]); - } - translate([7,-7,24.0]) - { - rotate([-90,0,90]) - { - triangle(3, 8, 14); - } - } - - } - */ - // So we render a cube instead of the small slope on a cube - translate([-6,-6,19.0]) - { - cube([12,6.5,4]); - } - } - if (axle_lenght > 0) - { - % cylinder(r=0.9, h=axle_lenght, center=true, $fn=8); - } - } - } + } + */ + // So we render a cube instead of the small slope on a cube + translate([ -6, -6, 19.0 ]) { cube([ 12, 6.5, 4 ]); } + } + if (axle_lenght > 0) { + % cylinder(r = 0.9, h = axle_lenght, center = true, $fn = 8); + } + } + } } /** @@ -112,45 +99,51 @@ module alignds420(position, rotation, screws = 0, axle_lenght = 0) */ module futabas3003(position, rotation) { - translate(position) - { - rotate(rotation) - { - union() - { - // Box and ears - translate([0,0,0]) - { - cube([20.1, 39.9, 36.1], false); - translate([1.1, -7.6, 26.6]) - { - difference() { - cube([18, 7.6, 2.5]); - translate([4, 3.5, 0]) cylinder(100, 2); - translate([14, 3.5, 0]) cylinder(100, 2); - } - } + translate(position) + { + rotate(rotation) + { + union() + { + // Box and ears + translate([ 0, 0, 0 ]) + { + cube([ 20.1, 39.9, 36.1 ], false); + translate([ 1.1, -7.6, 26.6 ]) + { + difference() + { + cube([ 18, 7.6, 2.5 ]); + translate([ 4, 3.5, 0 ]) cylinder(100, 2); + translate([ 14, 3.5, 0 ]) cylinder(100, 2); + } + } - translate([1.1, 39.9, 26.6]) - { - difference() { - cube([18, 7.6, 2.5]); - translate([4, 4.5, 0]) cylinder(100, 2); - translate([14, 4.5, 0]) cylinder(100, 2); - } - } - } + translate([ 1.1, 39.9, 26.6 ]) + { + difference() + { + cube([ 18, 7.6, 2.5 ]); + translate([ 4, 4.5, 0 ]) cylinder(100, 2); + translate([ 14, 4.5, 0 ]) cylinder(100, 2); + } + } + } - // Main axle - translate([10, 30, 36.1]) - { - cylinder(r=6, h=0.4, $fn=30); - cylinder(r=2.5, h=4.9, $fn=20); - } - } - } - } + // Main axle + translate([ 10, 30, 36.1 ]) + { + cylinder(r = 6, h = 0.4, $fn = 30); + cylinder(r = 2.5, h = 4.9, $fn = 20); + } + } + } + } } // Tests: -module test_alignds420(){alignds420(screws=1);} +module +test_alignds420() +{ + alignds420(screws = 1); +} diff --git a/motors/stepper.scad b/motors/stepper.scad index 1c8e5856..232a9c9c 100644 --- a/motors/stepper.scad +++ b/motors/stepper.scad @@ -1,15 +1,16 @@ /* * A nema standard stepper motor module. - * + * * Originally by Hans Häggström, 2010. - * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later + * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or + * later */ +include include include -include -// Parameters: +// Parameters: NemaModel = 0; NemaLengthShort = 1; NemaLengthMedium = 2; @@ -38,138 +39,127 @@ NemaShort = NemaA; NemaMedium = NemaB; NemaLong = NemaC; -// TODO: The small motors seem to be a bit too long, I picked the size specs from all over the place, is there some canonical reference? -Nema08 = [ - [NemaModel, 8], - [NemaLengthShort, 33*length_mm], - [NemaLengthMedium, 43*length_mm], - [NemaLengthLong, 43*length_mm], - [NemaSideSize, 20*length_mm], - [NemaDistanceBetweenMountingHoles, 15.4*length_mm], - [NemaMountingHoleDiameter, 2*length_mm], - [NemaMountingHoleDepth, 1.75*length_mm], - [NemaMountingHoleLip, -1*length_mm], - [NemaMountingHoleCutoutRadius, 0*length_mm], - [NemaEdgeRoundingRadius, 2*length_mm], - [NemaRoundExtrusionDiameter, 16*length_mm], - [NemaRoundExtrusionHeight, 1.5*length_mm], - [NemaAxleDiameter, 4*length_mm], - [NemaFrontAxleLength, 13.5*length_mm], - [NemaBackAxleLength, 9.9*length_mm], - [NemaAxleFlatDepth, -1*length_mm], - [NemaAxleFlatLengthFront, 0*length_mm], - [NemaAxleFlatLengthBack, 0*length_mm] - ]; - -Nema11 = [ - [NemaModel, 11], - [NemaLengthShort, 32*length_mm], - [NemaLengthMedium, 40*length_mm], - [NemaLengthLong, 52*length_mm], - [NemaSideSize, 28*length_mm], - [NemaDistanceBetweenMountingHoles, 23*length_mm], - [NemaMountingHoleDiameter, 2.5*length_mm], - [NemaMountingHoleDepth, 2*length_mm], - [NemaMountingHoleLip, -1*length_mm], - [NemaMountingHoleCutoutRadius, 0*length_mm], - [NemaEdgeRoundingRadius, 2.5*length_mm], - [NemaRoundExtrusionDiameter, 22*length_mm], - [NemaRoundExtrusionHeight, 1.8*length_mm], - [NemaAxleDiameter, 5*length_mm], - [NemaFrontAxleLength, 13.7*length_mm], - [NemaBackAxleLength, 10*length_mm], - [NemaAxleFlatDepth, 0.5*length_mm], - [NemaAxleFlatLengthFront, 10*length_mm], - [NemaAxleFlatLengthBack, 9*length_mm] - ]; - -Nema14 = [ - [NemaModel, 14], - [NemaLengthShort, 26*length_mm], - [NemaLengthMedium, 28*length_mm], - [NemaLengthLong, 34*length_mm], - [NemaSideSize, 35.3*length_mm], - [NemaDistanceBetweenMountingHoles, 26*length_mm], - [NemaMountingHoleDiameter, 3*length_mm], - [NemaMountingHoleDepth, 3.5*length_mm], - [NemaMountingHoleLip, -1*length_mm], - [NemaMountingHoleCutoutRadius, 0*length_mm], - [NemaEdgeRoundingRadius, 5*length_mm], - [NemaRoundExtrusionDiameter, 22*length_mm], - [NemaRoundExtrusionHeight, 1.9*length_mm], - [NemaAxleDiameter, 5*length_mm], - [NemaFrontAxleLength, 18*length_mm], - [NemaBackAxleLength, 10*length_mm], - [NemaAxleFlatDepth, 0.5*length_mm], - [NemaAxleFlatLengthFront, 15*length_mm], - [NemaAxleFlatLengthBack, 9*length_mm] - ]; - -Nema17 = [ - [NemaModel, 17], - [NemaLengthShort, 33*length_mm], - [NemaLengthMedium, 39*length_mm], - [NemaLengthLong, 47*length_mm], - [NemaSideSize, 42.20*length_mm], - [NemaDistanceBetweenMountingHoles, 31.04*length_mm], - [NemaMountingHoleDiameter, 4*length_mm], - [NemaMountingHoleDepth, 4.5*length_mm], - [NemaMountingHoleLip, -1*length_mm], - [NemaMountingHoleCutoutRadius, 0*length_mm], - [NemaEdgeRoundingRadius, 7*length_mm], - [NemaRoundExtrusionDiameter, 22*length_mm], - [NemaRoundExtrusionHeight, 1.9*length_mm], - [NemaAxleDiameter, 5*length_mm], - [NemaFrontAxleLength, 21*length_mm], - [NemaBackAxleLength, 15*length_mm], - [NemaAxleFlatDepth, 0.5*length_mm], - [NemaAxleFlatLengthFront, 15*length_mm], - [NemaAxleFlatLengthBack, 14*length_mm] - ]; - -Nema23 = [ - [NemaModel, 23], - [NemaLengthShort, 39*length_mm], - [NemaLengthMedium, 54*length_mm], - [NemaLengthLong, 76*length_mm], - [NemaSideSize, 56.4*length_mm], - [NemaDistanceBetweenMountingHoles, 47.14*length_mm], - [NemaMountingHoleDiameter, 4.75*length_mm], - [NemaMountingHoleDepth, 5*length_mm], - [NemaMountingHoleLip, 4.95*length_mm], - [NemaMountingHoleCutoutRadius, 9.5*length_mm], - [NemaEdgeRoundingRadius, 2.5*length_mm], - [NemaRoundExtrusionDiameter, 38.10*length_mm], - [NemaRoundExtrusionHeight, 1.52*length_mm], - [NemaAxleDiameter, 6.36*length_mm], - [NemaFrontAxleLength, 18.80*length_mm], - [NemaBackAxleLength, 15.60*length_mm], - [NemaAxleFlatDepth, 0.5*length_mm], - [NemaAxleFlatLengthFront, 16*length_mm], - [NemaAxleFlatLengthBack, 14*length_mm] - ]; - -Nema34 = [ - [NemaModel, 34], - [NemaLengthShort, 66*length_mm], - [NemaLengthMedium, 96*length_mm], - [NemaLengthLong, 126*length_mm], - [NemaSideSize, 85*length_mm], - [NemaDistanceBetweenMountingHoles, 69.58*length_mm], - [NemaMountingHoleDiameter, 6.5*length_mm], - [NemaMountingHoleDepth, 5.5*length_mm], - [NemaMountingHoleLip, 5*length_mm], - [NemaMountingHoleCutoutRadius, 17*length_mm], - [NemaEdgeRoundingRadius, 3*length_mm], - [NemaRoundExtrusionDiameter, 73.03*length_mm], - [NemaRoundExtrusionHeight, 1.9*length_mm], - [NemaAxleDiameter, 0.5*length_inch], - [NemaFrontAxleLength, 37*length_mm], - [NemaBackAxleLength, 34*length_mm], - [NemaAxleFlatDepth, 1.20*length_mm], - [NemaAxleFlatLengthFront, 25*length_mm], - [NemaAxleFlatLengthBack, 25*length_mm] - ]; +// TODO: The small motors seem to be a bit too long, I picked the size specs +// from all over the place, is there some canonical reference? +Nema08 = [[NemaModel, 8], + [NemaLengthShort, 33 * length_mm], + [NemaLengthMedium, 43 * length_mm], + [NemaLengthLong, 43 * length_mm], + [NemaSideSize, 20 * length_mm], + [NemaDistanceBetweenMountingHoles, 15.4 * length_mm], + [NemaMountingHoleDiameter, 2 * length_mm], + [NemaMountingHoleDepth, 1.75 * length_mm], + [NemaMountingHoleLip, -1 * length_mm], + [NemaMountingHoleCutoutRadius, 0 * length_mm], + [NemaEdgeRoundingRadius, 2 * length_mm], + [NemaRoundExtrusionDiameter, 16 * length_mm], + [NemaRoundExtrusionHeight, 1.5 * length_mm], + [NemaAxleDiameter, 4 * length_mm], + [NemaFrontAxleLength, 13.5 * length_mm], + [NemaBackAxleLength, 9.9 * length_mm], + [NemaAxleFlatDepth, -1 * length_mm], + [NemaAxleFlatLengthFront, 0 * length_mm], + [NemaAxleFlatLengthBack, 0 * length_mm]]; + +Nema11 = [[NemaModel, 11], + [NemaLengthShort, 32 * length_mm], + [NemaLengthMedium, 40 * length_mm], + [NemaLengthLong, 52 * length_mm], + [NemaSideSize, 28 * length_mm], + [NemaDistanceBetweenMountingHoles, 23 * length_mm], + [NemaMountingHoleDiameter, 2.5 * length_mm], + [NemaMountingHoleDepth, 2 * length_mm], + [NemaMountingHoleLip, -1 * length_mm], + [NemaMountingHoleCutoutRadius, 0 * length_mm], + [NemaEdgeRoundingRadius, 2.5 * length_mm], + [NemaRoundExtrusionDiameter, 22 * length_mm], + [NemaRoundExtrusionHeight, 1.8 * length_mm], + [NemaAxleDiameter, 5 * length_mm], + [NemaFrontAxleLength, 13.7 * length_mm], + [NemaBackAxleLength, 10 * length_mm], + [NemaAxleFlatDepth, 0.5 * length_mm], + [NemaAxleFlatLengthFront, 10 * length_mm], + [NemaAxleFlatLengthBack, 9 * length_mm]]; + +Nema14 = [[NemaModel, 14], + [NemaLengthShort, 26 * length_mm], + [NemaLengthMedium, 28 * length_mm], + [NemaLengthLong, 34 * length_mm], + [NemaSideSize, 35.3 * length_mm], + [NemaDistanceBetweenMountingHoles, 26 * length_mm], + [NemaMountingHoleDiameter, 3 * length_mm], + [NemaMountingHoleDepth, 3.5 * length_mm], + [NemaMountingHoleLip, -1 * length_mm], + [NemaMountingHoleCutoutRadius, 0 * length_mm], + [NemaEdgeRoundingRadius, 5 * length_mm], + [NemaRoundExtrusionDiameter, 22 * length_mm], + [NemaRoundExtrusionHeight, 1.9 * length_mm], + [NemaAxleDiameter, 5 * length_mm], + [NemaFrontAxleLength, 18 * length_mm], + [NemaBackAxleLength, 10 * length_mm], + [NemaAxleFlatDepth, 0.5 * length_mm], + [NemaAxleFlatLengthFront, 15 * length_mm], + [NemaAxleFlatLengthBack, 9 * length_mm]]; + +Nema17 = [[NemaModel, 17], + [NemaLengthShort, 33 * length_mm], + [NemaLengthMedium, 39 * length_mm], + [NemaLengthLong, 47 * length_mm], + [NemaSideSize, 42.20 * length_mm], + [NemaDistanceBetweenMountingHoles, 31.04 * length_mm], + [NemaMountingHoleDiameter, 4 * length_mm], + [NemaMountingHoleDepth, 4.5 * length_mm], + [NemaMountingHoleLip, -1 * length_mm], + [NemaMountingHoleCutoutRadius, 0 * length_mm], + [NemaEdgeRoundingRadius, 7 * length_mm], + [NemaRoundExtrusionDiameter, 22 * length_mm], + [NemaRoundExtrusionHeight, 1.9 * length_mm], + [NemaAxleDiameter, 5 * length_mm], + [NemaFrontAxleLength, 21 * length_mm], + [NemaBackAxleLength, 15 * length_mm], + [NemaAxleFlatDepth, 0.5 * length_mm], + [NemaAxleFlatLengthFront, 15 * length_mm], + [NemaAxleFlatLengthBack, 14 * length_mm]]; + +Nema23 = [[NemaModel, 23], + [NemaLengthShort, 39 * length_mm], + [NemaLengthMedium, 54 * length_mm], + [NemaLengthLong, 76 * length_mm], + [NemaSideSize, 56.4 * length_mm], + [NemaDistanceBetweenMountingHoles, 47.14 * length_mm], + [NemaMountingHoleDiameter, 4.75 * length_mm], + [NemaMountingHoleDepth, 5 * length_mm], + [NemaMountingHoleLip, 4.95 * length_mm], + [NemaMountingHoleCutoutRadius, 9.5 * length_mm], + [NemaEdgeRoundingRadius, 2.5 * length_mm], + [NemaRoundExtrusionDiameter, 38.10 * length_mm], + [NemaRoundExtrusionHeight, 1.52 * length_mm], + [NemaAxleDiameter, 6.36 * length_mm], + [NemaFrontAxleLength, 18.80 * length_mm], + [NemaBackAxleLength, 15.60 * length_mm], + [NemaAxleFlatDepth, 0.5 * length_mm], + [NemaAxleFlatLengthFront, 16 * length_mm], + [NemaAxleFlatLengthBack, 14 * length_mm]]; + +Nema34 = [[NemaModel, 34], + [NemaLengthShort, 66 * length_mm], + [NemaLengthMedium, 96 * length_mm], + [NemaLengthLong, 126 * length_mm], + [NemaSideSize, 85 * length_mm], + [NemaDistanceBetweenMountingHoles, 69.58 * length_mm], + [NemaMountingHoleDiameter, 6.5 * length_mm], + [NemaMountingHoleDepth, 5.5 * length_mm], + [NemaMountingHoleLip, 5 * length_mm], + [NemaMountingHoleCutoutRadius, 17 * length_mm], + [NemaEdgeRoundingRadius, 3 * length_mm], + [NemaRoundExtrusionDiameter, 73.03 * length_mm], + [NemaRoundExtrusionHeight, 1.9 * length_mm], + [NemaAxleDiameter, 0.5 * length_inch], + [NemaFrontAxleLength, 37 * length_mm], + [NemaBackAxleLength, 34 * length_mm], + [NemaAxleFlatDepth, 1.20 * length_mm], + [NemaAxleFlatLengthFront, 25 * length_mm], + [NemaAxleFlatLengthBack, 25 * length_mm]]; NemaDefinitions = [ -1, @@ -209,24 +199,34 @@ NemaDefinitions = [ Nema34 ]; - -function motorWidth(model=Nema23) = lookup(NemaSideSize, model); -function motorLength(model=Nema23, size=NemaMedium) = lookup(size, model); -function motorScrewSpacing(model=Nema23) = lookup(NemaDistanceBetweenMountingHoles, model); +function motorWidth(model = Nema23) = lookup(NemaSideSize, model); +function motorLength(model = Nema23, size = NemaMedium) = lookup(size, model); +function motorScrewSpacing(model = Nema23) = + lookup(NemaDistanceBetweenMountingHoles, model); function Nema(number) = NemaDefinitions[number]; -module motor(model=Nema23, size=NemaMedium, dualAxis=false, pos=[0,0,0], orientation = [0,0,0]) { +module motor(model = Nema23, + size = NemaMedium, + dualAxis = false, + pos = [ 0, 0, 0 ], + orientation = [ 0, 0, 0 ]) +{ - //motorDef = NemaDefinitions[model]; - //echo(model); + // motorDef = NemaDefinitions[model]; + // echo(model); motorDef = model; echo(motorDef); length = lookup(size, motorDef); - echo(str(" Motor: Nema",lookup(NemaModel, motorDef),", length= ",length,"mm, dual axis=",dualAxis)); + echo(str(" Motor: Nema", + lookup(NemaModel, motorDef), + ", length= ", + length, + "mm, dual axis=", + dualAxis)); - stepperBlack = BlackPaint; + stepperBlack = BlackPaint; stepperAluminum = Aluminum; side = lookup(NemaSideSize, motorDef); @@ -253,84 +253,106 @@ module motor(model=Nema23, size=NemaMedium, dualAxis=false, pos=[0,0,0], orienta axleFlatLengthFront = lookup(NemaAxleFlatLengthFront, motorDef); axleFlatLengthBack = lookup(NemaAxleFlatLengthBack, motorDef); - color(stepperBlack){ - translate(pos) rotate(orientation) { - translate([-mid, -mid, 0]) - difference() { - cube(size=[side, side, length + extrSize]); - - // Corner cutouts - if (lip > 0) { - translate([0, 0, lip]) cylinder(h=length, r=cutR); - translate([side, 0, lip]) cylinder(h=length, r=cutR); - translate([0, side, lip]) cylinder(h=length, r=cutR); - translate([side, side, lip]) cylinder(h=length, r=cutR); - - } + color(stepperBlack) + { + translate(pos) rotate(orientation) + { + translate([ -mid, -mid, 0 ]) difference() + { + cube(size = [ side, side, length + extrSize ]); + + // Corner cutouts + if (lip > 0) { + translate([ 0, 0, lip ]) cylinder(h = length, r = cutR); + translate([ side, 0, lip ]) cylinder(h = length, r = cutR); + translate([ 0, side, lip ]) cylinder(h = length, r = cutR); + translate([ side, side, lip ]) cylinder(h = length, r = cutR); + } - // Rounded edges - if (roundR > 0) { - translate([mid+mid, mid+mid, length/2]) - rotate([0,0,45]) - cube(size=[roundR, roundR*2, 4+length + extrSize+2], center=true); - translate([mid-(mid), mid+(mid), length/2]) - rotate([0,0,45]) - cube(size=[roundR*2, roundR, 4+length + extrSize+2], center=true); - translate([mid+mid, mid-mid, length/2]) - rotate([0,0,45]) - cube(size=[roundR*2, roundR, 4+length + extrSize+2], center=true); - translate([mid-mid, mid-mid, length/2]) - rotate([0,0,45]) - cube(size=[roundR, roundR*2, 4+length + extrSize+2], center=true); + // Rounded edges + if (roundR > 0) { + translate([ mid + mid, mid + mid, length / 2 ]) rotate([ 0, 0, 45 ]) + cube(size = [ roundR, roundR * 2, 4 + length + extrSize + 2 ], + center = true); + translate([ mid - (mid), mid + (mid), length / 2 ]) + rotate([ 0, 0, 45 ]) + cube(size = [ roundR * 2, roundR, 4 + length + extrSize + 2 ], + center = true); + translate([ mid + mid, mid - mid, length / 2 ]) rotate([ 0, 0, 45 ]) + cube(size = [ roundR * 2, roundR, 4 + length + extrSize + 2 ], + center = true); + translate([ mid - mid, mid - mid, length / 2 ]) rotate([ 0, 0, 45 ]) + cube(size = [ roundR, roundR * 2, 4 + length + extrSize + 2 ], + center = true); + } - } + // Bolt holes + color(stepperAluminum, $fs = holeRadius / 8) + { + translate([ mid + holeDist, mid + holeDist ]) + cylinder(h = holeDepth + 1 * length_mm, r = holeRadius); + translate([ mid - holeDist, mid + holeDist ]) + cylinder(h = holeDepth + 1 * length_mm, r = holeRadius); + translate([ mid + holeDist, mid - holeDist ]) + cylinder(h = holeDepth + 1 * length_mm, r = holeRadius); + translate([ mid - holeDist, mid - holeDist ]) + cylinder(h = holeDepth + 1 * length_mm, r = holeRadius); + } - // Bolt holes - color(stepperAluminum, $fs=holeRadius/8) { - translate([mid+holeDist,mid+holeDist]) cylinder(h=holeDepth+1*length_mm, r=holeRadius); - translate([mid-holeDist,mid+holeDist]) cylinder(h=holeDepth+1*length_mm, r=holeRadius); - translate([mid+holeDist,mid-holeDist]) cylinder(h=holeDepth+1*length_mm, r=holeRadius); - translate([mid-holeDist,mid-holeDist]) cylinder(h=holeDepth+1*length_mm, r=holeRadius); - - } - - // Grinded flat - color(stepperAluminum) { - difference() { - translate([-1*length_mm, -1*length_mm, -1*length_mm]) - cube(size=[side+2*length_mm, side+2*length_mm, extrSize + 1*length_mm]); - translate([side/2, side/2, -1.1*length_mm]) - cylinder(h=4*length_mm, r=extrRad); - } + // Grinded flat + color(stepperAluminum) + { + difference() + { + translate([ -1 * length_mm, -1 * length_mm, -1 * length_mm ]) + cube(size = [ + side + 2 * length_mm, + side + 2 * length_mm, + extrSize + 1 * + length_mm + ]); + translate([ side / 2, side / 2, -1.1 * length_mm ]) + cylinder(h = 4 * length_mm, r = extrRad); } - } + } // Axle - translate([0, 0, extrSize-axleLengthFront]) color(stepperAluminum) - difference() { - - cylinder(h=axleLengthFront + 1*length_mm , r=axleRadius, $fs=axleRadius/10); + translate([ 0, 0, extrSize - axleLengthFront ]) color(stepperAluminum) + difference() + { + + cylinder(h = axleLengthFront + 1 * length_mm, + r = axleRadius, + $fs = axleRadius / 10); + + // Flat + if (axleFlatDepth > 0) + translate([ + axleRadius - axleFlatDepth, + -5 * length_mm, + -extrSize * length_mm - (axleLengthFront - axleFlatLengthFront) + ]) cube(size = [ 5 * length_mm, 10 * length_mm, axleLengthFront ]); + } + + if (dualAxis) { + translate([ 0, 0, length + extrSize ]) color(stepperAluminum) + difference() + { + + cylinder(h = axleLengthBack + 0 * length_mm, + r = axleRadius, + $fs = axleRadius / 10); // Flat if (axleFlatDepth > 0) - translate([axleRadius - axleFlatDepth,-5*length_mm,-extrSize*length_mm -(axleLengthFront-axleFlatLengthFront)] ) cube(size=[5*length_mm, 10*length_mm, axleLengthFront]); - } - - if (dualAxis) { - translate([0, 0, length+extrSize]) color(stepperAluminum) - difference() { - - cylinder(h=axleLengthBack + 0*length_mm, r=axleRadius, $fs=axleRadius/10); - - // Flat - if (axleFlatDepth > 0) - translate([axleRadius - axleFlatDepth,-5*length_mm,(axleLengthBack-axleFlatLengthBack)]) cube(size=[5*length_mm, 10*length_mm, axleLengthBack]); - } - + translate([ + axleRadius - axleFlatDepth, + -5 * length_mm, + (axleLengthBack - axleFlatLengthBack) + ]) cube(size = [ 5 * length_mm, 10 * length_mm, axleLengthBack ]); } - + } } } } - diff --git a/motors/stepper_mount.scad b/motors/stepper_mount.scad index 419c111e..f3218a5b 100644 --- a/motors/stepper_mount.scad +++ b/motors/stepper_mount.scad @@ -1,4 +1,4 @@ -// stepper twist mount +// stepper twist mount // tigger@interthingy.com // 201029061241 @@ -11,11 +11,10 @@ // 3 - interference check // 4 - single stl -mode = 4; +mode = 4; // variables -nema = 17; - +nema = 17; bolt = 3; size = 42; @@ -29,245 +28,247 @@ clip_depth = 15; clip_thickness = 4; slot_height = 15; -clip_count = 6; - -//extras +clip_count = 6; +// extras overlap = 0.1; clearance = 0.1; -inc = 360/clip_count; +inc = 360 / clip_count; splitter = 150; -module pip() +module +pip() { - inc = 360/(2*clip_count); - clip_rad = boss_radius+clip_thickness/2-clip_thickness/2; - difference() - { - translate([boss_radius+clip_thickness/2,0,clearance]) - cylinder(h=slot_height-2*clearance,r=clip_thickness/2-clearance/2); - translate([0,0,-boss_radius-clip_thickness+slot_height-clearance]) - cylinder(h=boss_radius+clip_thickness+overlap,r1=0,r2=boss_radius+clip_thickness); - translate([0,0,clearance]) - cylinder(h=boss_radius+clip_thickness+overlap*2,r2=0,r1=boss_radius+clip_thickness); - } + inc = 360 / (2 * clip_count); + clip_rad = boss_radius + clip_thickness / 2 - clip_thickness / 2; + difference() + { + translate([ boss_radius + clip_thickness / 2, 0, clearance ]) cylinder( + h = slot_height - 2 * clearance, r = clip_thickness / 2 - clearance / 2); + translate([ 0, 0, -boss_radius - clip_thickness + slot_height - clearance ]) + cylinder(h = boss_radius + clip_thickness + overlap, + r1 = 0, + r2 = boss_radius + clip_thickness); + translate([ 0, 0, clearance ]) + cylinder(h = boss_radius + clip_thickness + overlap * 2, + r2 = 0, + r1 = boss_radius + clip_thickness); + } } -module slot() +module +slot() { - inc = 360/(2*clip_count); - clip_rad = boss_radius+clip_thickness/2-clip_thickness/2; - difference() - { - rotate([0,0,inc]) - translate([boss_radius+clip_thickness/2,0,0]) - cylinder(h=slot_height-overlap,r=clip_thickness/2); - union() - { - translate([0,0,-boss_radius-clip_thickness+slot_height+overlap]) - cylinder(h=boss_radius+clip_thickness,r1=0,r2=boss_radius+clip_thickness); - translate([0,0,-overlap]) - cylinder(h=boss_radius+clip_thickness+overlap*2,r2=0,r1=boss_radius+clip_thickness); - } - } - difference() - { - union() - { - translate([boss_radius+clip_thickness/2,0,0]) - cylinder(h=clip_depth+overlap,r=clip_thickness/2); - intersection() - { - intersection() - { - rotate(-90,[0,0,1]) - rotate(inc,[0,0,1]) - cube(size=boss_radius*4); - cube(size=boss_radius*4); - - } - difference() - { - cylinder(h=slot_height,r=boss_radius+clip_thickness+overlap); - translate([0,0,-overlap]) - cylinder(h=slot_height+overlap*2, r=clip_rad); - translate([0,0,-boss_radius-clip_thickness+slot_height+overlap]) - cylinder(h=boss_radius+clip_thickness,r1=0,r2=boss_radius+clip_thickness); - } - } - } - translate([0,0,-overlap]) - cylinder(h=boss_radius+clip_thickness+overlap*2,r2=0,r1=boss_radius+clip_thickness); - } + inc = 360 / (2 * clip_count); + clip_rad = boss_radius + clip_thickness / 2 - clip_thickness / 2; + difference() + { + rotate([ 0, 0, inc ]) translate([ boss_radius + clip_thickness / 2, 0, 0 ]) + cylinder(h = slot_height - overlap, r = clip_thickness / 2); + union() + { + translate([ 0, 0, -boss_radius - clip_thickness + slot_height + overlap ]) + cylinder(h = boss_radius + clip_thickness, + r1 = 0, + r2 = boss_radius + clip_thickness); + translate([ 0, 0, -overlap ]) + cylinder(h = boss_radius + clip_thickness + overlap * 2, + r2 = 0, + r1 = boss_radius + clip_thickness); + } + } + difference() + { + union() + { + translate([ boss_radius + clip_thickness / 2, 0, 0 ]) + cylinder(h = clip_depth + overlap, r = clip_thickness / 2); + intersection() + { + intersection() + { + rotate(-90, [ 0, 0, 1 ]) rotate(inc, [ 0, 0, 1 ]) + cube(size = boss_radius * 4); + cube(size = boss_radius * 4); + } + difference() + { + cylinder(h = slot_height, r = boss_radius + clip_thickness + overlap); + translate([ 0, 0, -overlap ]) + cylinder(h = slot_height + overlap * 2, r = clip_rad); + translate( + [ 0, 0, -boss_radius - clip_thickness + slot_height + overlap ]) + cylinder(h = boss_radius + clip_thickness, + r1 = 0, + r2 = boss_radius + clip_thickness); + } + } + } + translate([ 0, 0, -overlap ]) + cylinder(h = boss_radius + clip_thickness + overlap * 2, + r2 = 0, + r1 = boss_radius + clip_thickness); + } } -module pips() +module +pips() { - inc = 360/clip_count; - for ( z = [1:clip_count]) - { - rotate(z*inc,[0,0,1]) - pip(); - } + inc = 360 / clip_count; + for (z = [1:clip_count]) { + rotate(z * inc, [ 0, 0, 1 ]) pip(); + } } -module slots() +module +slots() { - inc = 360/clip_count; - for ( z = [1:clip_count]) - { - rotate(z*inc,[0,0,1]) - slot(); - } + inc = 360 / clip_count; + for (z = [1:clip_count]) { + rotate(z * inc, [ 0, 0, 1 ]) slot(); + } } -module bolt_hole() +module +bolt_hole() { - union() - { - cylinder(h=base_thickness*10,r=bolt/2,center=true); -// translate([0,0,base_thickness*2]) -// cylinder(h=base_thickness*10,r=bolt,center=false); - } + union() + { + cylinder(h = base_thickness * 10, r = bolt / 2, center = true); + // translate([0,0,base_thickness*2]) + // cylinder(h=base_thickness*10,r=bolt,center=false); + } } -module holes() +module +holes() { - union() - { - // bolt holes - translate([hole_size/2,hole_size/2,-2*base_thickness]) - bolt_hole(); - translate([hole_size/2,-hole_size/2,-2*base_thickness]) - bolt_hole(); - translate([-hole_size/2,-hole_size/2,-2*base_thickness]) - bolt_hole(); - translate([-hole_size/2,hole_size/2,-2*base_thickness]) - bolt_hole(); - - // center hole - cylinder(h = base_thickness+3*mount_height , r = inner_hole_radius, center=true); - } + union() + { + // bolt holes + translate([ hole_size / 2, hole_size / 2, -2 * base_thickness ]) + bolt_hole(); + translate([ hole_size / 2, -hole_size / 2, -2 * base_thickness ]) + bolt_hole(); + translate([ -hole_size / 2, -hole_size / 2, -2 * base_thickness ]) + bolt_hole(); + translate([ -hole_size / 2, hole_size / 2, -2 * base_thickness ]) + bolt_hole(); + + // center hole + cylinder(h = base_thickness + 3 * mount_height, + r = inner_hole_radius, + center = true); + } } -module socket_base() +module +socket_base() { - union() - { - difference() - { - cylinder(h=mount_height-clearance,r=boss_radius+clip_thickness); - cylinder(h=mount_height-clearance,r=boss_radius+clip_thickness/2+clearance/2); - } - translate([0,0,(clip_depth-slot_height)]) - rotate([0,0,inc/2]) - pips(); - } + union() + { + difference() + { + cylinder(h = mount_height - clearance, r = boss_radius + clip_thickness); + cylinder(h = mount_height - clearance, + r = boss_radius + clip_thickness / 2 + clearance / 2); + } + translate([ 0, 0, (clip_depth - slot_height) ]) rotate([ 0, 0, inc / 2 ]) + pips(); + } } -module twist_base() +module +twist_base() { - union() - { - difference() - { - translate([0,0,-overlap]) - cylinder(h=mount_height+overlap,r=boss_radius+clip_thickness/2); - union() - { - translate([0,0,mount_height-clip_depth]) - slots(); - } - } - } + union() + { + difference() + { + translate([ 0, 0, -overlap ]) cylinder( + h = mount_height + overlap, r = boss_radius + clip_thickness / 2); + union() { translate([ 0, 0, mount_height - clip_depth ]) slots(); } + } + } } -module base() +module +base() { - - difference() - { - union() - { - translate([0,0,base_thickness/2]) - cube( size = [size,size,base_thickness] , center = true); - translate([0,0,base_thickness]) - twist_base(); - } - holes(); - } + + difference() + { + union() + { + translate([ 0, 0, base_thickness / 2 ]) + cube(size = [ size, size, base_thickness ], center = true); + translate([ 0, 0, base_thickness ]) twist_base(); + } + holes(); + } } -module socket() +module +socket() { - difference() - { - union() - { - translate([0,0,base_thickness/2]) - cube( size = [size,size,base_thickness] , center = true); - translate([0,0,base_thickness]) - socket_base(); - } - holes(); - } + difference() + { + union() + { + translate([ 0, 0, base_thickness / 2 ]) + cube(size = [ size, size, base_thickness ], center = true); + translate([ 0, 0, base_thickness ]) socket_base(); + } + holes(); + } } -module placed_socket() +module +placed_socket() { - translate([0,0,2*base_thickness+mount_height]) - rotate([0,180,0]) + translate([ 0, 0, 2 * base_thickness + mount_height ]) rotate([ 0, 180, 0 ]) - socket(); + socket(); } -module splitter() +module +splitter() { - // for checking internal layout - translate([0,-splitter/2,-splitter/2]) - cube(splitter); + // for checking internal layout + translate([ 0, -splitter / 2, -splitter / 2 ]) cube(splitter); } -// modal display +// modal display -if ( mode == 0) -{ - base(); +if (mode == 0) { + base(); } -if (mode == 1) -{ - socket(); +if (mode == 1) { + socket(); } -if ( mode == 2) -{ - rotate([0,0,inc/2]) - difference() - { - placed_socket(); - //socket(); - rotate([0,0,inc/2]) - splitter(); - } - base(); +if (mode == 2) { + rotate([ 0, 0, inc / 2 ]) difference() + { + placed_socket(); + // socket(); + rotate([ 0, 0, inc / 2 ]) splitter(); + } + base(); } -if (mode == 3) -{ - intersection() - { - placed_socket(); - base(); - } +if (mode == 3) { + intersection() + { + placed_socket(); + base(); + } } -if( mode == 4) -{ - translate([size/2+5,0,0]) - socket(); - translate([-size/2-5,0,0]) - base(); +if (mode == 4) { + translate([ size / 2 + 5, 0, 0 ]) socket(); + translate([ -size / 2 - 5, 0, 0 ]) base(); } \ No newline at end of file diff --git a/multiply.scad b/multiply.scad index 8c214f4a..1b88e2e0 100644 --- a/multiply.scad +++ b/multiply.scad @@ -1,25 +1,23 @@ -include use +include /** * @deprecated * Evenly place children `no` number of times around `axis` for `angle / 360` * turns, */ -module spin (no, angle = 360, axis = Z) +module spin(no, angle = 360, axis = Z) { - mcad_rotate_multiply (no, angle / no, axis) - children (); + mcad_rotate_multiply(no, angle / no, axis) children(); } /** * @deprecated * Duplicate by rotating a copy 180° around `axis` */ -module duplicate (axis = Z) +module duplicate(axis = Z) { - mcad_duplicate (axis = axis) - children (); + mcad_duplicate(axis = axis) children(); } /** @@ -27,8 +25,8 @@ module duplicate (axis = Z) * Evenly multiply children `no` times by translating by `separation` distance * along `axis`. */ -module linear_multiply (no, separation, axis = Z) +module linear_multiply(no, separation, axis = Z) { - mcad_linear_multiply (no = no, separation = separation, axis = axis) - children (); + mcad_linear_multiply(no = no, separation = separation, axis = axis) + children(); } diff --git a/nuts_and_bolts.scad b/nuts_and_bolts.scad index 6612289e..42b86e96 100644 --- a/nuts_and_bolts.scad +++ b/nuts_and_bolts.scad @@ -3,20 +3,21 @@ include // @deprecated -module SKIPtestNutsAndBolts () +module +SKIPtestNutsAndBolts() { - mcad_test_nuts_and_bolts_1 (); + mcad_test_nuts_and_bolts_1(); } // @deprecated -module nutHole (size, units = MM, tolerance = +0.0001, proj = -1) +module nutHole(size, units = MM, tolerance = +0.0001, proj = -1) { - mcad_nut_hole (size = size, tolerance = tolerance, proj = proj); + mcad_nut_hole(size = size, tolerance = tolerance, proj = proj); } // @deprecated -module boltHole (size, units = MM, length, tolerance = +0.0001, proj = -1) +module boltHole(size, units = MM, length, tolerance = +0.0001, proj = -1) { - mcad_bolt_hole (size = size, length = length, tolerance = tolerance, - proj = proj); + mcad_bolt_hole( + size = size, length = length, tolerance = tolerance, proj = proj); } diff --git a/oshw.scad b/oshw.scad index c906f682..0b64eb55 100644 --- a/oshw.scad +++ b/oshw.scad @@ -11,31 +11,38 @@ // // cc-by-sa, pierre-alain dorange, july 2012 -module gear_tooth_2d(d) { - polygon( points=[ - [0.0,10.0*d/72.0], [0.5*d,d/15.0], - [0.5*d,-d/15.0], [0.0,-10.0*d/72.0] ] ); +module gear_tooth_2d(d) +{ + polygon(points = [ + [ 0.0, 10.0 * d / 72.0 ], + [ 0.5 * d, d / 15.0 ], + [ 0.5 * d, -d / 15.0 ], + [ 0.0, -10.0 * d / 72.0 ] + ]); } -module oshw_logo_2d(d=10.0) { - rotate(-135) { - difference() { - union() { - circle(r=14.0*d/36.0,$fn=20); - for(i=[1:7]) assign(rotAngle=45*i+45) - rotate(rotAngle) gear_tooth_2d(d); - } - circle(r=10.0*d/72.0,$fn=20); - intersection() { - rotate(-20) square(size=[10.0*d/18.0,10.0*d/18.0]); - rotate(20) square(size=[10.0*d/18.0,10.0*d/18.0]); - } - } - } +module oshw_logo_2d(d = 10.0) +{ + rotate(-135) + { + difference() + { + union() + { + circle(r = 14.0 * d / 36.0, $fn = 20); + for (i = [1:7]) + assign(rotAngle = 45 * i + 45) rotate(rotAngle) gear_tooth_2d(d); + } + circle(r = 10.0 * d / 72.0, $fn = 20); + intersection() + { + rotate(-20) square(size = [ 10.0 * d / 18.0, 10.0 * d / 18.0 ]); + rotate(20) square(size = [ 10.0 * d / 18.0, 10.0 * d / 18.0 ]); + } + } + } } // usage : oshw_logo_2d(diameter) -linear_extrude(height=2) - oshw_logo_2d(25); - +linear_extrude(height = 2) oshw_logo_2d(25); diff --git a/polyhole.scad b/polyhole.scad index 60029ac7..ab79b0d1 100644 --- a/polyhole.scad +++ b/polyhole.scad @@ -1,5 +1,4 @@ use // @deprecated -module polyhole (h, d) -mcad_polyhole (d, (h < 0) ? undef : h); +module polyhole(h, d) mcad_polyhole(d, (h < 0) ? undef : h); diff --git a/screw.scad b/screw.scad index eb444ec0..a1c139b2 100644 --- a/screw.scad +++ b/screw.scad @@ -11,54 +11,83 @@ outside_diameter inner_diameter: thickness of the shaft */ -//Uncomment to see examples -//test_auger(); -//test_ball_groove(); -//test_ball_groove2(); -//test_ball_screw(); +// Uncomment to see examples +// test_auger(); +// test_ball_groove(); +// test_ball_groove2(); +// test_ball_screw(); -module helix(pitch, length, slices=500){ - rotations = length/pitch; - linear_extrude(height=length, center=false, convexity=10, twist=360*rotations, slices=slices, $fn=100) - child(0); +module helix(pitch, length, slices = 500) +{ + rotations = length / pitch; + linear_extrude(height = length, + center = false, + convexity = 10, + twist = 360 * rotations, + slices = slices, + $fn = 100) child(0); } -module auger(pitch, length, outside_radius, inner_radius, taper_ratio = 0.25) { - union(){ - helix(pitch, length) - polygon(points=[[0,inner_radius],[outside_radius,(inner_radius * taper_ratio)],[outside_radius,(inner_radius * -1 * taper_ratio)],[0,(-1 * inner_radius)]], paths=[[0,1,2,3]]); - cylinder(h=length, r=inner_radius); - } +module auger(pitch, length, outside_radius, inner_radius, taper_ratio = 0.25) +{ + union() + { + helix(pitch, length) + polygon(points = + [ + [ 0, inner_radius ], + [ outside_radius, (inner_radius * taper_ratio) ], + [ outside_radius, (inner_radius * -1 * taper_ratio) ], + [ 0, (-1 * inner_radius) ] + ], + paths = [[ 0, 1, 2, 3 ]]); + cylinder(h = length, r = inner_radius); + } } -module test_auger(){translate([50, 0, 0]) auger(40, 80, 25, 5);} - +module +test_auger() +{ + translate([ 50, 0, 0 ]) auger(40, 80, 25, 5); +} -module ball_groove(pitch, length, diameter, ball_radius=10) { - helix(pitch, length, slices=100) - translate([diameter, 0, 0]) - circle(r = ball_radius); +module ball_groove(pitch, length, diameter, ball_radius = 10) +{ + helix(pitch, length, slices = 100) translate([ diameter, 0, 0 ]) + circle(r = ball_radius); } -module test_ball_groove(){ translate([0, 300, 0]) ball_groove(100, 300, 10);} +module +test_ball_groove() +{ + translate([ 0, 300, 0 ]) ball_groove(100, 300, 10); +} -module ball_groove2(pitch, length, diameter, ball_radius, slices=200){ - rotations = length/pitch; - radius=diameter/2; - offset = length/slices; - union(){ - for (i = [0:slices]) { - assign (z = i*offset){ - translate(helix_curve(pitch, radius, z)) sphere(ball_radius, $fa=5, $fs=1); - } - } +module ball_groove2(pitch, length, diameter, ball_radius, slices = 200) +{ + rotations = length / pitch; + radius = diameter / 2; + offset = length / slices; + union() + { + for (i = [0:slices]) { + assign(z = i * offset) + { + translate(helix_curve(pitch, radius, z)) + sphere(ball_radius, $fa = 5, $fs = 1); + } } + } } -module test_ball_groove2(){translate([0, 0, 0]) ball_groove2(100, 300, 100, 10);} - -module ball_screw(pitch, length, bearing_radius=2) { - +module +test_ball_groove2() +{ + translate([ 0, 0, 0 ]) ball_groove2(100, 300, 100, 10); } -module test_ball_screw(){} +module ball_screw(pitch, length, bearing_radius = 2) {} + +module +test_ball_screw() +{} diff --git a/shapes/2Dshapes.scad b/shapes/2Dshapes.scad index d7b4cdb1..a342748e 100644 --- a/shapes/2Dshapes.scad +++ b/shapes/2Dshapes.scad @@ -3,280 +3,316 @@ * Copyright (C) 2012 Peter Uithoven * * License: LGPL 2.1 or later -*/ + */ // 2D Shapes -//ngon(sides, radius, center=false); -//complexRoundSquare(size,rads1=[0,0], rads2=[0,0], rads3=[0,0], rads4=[0,0], center=true) -//roundedSquare(pos=[10,10],r=2) -//csquare(size, center = false) -//trapezoid (bottom, height, top = undef, left_angle = undef, right_angle = undef) +// ngon(sides, radius, center=false); +// complexRoundSquare(size,rads1=[0,0], rads2=[0,0], rads3=[0,0], rads4=[0,0], +// center=true) roundedSquare(pos=[10,10],r=2) csquare(size, center = false) +// trapezoid (bottom, height, top = undef, left_angle = undef, right_angle = +// undef) -//ring(inside_diameter, thickness) -//ellipse(width, height) -//ellipsePart(width,height,numQuarters) -//egg_outline(width, length) +// ring(inside_diameter, thickness) +// ellipse(width, height) +// ellipsePart(width,height,numQuarters) +// egg_outline(width, length) -//donutSlice(innerSize,outerSize, start_angle, end_angle) -//pieSlice(size, start_angle, end_angle) //size in radius(es) +// donutSlice(innerSize,outerSize, start_angle, end_angle) +// pieSlice(size, start_angle, end_angle) //size in radius(es) // Examples /*use ; grid(105,105,true,4) { - // ellipse - ellipse(50,75); - - // part of ellipse (a number of quarters) - ellipsePart(50,75,3); - ellipsePart(50,75,2); - ellipsePart(50,75,1); - - // complexRoundSquare examples - complexRoundSquare([75,100],[20,10],[20,10],[20,10],[20,10]); - complexRoundSquare([75,100],[0,0],[0,0],[30,50],[20,10]); - complexRoundSquare([50,50],[10,20],[10,20],[10,20],[10,20],false); - complexRoundSquare([100,100]); - complexRoundSquare([100,100],rads1=[20,20],rads3=[20,20]); - - // pie slice - pieSlice(50,0,10); - pieSlice(50,45,190); - pieSlice([50,20],180,270); - - // donut slice - donutSlice(20,50,0,350); - donutSlice(30,50,190,270); - donutSlice([40,22],[50,30],180,270); - donutSlice([50,20],50,180,270); - donutSlice([20,30],[50,40],0,270); + // ellipse + ellipse(50,75); + + // part of ellipse (a number of quarters) + ellipsePart(50,75,3); + ellipsePart(50,75,2); + ellipsePart(50,75,1); + + // complexRoundSquare examples + complexRoundSquare([75,100],[20,10],[20,10],[20,10],[20,10]); + complexRoundSquare([75,100],[0,0],[0,0],[30,50],[20,10]); + complexRoundSquare([50,50],[10,20],[10,20],[10,20],[10,20],false); + complexRoundSquare([100,100]); + complexRoundSquare([100,100],rads1=[20,20],rads3=[20,20]); + + // pie slice + pieSlice(50,0,10); + pieSlice(50,45,190); + pieSlice([50,20],180,270); + + // donut slice + donutSlice(20,50,0,350); + donutSlice(30,50,190,270); + donutSlice([40,22],[50,30],180,270); + donutSlice([50,20],50,180,270); + donutSlice([20,30],[50,40],0,270); }*/ //---------------------- // Regular 2D shapes // The orientation might change with the implementation of circle... -module ngon(sides, radius, center=false){ - rotate([0, 0, 360/sides/2]) circle(r=radius, $fn=sides, center=center); +module ngon(sides, radius, center = false) +{ + rotate([ 0, 0, 360 / sides / 2 ]) + circle(r = radius, $fn = sides, center = center); } // 2D regular shapes -module reg_polygon(sides, radius, center=false) +module reg_polygon(sides, radius, center = false) { - function dia(r) = sqrt(pow(r*2,2)/2); //sqrt((r*2^2)/2) if only we had an exponention op - if(sides<2) square([radius,0]); - if(sides==3) triangle(radius); - if(sides==4) square([dia(radius),dia(radius)],center=true); - if(sides>4) circle(r=radius,$fn=sides,center=center); + function dia(r) = + sqrt(pow(r * 2, 2) / 2); // sqrt((r*2^2)/2) if only we had an exponention op + if (sides < 2) + square([ radius, 0 ]); + if (sides == 3) + triangle(radius); + if (sides == 4) + square([ dia(radius), dia(radius) ], center = true); + if (sides > 4) + circle(r = radius, $fn = sides, center = center); } module pentagon(radius) { - reg_polygon(5,radius); + reg_polygon(5, radius); } module hexagon(radius) { - reg_polygon(6,radius); + reg_polygon(6, radius); } module heptagon(radius) { - reg_polygon(7,radius); + reg_polygon(7, radius); } module octagon(radius) { - reg_polygon(8,radius); + reg_polygon(8, radius); } module nonagon(radius) { - reg_polygon(9,radius); + reg_polygon(9, radius); } module decagon(radius) { - reg_polygon(10,radius); + reg_polygon(10, radius); } module hendecagon(radius) { - reg_polygon(11,radius); + reg_polygon(11, radius); } module dodecagon(radius) { - reg_polygon(12,radius); + reg_polygon(12, radius); } -// size, top left radius, top right radius, bottom right radius, bottom left radius, center -module complexRoundSquare(size,rads1=[0,0], rads2=[0,0], rads3=[0,0], rads4=[0,0], center=true) +// size, top left radius, top right radius, bottom right radius, bottom left +// radius, center +module complexRoundSquare(size, + rads1 = [ 0, 0 ], + rads2 = [ 0, 0 ], + rads3 = [ 0, 0 ], + rads4 = [ 0, 0 ], + center = true) { - width = size[0]; - height = size[1]; - //%square(size=[width, height],center=true); - x1 = 0-width/2+rads1[0]; - y1 = 0-height/2+rads1[1]; - x2 = width/2-rads2[0]; - y2 = 0-height/2+rads2[1]; - x3 = width/2-rads3[0]; - y3 = height/2-rads3[1]; - x4 = 0-width/2+rads4[0]; - y4 = height/2-rads4[1]; - - scs = 0.1; //straight corner size - - x = (center)? 0: width/2; - y = (center)? 0: height/2; - - translate([x,y,0]) - { - hull() { - // top left - if(rads1[0] > 0 && rads1[1] > 0) - translate([x1,y1]) mirror([1,0]) ellipsePart(rads1[0]*2,rads1[1]*2,1); - else - translate([x1,y1]) square(size=[scs, scs]); - - // top right - if(rads2[0] > 0 && rads2[1] > 0) - translate([x2,y2]) ellipsePart(rads2[0]*2,rads2[1]*2,1); - else - translate([width/2-scs,0-height/2]) square(size=[scs, scs]); - - // bottom right - if(rads3[0] > 0 && rads3[1] > 0) - translate([x3,y3]) mirror([0,1]) ellipsePart(rads3[0]*2,rads3[1]*2,1); - else - translate([width/2-scs,height/2-scs]) square(size=[scs, scs]); - - // bottom left - if(rads4[0] > 0 && rads4[1] > 0) - translate([x4,y4]) rotate([0,0,-180]) ellipsePart(rads4[0]*2,rads4[1]*2,1); - else - #translate([x4,height/2-scs]) square(size=[scs, scs]); - } - } + width = size[0]; + height = size[1]; + //%square(size=[width, height],center=true); + x1 = 0 - width / 2 + rads1[0]; + y1 = 0 - height / 2 + rads1[1]; + x2 = width / 2 - rads2[0]; + y2 = 0 - height / 2 + rads2[1]; + x3 = width / 2 - rads3[0]; + y3 = height / 2 - rads3[1]; + x4 = 0 - width / 2 + rads4[0]; + y4 = height / 2 - rads4[1]; + + scs = 0.1; // straight corner size + + x = (center) ? 0 : width / 2; + y = (center) ? 0 : height / 2; + + translate([ x, y, 0 ]) + { + hull() + { + // top left + if (rads1[0] > 0 && rads1[1] > 0) + translate([ x1, y1 ]) mirror([ 1, 0 ]) + ellipsePart(rads1[0] * 2, rads1[1] * 2, 1); + else + translate([ x1, y1 ]) square(size = [ scs, scs ]); + + // top right + if (rads2[0] > 0 && rads2[1] > 0) + translate([ x2, y2 ]) ellipsePart(rads2[0] * 2, rads2[1] * 2, 1); + else + translate([ width / 2 - scs, 0 - height / 2 ]) + square(size = [ scs, scs ]); + + // bottom right + if (rads3[0] > 0 && rads3[1] > 0) + translate([ x3, y3 ]) mirror([ 0, 1 ]) + ellipsePart(rads3[0] * 2, rads3[1] * 2, 1); + else + translate([ width / 2 - scs, height / 2 - scs ]) + square(size = [ scs, scs ]); + + // bottom left + if (rads4[0] > 0 && rads4[1] > 0) + translate([ x4, y4 ]) rotate([ 0, 0, -180 ]) + ellipsePart(rads4[0] * 2, rads4[1] * 2, 1); + else +#translate([ x4, height / 2 - scs ]) square(size = [ scs, scs ]); + } + } } -module roundedSquare(pos=[10,10],r=2) { - minkowski() { - square([pos[0]-r*2,pos[1]-r*2],center=true); - circle(r=r); - } +module roundedSquare(pos = [ 10, 10 ], r = 2) +{ + minkowski() + { + square([ pos[0] - r * 2, pos[1] - r * 2 ], center = true); + circle(r = r); + } } -module csquare (size, center = false) +module csquare(size, center = false) { - center = (len (center) == undef) ? [center, center] : center; - size = (len (size) == undef) ? [size, size] : size; + center = (len(center) == undef) ? [ center, center ] : center; + size = (len(size) == undef) ? [ size, size ] : size; - function get_offset (i) = center[i] ? - size[i] / 2 : 0; + function get_offset(i) = center[i] ? -size[i] / 2 : 0; - translate ([get_offset (0), get_offset (1)]) - square (size); + translate([ get_offset(0), get_offset(1) ]) square(size); } module triangle(radius) { - o=radius/2; //equivalent to radius*sin(30) - a=radius*sqrt(3)/2; //equivalent to radius*cos(30) - polygon(points=[[-a,-o],[0,radius],[a,-o]],paths=[[0,1,2]]); + o = radius / 2; // equivalent to radius*sin(30) + a = radius * sqrt(3) / 2; // equivalent to radius*cos(30) + polygon(points = [ [ -a, -o ], [ 0, radius ], [ a, -o ] ], + paths = [[ 0, 1, 2 ]]); } -module trapezoid (bottom, height, top = undef, - left_angle = undef, right_angle = undef) +module trapezoid(bottom, + height, + top = undef, + left_angle = undef, + right_angle = undef) { - function tan90 (angle) = (angle == 90) ? 0 : tan (angle); - - function get_trapezoid_offset (adjacent, opposite) = ( - (adjacent == undef && opposite == undef) ? (bottom - top) / 2 : - (adjacent == undef) ? bottom - tan90 (90 - opposite) * height - top : - tan90 (90 - adjacent) * height - ); - - offset_left = get_trapezoid_offset (left_angle, right_angle); - offset_right = get_trapezoid_offset (right_angle, left_angle); - - polygon ([ - [-bottom / 2, 0], - [bottom / 2, 0], - [bottom / 2 - offset_right, height], - [-bottom / 2 + offset_left, height] - ]); + function tan90(angle) = (angle == 90) ? 0 : tan(angle); + + function get_trapezoid_offset(adjacent, opposite) = + ((adjacent == undef && opposite == undef) + ? (bottom - top) / 2 + : (adjacent == undef) ? bottom - tan90(90 - opposite) * height - top + : tan90(90 - adjacent) * height); + + offset_left = get_trapezoid_offset(left_angle, right_angle); + offset_right = get_trapezoid_offset(right_angle, left_angle); + + polygon([ + [ -bottom / 2, 0 ], + [ bottom / 2, 0 ], + [ bottom / 2 - offset_right, height ], + [ -bottom / 2 + offset_left, height ] + ]); } -module ring(inside_diameter, thickness){ - difference(){ - circle(r=(inside_diameter+thickness*2)/2); - circle(r=inside_diameter/2); +module ring(inside_diameter, thickness) +{ + difference() + { + circle(r = (inside_diameter + thickness * 2) / 2); + circle(r = inside_diameter / 2); } } -module ellipse(width, height) { - scale([1, height/width, 1]) circle(r=width/2); +module ellipse(width, height) +{ + scale([ 1, height / width, 1 ]) circle(r = width / 2); } -module ellipsePart(width,height,numQuarters) +module ellipsePart(width, height, numQuarters) { - o = 1; //slight overlap to fix a bug - difference() - { - ellipse(width,height); - if(numQuarters <= 3) - translate([0-width/2-o,0-height/2-o,0]) square([width/2+o,height/2+o]); - if(numQuarters <= 2) - translate([0-width/2-o,-o,0]) square([width/2+o,height/2+o*2]); - if(numQuarters < 2) - translate([-o,0,0]) square([width/2+o*2,height/2+o]); - } + o = 1; // slight overlap to fix a bug + difference() + { + ellipse(width, height); + if (numQuarters <= 3) + translate([ 0 - width / 2 - o, 0 - height / 2 - o, 0 ]) + square([ width / 2 + o, height / 2 + o ]); + if (numQuarters <= 2) + translate([ 0 - width / 2 - o, -o, 0 ]) + square([ width / 2 + o, height / 2 + o * 2 ]); + if (numQuarters < 2) + translate([ -o, 0, 0 ]) square([ width / 2 + o * 2, height / 2 + o ]); + } } // The ratio of length and width is about 1.39 for a real egg -module egg_outline(width, length){ - translate([0, width/2, 0]) union(){ - rotate([0, 0, 180]) difference(){ - ellipse(width, 2*length-width); - translate([-length/2, 0, 0]) square(length); - } - circle(r=width/2); +module egg_outline(width, length) +{ + translate([ 0, width / 2, 0 ]) union() + { + rotate([ 0, 0, 180 ]) difference() + { + ellipse(width, 2 * length - width); + translate([ -length / 2, 0, 0 ]) square(length); } + circle(r = width / 2); + } } -module donutSlice(innerSize,outerSize, start_angle, end_angle) -{ - difference() - { - pieSlice(outerSize, start_angle, end_angle); - if(len(innerSize) > 1) ellipse(innerSize[0]*2,innerSize[1]*2); - else circle(innerSize); - } +module donutSlice(innerSize, outerSize, start_angle, end_angle) +{ + difference() + { + pieSlice(outerSize, start_angle, end_angle); + if (len(innerSize) > 1) + ellipse(innerSize[0] * 2, innerSize[1] * 2); + else + circle(innerSize); + } } -module pieSlice(size, start_angle, end_angle) //size in radius(es) -{ - rx = ((len(size) > 1)? size[0] : size); - ry = ((len(size) > 1)? size[1] : size); - trx = rx* sqrt(2) + 1; - try = ry* sqrt(2) + 1; - a0 = (4 * start_angle + 0 * end_angle) / 4; - a1 = (3 * start_angle + 1 * end_angle) / 4; - a2 = (2 * start_angle + 2 * end_angle) / 4; - a3 = (1 * start_angle + 3 * end_angle) / 4; - a4 = (0 * start_angle + 4 * end_angle) / 4; - if(end_angle > start_angle) - intersection() { - if(len(size) > 1) - ellipse(rx*2,ry*2); - else - circle(rx); - polygon([ - [0,0], - [trx * cos(a0), try * sin(a0)], - [trx * cos(a1), try * sin(a1)], - [trx * cos(a2), try * sin(a2)], - [trx * cos(a3), try * sin(a3)], - [trx * cos(a4), try * sin(a4)], - [0,0] - ]); +module pieSlice(size, start_angle, end_angle) // size in radius(es) +{ + rx = ((len(size) > 1) ? size[0] : size); + ry = ((len(size) > 1) ? size[1] : size); + trx = rx * sqrt(2) + 1; + try + = ry * sqrt(2) + 1; + a0 = (4 * start_angle + 0 * end_angle) / 4; + a1 = (3 * start_angle + 1 * end_angle) / 4; + a2 = (2 * start_angle + 2 * end_angle) / 4; + a3 = (1 * start_angle + 3 * end_angle) / 4; + a4 = (0 * start_angle + 4 * end_angle) / 4; + if (end_angle > start_angle) + intersection() + { + if (len(size) > 1) + ellipse(rx * 2, ry * 2); + else + circle(rx); + polygon([ + [ 0, 0 ], + [ trx * cos(a0), try * sin(a0) ], + [ trx * cos(a1), try * sin(a1) ], + [ trx * cos(a2), try * sin(a2) ], + [ trx * cos(a3), try * sin(a3) ], + [ trx * cos(a4), try * sin(a4) ], + [ 0, 0 ] + ]); } } diff --git a/shapes/3Dshapes.scad b/shapes/3Dshapes.scad index 45d155ba..13aef80a 100644 --- a/shapes/3Dshapes.scad +++ b/shapes/3Dshapes.scad @@ -10,44 +10,43 @@ */ // 3D Shapes -//box(width, height, depth); -//mcad_rounded_box (size, radius, sidesonly, center=false); -//ccube (size, center = false); +// box(width, height, depth); +// mcad_rounded_box (size, radius, sidesonly, center=false); +// ccube (size, center = false); -//cone(height, radius); -//ellipsoid(width, height); -//teardrop(radius, length, angle); -//flat_teardrop(radius, length, angle); +// cone(height, radius); +// ellipsoid(width, height); +// teardrop(radius, length, angle); +// flat_teardrop(radius, length, angle); -//torus(outerRadius, innerRadius); -//torus2(r1, r2); -//oval_torus(inner_radius, thickness=[0, 0]); +// torus(outerRadius, innerRadius); +// torus2(r1, r2); +// oval_torus(inner_radius, thickness=[0, 0]); -//tube(height, radius, wall, center = false); -//tube2(height, ID, OD, center = false); -//oval_tube(width, height, depth, wall, center = false); +// tube(height, radius, wall, center = false); +// tube2(height, ID, OD, center = false); +// oval_tube(width, height, depth, wall, center = false); -//hexagon(height, depth); -//octagon(height, depth); -//dodecagon(height, depth); -//hexagram(height, depth); +// hexagon(height, depth); +// octagon(height, depth); +// dodecagon(height, depth); +// hexagram(height, depth); -//rightTriangle(adjacent, opposite, depth); -//equiTriangle(side, depth); -//triangle_pyramid(radius); -//square_pyramid(base_x, base_y,height); - - -//12ptStar(height, depth); +// rightTriangle(adjacent, opposite, depth); +// equiTriangle(side, depth); +// triangle_pyramid(radius); +// square_pyramid(base_x, base_y,height); +// 12ptStar(height, depth); //---------------------- use // size is a vector [w, h, d] -module box(width, height, depth) { - cube([width, height, depth], true); +module box(width, height, depth) +{ + cube([ width, height, depth ], true); } // Author: Marius Kintel @@ -60,53 +59,54 @@ module box(width, height, depth) { // mcad_rounded_box([20, 30, 40], 5, true); // size is a vector [w, h, d] -module mcad_rounded_box (size, radius, sidesonly, center=false) -{ - module place_xy () - for (x = [size[0]/2 - radius, -size[0]/2 + radius]) - for (y = [size[1]/2 - radius, -size[1]/2 + radius]) - translate ([x, y, 0]) - children (); - - translate (center ? [0, 0, 0] : size / 2) - hull () - if (sidesonly) { - place_xy () - cylinder (r = radius, h = size[2], center=true); - - } else { - for (z = [size[2]/2 - radius, -size[2]/2 + radius]) - translate ([0, 0, z]) - place_xy () - sphere (r = radius); - } +module mcad_rounded_box(size, radius, sidesonly, center = false) +{ + module + place_xy() for (x = [ + size[0] / 2 - radius, + -size[0] / 2 + + radius + ]) for (y = [ size[1] / 2 - radius, -size[1] / 2 + + radius ]) translate([ x, y, 0 ]) children(); + + translate(center ? [ 0, 0, 0 ] : size / 2) hull() if (sidesonly) + { + place_xy() cylinder(r = radius, h = size[2], center = true); + } + else + { + for (z = [ size[2] / 2 - radius, -size[2] / 2 + radius ]) + translate([ 0, 0, z ]) place_xy() sphere(r = radius); + } } -module ccube (size, center = false) +module ccube(size, center = false) { - center = (len (center) == undef) ? [center, center, center] : center; - size = (len (size) == undef) ? [size, size, size] : size; + center = (len(center) == undef) ? [ center, center, center ] : center; + size = (len(size) == undef) ? [ size, size, size ] : size; - function get_offset (i) = center[i] ? - size[i] / 2 : 0; + function get_offset(i) = center[i] ? -size[i] / 2 : 0; - translate ([get_offset (0), get_offset (1), get_offset (2)]) - cube (size); + translate([ get_offset(0), get_offset(1), get_offset(2) ]) cube(size); } -module cone(height, radius, center = false) { +module cone(height, radius, center = false) +{ cylinder(height, radius, 0, center); } -module ellipsoid(w, h, center = false) { - scale([1, h/w, 1]) sphere(r=w/2, center=center); +module ellipsoid(w, h, center = false) +{ + scale([ 1, h / w, 1 ]) sphere(r = w / 2, center = center); } -module egg(width, lenght){ - rotate_extrude() - difference(){ - egg_outline(width, lenght); - translate([-lenght, 0, 0]) cube(2*lenght, center=true); - } +module egg(width, lenght) +{ + rotate_extrude() difference() + { + egg_outline(width, lenght); + translate([ -lenght, 0, 0 ]) cube(2 * lenght, center = true); + } } /* From http://www.thingiverse.com/thing:3457 @@ -126,247 +126,310 @@ module egg(width, lenght){ along with this program. If not, see . */ - /* -This script generates a teardrop shape at the appropriate angle -to prevent overhangs greater than 45 degrees. The angle is in degrees, -and is a rotation around the Y axis. You can then rotate around Z -to point it in any direction. Rotation around X or Y will cause the angle to +This script generates a teardrop shape at the appropriate angle +to prevent overhangs greater than 45 degrees. The angle is in degrees, +and is a rotation around the Y axis. You can then rotate around Z +to point it in any direction. Rotation around X or Y will cause the angle to be wrong. */ -module teardrop(radius, length, angle) { - rotate([0, angle, 0]) union() { - linear_extrude(height = length, center = true, convexity = radius, twist = 0) - circle(r = radius, center = true, $fn = 30); - linear_extrude(height = length, center = true, convexity = radius, twist = 0) - projection(cut = false) rotate([0, -angle, 0]) translate([0, 0, radius * sin(45) * 1.5]) cylinder(h = radius * sin(45), r1 = radius * sin(45), r2 = 0, center = true, $fn = 30); - } - -//I worked this portion out when a bug was causing the projection -//above to take FOREVER to calculate. It works as a replacement, -//and I figured I'd leave it here just in case. -/* - #polygon(points = [[radius * cos(-angle / 2), radius * sin(-angle / 2), 0],[radius * cos(-angle / 2), radius * -sin(-angle / 2), 0],[(sin(-angle - 45) + cos(-angle - 45)) * radius, 0, 0]], paths = [[0, 1, 2]]); - #polygon(points = [[radius * -cos(-angle / 2), radius * sin(-angle / 2), 0],[radius * -cos(-angle / 2), radius * -sin(-angle / 2), 0],[(sin(-angle - 45) + cos(-angle - 45)) * radius, 0, 0]], paths = [[0, 1, 2]]); - #polygon(points = [[radius * sin(-angle / 2), radius * cos(-angle / 2), 0],[radius * sin(-angle / 2), radius * -cos(-angle / 2), 0],[(sin(-angle - 45) + cos(-angle - 45)) * radius, 0, 0]], paths = [[0, 1, 2]]); - */ +module teardrop(radius, length, angle) +{ + rotate([ 0, angle, 0 ]) union() + { + linear_extrude( + height = length, center = true, convexity = radius, twist = 0) + circle(r = radius, center = true, $fn = 30); + linear_extrude( + height = length, center = true, convexity = radius, twist = 0) + projection(cut = false) rotate([ 0, -angle, 0 ]) + translate([ 0, 0, radius * sin(45) * 1.5 ]) + cylinder(h = radius * sin(45), + r1 = radius * sin(45), + r2 = 0, + center = true, + $fn = 30); + } + + // I worked this portion out when a bug was causing the projection + // above to take FOREVER to calculate. It works as a replacement, + // and I figured I'd leave it here just in case. + /* + #polygon(points = [[radius * cos(-angle / 2), radius * sin(-angle / 2), + 0],[radius * cos(-angle / 2), radius * -sin(-angle / 2), 0],[(sin(-angle - + 45) + cos(-angle - 45)) * radius, 0, 0]], paths = [[0, 1, 2]]); + #polygon(points = [[radius * -cos(-angle / 2), radius * sin(-angle / 2), + 0],[radius * -cos(-angle / 2), radius * -sin(-angle / 2), 0],[(sin(-angle - + 45) + cos(-angle - 45)) * radius, 0, 0]], paths = [[0, 1, 2]]); + #polygon(points = [[radius * sin(-angle / 2), radius * cos(-angle / 2), + 0],[radius * sin(-angle / 2), radius * -cos(-angle / 2), 0],[(sin(-angle - + 45) + cos(-angle - 45)) * radius, 0, 0]], paths = [[0, 1, 2]]); + */ } /* * Simple intersection method to implement a flat/truncated teardrop */ -module flat_teardrop(radius, length, angle) { - intersection() { - rotate([0, angle, 0]) { - cube(size=[radius * 2, radius * 2, length], center=true); - } - teardrop(radius, length, angle); - } +module flat_teardrop(radius, length, angle) +{ + intersection() + { + rotate([ 0, angle, 0 ]) + { + cube(size = [ radius * 2, radius * 2, length ], center = true); + } + teardrop(radius, length, angle); + } } module torus(outerRadius, innerRadius) { - r=(outerRadius-innerRadius)/2; - rotate_extrude() translate([innerRadius+r,0,0]) circle(r); + r = (outerRadius - innerRadius) / 2; + rotate_extrude() translate([ innerRadius + r, 0, 0 ]) circle(r); } module torus2(r1, r2) { - rotate_extrude() translate([r1,0,0]) circle(r2); + rotate_extrude() translate([ r1, 0, 0 ]) circle(r2); } -module oval_torus(inner_radius, thickness=[0, 0]) +module oval_torus(inner_radius, thickness = [ 0, 0 ]) { - rotate_extrude() translate([inner_radius+thickness[0]/2,0,0]) ellipse(width=thickness[0], height=thickness[1]); + rotate_extrude() translate([ inner_radius + thickness[0] / 2, 0, 0 ]) + ellipse(width = thickness[0], height = thickness[1]); } // wall is wall thickness -module tube(h, r, wall, center = false) { - linear_extrude (height=h, center=center) - difference() { - circle(r=r, center=center); - circle(r=r-wall, center=center); +module tube(h, r, wall, center = false) +{ + linear_extrude(height = h, center = center) difference() + { + circle(r = r, center = center); + circle(r = r - wall, center = center); } } -module tube2(height, ID, OD, center = false) { - difference() { - cylinder(h=height, r=OD/2, center=center); - cylinder(h=height, r=ID/2, center=center); +module tube2(height, ID, OD, center = false) +{ + difference() + { + cylinder(h = height, r = OD / 2, center = center); + cylinder(h = height, r = ID / 2, center = center); } } module oval_prism(height, rx, ry, center = false) { - scale([1, rx/ry, 1]) cylinder(h=height, r=ry, center=center); + scale([ 1, rx / ry, 1 ]) cylinder(h = height, r = ry, center = center); } // wall is wall thickness -module oval_tube(height, rx, ry, wall, center = false) { - difference() { - scale([1, ry/rx, 1]) cylinder(h=height, r=rx, center=center); - translate([0,0,-0.1]) - #scale([(rx-wall)/rx, (ry-wall)/rx, 1]) cylinder(h=height+0.2, r=rx, center=center); +module oval_tube(height, rx, ry, wall, center = false) +{ + difference() + { + scale([ 1, ry / rx, 1 ]) cylinder(h = height, r = rx, center = center); + translate([ 0, 0, -0.1 ]) +#scale([ (rx - wall) / rx, (ry - wall) / rx, 1 ]) \ + cylinder(h = height + 0.2, r = rx, center = center); } } -//Tubifies any regular prism -module tubify(radius,wall) +// Tubifies any regular prism +module tubify(radius, wall) { difference() { child(0); - translate([0, 0, -0.1]) scale([(radius-wall)/radius, (radius-wall)/radius, 2]) child(0); + translate([ 0, 0, -0.1 ]) + scale([ (radius - wall) / radius, (radius - wall) / radius, 2 ]) child(0); } } module cylinder_tube(height, radius, wall, center = false) { - tubify(radius,wall) - cylinder(h=height, r=radius, center=center); + tubify(radius, wall) cylinder(h = height, r = radius, center = center); } -module triangle_prism(height,radius) +module triangle_prism(height, radius) { - linear_extrude(height=height) triangle(radius); + linear_extrude(height = height) triangle(radius); } -module triangle_tube(height,radius,wall) +module triangle_tube(height, radius, wall) { - tubify(radius,wall) triangle_prism(height,radius); + tubify(radius, wall) triangle_prism(height, radius); } -module pentagon_prism(height,radius) +module pentagon_prism(height, radius) { - linear_extrude(height=height) pentagon(radius); + linear_extrude(height = height) pentagon(radius); } -module pentagon_tube(height,radius,wall) +module pentagon_tube(height, radius, wall) { - tubify(radius,wall) pentagon_prism(height,radius); + tubify(radius, wall) pentagon_prism(height, radius); } -module hexagon_prism(height,radius) +module hexagon_prism(height, radius) { - linear_extrude(height=height) hexagon(radius); + linear_extrude(height = height) hexagon(radius); } -module hexagon_tube(height,radius,wall) +module hexagon_tube(height, radius, wall) { - tubify(radius,wall) hexagon_prism(height,radius); + tubify(radius, wall) hexagon_prism(height, radius); } -module heptagon_prism(height,radius) +module heptagon_prism(height, radius) { - linear_extrude(height=height) heptagon(radius); + linear_extrude(height = height) heptagon(radius); } -module heptagon_tube(height,radius,wall) +module heptagon_tube(height, radius, wall) { - tubify(radius,wall) heptagon_prism(height,radius); + tubify(radius, wall) heptagon_prism(height, radius); } -module octagon_prism(height,radius) +module octagon_prism(height, radius) { - linear_extrude(height=height) octagon(radius); + linear_extrude(height = height) octagon(radius); } -module octagon_tube(height,radius,wall) +module octagon_tube(height, radius, wall) { - tubify(radius,wall) octagon_prism(height,radius); + tubify(radius, wall) octagon_prism(height, radius); } -module nonagon_prism(height,radius) +module nonagon_prism(height, radius) { - linear_extrude(height=height) nonagon(radius); + linear_extrude(height = height) nonagon(radius); } -module decagon_prism(height,radius) +module decagon_prism(height, radius) { - linear_extrude(height=height) decagon(radius); + linear_extrude(height = height) decagon(radius); } -module hendecagon_prism(height,radius) +module hendecagon_prism(height, radius) { - linear_extrude(height=height) hendecagon(radius); + linear_extrude(height = height) hendecagon(radius); } -module dodecagon_prism(height,radius) +module dodecagon_prism(height, radius) { - linear_extrude(height=height) dodecagon(radius); + linear_extrude(height = height) dodecagon(radius); } -module rightTriangle(adjacent, opposite, height) { - difference() { - translate([-adjacent/2,opposite/2,0]) cube([adjacent, opposite, height], true); - translate([-adjacent,0,0]) { - rotate([0,0,atan(opposite/adjacent)]) dislocateBox(adjacent*2, opposite, height+2); +module rightTriangle(adjacent, opposite, height) +{ + difference() + { + translate([ -adjacent / 2, opposite / 2, 0 ]) + cube([ adjacent, opposite, height ], true); + translate([ -adjacent, 0, 0 ]) + { + rotate([ 0, 0, atan(opposite / adjacent) ]) + dislocateBox(adjacent * 2, opposite, height + 2); } } } -module equiTriangle(side, height) { - difference() { - translate([-side/2,side/2,0]) cube([side, side, height], true); - rotate([0,0,30]) dislocateBox(side*2, side, height); - translate([-side,0,0]) { - rotate([0,0,60]) dislocateBox(side*2, side, height); +module equiTriangle(side, height) +{ + difference() + { + translate([ -side / 2, side / 2, 0 ]) cube([ side, side, height ], true); + rotate([ 0, 0, 30 ]) dislocateBox(side * 2, side, height); + translate([ -side, 0, 0 ]) + { + rotate([ 0, 0, 60 ]) dislocateBox(side * 2, side, height); } } } module triangle_pyramid(radius) { - o=radius/2; //equivalent to radius*sin(30) - a=radius*sqrt(3)/2; //equivalent to radius*cos(30) - polyhedron(points=[[-a,-o,-o],[a,-o,-o],[0,radius,-o],[0,0,radius]],triangles=[[0,1,2],[1,2,3],[0,1,3],[0,2,3]]); + o = radius / 2; // equivalent to radius*sin(30) + a = radius * sqrt(3) / 2; // equivalent to radius*cos(30) + polyhedron( + points = + [ [ -a, -o, -o ], [ a, -o, -o ], [ 0, radius, -o ], [ 0, 0, radius ] ], + triangles = [ [ 0, 1, 2 ], [ 1, 2, 3 ], [ 0, 1, 3 ], [ 0, 2, 3 ] ]); } -module square_pyramid(base_x, base_y,height) +module square_pyramid(base_x, base_y, height) { - w=base_x/2; - h=base_y/2; - polyhedron(points=[[-w,-h,0],[-w,h,0],[w,h,0],[w,-h,0],[0,0,height]],triangles=[[0,3,2,1], [0,1,4], [1,2,4], [2,3,4], [3,0,4]]); + w = base_x / 2; + h = base_y / 2; + polyhedron( + points = + [ + [ -w, -h, 0 ], + [ -w, h, 0 ], + [ w, h, 0 ], + [ w, -h, 0 ], + [ 0, 0, height ] + ], + triangles = + [ [ 0, 3, 2, 1 ], [ 0, 1, 4 ], [ 1, 2, 4 ], [ 2, 3, 4 ], [ 3, 0, 4 ] ]); } // Tests: -module test_square_pyramid() +module +test_square_pyramid() { - square_pyramid(10, 20, 30); + square_pyramid(10, 20, 30); } - -module 12ptStar(size, height) { +module 12ptStar(size, height) +{ starNum = 3; - starAngle = 360/starNum; + starAngle = 360 / starNum; for (s = [1:starNum]) { - rotate([0, 0, s*starAngle]) cube([size, size, height], true); + rotate([ 0, 0, s * starAngle ]) cube([ size, size, height ], true); } } //----------------------- -//MOVES THE ROTATION AXIS OF A BOX FROM ITS CENTER TO THE BOTTOM LEFT CORNER -module dislocateBox(w, h, d) { - translate([0,0,-d/2]) cube([w,h,d]); +// MOVES THE ROTATION AXIS OF A BOX FROM ITS CENTER TO THE BOTTOM LEFT CORNER +module dislocateBox(w, h, d) +{ + translate([ 0, 0, -d / 2 ]) cube([ w, h, d ]); } //----------------------- // Tests -//module test2D_ellipse(){ellipse(10, 5);} -module test_ellipsoid(){ellipsoid(10, 5);} +// module test2D_ellipse(){ellipse(10, 5);} +module +test_ellipsoid() +{ + ellipsoid(10, 5); +} -//module test2D_egg_outline(){egg_outline();} +// module test2D_egg_outline(){egg_outline();} // unregular_shapes.scad // Copyright 2011 Elmo Mäntynen // LGPL 2.1 -// Give a list of 4+4 points (check order) to form an 8 point polyhedron -module connect_squares(points){ - polyhedron(points=points, - triangles=[[0,1,2], [3,0,2], [7,6,5], [7,5,4], // Given polygons - [0,4,1], [4,5,1], [1,5,2], [2,5,6], // Connecting - [2,6,3], [3,6,7], [3,4,0], [3,7,4]]);// sides +// Give a list of 4+4 points (check order) to form an 8 point polyhedron +module connect_squares(points) +{ + polyhedron(points = points, triangles = [ + [ 0, 1, 2 ], + [ 3, 0, 2 ], + [ 7, 6, 5 ], + [ 7, 5, 4 ], // Given polygons + [ 0, 4, 1 ], + [ 4, 5, 1 ], + [ 1, 5, 2 ], + [ 2, 5, 6 ], // Connecting + [ 2, 6, 3 ], + [ 3, 6, 7 ], + [ 3, 4, 0 ], + [ 3, 7, 4 ] + ]); // sides } diff --git a/shapes/3d_triangle.scad b/shapes/3d_triangle.scad index f313433a..591bed82 100644 --- a/shapes/3d_triangle.scad +++ b/shapes/3d_triangle.scad @@ -1,4 +1,4 @@ -// Enhancement of OpenSCAD Primitives Solid with Trinagles +// Enhancement of OpenSCAD Primitives Solid with Trinagles // Copyright (C) 2011 Rene BAUMANN, Switzerland // // This library is free software; you can redistribute it and/or @@ -12,16 +12,16 @@ // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public -// License along with this library; If not, see -// or write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// License along with this library; If not, see +// or write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // ================================================================ // -// File providing functions and modules to draw 3D - triangles -// created in the X-Y plane with hight h, using various triangle -// specification methods. -// Standard traingle geometrical definition is used. Vertices are named A,B,C, -// side a is opposite vertex A a.s.o. the angle at vertex A is named alpha, +// File providing functions and modules to draw 3D - triangles +// created in the X-Y plane with hight h, using various triangle +// specification methods. +// Standard traingle geometrical definition is used. Vertices are named A,B,C, +// side a is opposite vertex A a.s.o. the angle at vertex A is named alpha, // B(beta), C(gamma). // // This SW is a contribution to the Free Software Community doing a marvelous @@ -42,8 +42,8 @@ // co-ordinates. The trinagle's c-side lies on the x-axis // and A-corner in the co-ordinates center [0,0,0]. Geometry rules // required that a + b is greater then c. The traingle's vertices are -// computed such that it is located in the X-Y plane, side c is on the -// positive x-axis. +// computed such that it is located in the X-Y plane, side c is on the +// positive x-axis. // PARAMETER: // a : real length of side a // b : real length of side b @@ -53,14 +53,18 @@ // // COMMENT: // vertices = 3dtri_sides2coord (3,4,5); -// vertices[0] : Acord vertex A cordinates the like [x,y,z] -// ------------------------------------------------------------------------------------- +// vertices[0] : Acord vertex A cordinates the like [x,y,z] +// ------------------------------------------------------------------------------------- // -function 3dtri_sides2coord (a,b,c) = [ - [0,0,0], - [c,0,0], - [(pow(c,2)+pow(a,2)-pow(b,2))/(2*c),sqrt ( pow(a,2) - - pow((pow(c,2)+pow(a,2)-pow(b,2))/(2*c),2)),0]]; +function 3dtri_sides2coord(a, b, c) = [ + [ 0, 0, 0 ], + [ c, 0, 0 ], + [ + (pow(c, 2) + pow(a, 2) - pow(b, 2)) / (2 * c), + sqrt(pow(a, 2) - pow((pow(c, 2) + pow(a, 2) - pow(b, 2)) / (2 * c), 2)), + 0 + ] +]; // // // =========================================== @@ -69,7 +73,7 @@ function 3dtri_sides2coord (a,b,c) = [ // DESCRIPTION: // Enter triangle A,B,C - corner coordinates to get the // triangles Center of Gravity coordinates. It is assumed -// the triangle is parallel to the X-Y plane. The function +// the triangle is parallel to the X-Y plane. The function // returns always zero for the z-coordinate // PARAMETER: // Acord : [x,y,z] Coordinates of vertex A @@ -81,10 +85,13 @@ function 3dtri_sides2coord (a,b,c) = [ // COMMENT: // vertices = 3dtri_sides2coord (3,4,5); // cg = 3dtri_centerOfGravityCoord(vertices[0],vertices[1],vertices[2]); -// ------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------- // -function 3dtri_centerOfGravityCoord (Acord,Bcord,Ccord) = [ - (Acord[0]+Bcord[0]+Ccord[0])/3,(Acord[1]+Bcord[1]+Ccord[1])/3,0]; +function 3dtri_centerOfGravityCoord(Acord, Bcord, Ccord) = [ + (Acord[0] + Bcord[0] + Ccord[0]) / 3, + (Acord[1] + Bcord[1] + Ccord[1]) / 3, + 0 +]; // // // =========================================== @@ -93,7 +100,7 @@ function 3dtri_centerOfGravityCoord (Acord,Bcord,Ccord) = [ // DESCRIPTION: // Enter triangle A,B,C - corner coordinates to get the // circum circle coordinates. It is assumed -// the triangle is parallel to the X-Y plane. The function +// the triangle is parallel to the X-Y plane. The function // returns always zero for the z-coordinate // PARAMETER: // Acord : [x,y,z] Coordinates of vertex A @@ -105,21 +112,23 @@ function 3dtri_centerOfGravityCoord (Acord,Bcord,Ccord) = [ // COMMENT: // vertices = 3dtri_sides2coord (3,4,5); // cc = 3dtri_centerOfcircumcircle (vertices[0],vertices[1],vertices[2]); -// ------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------- +// +function 3dtri_centerOfcircumcircle(Acord, Bcord, Ccord) = [ + 0.5 * Bcord[0], + 0.5 * + ((pow(Ccord[1], 2) + pow(Ccord[0], 2) - Bcord[0] * Ccord[0]) / Ccord[1]), + 0 +]; // -function 3dtri_centerOfcircumcircle (Acord,Bcord,Ccord) = - [0.5*Bcord[0], - 0.5*((pow(Ccord[1],2)+pow(Ccord[0],2)-Bcord[0]*Ccord[0])/Ccord[1]), - 0]; // -// // // =========================================== // // FUNCTION: 3dtri_radiusOfcircumcircle // DESCRIPTION: // Provides the triangle's radius from circumcircle to the vertices. -// It is assumed the triangle is parallel to the X-Y plane. The function +// It is assumed the triangle is parallel to the X-Y plane. The function // returns always zero for the z-coordinate // PARAMETER: // Vcord : [x,y,z] Coordinates of a vertex A or B,C @@ -129,15 +138,14 @@ function 3dtri_centerOfcircumcircle (Acord,Bcord,Ccord) = // RETURNS: // cr : Circumcircle radius // -// COMMENT: Calculate circumcircle radius of trinagle with round vertices having -// radius R = 2 -// vertices = 3dtri_sides2coord (3,4,5); -// cc = 3dtri_centerOfcircumcircle (vertices[0],vertices[1],vertices[2]); -// cr = 3dtri_radiusOfcircumcircle (vertices[0],cc,2); -// ------------------------------------------------------------------------------------- +// COMMENT: Calculate circumcircle radius of trinagle with round vertices +// having radius R = 2 vertices = 3dtri_sides2coord (3,4,5); cc = +// 3dtri_centerOfcircumcircle (vertices[0],vertices[1],vertices[2]); cr = +// 3dtri_radiusOfcircumcircle (vertices[0],cc,2); +// ------------------------------------------------------------------------------------- // -function 3dtri_radiusOfcircumcircle (Vcord,CCcord,R) = - sqrt(pow(CCcord[0]-Vcord[0],2)+pow(CCcord[1]-Vcord[1],2))+ R; +function 3dtri_radiusOfcircumcircle(Vcord, CCcord, R) = + sqrt(pow(CCcord[0] - Vcord[0], 2) + pow(CCcord[1] - Vcord[1], 2)) + R; // // // @@ -146,27 +154,28 @@ function 3dtri_radiusOfcircumcircle (Vcord,CCcord,R) = // FUNCTION: 3dtri_radiusOfIn_circle // DESCRIPTION: // Enter triangle A,B,C - corner coordinates to get the -// in-circle radius. It is assumed the triangle is parallel to the -// X-Y plane. The function always returns zero for the z-coordinate. +// in-circle radius. It is assumed the triangle is parallel to the +// X-Y plane. The function always returns zero for the z-coordinate. // Formula used for inner circle radius: r = 2A /(a+b+c) // PARAMETER: // Acord : [x,y,z] Coordinates of vertex A // Bcord : [x,y,z] Coordinates of vertex B // Ccord : [x,y,z] Coordinates of vertex C -// +// // RETURNS: // ir : real radius of in-circle // // COMMENT: // vertices = 3dtri_sides2coord (3,4,5); // ir = 3dtri_radiusOfIn_circle (vertices[0],vertices[1],vertices[2]); -// ------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------- +// +function 3dtri_radiusOfIn_circle(Acord, Bcord, Ccord) = + Bcord[0] * Ccord[1] / + (Bcord[0] + sqrt(pow(Ccord[0] - Bcord[0], 2) + pow(Ccord[1], 2)) + + sqrt(pow(Ccord[0], 2) + pow(Ccord[1], 2))); // -function 3dtri_radiusOfIn_circle (Acord,Bcord,Ccord) = - Bcord[0]*Ccord[1]/(Bcord[0]+sqrt(pow(Ccord[0]-Bcord[0],2)+pow(Ccord[1],2))+ - sqrt(pow(Ccord[0],2)+pow(Ccord[1],2))); // -// // // =========================================== // @@ -174,7 +183,7 @@ function 3dtri_radiusOfIn_circle (Acord,Bcord,Ccord) = // DESCRIPTION: // Enter triangle A,B,C - corner coordinates to get the // in-circle coordinates. It is assumed -// the triangle is parallel to the X-Y plane. The function +// the triangle is parallel to the X-Y plane. The function // returns always zero for the z-coordinate // PARAMETER: // Acord : [x,y,z] Coordinates of vertex A @@ -188,19 +197,24 @@ function 3dtri_radiusOfIn_circle (Acord,Bcord,Ccord) = // vertices = 3dtri_sides2coord (3,4,5); // ir = 3dtri_radiusOfIn_circle (vertices[0],vertices[1],vertices[2]); // ic = 3dtri_centerOfIn_circle (vertices[0],vertices[1],vertices[2],ir); -// ------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------- // -function 3dtri_centerOfIn_circle (Acord,Bcord,Ccord,r) = - [(Bcord[0]+sqrt(pow(Ccord[0]-Bcord[0],2)+pow(Ccord[1],2))+ - sqrt(pow(Ccord[0],2)+pow(Ccord[1],2)))/2-sqrt(pow(Ccord[0]-Bcord[0],2)+pow(Ccord[1],2)),r,0]; +function 3dtri_centerOfIn_circle(Acord, Bcord, Ccord, r) = [ + (Bcord[0] + sqrt(pow(Ccord[0] - Bcord[0], 2) + pow(Ccord[1], 2)) + + sqrt(pow(Ccord[0], 2) + pow(Ccord[1], 2))) / + 2 - + sqrt(pow(Ccord[0] - Bcord[0], 2) + pow(Ccord[1], 2)), + r, + 0 +]; // // // ============================================ // // MODULE: 3dtri_draw // DESCRIPTION: -// Draw a standard solid triangle with A,B,C - vertices specified by its -// co-ordinates and height "h", as given by the input parameters. +// Draw a standard solid triangle with A,B,C - vertices specified by its +// co-ordinates and height "h", as given by the input parameters. // PARAMETER: // Acord : [x,y,z] Coordinates of vertex A // Bcord : [x,y,z] Coordinates of vertex B @@ -211,16 +225,30 @@ function 3dtri_centerOfIn_circle (Acord,Bcord,Ccord,r) = // // COMMENT: // You might use the result from function 3dtri_sides2coord -// to call module 3dtri_draw ( vertices[0],vertices[1],vertices[2], h) -// ------------------------------------------------------------------------------------- -// -module 3dtri_draw ( Acord, Bcord, Ccord, h) { -polyhedron (points=[Acord,Bcord,Ccord, - Acord+[0,0,h],Bcord+[0,0,h],Ccord+[0,0,h]], - triangles=[ [0,1,2],[0,2,3],[3,2,5], - [3,5,4],[1,5,2],[4,5,1], - [4,1,0],[0,3,4]]); - +// to call module 3dtri_draw ( vertices[0],vertices[1],vertices[2], h) +// ------------------------------------------------------------------------------------- +// +module 3dtri_draw(Acord, Bcord, Ccord, h) +{ + polyhedron(points = + [ + Acord, + Bcord, + Ccord, + Acord + [ 0, 0, h ], + Bcord + [ 0, 0, h ], + Ccord + [ 0, 0, h ] + ], + triangles = [ + [ 0, 1, 2 ], + [ 0, 2, 3 ], + [ 3, 2, 5 ], + [ 3, 5, 4 ], + [ 1, 5, 2 ], + [ 4, 5, 1 ], + [ 4, 1, 0 ], + [ 0, 3, 4 ] + ]); }; // // @@ -228,12 +256,12 @@ polyhedron (points=[Acord,Bcord,Ccord, // // MODULE: 3dtri_rnd_draw // DESCRIPTION: -// Draw a round corner triangle with A,B,C - vertices specified by its +// Draw a round corner triangle with A,B,C - vertices specified by its // co-ordinates, height h and round vertices having radius "r". // As specified by the input parameters. // Please note, the tringles side lenght gets extended by "2 * r", -// and the vertices coordinates define the centers of the -// circles with radius "r". +// and the vertices coordinates define the centers of the +// circles with radius "r". // PARAMETER: // Acord : [x,y,z] Coordinates of vertex A // Bcord : [x,y,z] Coordinates of vertex B @@ -245,72 +273,99 @@ polyhedron (points=[Acord,Bcord,Ccord, // // COMMENT: // You might use the result from function 3dtri_sides2coord -// to call module 3dtri_rnd_draw ( vertices[0],vertices[1],vertices[2], h, r) -// ------------------------------------------------------------------------------------- -// -module 3dtri_rnd_draw ( Acord, Bcord, Ccord, h, r) { -Avect=Ccord-Bcord; // vector pointing from vertex B to vertex C -p0=Acord + [0,-r,0]; -p1=Bcord + [0,-r,0]; -p2=Bcord + [r*Avect[1]/sqrt(pow(Avect[0],2)+pow(Avect[1],2)), - -r*Avect[0]/sqrt(pow(Avect[0],2)+pow(Avect[1],2)) ,0]; -p3=Ccord + [r*Avect[1]/sqrt(pow(Avect[0],2)+pow(Avect[1],2)), - -r*Avect[0]/sqrt(pow(Avect[0],2)+pow(Avect[1],2)) ,0]; -p4=Ccord +[- r*Ccord[1]/sqrt(pow(Ccord[0],2)+pow(Ccord[1],2)), - r*Ccord[0]/sqrt(pow(Ccord[0],2)+pow(Ccord[1],2)) ,0]; -p5=Acord + [- r*Ccord[1]/sqrt(pow(Ccord[0],2)+pow(Ccord[1],2)), - r*Ccord[0]/sqrt(pow(Ccord[0],2)+pow(Ccord[1],2)) ,0]; -bottom_triangles = [[0,1,2],[0,2,3],[0,3,4],[0,4,5]]; -c_side_triangles = [[7,1,0],[0,6,7]]; -a_side_triangles = [[2,8,3],[8,9,3]]; -b_side_triangles = [[4,10,5],[10,11,5]]; -A_edge_triangles = [[0,5,11],[0,11,6]]; -B_edge_triangles = [[1,7,2],[2,7,8]]; -C_edge_triangles = [[3,9,4],[9,10,4]]; -top_triangles = [[11,7,6],[11,8,7],[11,10,8],[8,10,9]]; -union () { - polyhedron (points=[p0,p1,p2,p3,p4,p5, - p0+[0,0,h],p1+[0,0,h],p2+[0,0,h],p3+[0,0,h],p4+[0,0,h],p5+[0,0,h]], - triangles=[ bottom_triangles[0],bottom_triangles[1],bottom_triangles[2],bottom_triangles[3], - A_edge_triangles[0],A_edge_triangles[1], - c_side_triangles[0],c_side_triangles[1], - B_edge_triangles[0],B_edge_triangles[1], - a_side_triangles[0],a_side_triangles[1], - C_edge_triangles[0],C_edge_triangles[1], - b_side_triangles[0],b_side_triangles[1], - top_triangles[0],top_triangles[1],top_triangles[2],top_triangles[3]]); - translate(Acord) cylinder(r1=r,r2=r,h=h,center=false); - translate(Bcord) cylinder(r1=r,r2=r,h=h,center=false); - translate(Ccord) cylinder(r1=r,r2=r,h=h,center=false); -}; +// to call module 3dtri_rnd_draw ( vertices[0],vertices[1],vertices[2], h, r) +// ------------------------------------------------------------------------------------- +// +module 3dtri_rnd_draw(Acord, Bcord, Ccord, h, r) +{ + Avect = Ccord - Bcord; // vector pointing from vertex B to vertex C + p0 = Acord + [ 0, -r, 0 ]; + p1 = Bcord + [ 0, -r, 0 ]; + p2 = Bcord + [ + r * Avect[1] / sqrt(pow(Avect[0], 2) + pow(Avect[1], 2)), + -r * Avect[0] / sqrt(pow(Avect[0], 2) + pow(Avect[1], 2)), + 0 + ]; + p3 = Ccord + [ + r * Avect[1] / sqrt(pow(Avect[0], 2) + pow(Avect[1], 2)), + -r * Avect[0] / sqrt(pow(Avect[0], 2) + pow(Avect[1], 2)), + 0 + ]; + p4 = Ccord + [ + -r * Ccord[1] / sqrt(pow(Ccord[0], 2) + pow(Ccord[1], 2)), + r * Ccord[0] / sqrt(pow(Ccord[0], 2) + pow(Ccord[1], 2)), + 0 + ]; + p5 = Acord + [ + -r * Ccord[1] / sqrt(pow(Ccord[0], 2) + pow(Ccord[1], 2)), + r * Ccord[0] / sqrt(pow(Ccord[0], 2) + pow(Ccord[1], 2)), + 0 + ]; + bottom_triangles = [ [ 0, 1, 2 ], [ 0, 2, 3 ], [ 0, 3, 4 ], [ 0, 4, 5 ] ]; + c_side_triangles = [ [ 7, 1, 0 ], [ 0, 6, 7 ] ]; + a_side_triangles = [ [ 2, 8, 3 ], [ 8, 9, 3 ] ]; + b_side_triangles = [ [ 4, 10, 5 ], [ 10, 11, 5 ] ]; + A_edge_triangles = [ [ 0, 5, 11 ], [ 0, 11, 6 ] ]; + B_edge_triangles = [ [ 1, 7, 2 ], [ 2, 7, 8 ] ]; + C_edge_triangles = [ [ 3, 9, 4 ], [ 9, 10, 4 ] ]; + top_triangles = [ [ 11, 7, 6 ], [ 11, 8, 7 ], [ 11, 10, 8 ], [ 8, 10, 9 ] ]; + union() + { + polyhedron(points = + [ + p0, + p1, + p2, + p3, + p4, + p5, + p0 + [ 0, 0, h ], + p1 + [ 0, 0, h ], + p2 + [ 0, 0, h ], + p3 + [ 0, 0, h ], + p4 + [ 0, 0, h ], + p5 + [ 0, 0, h ] + ], + triangles = [ + bottom_triangles[0], bottom_triangles[1], bottom_triangles[2], + bottom_triangles[3], A_edge_triangles[0], A_edge_triangles[1], + c_side_triangles[0], c_side_triangles[1], B_edge_triangles[0], + B_edge_triangles[1], a_side_triangles[0], a_side_triangles[1], + C_edge_triangles[0], C_edge_triangles[1], b_side_triangles[0], + b_side_triangles[1], top_triangles[0], top_triangles[1], + top_triangles[2], top_triangles[3] + ]); + translate(Acord) cylinder(r1 = r, r2 = r, h = h, center = false); + translate(Bcord) cylinder(r1 = r, r2 = r, h = h, center = false); + translate(Ccord) cylinder(r1 = r, r2 = r, h = h, center = false); + }; } // // ============================================== // // Demo Application - copy into new file and uncomment or uncomment here but -// without uncommenting the use <...> statement, then press F6 - Key +// without uncommenting the use <...> statement, then press F6 - Key // // use ; //$fn=50; // h =4; // r=2; // echo ("Draws a right angle triangle with its circumcircle and in-circle"); -// echo ("The calculated co-ordinates and radius are show in this console window"); -// echo ("Geometry rules for a right angle triangle say, that the circumcircle is the"); -// echo ("Thales Circle which center must be in the middle of the triangle's c - side"); -// echo ("==========================================="); -// vertices = 3dtri_sides2coord (30,40,50); -// echo("A = ",vertices[0]," B = ",vertices[1]," C = ",vertices[2]); -// cg = 3dtri_centerOfGravityCoord (vertices[0],vertices[1],vertices[2]); -// echo (" Center of gravity = ",cg); -// cc = 3dtri_centerOfcircumcircle (vertices[0],vertices[1],vertices[2]); -// echo (" Center of circumcircle = ",cc); -// cr = 3dtri_radiusOfcircumcircle (vertices[0],cc,r); -// echo(" Radius of circumcircle ",cr); -// ir = 3dtri_radiusOfIn_circle (vertices[0],vertices[1],vertices[2]); -// echo (" Radius of in-circle = ",ir); -// ic = 3dtri_centerOfIn_circle (vertices[0],vertices[1],vertices[2],ir); -// echo (" Center of in-circle = ",ic); +// echo ("The calculated co-ordinates and radius are show in this console +// window"); echo ("Geometry rules for a right angle triangle say, that the +// circumcircle is the"); echo ("Thales Circle which center must be in the +// middle of the triangle's c - side"); echo +// ("==========================================="); vertices = +// 3dtri_sides2coord (30,40,50); echo("A = ",vertices[0]," B = ",vertices[1]," +// C = ",vertices[2]); cg = 3dtri_centerOfGravityCoord +// (vertices[0],vertices[1],vertices[2]); echo (" Center of gravity = ",cg); cc +// = 3dtri_centerOfcircumcircle (vertices[0],vertices[1],vertices[2]); echo (" +// Center of circumcircle = ",cc); cr = 3dtri_radiusOfcircumcircle +// (vertices[0],cc,r); echo(" Radius of circumcircle ",cr); ir = +// 3dtri_radiusOfIn_circle (vertices[0],vertices[1],vertices[2]); echo (" +// Radius of in-circle = ",ir); ic = 3dtri_centerOfIn_circle +// (vertices[0],vertices[1],vertices[2],ir); echo (" Center of in-circle = +// ",ic); // translate(cc+[0,0,5*h/2]) difference () { // cylinder (h=5*h,r1=cr+4,r2=cr+4,center=true); // cylinder (h=6*h,r1=cr,r2=cr,center=true);} @@ -318,10 +373,11 @@ union () { // union () { // difference () { // 3dtri_rnd_draw (vertices[0], vertices[1], vertices[2],5*h,r); -// scale([0.8,0.8,1]) translate([6,2,4*h]) 3dtri_rnd_draw (vertices[0], vertices[1], vertices[2],5*h,r); +// scale([0.8,0.8,1]) translate([6,2,4*h]) 3dtri_rnd_draw (vertices[0], +// vertices[1], vertices[2],5*h,r); // } -// translate (ic+[0,0,5*h]) cylinder(h=10*h,r1=ir+r,r2=ir+r,center=true); +// translate (ic+[0,0,5*h]) +// cylinder(h=10*h,r1=ir+r,r2=ir+r,center=true); // } // translate (ic+[0,0,5*h]) cylinder(h=12*h,r1=0.5*ir,r2=0.5*ir,center=true); // } - diff --git a/shapes/cylinder.scad b/shapes/cylinder.scad index 438fe124..dff913a3 100644 --- a/shapes/cylinder.scad +++ b/shapes/cylinder.scad @@ -1,107 +1,94 @@ -include -use use +use +include -module mcad_rounded_cylinder ( - // same options as cylinder() - r = undef, h = undef, d = undef, - r1 = undef, r2 = undef, - d1 = undef, d2 = undef, - center = false, - - // rounding radius - round_r = 0, - round_r1 = 0, round_r2 = 0, - slices = 0 -) +module mcad_rounded_cylinder( + // same options as cylinder() + r = undef, + h = undef, + d = undef, + r1 = undef, + r2 = undef, + d1 = undef, + d2 = undef, + center = false, + + // rounding radius + round_r = 0, + round_r1 = 0, + round_r2 = 0, + slices = 0) { - // First resolve all the required values from arguments... - r = (r == undef && d != undef) ? d / 2 : r; + // First resolve all the required values from arguments... + r = (r == undef && d != undef) ? d / 2 : r; - function resolve_numbered_radius (rN, dN) = ( - (rN == undef) ? ( - (dN != undef) ? dN / 2 : - r - ) : rN - ); + function resolve_numbered_radius(rN, dN) = + ((rN == undef) ? ((dN != undef) ? dN / 2 : r) : rN); - r1 = resolve_numbered_radius (r1, d1); - r2 = resolve_numbered_radius (r2, d2); + r1 = resolve_numbered_radius(r1, d1); + r2 = resolve_numbered_radius(r2, d2); - round_r1 = (round_r1 == 0) ? round_r : round_r1; - round_r2 = (round_r2 == 0) ? round_r : round_r2; + round_r1 = (round_r1 == 0) ? round_r : round_r1; + round_r2 = (round_r2 == 0) ? round_r : round_r2; - inv_gradient = (r2 - r1) / h; + inv_gradient = (r2 - r1) / h; - module trapezoid (top, bottom, h) - { - polygon ([ - [0, 0], - [0, h], - [top, h], - [bottom, 0] - ]); - } + module trapezoid(top, bottom, h) + { + polygon([ [ 0, 0 ], [ 0, h ], [ top, h ], [ bottom, 0 ] ]); + } - module basic_section () - { - trapezoid (top = r2, bottom = r1, h = h); - } + module basic_section() { trapezoid(top = r2, bottom = r1, h = h); } - module scale_at (factor, pos = [0, 0, 0]) - { - translate (pos) - scale (factor) - translate (pos * -1) - children (); - } + module scale_at(factor, pos = [ 0, 0, 0 ]) + { + translate(pos) scale(factor) translate(pos * -1) children(); + } + + module round_corner(r, pos) + { + offset(r = r, $fn = slices) offset(r = -r) scale_at(10, pos = pos) + children(); + } - module round_corner (r, pos) + translate([ 0, 0, center ? -h / 2 : 0 ]) rotate_extrude() hull() + { + intersection() { - offset (r = r, $fn = slices) - offset (r = -r) - scale_at (10, pos = pos) - children (); - } + union() + { + difference() + { + round_corner(round_r2, [ r2, h ]) basic_section(); + + translate([ -epsilon, -epsilon ]) square( + [ max(r1, r2) + epsilon * 2, max(epsilon, round_r1 + epsilon) ]); + } + + difference() + { + round_corner(round_r1, [ r1, 0 ]) basic_section(); - translate ([0, 0, center ? -h / 2 : 0]) - rotate_extrude () - hull () { - intersection () { - union () { - difference () { - round_corner (round_r2, [r2, h]) - basic_section (); - - translate ([-epsilon, -epsilon]) - square ([max (r1, r2) + epsilon * 2, - max (epsilon, round_r1 + epsilon)]); - } - - difference () { - round_corner (round_r1, [r1, 0]) - basic_section (); - - translate ([-epsilon, h + epsilon]) - mirror (Y) - square ([max (r1, r2) + epsilon * 2, round_r2]); - } - } - - basic_section (); + translate([ -epsilon, h + epsilon ]) mirror(Y) + square([ max(r1, r2) + epsilon * 2, round_r2 ]); } + } + + basic_section(); } + } } -module mcad_tube (od, id, h = undef) -{ - linear_extrude_if (h != undef, height = h) - difference () { - circle (d = od); - mcad_polyhole (d = id); - } +module mcad_tube(od, id, h = undef){ linear_extrude_if(h != undef, height = h) + difference(){ circle(d = od); +mcad_polyhole(d = id); +} } -*mcad_rounded_cylinder (r1 = 3, r2 = 10, h = 40, round_r1 = 3, round_r2 = 10, - slices = 100); -*mcad_rounded_cylinder (r = 3, h = 40, round_r1 = 3, slices = 100); +*mcad_rounded_cylinder(r1 = 3, + r2 = 10, + h = 40, + round_r1 = 3, + round_r2 = 10, + slices = 100); +*mcad_rounded_cylinder(r = 3, h = 40, round_r1 = 3, slices = 100); diff --git a/shapes/polyhole.scad b/shapes/polyhole.scad index 16d4654b..2be3f5dc 100644 --- a/shapes/polyhole.scad +++ b/shapes/polyhole.scad @@ -1,20 +1,14 @@ // Copyright 2011 Nophead (of RepRap fame) -// This file is licensed under the terms of Creative Commons Attribution 3.0 Unported. +// This file is licensed under the terms of Creative Commons Attribution 3.0 +// Unported. // Using this holes should come out approximately right when printed -module mcad_polyhole(d, h = undef, center = false) { - n = max (round (2 * d), 3); - flat = (h == undef); +module mcad_polyhole(d, h = undef, center = false) +{ + n = max(round(2 * d), 3); + flat = (h == undef); - rotate([0,0,180]) - if (flat) - circle (r = (d / 2) / cos (180 / n), $fn = n); - else - cylinder ( - h = h, - r = (d / 2) / cos (180 / n), - center = center, - $fn = n - ); + rotate([ 0, 0, 180 ]) if (flat) circle(r = (d / 2) / cos(180 / n), $fn = n); + else cylinder(h = h, r = (d / 2) / cos(180 / n), center = center, $fn = n); } diff --git a/shapes/standard_shapes.scad b/shapes/standard_shapes.scad index fcf99f12..4fd8e271 100644 --- a/shapes/standard_shapes.scad +++ b/shapes/standard_shapes.scad @@ -15,38 +15,41 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -*/ + */ -include ; -include ; +include +include -module cylinderSegment_angle(r,h,Phi,center = false){ - a = Phi/2; - if(center == false ){ - translate([0, 0, h/2]){ - _halfCircelSegment(radius=r,height=h,angle=abs(a)); - rotate(a = 180, v = X) - _halfCircelSegment(radius=r,height=h,angle=abs(a)); - } - }else{ - _halfCircelSegment(radius=r,height=h,angle=abs(a)); - rotate(a = 180, v = X) - _halfCircelSegment(radius=r,height=h,angle=abs(a)); - } +module cylinderSegment_angle(r, h, Phi, center = false) +{ + a = Phi / 2; + if (center == false) { + translate([ 0, 0, h / 2 ]) + { + _halfCircelSegment(radius = r, height = h, angle = abs(a)); + rotate(a = 180, v = X) + _halfCircelSegment(radius = r, height = h, angle = abs(a)); + } + } else { + _halfCircelSegment(radius = r, height = h, angle = abs(a)); + rotate(a = 180, v = X) + _halfCircelSegment(radius = r, height = h, angle = abs(a)); + } } -//cylinderSegment_angle(radius=10,height=1,Phi=360); +// cylinderSegment_angle(radius=10,height=1,Phi=360); -module _halfCircelSegment(radius,height,angle){ - difference(){ - union(){ - cylinder(h = height, r = radius, center = true); - } - union(){ - translate([0, -radius/2-OS, 0]) - cube ([(radius+OS)*2,radius+OS,height+2*OS],center =true); - rotate(a = angle, v = Z) translate([0, -radius/2, 0]) - cube ([(radius+OS)*2,radius+OS,height+2*OS],center =true); - } - } +module _halfCircelSegment(radius, height, angle) +{ + difference() + { + union() { cylinder(h = height, r = radius, center = true); } + union() + { + translate([ 0, -radius / 2 - OS, 0 ]) cube( + [ (radius + OS) * 2, radius + OS, height + 2 * OS ], center = true); + rotate(a = angle, v = Z) translate([ 0, -radius / 2, 0 ]) cube( + [ (radius + OS) * 2, radius + OS, height + 2 * OS ], center = true); + } + } } //_halfCircelSegment(10,1,111); diff --git a/shapes/triangles_pyramids.scad b/shapes/triangles_pyramids.scad index 7bbd9a31..12964b62 100644 --- a/shapes/triangles_pyramids.scad +++ b/shapes/triangles_pyramids.scad @@ -1,70 +1,126 @@ -/* +/* MCAD triangles - Copyright (C) 2013 Alex Davies License: LGPL 2.1 or later -rightpyramid(rightpyramidx, rightpyramidy, rightpyramidz) -cornerpyramid(cornerpyramidx, cornerpyramidy, cornerpyramidz) -eqlpyramid(eqlpyramidx, eqlpyramidy, eqlpyramidz) +rightpyramid(rightpyramidx, rightpyramidy, rightpyramidz) +cornerpyramid(cornerpyramidx, cornerpyramidy, cornerpyramidz) +eqlpyramid(eqlpyramidx, eqlpyramidy, eqlpyramidz) rightprism(rightprismx,rightprismy,rightprismz) eqlprism(eqlprismx,eqlprismy,eqlprismz) -todo, make library work with negative lengths by adding triangles to the inside of every surface. basicaly copy and paste the current triangles set and reverse the first and last digit of every triangle. In 4 character triangles switch the middle ones around as well. Not sure if that's actually useful though. +todo, make library work with negative lengths by adding triangles to the inside +of every surface. basicaly copy and paste the current triangles set and reverse +the first and last digit of every triangle. In 4 character triangles switch the +middle ones around as well. Not sure if that's actually useful though. - Copyright Eero 'rambo' af Heurlin 2010- triangle(o_len, a_len, depth) a_triangle(tan_angle, a_len, depth) */ -module rightpyramid(rightpyramidx, rightpyramidy, rightpyramidz) { - polyhedron ( points = [[0,0,0], - [rightpyramidx, 0, 0], - [0, rightpyramidy, 0], - [rightpyramidx, rightpyramidy, 0], - [rightpyramidx/2, rightpyramidy, rightpyramidz]], - - faces = [[0,1,2],[2,1,3],[4,1,0],[3,1,4],[2,3,4],[0,2,4]]); +module rightpyramid(rightpyramidx, rightpyramidy, rightpyramidz) +{ + polyhedron(points = + [ + [ 0, 0, 0 ], + [ rightpyramidx, 0, 0 ], + [ 0, rightpyramidy, 0 ], + [ rightpyramidx, rightpyramidy, 0 ], + [ rightpyramidx / 2, rightpyramidy, rightpyramidz ] + ], + + faces = [ + [ 0, 1, 2 ], + [ 2, 1, 3 ], + [ 4, 1, 0 ], + [ 3, 1, 4 ], + [ 2, 3, 4 ], + [ 0, 2, 4 ] + ]); } -module cornerpyramid(cornerpyramidx, cornerpyramidy, cornerpyramidz) { - polyhedron ( points = [[0,0,0], - [cornerpyramidx, 0, 0], - [0, cornerpyramidy, 0], - [cornerpyramidx, cornerpyramidy, 0], - [0, cornerpyramidy, cornerpyramidz]], - - faces = [[0,1,2],[2,1,3],[4,1,0],[3,1,4],[2,3,4],[0,2,4]]); +module cornerpyramid(cornerpyramidx, cornerpyramidy, cornerpyramidz) +{ + polyhedron(points = + [ + [ 0, 0, 0 ], + [ cornerpyramidx, 0, 0 ], + [ 0, cornerpyramidy, 0 ], + [ cornerpyramidx, cornerpyramidy, 0 ], + [ 0, cornerpyramidy, cornerpyramidz ] + ], + + faces = [ + [ 0, 1, 2 ], + [ 2, 1, 3 ], + [ 4, 1, 0 ], + [ 3, 1, 4 ], + [ 2, 3, 4 ], + [ 0, 2, 4 ] + ]); } -module eqlpyramid(eqlpyramidx, eqlpyramidy, eqlpyramidz) { - polyhedron ( points = [[0,0,0], - [eqlpyramidx, 0, 0], - [0, eqlpyramidy, 0], - [eqlpyramidx, eqlpyramidy, 0], - [eqlpyramidx/2, eqlpyramidy/2, eqlpyramidz]], - - faces = [[0,1,2],[2,1,3],[4,1,0],[3,1,4],[2,3,4],[0,2,4]]); +module eqlpyramid(eqlpyramidx, eqlpyramidy, eqlpyramidz) +{ + polyhedron(points = + [ + [ 0, 0, 0 ], + [ eqlpyramidx, 0, 0 ], + [ 0, eqlpyramidy, 0 ], + [ eqlpyramidx, eqlpyramidy, 0 ], + [ eqlpyramidx / 2, eqlpyramidy / 2, eqlpyramidz ] + ], + + faces = [ + [ 0, 1, 2 ], + [ 2, 1, 3 ], + [ 4, 1, 0 ], + [ 3, 1, 4 ], + [ 2, 3, 4 ], + [ 0, 2, 4 ] + ]); } -module rightprism(rightprismx,rightprismy,rightprismz){ - polyhedron ( points = [[0,0,0], - [rightprismx,0,0], - [rightprismx,rightprismy,0], - [0,rightprismy,0], - [0,rightprismy,rightprismz], - [0,0,rightprismz]], - faces = [[0,1,2,3],[5,1,0],[5,4,2,1],[4,3,2],[0,3,4,5]]); +module rightprism(rightprismx, rightprismy, rightprismz) +{ + polyhedron(points = + [ + [ 0, 0, 0 ], + [ rightprismx, 0, 0 ], + [ rightprismx, rightprismy, 0 ], + [ 0, rightprismy, 0 ], + [ 0, rightprismy, rightprismz ], + [ 0, 0, rightprismz ] + ], + faces = [ + [ 0, 1, 2, 3 ], + [ 5, 1, 0 ], + [ 5, 4, 2, 1 ], + [ 4, 3, 2 ], + [ 0, 3, 4, 5 ] + ]); } -module eqlprism(eqlprismx,eqlprismy,eqlprismz){ - polyhedron ( points = [[0,0,0], - [eqlprismx,0,0], - [eqlprismx,eqlprismy,0], - [0,eqlprismy,0], - [eqlprismx/2,eqlprismy,eqlprismz], - [eqlprismx/2,0,eqlprismz]], - faces = [[0,1,2,3],[5,1,0],[5,4,2,1],[4,3,2],[0,3,4,5]]); +module eqlprism(eqlprismx, eqlprismy, eqlprismz) +{ + polyhedron(points = + [ + [ 0, 0, 0 ], + [ eqlprismx, 0, 0 ], + [ eqlprismx, eqlprismy, 0 ], + [ 0, eqlprismy, 0 ], + [ eqlprismx / 2, eqlprismy, eqlprismz ], + [ eqlprismx / 2, 0, eqlprismz ] + ], + faces = [ + [ 0, 1, 2, 3 ], + [ 5, 1, 0 ], + [ 5, 4, 2, 1 ], + [ 4, 3, 2 ], + [ 0, 3, 4, 5 ] + ]); } /** @@ -77,10 +133,11 @@ module eqlprism(eqlprismx,eqlprismy,eqlprismz){ */ module triangle(o_len, a_len, depth) { - linear_extrude(height=depth) - { - polygon(points=[[0,0],[a_len,0],[0,o_len]], paths=[[0,1,2]]); - } + linear_extrude(height = depth) + { + polygon(points = [ [ 0, 0 ], [ a_len, 0 ], [ 0, o_len ] ], + paths = [[ 0, 1, 2 ]]); + } } /** @@ -92,32 +149,37 @@ module triangle(o_len, a_len, depth) */ module a_triangle(tan_angle, a_len, depth) { - linear_extrude(height=depth) - { - polygon(points=[[0,0],[a_len,0],[0,tan(tan_angle) * a_len]], paths=[[0,1,2]]); - } + linear_extrude(height = depth) + { + polygon(points = [ [ 0, 0 ], [ a_len, 0 ], [ 0, tan(tan_angle) * a_len ] ], + paths = [[ 0, 1, 2 ]]); + } } // Tests: -module test_triangle() { triangle(5, 5, 5); } -module test_a_triangle() { a_triangle(45, 5, 5); } -module test_triangles() +module +test_triangle() +{ + triangle(5, 5, 5); +} +module +test_a_triangle() { - // Generate a bunch of triangles by sizes - for (i = [1:10]) + a_triangle(45, 5, 5); +} +module +test_triangles() +{ + // Generate a bunch of triangles by sizes + for (i = [1:10]) { + translate([ i * 7, -30, i * 7 ]) { - translate([i*7, -30, i*7]) - { - triangle(i*5, sqrt(i*5+pow(i,2)), 5); - } + triangle(i * 5, sqrt(i * 5 + pow(i, 2)), 5); } + } - // Generate a bunch of triangles by angle - for (i = [1:85/5]) - { - translate([i*7, 22, i*7]) - { - a_triangle(i*5, 10, 5); - } - } + // Generate a bunch of triangles by angle + for (i = [1:85 / 5]) { + translate([ i * 7, 22, i * 7 ]) { a_triangle(i * 5, 10, 5); } + } } diff --git a/shapes/trochoids.scad b/shapes/trochoids.scad index 99083303..c71445f0 100644 --- a/shapes/trochoids.scad +++ b/shapes/trochoids.scad @@ -8,16 +8,16 @@ // applications. Attribution would be nice, but is not required. There is // no warranty of any kind, including its correctness, usefulness, or safety. // -// An EPITROCHOID is a curve traced by a point -// fixed at a distance "d" +// An EPITROCHOID is a curve traced by a point +// fixed at a distance "d" // to the center of a circle of radius "r" -// as the circle rolls +// as the circle rolls // outside another circle of radius "R". // -// An HYPOTROCHOID is a curve traced by a point -// fixed at a distance "d" +// An HYPOTROCHOID is a curve traced by a point +// fixed at a distance "d" // to the center of a circle of radius "r" -// as the circle rolls +// as the circle rolls // inside another circle of radius "R". // // An EPICYCLOID is an epitrochoid with d = r. @@ -26,7 +26,7 @@ // // See http://en.wikipedia.org/wiki/Epitrochoid // and http://en.wikipedia.org/wiki/Hypotrochoid -// +// // Beware the polar forms of the equations on Wikipedia... // They are correct, but theta is measured to the center of the small disk!! //=========================================== @@ -34,16 +34,15 @@ // There are several different methods for extruding. The best are probably // the ones using linear extrude. - //=========================================== // Demo - draws one of each, plus some little wheels and sticks. // -// Fun stuff to try: +// Fun stuff to try: // Animate, try FPS = 5 and Steps = 200 // R = 2, r = 1, d = 0.2 // R = 4, r = 1, d = 1 // R = 2, r = 1, d = 0.5 -// +// // What happens when you make d > r ?? // What happens when d < 0 ?? // What happens when r < 0 ?? @@ -58,233 +57,355 @@ r = 1; d = 1; n = 60; // number of wedge segments -alpha = 360*$t; +alpha = 360 * $t; -color([0, 0, 1]) -translate([0, 0, -0.5]) - cylinder(h = 1, r= R, center = true); +color([ 0, 0, 1 ]) translate([ 0, 0, -0.5 ]) + cylinder(h = 1, r = R, center = true); -color([0, 1, 0]) -epitrochoid(R,r,d,n,thickness); +color([ 0, 1, 0 ]) epitrochoid(R, r, d, n, thickness); -color([1, 0, 0]) -translate([ (R+r)*cos(alpha) , (R+r)*sin(alpha), -0.5]) { - rotate([0, 0, alpha + R/r*alpha]) { - cylinder(h = 1, r = r, center = true); - translate([-d, 0, 1.5]) { - cylinder(h = 2.2, r = 0.1, center = true); - } - } +color([ 1, 0, 0 ]) + translate([ (R + r) * cos(alpha), (R + r) * sin(alpha), -0.5 ]) +{ + rotate([ 0, 0, alpha + R / r * alpha ]) + { + cylinder(h = 1, r = r, center = true); + translate([ -d, 0, 1.5 ]) { cylinder(h = 2.2, r = 0.1, center = true); } + } } +translate([ 2 * (abs(R) + abs(r) + abs(d)), 0, 0 ]) +{ + color([ 0, 0, 1 ]) translate([ 0, 0, -0.5 ]) difference() + { + cylinder(h = 1, r = 1.1 * R, center = true); + cylinder(h = 1.1, r = R, center = true); + } -translate([2*(abs(R) + abs(r) + abs(d)), 0, 0]){ -color([0, 0, 1]) -translate([0, 0, -0.5]) - difference() { - cylinder(h = 1, r = 1.1*R, center = true); - cylinder(h = 1.1, r= R, center = true); - } - -color([0, 1, 0]) -hypotrochoid(R,r,d,n,thickness); + color([ 0, 1, 0 ]) hypotrochoid(R, r, d, n, thickness); -color([1, 0, 0]) -translate([ (R-r)*cos(alpha) , (R-r)*sin(alpha), -0.5]) { - rotate([0, 0, alpha - R/r*alpha]) { - cylinder(h = 1, r = r, center = true); - translate([d, 0, 1.5]) { - cylinder(h = 2.2, r = 0.1, center = true); - } - } -} + color([ 1, 0, 0 ]) + translate([ (R - r) * cos(alpha), (R - r) * sin(alpha), -0.5 ]) + { + rotate([ 0, 0, alpha - R / r * alpha ]) + { + cylinder(h = 1, r = r, center = true); + translate([ d, 0, 1.5 ]) { cylinder(h = 2.2, r = 0.1, center = true); } + } + } } // This just makes a twisted hypotrochoid -translate([0,14, 0]) -hypotrochoidLinear(4, 1, 1, 40, 40, 10, 30); +translate([ 0, 14, 0 ]) hypotrochoidLinear(4, 1, 1, 40, 40, 10, 30); // End of Demo Section //=========================================== - //=========================================== // Epitrochoid // -module epitrochoid(R, r, d, n, thickness) { - dth = 360/n; - for ( i = [0:n-1] ) { - polyhedron(points = [[0,0,0], - [(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i), 0], - [(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1)), 0], - [0,0,thickness], - [(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i), thickness], - [(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1)), thickness]], - triangles = [[0, 2, 1], - [0, 1, 3], - [3, 1, 4], - [3, 4, 5], - [0, 3, 2], - [2, 3, 5], - [1, 2, 4], - [2, 5, 4]]); - } +module epitrochoid(R, r, d, n, thickness) +{ + dth = 360 / n; + for (i = [0:n - 1]) { + polyhedron( + points = + [ + [ 0, 0, 0 ], + [ + (R + r) * cos(dth * i) - d * cos((R + r) / r * dth * i), + (R + r) * sin(dth * i) - d * sin((R + r) / r * dth * i), + 0 + ], + [ + (R + r) * cos(dth * (i + 1)) - d * cos((R + r) / r * dth * (i + 1)), + (R + r) * sin(dth * (i + 1)) - d * sin((R + r) / r * dth * (i + 1)), + 0 + ], + [ 0, 0, thickness ], + [ + (R + r) * cos(dth * i) - d * cos((R + r) / r * dth * i), + (R + r) * sin(dth * i) - d * sin((R + r) / r * dth * i), + thickness + ], + [ + (R + r) * cos(dth * (i + 1)) - d * cos((R + r) / r * dth * (i + 1)), + (R + r) * sin(dth * (i + 1)) - d * sin((R + r) / r * dth * (i + 1)), + thickness + ] + ], + triangles = [ + [ 0, 2, 1 ], + [ 0, 1, 3 ], + [ 3, 1, 4 ], + [ 3, 4, 5 ], + [, 0, 3, 2 ], + [ 2, 3, 5 ], + [ 1, 2, 4 ], + [ 2, 5, 4 ] + ]); + } } //=========================================== - //=========================================== // Hypotrochoid // -module hypotrochoid(R, r, d, n, thickness) { - dth = 360/n; - for ( i = [0:n-1] ) { - polyhedron(points = [[0,0,0], - [(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i), 0], - [(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1)), 0], - [0,0,thickness], - [(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i), thickness], - [(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1)), thickness]], - triangles = [[0, 2, 1], - [0, 1, 3], - [3, 1, 4], - [3, 4, 5], - [0, 3, 2], - [2, 3, 5], - [1, 2, 4], - [2, 5, 4]]); - } +module hypotrochoid(R, r, d, n, thickness) +{ + dth = 360 / n; + for (i = [0:n - 1]) { + polyhedron( + points = + [ + [ 0, 0, 0 ], + [ + (R - r) * cos(dth * i) + d * cos((R - r) / r * dth * i), + (R - r) * sin(dth * i) - d * sin((R - r) / r * dth * i), + 0 + ], + [ + (R - r) * cos(dth * (i + 1)) + d * cos((R - r) / r * dth * (i + 1)), + (R - r) * sin(dth * (i + 1)) - d * sin((R - r) / r * dth * (i + 1)), + 0 + ], + [ 0, 0, thickness ], + [ + (R - r) * cos(dth * i) + d * cos((R - r) / r * dth * i), + (R - r) * sin(dth * i) - d * sin((R - r) / r * dth * i), + thickness + ], + [ + (R - r) * cos(dth * (i + 1)) + d * cos((R - r) / r * dth * (i + 1)), + (R - r) * sin(dth * (i + 1)) - d * sin((R - r) / r * dth * (i + 1)), + thickness + ] + ], + triangles = [ + [ 0, 2, 1 ], + [ 0, 1, 3 ], + [ 3, 1, 4 ], + [ 3, 4, 5 ], + [ 0, 3, 2 ], + [ 2, 3, 5 ], + [ 1, 2, 4 ], + [ 2, 5, 4 ] + ]); + } } //=========================================== - //=========================================== // Epitrochoid Wedge with Bore // -module epitrochoidWBore(R, r, d, n, p, thickness, rb) { - dth = 360/n; - union() { - for ( i = [0:p-1] ) { - polyhedron(points = [[rb*cos(dth*i), rb*sin(dth*i),0], - [(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i), 0], - [(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1)), 0], - [rb*cos(dth*(i+1)), rb*sin(dth*(i+1)), 0], - [rb*cos(dth*i), rb*sin(dth*i), thickness], - [(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i), thickness], - [(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1)), thickness], - [rb*cos(dth*(i+1)), rb*sin(dth*(i+1)), thickness]], - triangles = [[0, 1, 4], [4, 1, 5], - [1, 2, 5], [5, 2, 6], - [2, 3, 7], [7, 6, 2], - [3, 0, 4], [4, 7, 3], - [4, 5, 7], [7, 5, 6], - [0, 3, 1], [1, 3, 2]]); - } - } +module epitrochoidWBore(R, r, d, n, p, thickness, rb) +{ + dth = 360 / n; + union() + { + for (i = [0:p - 1]) { + polyhedron( + points = + [[rb * cos(dth * i), rb * sin(dth * i), 0], + [(R + r) * cos(dth * i) - d * cos((R + r) / r * dth * i), + (R + r) * sin(dth * i) - d * sin((R + r) / r * dth * i), + 0], + [(R + r) * cos(dth * (i + 1)) - d * cos((R + r) / r * dth * (i + 1)), + (R + r) * sin(dth * (i + 1)) - d * sin((R + r) / r * dth * (i + 1)), + 0], + [rb * cos(dth * (i + 1)), rb * sin(dth * (i + 1)), 0], + [rb * cos(dth * i), rb * sin(dth * i), thickness], + [(R + r) * cos(dth * i) - d * cos((R + r) / r * dth * i), + (R + r) * sin(dth * i) - d * sin((R + r) / r * dth * i), + thickness], + [(R + r) * cos(dth * (i + 1)) - d * cos((R + r) / r * dth * (i + 1)), + (R + r) * sin(dth * (i + 1)) - d * sin((R + r) / r * dth * (i + 1)), + thickness], + [rb * cos(dth * (i + 1)), rb * sin(dth * (i + 1)), thickness]], + triangles = [ + [ 0, 1, 4 ], + [ 4, 1, 5 ], + [ 1, 2, 5 ], + [ 5, 2, 6 ], + [ 2, 3, 7 ], + [ 7, 6, 2 ], + [ 3, 0, 4 ], + [ 4, 7, 3 ], + [ 4, 5, 7 ], + [ 7, 5, 6 ], + [ 0, 3, 1 ], + [ 1, 3, 2 ] + ]); + } + } } //=========================================== - //=========================================== // Epitrochoid Wedge with Bore, Linear Extrude // -module epitrochoidWBoreLinear(R, r, d, n, p, thickness, rb, twist) { - dth = 360/n; - linear_extrude(height = thickness, convexity = 10, twist = twist) { - union() { - for ( i = [0:p-1] ) { - polygon(points = [[rb*cos(dth*i), rb*sin(dth*i)], - [(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i)], - [(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1))], - [rb*cos(dth*(i+1)), rb*sin(dth*(i+1))]], - paths = [[0, 1, 2, 3]], convexity = 10); - } - } - } +module epitrochoidWBoreLinear(R, r, d, n, p, thickness, rb, twist) +{ + dth = 360 / n; + linear_extrude(height = thickness, convexity = 10, twist = twist) + { + union() + { + for (i = [0:p - 1]) { + polygon(points = + [[rb * cos(dth * i), rb * sin(dth * i)], + [(R + r) * cos(dth * i) - d * cos((R + r) / r * dth * i), + (R + r) * sin(dth * i) - d * sin((R + r) / r * dth * i)], + [(R + r) * cos(dth * (i + 1)) - + d * cos((R + r) / r * dth * (i + 1)), + (R + r) * sin(dth * (i + 1)) - + d * sin((R + r) / r * dth * (i + 1))], + [rb * cos(dth * (i + 1)), rb * sin(dth * (i + 1))]], + paths = [[ 0, 1, 2, 3 ]], + convexity = 10); + } + } + } } //=========================================== - //=========================================== // Epitrochoid Wedge, Linear Extrude // -module epitrochoidLinear(R, r, d, n, p, thickness, twist) { - dth = 360/n; - linear_extrude(height = thickness, convexity = 10, twist = twist) { - union() { - for ( i = [0:p-1] ) { - polygon(points = [[0, 0], - [(R+r)*cos(dth*i) - d*cos((R+r)/r*dth*i), (R+r)*sin(dth*i) - d*sin((R+r)/r*dth*i)], - [(R+r)*cos(dth*(i+1)) - d*cos((R+r)/r*dth*(i+1)), (R+r)*sin(dth*(i+1)) - d*sin((R+r)/r*dth*(i+1))]], - paths = [[0, 1, 2]], convexity = 10); - } - } - } +module epitrochoidLinear(R, r, d, n, p, thickness, twist) +{ + dth = 360 / n; + linear_extrude(height = thickness, convexity = 10, twist = twist) + { + union() + { + for (i = [0:p - 1]) { + polygon(points = + [ + [ 0, 0 ], + [ + , + (R + r) * cos(dth * i) - d * cos((R + r) / r * dth * i), + (R + r) * sin(dth * i) - d * sin((R + r) / r * dth * i) + ], + [ + (R + r) * cos(dth * (i + 1)) - + d * cos((R + r) / r * dth * (i + 1)), + (R + r) * sin(dth * (i + 1)) - + d * sin((R + r) / r * dth * (i + 1)) + ] + ], + paths = [[ 0, 1, 2 ]], + convexity = 10); + } + } + } } //=========================================== - //=========================================== // Hypotrochoid Wedge with Bore // -module hypotrochoidWBore(R, r, d, n, p, thickness, rb) { - dth = 360/n; - union() { - for ( i = [0:p-1] ) { - polyhedron(points = [[rb*cos(dth*i), rb*sin(dth*i),0], - [(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i), 0], - [(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1)), 0], - [rb*cos(dth*(i+1)), rb*sin(dth*(i+1)), 0], - [rb*cos(dth*i), rb*sin(dth*i), thickness], - [(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i), thickness], - [(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1)), thickness], - [rb*cos(dth*(i+1)), rb*sin(dth*(i+1)), thickness]], - triangles = [[0, 1, 4], [4, 1, 5], - [1, 2, 5], [5, 2, 6], - [2, 3, 7], [7, 6, 2], - [3, 0, 4], [4, 7, 3], - [4, 5, 7], [7, 5, 6], - [0, 3, 1], [1, 3, 2]]); - } - } +module hypotrochoidWBore(R, r, d, n, p, thickness, rb) +{ + dth = 360 / n; + union() + { + for (i = [0:p - 1]) { + polyhedron( + points = + [[rb * cos(dth * i), rb * sin(dth * i), 0], + [(R - r) * cos(dth * i) + d * cos((R - r) / r * dth * i), + (R - r) * sin(dth * i) - d * sin((R - r) / r * dth * i), + 0], + [(R - r) * cos(dth * (i + 1)) + d * cos((R - r) / r * dth * (i + 1)), + (R - r) * sin(dth * (i + 1)) - d * sin((R - r) / r * dth * (i + 1)), + 0], + [rb * cos(dth * (i + 1)), rb * sin(dth * (i + 1)), 0], + [rb * cos(dth * i), rb * sin(dth * i), thickness], + [(R - r) * cos(dth * i) + d * cos((R - r) / r * dth * i), + (R - r) * sin(dth * i) - d * sin((R - r) / r * dth * i), + thickness], + [(R - r) * cos(dth * (i + 1)) + d * cos((R - r) / r * dth * (i + 1)), + (R - r) * sin(dth * (i + 1)) - d * sin((R - r) / r * dth * (i + 1)), + thickness], + [rb * cos(dth * (i + 1)), rb * sin(dth * (i + 1)), thickness]], + triangles = [ + [ 0, 1, 4 ], + [ 4, 1, 5 ], + [ 1, 2, 5 ], + [ 5, 2, 6 ], + [ 2, 3, 7 ], + [ 7, 6, 2 ], + [ 3, 0, 4 ], + [ 4, 7, 3 ], + [ 4, 5, 7 ], + [ 7, 5, 6 ], + [ 0, 3, 1 ], + [ 1, 3, 2 ] + ]); + } + } } //=========================================== - //=========================================== // Hypotrochoid Wedge with Bore, Linear Extrude // -module hypotrochoidWBoreLinear(R, r, d, n, p, thickness, rb, twist) { - dth = 360/n; - linear_extrude(height = thickness, convexity = 10, twist = twist) { - union() { - for ( i = [0:p-1] ) { - polygon(points = [[rb*cos(dth*i), rb*sin(dth*i)], - [(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i)], - [(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1))], - [rb*cos(dth*(i+1)), rb*sin(dth*(i+1))]], - paths = [[0, 1, 2, 3]], convexity = 10); - } - } - } +module hypotrochoidWBoreLinear(R, r, d, n, p, thickness, rb, twist) +{ + dth = 360 / n; + linear_extrude(height = thickness, convexity = 10, twist = twist) + { + union() + { + for (i = [0:p - 1]) { + polygon(points = + [[rb * cos(dth * i), rb * sin(dth * i)], + [(R - r) * cos(dth * i) + d * cos((R - r) / r * dth * i), + (R - r) * sin(dth * i) - d * sin((R - r) / r * dth * i)], + [(R - r) * cos(dth * (i + 1)) + + d * cos((R - r) / r * dth * (i + 1)), + (R - r) * sin(dth * (i + 1)) - + d * sin((R - r) / r * dth * (i + 1))], + [rb * cos(dth * (i + 1)), rb * sin(dth * (i + 1))]], + paths = [[ 0, 1, 2, 3 ]], + convexity = 10); + } + } + } } //=========================================== - //=========================================== // Hypotrochoid Wedge, Linear Extrude // -module hypotrochoidLinear(R, r, d, n, p, thickness, twist) { - dth = 360/n; - linear_extrude(height = thickness, convexity = 10, twist = twist) { - union() { - for ( i = [0:p-1] ) { - polygon(points = [[0, 0], - [(R-r)*cos(dth*i) + d*cos((R-r)/r*dth*i), (R-r)*sin(dth*i) - d*sin((R-r)/r*dth*i)], - [(R-r)*cos(dth*(i+1)) + d*cos((R-r)/r*dth*(i+1)), (R-r)*sin(dth*(i+1)) - d*sin((R-r)/r*dth*(i+1))]], - paths = [[0, 1, 2]], convexity = 10); - } - } - } +module hypotrochoidLinear(R, r, d, n, p, thickness, twist) +{ + dth = 360 / n; + linear_extrude(height = thickness, convexity = 10, twist = twist) + { + union() + { + for (i = [0:p - 1]) { + polygon(points = + [ + [ 0, 0 ], + [ + (R - r) * cos(dth * i) + d * cos((R - r) / r * dth * i), + (R - r) * sin(dth * i) - d * sin((R - r) / r * dth * i) + ], + [ + (R - r) * cos(dth * (i + 1)) + + d * cos((R - r) / r * dth * (i + 1)), + (R - r) * sin(dth * (i + 1)) - + d * sin((R - r) / r * dth * (i + 1)) + ] + ], + paths = [[ 0, 1, 2 ]], + convexity = 10); + } + } + } } -//=========================================== +//=========================================== diff --git a/text/alphabet_block.scad b/text/alphabet_block.scad index ff82cba2..45a5c7bb 100644 --- a/text/alphabet_block.scad +++ b/text/alphabet_block.scad @@ -1,5 +1,5 @@ /* -Parametric Alphabet Block +Parametric Alphabet Block Tony Buser http://tonybuser.com http://creativecommons.org/licenses/by/3.0/ @@ -10,15 +10,13 @@ use // change to any letter letter = "A"; -union() { - difference() { - cube(size = 20); - translate(v = [2, 2, 17]) { - cube(size = [16, 16, 5]); - } - } +union() +{ + difference() + { + cube(size = 20); + translate(v = [ 2, 2, 17 ]) { cube(size = [ 16, 16, 5 ]); } + } - translate(v = [10, 10, 15]) { - 8bit_char(letter, 2, 5); - } + translate(v = [ 10, 10, 15 ]) { 8bit_char(letter, 2, 5); } } diff --git a/text/bitmap.scad b/text/bitmap.scad index 3ae5db8a..f46c5a76 100644 --- a/text/bitmap.scad +++ b/text/bitmap.scad @@ -5,1022 +5,943 @@ http://tonybuser.com http://creativecommons.org/licenses/by/3.0/ */ -module bitmap(bitmap, block_size, height, row_size) { - width = block_size * row_size; - bitmap_size = row_size * row_size; - - function loc_x(loc) = floor(loc / row_size) * block_size; - function loc_y(loc) = loc % row_size * block_size; - function loc_z(loc) = (bitmap[loc]*height-height)/2; +module bitmap(bitmap, block_size, height, row_size) +{ + width = block_size * row_size; + bitmap_size = row_size * row_size; - translate(v = [-width/2+block_size/2,-width/2+block_size/2,height/2]) { - for (loc = [0:bitmap_size - 1]) { - if (bitmap[loc] != 0) { - union() { - translate(v = [loc_x(loc), loc_y(loc), loc_z(loc)]) { - cube(size = [block_size, block_size, height * bitmap[loc]], center = true); - } - } - } - } - } -} + function loc_x(loc) = floor(loc / row_size) * block_size; + function loc_y(loc) = loc % row_size * block_size; + function loc_z(loc) = (bitmap[loc] * height - height) / 2; -module 8bit_char(char, block_size, height, include_base) { - if (char == "0") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,1,1,1,0, - 0,1,1,1,1,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "1") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "2") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "3") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "4") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,1,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,1,1,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "5") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,1,1,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,0,0,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "6") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "7") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "8") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "9") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,1,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "A") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "B") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "C") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "D") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,0,0,0, - 0,1,1,0,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,1,1,0,0, - 0,1,1,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "E") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,1,1,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "F") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,1,1,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "G") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,1,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,1,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "H") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "I") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "J") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,1,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "K") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,1,1,0,0, - 0,1,1,1,1,0,0,0, - 0,1,1,1,1,0,0,0, - 0,1,1,0,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "L") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "M") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,0,1,1, - 0,1,1,1,0,1,1,1, - 0,1,1,1,1,1,1,1, - 0,1,1,0,1,0,1,1, - 0,1,1,0,0,0,1,1, - 0,1,1,0,0,0,1,1, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "N") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,0,1,1,0, - 0,1,1,1,1,1,1,0, - 0,1,1,1,1,1,1,0, - 0,1,1,0,1,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "O") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "P") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "Q") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,0,0, - 0,0,1,1,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "R") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "S") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "T") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "U") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "V") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "W") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,0,1,1, - 0,1,1,0,0,0,1,1, - 0,1,1,0,1,0,1,1, - 0,1,1,1,1,1,1,1, - 0,1,1,1,0,1,1,1, - 0,1,1,0,0,0,1,1, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "X") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "Y") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "Z") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "OE") { - bitmap([ - 0,0,1,0,0,1,0,0, - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0 - ], block_size, height, 8); - } else if (char == "a") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "b") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "c") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "d") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "e") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,1,0, - 0,1,1,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "f") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,1,1,1,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,1,1,1,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "g") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,0,0,0,0,1,1,0, - 0,1,1,1,1,1,0,0 - ], block_size, height, 8); - } else if (char == "h") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "i") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "j") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,1,1,1,1,0,0 - ], block_size, height, 8); - } else if (char == "k") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,1,1,0,0, - 0,1,1,1,1,0,0,0, - 0,1,1,0,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "l") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "m") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,1,1, - 0,1,1,1,1,1,1,1, - 0,1,1,0,1,0,1,1, - 0,1,1,0,0,0,1,1, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "n") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "o") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "p") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "q") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,1,1,0 - ], block_size, height, 8); - } else if (char == "r") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "s") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,1,0, - 0,1,1,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,1,1,0, - 0,1,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "t") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "u") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "v") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "w") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,0,1,1, - 0,1,1,0,1,0,1,1, - 0,1,1,1,1,1,1,1, - 0,0,1,1,1,1,1,0, - 0,0,1,1,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "x") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "y") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,1,0, - 0,0,0,0,1,1,0,0, - 0,1,1,1,1,0,0,0 - ], block_size, height, 8); - } else if (char == "z") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "+") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,1,1,1,1,1,1,0, - 0,1,1,1,1,1,1,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "-") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == ":") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == ".") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == ",") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,0,0,0,0 - ], block_size, height, 8); - } else if (char == "?") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "=") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "*") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,0,1,1,1,1,0,0, - 1,1,1,1,1,1,1,1, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "!") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "''") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "#") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 1,1,1,1,1,1,1,1, - 0,1,1,0,0,1,1,0, - 0,1,1,0,0,1,1,0, - 1,1,1,1,1,1,1,1, - 0,1,1,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "$") { - bitmap([ - 0,0,0,1,1,0,0,0, - 0,0,1,1,1,1,1,0, - 0,1,1,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,1,1,0, - 0,1,1,1,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "%") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,1,1,0,0, - 0,0,1,1,1,0,0,0, - 0,0,1,1,0,0,0,0, - 0,1,1,0,0,1,1,0, - 0,1,0,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "&") { - bitmap([ - 0,0,0,1,1,1,0,0, - 0,0,1,1,0,1,1,0, - 0,0,0,1,1,1,0,0, - 0,0,1,1,1,0,0,0, - 0,1,1,0,1,1,1,1, - 0,1,1,0,1,1,1,0, - 0,0,1,1,1,0,1,1, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "@") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,1,1,0,0,1,1,0, - 0,1,1,0,1,1,1,0, - 0,1,1,0,1,1,1,0, - 0,1,1,0,0,0,0,0, - 0,0,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "'") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "(") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,1,1,1,0,0, - 0,0,1,1,1,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,1,1,1,0,0,0, - 0,0,0,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == ")") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,0,0,0, - 0,0,0,1,1,1,0,0, - 0,0,0,0,1,1,0,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,1,0,0, - 0,0,1,1,1,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "<") { - bitmap([ - 0,0,0,0,0,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,1,1,0,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == ">") { - bitmap([ - 0,1,1,0,0,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "[") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,1,1,0,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "]") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,1,1,0,0, - 0,0,0,0,1,1,0,0, - 0,0,0,0,1,1,0,0, - 0,0,0,0,1,1,0,0, - 0,0,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "/") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,1,1,0,0, - 0,0,0,1,1,0,0,0, - 0,0,1,1,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,1,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "\\") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,0,1,1,0,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,0,1,1,0,0, - 0,0,0,0,0,1,1,0, - 0,0,0,0,0,0,1,0, - 0,0,0,0,0,0,0,0 - ], block_size, height, 8); - } else if (char == "_") { - bitmap([ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 1,1,1,1,1,1,1,1 - ], block_size, height, 8); - } else if (char == "|") { - bitmap([ - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0, - 0,0,0,1,1,0,0,0 - ], block_size, height, 8); - } else { - echo("Invalid Character: ", char); - } + translate( + v = + [ -width / 2 + block_size / 2, -width / 2 + block_size / 2, height / 2 ]) + { + for (loc = [0:bitmap_size - 1]) { + if (bitmap[loc] != 0) { + union() + { + translate(v = [ loc_x(loc), loc_y(loc), loc_z(loc) ]) + { + cube(size = [ block_size, block_size, height * bitmap[loc] ], + center = true); + } + } + } + } + } +} +module 8bit_char(char, block_size, height, include_base) +{ + if (char == "0") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "1") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, + 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "2") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "3") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "4") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, + 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "5") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "6") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "7") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, + 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "8") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "9") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "A") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, + 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "B") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "C") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "D") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, + 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "E") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "F") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "G") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "H") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "I") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, + 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "J") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "K") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, + 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, + 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "L") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "M") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, + 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, + 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "N") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, + 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, + 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "O") { + bitmap( + [ + 0, 0, , 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, + 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, + 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "P") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "Q") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "R") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, + 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "S") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "T") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "U") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "V") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "W") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, + 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, + 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "X") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "Y") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "Z") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "OE") { + bitmap( + [ + 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "a") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "b") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "c") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "d") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, + 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "e") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "f") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "g") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "h") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "i") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "j") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "k") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, + 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "l") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "m") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, + 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "n") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, + 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "o") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "p") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, + 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, + 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "q") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0 + ], + block_size, + height, + 8); + } else if (char == "r") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, + 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "s") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "t") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "u") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "v") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "w") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, + 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "x") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "y") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "z") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "+") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "-") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == ":") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == ".") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == ",") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "?") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "=") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "*") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, + 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "!") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "''") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "#") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "$") { + bitmap( + [ + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "%") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, + 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "&") { + bitmap( + [ + 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, + 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, + 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "@") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "'") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "(") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == ")") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, + 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "<") { + bitmap( + [ + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == ">") { + bitmap( + [ + 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "[") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "]") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, + 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, + 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "/") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "\\") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ], + block_size, + height, + 8); + } else if (char == "_") { + bitmap( + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 + ], + block_size, + height, + 8); + } else if (char == "|") { + bitmap( + [ + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, + , 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 + ], + block_size, + height, + 8); + } else { + echo("Invalid Character: ", char); + } } -module 8bit_str(chars, char_count, block_size, height) { - echo(str("Total Width: ", block_size * 8 * char_count, "mm")); - union() { - for (count = [0:char_count-1]) { - translate(v = [0, count * block_size * 8, 0]) { - 8bit_char(chars[count], block_size, height); - } - } - } +module 8bit_str(chars, char_count, block_size, height) +{ + echo(str("Total Width: ", block_size * 8 * char_count, "mm")); + union() + { + for (count = [0:char_count - 1]) { + translate(v = [ 0, count * block_size * 8, 0 ]) + { + 8bit_char(chars[count], block_size, height); + } + } + } } /* @@ -1030,32 +951,32 @@ block_size = 5; height = 10; union() { - translate(v = [0,0,5]) { - 8bit_char("A", block_size, height); + translate(v = [0,0,5]) { + 8bit_char("A", block_size, height); - //bitmap([ - // 1,1,1,1,1,1,1,1, - // 1,0,0,1,1,0,0,1, - // 1,0,1,1,1,1,0,1, - // 1,1,1,0,0,1,1,1, - // 1,1,1,0,0,1,1,1, - // 1,0,1,1,1,1,0,1, - // 1,0,0,1,1,0,0,1, - // 1,1,1,1,1,1,1,1 - //], block_size, height, 8); + //bitmap([ + // 1,1,1,1,1,1,1,1, + // 1,0,0,1,1,0,0,1, + // 1,0,1,1,1,1,0,1, + // 1,1,1,0,0,1,1,1, + // 1,1,1,0,0,1,1,1, + // 1,0,1,1,1,1,0,1, + // 1,0,0,1,1,0,0,1, + // 1,1,1,1,1,1,1,1 + //], block_size, height, 8); - //bitmap([ - // 1,1,1,1, - // 1,0,0,1, - // 1,0,0,1, - // 1,1,1,1 - //], block_size, height, 4); - } - translate(v = [0,0,5/2]) { - color([0,0,1,1]) { - cube(size = [block_size * 8, block_size * 8, 5], center = true); - } - } + //bitmap([ + // 1,1,1,1, + // 1,0,0,1, + // 1,0,0,1, + // 1,1,1,1 + //], block_size, height, 4); + } + translate(v = [0,0,5/2]) { + color([0,0,1,1]) { + cube(size ,= [block_size * 8, block_size * 8, 5], center = true); + } + } } @@ -1066,13 +987,14 @@ block_size = 1; height = 5; union() { - translate(v = [0,-block_size*8*char_count/2+block_size*8/2,5]) { - 8bit_str(chars, char_count, block_size, height); - } - translate(v = [0,0,5/2]) { - color([0,0,1,1]) { - cube(size = [block_size * 8, block_size * 8 * char_count, 5], center = true); - } - } + translate(v = [0,-block_size*8*char_count/2+block_size*8/2,5]) { + 8bit_str(chars, char_count, block_size, height); + } + translate(v = [0,0,5/2]) { + color([0,0,1,1]) { + cube(size = [block_size * 8, block_size * 8 * char_count, 5], center = +true); + } + } } */ diff --git a/text/fonts.scad b/text/fonts.scad index 91e2d17f..211aeb99 100644 --- a/text/fonts.scad +++ b/text/fonts.scad @@ -3,30 +3,44 @@ // Author: Andrew Plumb // License: LGPL 2.1 -module outline_2d(outline,points,paths,width=0.1,resolution=8) { - if(outline && resolution > 4) { - for(j=[0:len(paths)-1]) union() { - for(i=[1:len(paths[j])-1]) hull() { - translate(points[paths[j][i-1]]) circle($fn=resolution,r=width/2); - translate(points[paths[j][i]]) circle($fn=resolution,r=width/2); +module outline_2d(outline, points, paths, width = 0.1, resolution = 8) +{ + if (outline && resolution > 4) { + for (j = [0:len(paths) - 1]) + union() + { + for (i = [1:len(paths[j]) - 1]) + hull() + { + translate(points[paths[j][i - 1]]) + circle($fn = resolution, r = width / 2); + translate(points[paths[j][i]]) + circle($fn = resolution, r = width / 2); + } + hull() + { + translate(points[paths[j][len(paths[j]) - 1]]) + circle($fn = resolution, r = width / 2); + translate(points[paths[j][0]]) + circle($fn = resolution, r = width / 2); + } } - hull() { - translate(points[paths[j][len(paths[j])-1]]) circle($fn=resolution,r=width/2); - translate(points[paths[j][0]]) circle($fn=resolution,r=width/2); - } - } } else { - polygon(points=points,paths=paths); + polygon(points = points, paths = paths); } } -module bold_2d(bold,width=0.2,resolution=8) { - for(j=[0:$children-1]) { - if(bold) { - union() { +module bold_2d(bold, width = 0.2, resolution = 8) +{ + for (j = [0:$children - 1]) { + if (bold) { + union() + { + child(j); + for (i = [0:resolution - 1]) + assign(dx = width * cos(360 * i / resolution), + dy = width * sin(360 * i / resolution)) translate([ dx, dy ]) child(j); - for(i=[0:resolution-1]) assign(dx=width*cos(360*i/resolution),dy=width*sin(360*i/resolution)) - translate([dx,dy]) child(j); } } else { child(j); @@ -34,38 +48,63 @@ module bold_2d(bold,width=0.2,resolution=8) { } } -module polytext(charstring,size,font,line=0,justify=1,align=-1 - ,bold=false,bold_width=0.2,bold_resolution=8 - ,underline=false,underline_start=[0,0],underline_width=1.0 - ,outline=false,outline_width=0.2,outline_resolution=8 - ,strike=false,strike_start=[-0.5,0],strike_width=1.0 - ) { - line_length=len(charstring)*font[0][0]; - line_shift_x=-line_length/2+justify*line_length/2; - char_width=font[0][0]; - char_height=font[0][1]; - char_shift_height=-char_height/2-align*char_height/2; - char_thickness=font[0][2]; - char_index_map=search(charstring,font[2],1,1); - for(i=[0:len(char_index_map)-1]) assign( thisCharIndex=char_index_map[i], x_pos=i*size+line_shift_x*size/char_width) { - translate([x_pos,line*size+char_shift_height*size/char_height]) scale([size/char_width,size/char_height]) { - if(char_thickness==0) - bold_2d(bold,width=bold_width,resolution=bold_resolution) - outline_2d(outline,points=font[2][thisCharIndex][6][0],paths=font[2][thisCharIndex][6][1] - ,width=outline_width,resolution=outline_resolution); - if( charstring[i] != " " ) { - if(underline) translate(underline_start) - square(size=[char_width-2*underline_start[0],underline_width],center=false); - if(strike) translate([strike_start[0],char_height/2+strike_start[1]]) - square(size=[char_width-2*strike_start[0],strike_width],center=false); +module polytext(charstring, + size, + font, + line = 0, + justify = 1, + align = -1, + bold = false, + bold_width = 0.2, + bold_resolution = 8, + underline = false, + underline_start = [ 0, 0 ], + underline_width = 1.0, + outline = false, + outline_width = 0.2, + outline_resolution = 8, + strike = false, + strike_start = [ -0.5, 0 ], + strike_width = 1.0) +{ + line_length = len(charstring) * font[0][0]; + line_shift_x = -line_length / 2 + justify * line_length / 2; + char_width = font[0][0]; + char_height = font[0][1]; + char_shift_height = -char_height / 2 - align * char_height / 2; + char_thickness = font[0][2]; + char_index_map = search(charstring, font[2], 1, 1); + for (i = [0:len(char_index_map) - 1]) + assign(thisCharIndex = char_index_map[i], + x_pos = i * size + line_shift_x * size / char_width) + { + translate([ x_pos, line * size + char_shift_height * size / char_height ]) + scale([ size / char_width, size / char_height ]) + { + if (char_thickness == 0) + bold_2d(bold, width = bold_width, resolution = bold_resolution) + outline_2d(outline, + points = font[2][thisCharIndex][6][0], + paths = font[2][thisCharIndex][6][1], + width = outline_width, + resolution = outline_resolution); + if (charstring[i] != " ") { + if (underline) + translate(underline_start) square( + size = [ char_width - 2 * underline_start[0], underline_width ], + center = false); + if (strike) + translate([ strike_start[0], char_height / 2 + strike_start[1] ]) + square(size = [ char_width - 2 * strike_start[0], strike_width ], + center = false); + } + if (char_thickness > 0) + polyhedron(points = font[2][thisCharIndex][6][0], + triangles = font[2][thisCharIndex][6][1]); } - if(char_thickness>0) - polyhedron(points=font[2][thisCharIndex][6][0],triangles=font[2][thisCharIndex][6][1]); } - } } - function 8bit_polyfont(dx=0.1,dy=0.1) = [ [8,8,0,"fixed"],["Decimal Byte","Caret Notation","Character Escape Code","Abbreviation","Name","Bound Box","[points,paths]"] ,[ @@ -550,21 +589,37 @@ function 8bit_polyfont(dx=0.1,dy=0.1) = [ // From http://www.brailleauthority.org/sizespacingofbraille/ // -// Section 3.2 of Specification 800 (Braille Books and Pamphlets) February 2008 reads as follows: +// Section 3.2 of Specification 800 (Braille Books and Pamphlets) February +// 2008 reads as follows: // Size and Spacing -// 3.2.1 The nominal height of braille dots shall be 0.019 inches [0.48 mm] and shall be uniform within any given transcription. -// 3.2.2 The nominal base diameter of braille dots shall be 0.057 inches [1.44 mm]. -// 3.2.3 Cell spacing of dots shall conform to the following: -// 3.2.3.1 The nominal distance from center to center of adjacent dots (horizontally or vertically, but not diagonally) +// 3.2.1 The nominal height of braille dots shall be 0.019 inches [0.48 mm] +// and shall be uniform within any given transcription. 3.2.2 The nominal +// base diameter of braille dots shall be 0.057 inches [1.44 mm]. 3.2.3 Cell +// spacing of dots shall conform to the following: 3.2.3.1 The nominal +// distance from center to center of adjacent dots (horizontally or +// vertically, but not diagonally) // in the same cell shall be 0.092 inches [2.340 mm]. -// 3.2.3.2 The nominal distance from center to center of corresponding dots in adjacent cells shall be 0.245 inches [6.2 mm]. -// 3.2.4 The nominal line spacing of braille cells from center to center of nearest corresponding dots in adjacent lines shall +// 3.2.3.2 The nominal distance from center to center of corresponding dots +// in adjacent cells shall be 0.245 inches [6.2 mm]. 3.2.4 The nominal +// line spacing of braille cells from center to center of nearest +// corresponding dots in adjacent lines shall // be 0.400 inches [1.000 cm]. // // Additional References: // http://www.loc.gov/nls/specs/800.pdf // http://www.tiresias.org/research/reports/braille_cell.htm -module braille_ascii_spec800(inString,dot_backing=true,cell_backing=false,justify=1,align=-1,dot_h=0.48,dot_d=1.44,dot_spacing=2.340,cell_d2d_spacing=6.2, line_d2d_spacing=10.0, echo_translate=true) { +module braille_ascii_spec800(inString, + dot_backing = true, + cell_backing = false, + justify = 1, + align = -1, + dot_h = 0.48, + dot_d = 1.44, + dot_spacing = 2.340, + cell_d2d_spacing = 6.2, + line_d2d_spacing = 10.0, + echo_translate = true) +{ // justify: // -1 : left side // 0 : center @@ -573,24 +628,42 @@ module braille_ascii_spec800(inString,dot_backing=true,cell_backing=false,justif // -1 : bottom braille cell edge - shift up (default) // 0 : center braille cell // 1 : top braille cell edge - shift down - thisFont=braille_ascii_font(dot_h=dot_h,dot_d=dot_d,dot_spacing=dot_spacing - ,cell_d2d_spacing=cell_d2d_spacing,line_d2d_spacing=line_d2d_spacing); - x_shift=thisFont[0][0]; - y_shift=thisFont[0][1]; - theseIndicies=search(inString,thisFont[2],1,1); - for( i=[0:len(theseIndicies)-1]) translate([i*x_shift-(1-justify)*x_shift*len(theseIndicies)/2,-y_shift*(align+1)/2]) - assign(dotPattern=thisFont[2][theseIndicies[i]][6]) { - if(dot_backing) translate([cell_d2d_spacing/2-dot_spacing/2-dot_d/2,line_d2d_spacing/2-dot_spacing-dot_d/2,-dot_h]) - cube(size=[dot_spacing+dot_d,2*dot_spacing+dot_d,dot_h],center=false); - if(cell_backing) translate([0,0,-dot_h]) - cube(size=[x_shift,y_shift,dot_h],center=false); - if(echo_translate) echo(str(inString[i]," maps to '",thisFont[2][theseIndicies[i]][4],"'")); - for(dotIndex=dotPattern) { - translate([cell_d2d_spacing/2-dot_spacing/2+floor((dotIndex-1)/3)*dot_spacing - , line_d2d_spacing/2-dot_spacing+(2-(dotIndex-1)%3)*dot_spacing]) - scale([dot_d,dot_d,2*dot_h]) sphere($fn=8,r=0.5); + thisFont = braille_ascii_font(dot_h = dot_h, + dot_d = dot_d, + dot_spacing = dot_spacing, + cell_d2d_spacing = cell_d2d_spacing, + line_d2d_spacing = line_d2d_spacing); + x_shift = thisFont[0][0]; + y_shift = thisFont[0][1]; + theseIndicies = search(inString, thisFont[2], 1, 1); + for (i = [0:len(theseIndicies) - 1]) + translate([ + i * x_shift - (1 - justify) * x_shift * len(theseIndicies) / 2, + -y_shift * (align + 1) / 2 + ]) assign(dotPattern = thisFont[2][theseIndicies[i]][6]) + { + if (dot_backing) + translate([ + cell_d2d_spacing / 2 - dot_spacing / 2 - dot_d / 2, + line_d2d_spacing / 2 - dot_spacing - dot_d / 2, + -dot_h + ]) cube(size = [ dot_spacing + dot_d, 2 * dot_spacing + dot_d, dot_h ], + center = false); + if (cell_backing) + translate([ 0, 0, -dot_h ]) + cube(size = [ x_shift, y_shift, dot_h ], center = false); + if (echo_translate) + echo(str( + inString[i], " maps to '", thisFont[2][theseIndicies[i]][4], "'")); + for (dotIndex = dotPattern) { + translate([ + cell_d2d_spacing / 2 - dot_spacing / 2 + + floor((dotIndex - 1) / 3) * dot_spacing, + line_d2d_spacing / 2 - dot_spacing + (2 - (dotIndex - 1) % 3) * + dot_spacing + ]) scale([ dot_d, dot_d, 2 * dot_h ]) sphere($fn = 8, r = 0.5); + } } - } } // Encoding from http://en.wikipedia.org/wiki/Braille_ASCII @@ -598,141 +671,148 @@ module braille_ascii_spec800(inString,dot_backing=true,cell_backing=false,justif // 1 4 // 2 5 // 3 6 -function braille_ascii_font(dot_h=0.48,dot_d=1.44,dot_spacing=2.340,cell_d2d_spacing=6.2,line_d2d_spacing=10.0) = [ - [cell_d2d_spacing,line_d2d_spacing,0,"bump"],["Decimal Byte","Caret Notation","Character Escape Code","Abbreviation","Name","Bound Box","[bump_list]"] - ,[ - [ 0,"^@","\0","NUL","Null character",[[0,0],[2,3]],[]] - ,[ 1,"^A","", "SOH","Start of Header",[[0,0],[2,3]],[]] - ,[ 2,"^B","", "STX","Start of Text",[[0,0],[2,3]],[]] - ,[ 3,"^C","", "ETX","End of Text",[[0,0],[2,3]],[]] - ,[ 4,"^D","", "EOT","End of Transmission",[[0,0],[2,3]],[]] - ,[ 5,"^E","", "ENQ","Enquiry",[[0,0],[2,3]],[]] - ,[ 6,"^F","", "ACK","Acknowledgment",[[0,0],[2,3]],[]] - ,[ 7,"^G","\a","BEL","Bell",[[0,0],[2,3]],[]] - ,[ 8,"^H","\b","BS", "Backspace",[[0,0],[2,3]],[]] - ,[ 9,"^I","\t","HT", "Horizontal Tab",[[0,0],[2,3]],[]] - ,[ 10,"^J","\n","LF", "Line Feed",[[0,0],[2,3]],[]] - ,[ 11,"^K","\v","VT", "Vertical Tab",[[0,0],[2,3]],[]] - ,[ 12,"^L","\f","FF", "Form feed",[[0,0],[2,3]],[]] - ,[ 13,"^M","\r","CR", "Carriage return",[[0,0],[2,3]],[]] - ,[ 14,"^N","", "SO", "Shift Out",[[0,0],[2,3]],[]] - ,[ 15,"^O","", "SI", "Shift In",[[0,0],[2,3]],[]] - ,[ 16,"^P","", "DLE","Data Link Escape",[[0,0],[2,3]],[]] - ,[ 17,"^Q","", "DC1","Device Control 1",[[0,0],[2,3]],[]] - ,[ 18,"^R","", "DC2","Device Control 2",[[0,0],[2,3]],[]] - ,[ 19,"^S","", "DC3","Device Control 3",[[0,0],[2,3]],[]] - ,[ 20,"^T","", "DC4","Device Control 4",[[0,0],[2,3]],[]] - ,[ 21,"^U","", "NAK","Negative Acknowledgement",[[0,0],[2,3]],[]] - ,[ 22,"^V","", "SYN","Synchronous Idle",[[0,0],[2,3]],[]] - ,[ 23,"^W","", "ETB","End of Transmission Block",[[0,0],[2,3]],[]] - ,[ 24,"^X","", "CAN","Cancel",[[0,0],[2,3]],[]] - ,[ 25,"^Y","", "EM", "End of Medium",[[0,0],[2,3]],[]] - ,[ 26,"^Z","", "SUB","Substitute",[[0,0],[2,3]],[]] - ,[ 27,"^[","\e","ESC","Escape",[[0,0],[2,3]],[]] - ,[ 28,"^\\","", "FS", "File Separator",[[0,0],[2,3]],[]] - ,[ 29,"^]","", "GS", "Group Separator",[[0,0],[2,3]],[]] - ,[ 30,"^^","", "RS", "Record Separator",[[0,0],[2,3]],[]] - ,[ 31,"^_","", "US", "Unit Separator",[[0,0],[2,3]],[]] - ,[ 32," "," ", "", "Space",[[0,0],[2,3]],[]] - ,[ 33,"!","!", "", "the",[[0,0],[2,3]],[ 2,3,4,6 ]] - ,[ 34,"\"","\"","", "(contraction)",[[0,0],[2,3]],[ 5 ]] - ,[ 35,"#","#", "", "(number prefix)",[[0,0],[2,3]],[ 3,4,5,6 ]] - ,[ 36,"$","$", "", "ed",[[0,0],[2,3]],[ 1,2,4,6 ]] - ,[ 37,"%","%", "", "sh",[[0,0],[2,3]],[ 1,4,6 ]] - ,[ 38,"&","&", "", "and",[[0,0],[2,3]],[ 1,2,3,4,6 ]] - ,[ 39,"'","'", "", "",[[0,0],[2,3]],[ 3 ]] - ,[ 40,"(","(", "", "of",[[0,0],[2,3]],[ 1,2,3,5,6 ]] - ,[ 41,")",")", "", "with",[[0,0],[2,3]],[ 2,3,4,5,6 ]] - ,[ 42,"*","*", "", "ch",[[0,0],[2,3]],[ 1,6 ]] - ,[ 43,"+","+", "", "ing",[[0,0],[2,3]],[ 3,4,6 ]] - ,[ 44,",",",", "", "(uppercase prefix)",[[0,0],[2,3]],[ 6 ]] - ,[ 45,"-","-", "", "",[[0,0],[2,3]],[ 3,6 ]] - ,[ 46,".",".", "", "(italic prefix)",[[0,0],[2,3]],[ 4,6 ]] - ,[ 47,"/","/", "", "st",[[0,0],[2,3]],[ 3,4 ]] - ,[ 48,"0","0", "", "\"",[[0,0],[2,3]],[ 3,5,6 ]] - ,[ 49,"1","1", "", ",",[[0,0],[2,3]],[ 2 ]] - ,[ 50,"2","2", "", ";",[[0,0],[2,3]],[ 2,3 ]] - ,[ 51,"3","3", "", ":",[[0,0],[2,3]],[ 2,5 ]] - ,[ 52,"4","4", "", ".",[[0,0],[2,3]],[ 2,5,6 ]] - ,[ 53,"5","5", "", "en",[[0,0],[2,3]],[ 2,6 ]] - ,[ 54,"6","6", "", "!",[[0,0],[2,3]],[ 2,3,5 ]] - ,[ 55,"7","7", "", "( or )",[[0,0],[2,3]],[ 2,3,5,6 ]] - ,[ 56,"8","8", "", "\" or ?",[[0,0],[2,3]],[ 2,3,6 ]] - ,[ 57,"9","9", "", "in",[[0,0],[2,3]],[ 3,5 ]] - ,[ 58,":",":", "", "wh",[[0,0],[2,3]],[ 1,5,6 ]] - ,[ 59,";",";", "", "(letter prefix)",[[0,0],[2,3]],[ 5,6 ]] - ,[ 60,"<","<", "", "gh",[[0,0],[2,3]],[ 1,2,6 ]] - ,[ 61,"=","=", "", "for",[[0,0],[2,3]],[ 1,2,3,4,5,6 ]] - ,[ 62,">",">", "", "ar",[[0,0],[2,3]],[ 3,4,5 ]] - ,[ 63,"?","?", "", "th",[[0,0],[2,3]],[ 1,4,5,6 ]] - ,[ 64,"@","@", "", "(accent prefix)",[[0,0],[2,3]],[ 4 ]] - ,[ 65,"A","A", "", "a",[[0,0],[2,3]],[ 1 ]] - ,[ 66,"B","B", "", "b",[[0,0],[2,3]],[ 1,2 ]] - ,[ 67,"C","C", "", "c",[[0,0],[2,3]],[ 1,4 ]] - ,[ 68,"D","D", "", "d",[[0,0],[2,3]],[ 1,4,5 ]] - ,[ 69,"E","E", "", "e",[[0,0],[2,3]],[ 1,5 ]] - ,[ 70,"F","F", "", "f",[[0,0],[2,3]],[ 1,2,4 ]] - ,[ 71,"G","G", "", "g",[[0,0],[2,3]],[ 1,2,4,5 ]] - ,[ 72,"H","H", "", "h",[[0,0],[2,3]],[ 1,2,5 ]] - ,[ 73,"I","I", "", "i",[[0,0],[2,3]],[ 2,4 ]] - ,[ 74,"J","J", "", "j",[[0,0],[2,3]],[ 2,4,5 ]] - ,[ 75,"K","K", "", "k",[[0,0],[2,3]],[ 1,3 ]] - ,[ 76,"L","L", "", "l",[[0,0],[2,3]],[ 1,2,3 ]] - ,[ 77,"M","M", "", "m",[[0,0],[2,3]],[ 1,3,4 ]] - ,[ 78,"N","N", "", "n",[[0,0],[2,3]],[ 1,3,4,5 ]] - ,[ 79,"O","O", "", "o",[[0,0],[2,3]],[ 1,3,5 ]] - ,[ 80,"P","P", "", "p",[[0,0],[2,3]],[ 1,2,3,4 ]] - ,[ 81,"Q","Q", "", "q",[[0,0],[2,3]],[ 1,2,3,4,5 ]] - ,[ 82,"R","R", "", "r",[[0,0],[2,3]],[ 1,2,3,5 ]] - ,[ 83,"S","S", "", "s",[[0,0],[2,3]],[ 2,3,4 ]] - ,[ 84,"T","T", "", "t",[[0,0],[2,3]],[ 2,3,4,5 ]] - ,[ 85,"U","U", "", "u",[[0,0],[2,3]],[ 1,3,6 ]] - ,[ 86,"V","V", "", "v",[[0,0],[2,3]],[ 1,2,3,6 ]] - ,[ 87,"W","W", "", "w",[[0,0],[2,3]],[ 2,4,5,6 ]] - ,[ 88,"X","X", "", "x",[[0,0],[2,3]],[ 1,3,4,6 ]] - ,[ 89,"Y","Y", "", "y",[[0,0],[2,3]],[ 1,3,4,5,6 ]] - ,[ 90,"Z","Z", "", "z",[[0,0],[2,3]],[ 1,3,5,6 ]] - ,[ 91,"[","[", "", "ow",[[0,0],[2,3]],[ 2,4,6 ]] // ]] - ,[ 92,"\\","\\","", "ou",[[0,0],[2,3]],[ 1,2,5,6 ]] // [[ - ,[ 93,"]","]", "", "er",[[0,0],[2,3]],[ 1,2,4,5,6 ]] - ,[ 94,"^","^", "", "(contraction)",[[0,0],[2,3]],[ 4,5 ]] - ,[ 95,"_","_", "", "(contraction)",[[0,0],[2,3]],[ 4,5,6 ]] - ,[ 96,"`","`", "", "",[[0,0],[2,3]],[ - ]] -// Repeating upper-case patterns for lower-case letters. - ,[ 97,"a","a", "", "a",[[0,0],[2,3]],[ 1 ]] - ,[ 98,"b","b", "", "b",[[0,0],[2,3]],[ 1,2 ]] - ,[ 99,"c","c", "", "c",[[0,0],[2,3]],[ 1,4 ]] - ,[100,"d","d", "", "d",[[0,0],[2,3]],[ 1,4,5 ]] - ,[101,"e","e", "", "e",[[0,0],[2,3]],[ 1,5 ]] - ,[102,"f","f", "", "f",[[0,0],[2,3]],[ 1,2,4 ]] - ,[103,"g","g", "", "g",[[0,0],[2,3]],[ 1,2,4,5 ]] - ,[104,"h","h", "", "h",[[0,0],[2,3]],[ 1,2,5 ]] - ,[105,"i","i", "", "i",[[0,0],[2,3]],[ 2,4 ]] - ,[106,"j","j", "", "j",[[0,0],[2,3]],[ 2,4,5 ]] - ,[107,"k","k", "", "k",[[0,0],[2,3]],[ 1,3 ]] - ,[108,"l","l", "", "l",[[0,0],[2,3]],[ 1,2,3 ]] - ,[109,"m","m", "", "m",[[0,0],[2,3]],[ 1,3,4 ]] - ,[110,"n","n", "", "n",[[0,0],[2,3]],[ 1,3,4,5 ]] - ,[111,"o","o", "", "o",[[0,0],[2,3]],[ 1,3,5 ]] - ,[112,"p","p", "", "p",[[0,0],[2,3]],[ 1,2,3,4 ]] - ,[113,"q","q", "", "q",[[0,0],[2,3]],[ 1,2,3,4,5 ]] - ,[114,"r","r", "", "r",[[0,0],[2,3]],[ 1,2,3,5 ]] - ,[115,"s","s", "", "s",[[0,0],[2,3]],[ 2,3,4 ]] - ,[116,"t","t", "", "t",[[0,0],[2,3]],[ 2,3,4,5 ]] - ,[117,"u","u", "", "u",[[0,0],[2,3]],[ 1,3,6 ]] - ,[118,"v","v", "", "v",[[0,0],[2,3]],[ 1,2,3,6 ]] - ,[119,"w","w", "", "w",[[0,0],[2,3]],[ 2,4,5,6 ]] - ,[120,"x","x", "", "x",[[0,0],[2,3]],[ 1,3,4,6 ]] - ,[121,"y","y", "", "y",[[0,0],[2,3]],[ 1,3,4,5,6 ]] - ,[122,"z","z", "", "z",[[0,0],[2,3]],[ 1,3,5,6 ]] - ,[123,"{","{", "", "",[[0,0],[2,3]],[ - ]] - ,[124,"|","|", "", "",[[0,0],[2,3]],[ - ]] - ,[125,"}","}", "", "",[[0,0],[2,3]],[ - ]] - ,[126,"~","~", "", "",[[0,0],[2,3]],[ - ]] - ,[127,"^?","", "DEL","Delete",[[0,0],[2,3]],[]] - ] ]; +function braille_ascii_font(dot_h = 0.48, + dot_d = 1.44, + dot_spacing = 2.340, + cell_d2d_spacing = 6.2, + line_d2d_spacing = 10.0) = + [[cell_d2d_spacing, line_d2d_spacing, 0, "bump"], + ["Decimal Byte", + "Caret Notation", + "Character Escape Code", + "Abbreviation", + "Name", + "Bound Box", + "[bump_list]"], + [[0, "^@", "\0", "NUL", "Null character", [[0, 0], [2, 3]], []], + [1, "^A", "", "SOH", "Start of Header", [[0, 0], [2, 3]], []], + [2, "^B", "", "STX", "Start of Text", [[0, 0], [2, 3]], []], + [3, "^C", "", "ETX", "End of Text", [[0, 0], [2, 3]], []], + [4, "^D", "", "EOT", "End of Transmission", [[0, 0], [2, 3]], []], + [5, "^E", "", "ENQ", "Enquiry", [[0, 0], [2, 3]], []], + [6, "^F", "", "ACK", "Acknowledgment", [[0, 0], [2, 3]], []], + [7, "^G", "\a", "BEL", "Bell", [[0, 0], [2, 3]], []], + [8, "^H", "\b", "BS", "Backspace", [[0, 0], [2, 3]], []], + [9, "^I", "\t", "HT", "Horizontal Tab", [[0, 0], [2, 3]], []], + [10, "^J", "\n", "LF", "Line Feed", [[0, 0], [2, 3]], []], + [11, "^K", "\v", "VT", "Vertical Tab", [[0, 0], [2, 3]], []], + [12, "^L", "\f", "FF", "Form feed", [[0, 0], [2, 3]], []], + [13, "^M", "\r", "CR", "Carriage return", [[0, 0], [2, 3]], []], + [14, "^N", "", "SO", "Shift Out", [[0, 0], [2, 3]], []], + [15, "^O", "", "SI", "Shift In", [[0, 0], [2, 3]], [, ]], + [16, "^P", "", "DLE", "Data Link Escape", [[0, 0], [2, 3]], []], + [17, "^Q", "", "DC1", "Device Control 1", [[0, 0], [2, 3]], []], + [18, "^R", "", "DC2", "Device Control 2", [[0, 0], [2, 3]], []], + [19, "^S", "", "DC3", "Device Control 3", [[0, 0], [2, 3]], []], + [20, "^T", "", "DC4", "Device Control 4", [[0, 0], [2, 3]], []], + [21, "^U", "", "NAK", "Negative Acknowledgement", [[0, 0], [2, 3]], []], + [22, "^V", "", "SYN", "Synchronous Idle", [[0, 0], [2, 3]], []], + [23, "^W", "", "ETB", "End of Transmission Block", [[0, 0], [2, 3]], []], + [24, "^X", "", "CAN", "Cancel", [[0, 0], [2, 3]], []], + [25, "^Y", "", "EM", "End of Medium", [[0, 0], [2, 3]], []], + [26, "^Z", "", "SUB", "Substitute", [[0, 0], [2, 3]], []], + [27, "^[", "\e", "ESC", "Escape", [[0, 0], [2, 3]], []], + [28, "^\\", "", "FS", "File Separator", [[0, 0], [2, 3]], []], + [29, "^]", "", "GS", "Group Separator", [[0, 0], [2, 3]], []], + [30, "^^", "", "RS", "Record Separator", [[0, 0], [2, 3]], []], + [31, "^_", "", "US", "Unit Separator", [[0, 0], [2, 3]], []], + [32, " ", " ", "", "Space", [[0, 0], [2, 3]], []], + [33, "!", "!", "", "the", [[0, 0], [2, 3]], [2, 3, 4, 6]], + [34, "\"", "\"", "", "(contraction)", [[0, 0], [2, 3]], [5]], + [35, "#", "#", "", "(number prefix)", [[0, 0], [2, 3]], [3, 4, 5, 6]], + [36, "$", "$", "", "ed", [[0, 0], [2, 3]], [1, 2, 4, 6]], + [37, "%", "%", "", "sh", [[0, 0], [2, 3]], [1, 4, 6]], + [38, "&", "&", "", "and", [[0, 0], [2, 3]], [1, 2, 3, 4, 6]], + [39, "'", "'", "", "", [[0, 0], [2, 3]], [3]], + [40, "(", "(", "", "of", [[0, 0], [2, 3]], [1, 2, 3, 5, 6]], + [41, ")", ")", "", "with", [[0, 0], [2, 3]], [2, 3, 4, 5, 6]], + [42, "*", "*", "", "ch", [[0, 0], [2, 3]], [1, 6]], + [43, "+", "+", "", "ing", [[0, 0], [2, 3]], [3, 4, 6]], + [44, ",", ",", "", "(uppercase prefix)", [[0, 0], [2, 3]], [6]], + [45, "-", "-", "", "", [[0, 0], [2, 3]], [3, 6]], + [46, ".", ".", "", "(italic prefix)", [[0, 0], [2, 3]], [4, 6]], + [47, "/", "/", "", "st", [[0, 0], [2, 3]], [3, 4]], + [48, "0", "0", "", "\"", [[0, 0], [2, 3]], [3, 5, 6]], + [49, "1", "1", "", ",", [[0, 0], [2, 3]], [2]], + [50, "2", "2", "", ";", [[0, 0], [2, 3]], [2, 3]], + [51, "3", "3", "", ":", [[0, 0], [2, 3]], [2, 5]], + [52, "4", "4", "", ".", [[0, 0], [2, 3]], [2, 5, 6]], + [53, "5", "5", "", "en", [[0, 0], [2, 3]], [2, 6]], + [54, "6", "6", "", "!", [[0, 0], [2, 3]], [2, 3, 5]], + [55, "7", "7", "", "( or )", [[0, 0], [2, 3]], [2, 3, 5, 6]], + [56, "8", "8", "", "\" or ?", [[0, 0], [2, 3]], [2, 3, 6]], + [57, "9", "9", "", "in", [[0, 0], [2, 3]], [3, 5]], + [58, ":", ":", "", "wh", [[0, 0], [2, 3]], [1, 5, 6]], + [59, ";", ";", "", "(letter prefix)", [[0, 0], [2, 3]], [5, 6]], + [60, "<", "<", "", "gh", [[0, 0], [2, 3]], [1, 2, 6]], + [61, "=", "=", "", "for", [[0, 0], [2, 3]], [1, 2, 3, 4, 5, 6]], + [62, ">", ">", "", "ar", [[0, 0], [2, 3]], [3, 4, 5]], + [63, "?", "?", "", "th", [[0, 0], [2, 3]], [1, 4, 5, 6]], + [64, "@", "@", "", "(accent prefix)", [[0, 0], [2, 3]], [4]], + [65, "A", "A", "", "a", [[0, 0], [2, 3]], [1]], + [66, "B", "B", "", "b", [[0, 0], [2, 3]], [1, 2]], + [67, "C", "C", "", "c", [[0, 0], [2, 3]], [1, 4]], + [68, "D", "D", "", "d", [[0, 0], [2, 3]], [1, 4, 5]], + [69, "E", "E", "", "e", [[0, 0], [2, 3]], [1, 5]], + [70, "F", "F", "", "f", [[0,, 0], [2, 3]], [1, 2, 4]], + [71, "G", "G", "", "g", [[0, 0], [2, 3]], [1, 2, 4, 5]], + [72, "H", "H", "", "h", [[0, 0], [2, 3]], [1, 2, 5]], + [73, "I", "I", "", "i", [[0, 0], [2, 3]], [2, 4]], + [74, "J", "J", "", "j", [[0, 0], [2, 3]], [2, 4, 5]], + [75, "K", "K", "", "k", [[0, 0], [2, 3]], [1, 3]], + [76, "L", "L", "", "l", [[0, 0], [2, 3]], [1, 2, 3]], + [77, "M", "M", "", "m", [[0, 0], [2, 3]], [1, 3, 4]], + [78, "N", "N", "", "n", [[0, 0], [2, 3]], [1, 3, 4, 5]], + [79, "O", "O", "", "o", [[0, 0], [2, 3]], [1, 3, 5]], + [80, "P", "P", "", "p", [[0, 0], [2, 3]], [1, 2, 3, 4]], + [81, "Q", "Q", "", "q", [[0, 0], [2, 3]], [1, 2, 3, 4, 5]], + [82, "R", , "R", "", "r", [[0, 0], [2, 3]], [1, 2, 3, 5]], + [83, "S", "S", "", "s", [[0, 0], [2, 3]], [2, 3, 4]], + [84, "T", "T", "", "t", [[0, 0], [2, 3]], [2, 3, 4, 5]], + [85, "U", "U", "", "u", [[0, 0], [2, 3]], [1, 3, 6]], + [86, "V", "V", "", "v", [[0, 0], [2, 3]], [1, 2, 3, 6]], + [87, "W", "W", "", "w", [[0, 0], [2, 3]], [2, 4, 5, 6]], + [88, "X", "X", "", "x", [[0, 0], [2, 3]], [1, 3, 4, 6]], + [89, "Y", "Y", "", "y", [[0, 0], [2, 3]], [1, 3, 4, 5, 6]], + [90, "Z", "Z", "", "z", [[0, 0], [2, 3]], [1, 3, 5, 6]], + [91, "[", "[", "", "ow", [[0, 0], [2, 3]], [2, 4, 6]] // ]] + , + [92, "\\", "\\", "", "ou", [[0, 0], [2, 3]], [1, 2, 5, 6]] // [[ + , + [93, "]", "]", "", "er", [[0, 0], [2, 3]], [1, 2, 4, 5, 6]], + [94, "^", "^", "", "(contraction)", [[0, 0], [2, 3]], [4, 5]], + [95, "_", "_", "", "(contraction)", [[0, 0], [2, 3]], [4, 5, 6]], + [96, "`", "`", "", "", [[0, 0], [2, 3]], []] + // Repeating upper-case patterns for lower-case letters. + , + [97, "a", "a", "", "a", [[0, 0], [2, 3]], [1]], + [98, "b", "b", "", "b", [[0, 0], [2, 3]], [1, 2]], + [99, "c", "c", "", "c", [[0, 0], [2, 3]], [1, 4]], + [100, "d", "d", "", "d", [[0, 0], [2, 3]], [1, 4, 5]], + [101, "e", "e", "", "e", [[0, 0], [2, 3]], [1, 5]], + [102, "f", "f", "", "f", [[0, 0], [2, 3]], [1, 2, 4]], + [103, "g", "g", "", "g", [[0, 0], [2, 3]], [1, 2, 4, 5]], + [104, "h", "h", "", "h", [[0, 0], [2, 3]], [1, 2, 5]], + [105, "i", "i", "", "i", [[0, 0], [2, 3]], [2, 4]], + [106, "j", "j", "", "j", [[0, 0], [2, 3]], [2, 4, 5]], + [107, "k", "k", "", "k", [[0, 0], [2, 3]], [1, 3]], + [108, "l", "l", "", "l", [[0, 0], [2, 3]], [1, 2, 3]], + [109, "m", "m", "", "m", [[0, 0], [2, 3]], [1, 3, 4]], + [110, "n", "n", "", "n", [[0, 0], [2, 3]], [1, 3, 4, 5]], + [111, "o", "o", "", "o", [[0, 0], [2, 3]], [1, 3, 5]], + [112, "p", "p", "", "p", [[0, 0], [2, 3]], [1, 2, 3, 4]], + [113, "q", "q", "", "q", [[0, 0], [2, 3]], [1, 2, 3, 4, 5]], + [114, "r", "r", "", "r", [[0, 0], [2, 3]], [1, 2, 3, 5]], + [115, "s", "s", "", "s", [[0, 0], [2, 3]], [2, 3, 4]], + [116, "t", "t", "", "t", [[0, 0], [2, 3]], [2, 3, 4, 5]], + [117, "u", "u", "", "u", [[0, 0], [2, 3]], [1, 3, 6]], + [118, "v", "v", "", "v", [[0, 0], [2, 3]], [1, 2, 3, 6]], + [119, "w", "w", "", "w", [[0, 0], [2, 3]], [2, 4, 5, 6]], + [120, "x", "x", "", "x", [[0, 0], [2, 3]], [1, 3, 4, 6]], + [121, "y", "y", "", "y", [[0, 0], [2, 3]], [1, 3, 4, 5, 6]], + [122, "z", "z", "", "z", [[0, 0], [2, 3]], [1, 3, 5, 6]], + [123, "{", "{", "", "", [[0, 0], [2, 3]], []], + [124, "|", "|", "", "", [[0, 0], [2, 3]], []], + [125, "}", "}", "", "", [[0, 0], [2, 3]], []], + [126, "~", "~", "", "", [[0, 0], [2, 3]], []], + [127, "^?", "", "DEL", "Delete", [[0, 0], [2, 3]], []]]]; diff --git a/text/height_map.scad b/text/height_map.scad index 0b75f569..676208a6 100644 --- a/text/height_map.scad +++ b/text/height_map.scad @@ -6,7 +6,8 @@ http://creativecommons.org/licenses/by/3.0/ Can also dynamically run this by passing an array on the command line: -/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD -m make -D bitmap=[2,2,2,0,1,3,2,2,2] -D row_size=3 -s height_map.stl height_map.scad +/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD -m make -D +bitmap=[2,2,2,0,1,3,2,2,2] -D row_size=3 -s height_map.stl height_map.scad */ use @@ -16,16 +17,10 @@ height = 5; row_size = 10; // 10x10 pixels bitmap = [ - 1,1,0,0,1,1,0,0,1,1, - 1,1,1,1,1,1,1,1,1,1, - 0,1,2,2,1,1,2,2,1,0, - 0,1,2,1,1,1,1,2,1,0, - 1,1,1,1,3,3,1,1,1,1, - 1,1,1,1,3,3,1,1,1,1, - 0,1,2,1,1,1,1,2,1,0, - 0,1,2,2,1,1,2,2,1,0, - 1,1,1,1,1,1,1,1,1,1, - 1,1,0,0,1,1,0,0,1,1 + 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 2, 1, + 1, 2, 2, 1, 0, 0, 1, 2, 1, 1, 1, 1, 2, 1, 0, 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, + 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, 0, 1, 2, 1, 1, 1, 1, 2, 1, 0, 0, 1, 2, 2, 1, + 1, 2, 2, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1 ]; bitmap(bitmap, block_size, height, row_size); diff --git a/text/letter_necklace.scad b/text/letter_necklace.scad index 8d357816..812547f4 100644 --- a/text/letter_necklace.scad +++ b/text/letter_necklace.scad @@ -8,7 +8,7 @@ use // change chars array and char_count // OpenSCAD has no string or length methods :( -chars = ["M","a","k","e","r","B","o","t"]; +chars = [ "M", "a", "k", "e", "r", "B", "o", "t" ]; char_count = 8; // block size 1 will result in 8mm per letter @@ -16,44 +16,58 @@ block_size = 2; // height is the Z height of each letter height = 3; -//Hole for the necklace +// Hole for the necklace hole_diameter = 5; -module 8bit_str(chars, char_count, block_size, height) { - echo(str("Total Width: ", block_size * 8 * char_count, "mm")); - union() { - for (count = [0:char_count-1]) { - translate(v = [0, count * block_size * 8, 0]) { - 8bit_char(chars[count], block_size, height); - } - } - } +module 8bit_str(chars, char_count, block_size, height) +{ + echo(str("Total Width: ", block_size * 8 * char_count, "mm")); + union() + { + for (count = [0:char_count - 1]) { + translate(v = [ 0, count * block_size * 8, 0 ]) + { + 8bit_char(chars[count], block_size, height); + } + } + } } -module letter(char, block_size, height, hole_diameter) { - union() { - translate(v = [0,0, hole_diameter*1.3]) { - 8bit_char(char, block_size, height); - } - translate(v = [0,0,(hole_diameter*1.3)/2]) { - color([0,0,1,1]) { - difference() { - cube(size = [block_size * 8, block_size * 8, hole_diameter+2], center = true); - rotate([90, 0, 0]) cylinder(h = block_size * 8 + 1, r = hole_diameter/2, center = true); - } - } - } - } +module +letter(char, block_size, height, hole_diameter) +{ + union() + { + translate(v = [ 0, 0, hole_diameter * 1.3 ]) + { + 8bit_char(char, block_size, height); + } + translate(v = [ 0, 0, (hole_diameter * 1.3) / 2 ]) + { + color([ 0, 0, 1, 1 ]) + { + difference() + { + cube(size = [ block_size * 8, block_size * 8, hole_diameter + 2 ], + center = true); + rotate([ 90, 0, 0 ]) cylinder( + h = block_size * 8 + 1, r = hole_diameter / 2, center = true); + } + } + } + } } -matrix = [["O", "L", "E", "N", "S"], - [ "Y", "OE", "N", "Y", "T"]]; +matrix = [ [ "O", "L", "E", "N", "S" ], [ "Y", "OE", "N", "Y", "T" ] ]; -union() { - for (column = [0:1]) { - for (row = [0:4]) { - translate(v=[column*(block_size*1.1)*8, row*(block_size*1.1)*8, 0]) - letter(matrix[column][row], block_size, height, hole_diameter); - } - } +union() +{ + for (column = [0:1]) { + for (row = [0:4]) { + translate( + v = + [ column * (block_size * 1.1) * 8, row * (block_size * 1.1) * 8, 0 ]) + letter(matrix[column][row], block_size, height, hole_diameter); + } + } } diff --git a/text/name_tag.scad b/text/name_tag.scad index 4b392bb3..0d0029b4 100644 --- a/text/name_tag.scad +++ b/text/name_tag.scad @@ -1,5 +1,5 @@ /* -Parametric Name Tag +Parametric Name Tag Tony Buser http://tonybuser.com http://creativecommons.org/licenses/by/3.0/ @@ -13,23 +13,33 @@ use height = the Z height of each letter in mm key_ring_hole = (boolean) Append a hole to a keyring, necklace etc. ? */ -module name_tag(chars = ["R", "E", "P", "R", "A", "P"], - block_size = 2, height = 3, key_ring_hole = true) { +module name_tag(chars = [ "R", "E", "P", "R", "A", "P" ], + block_size = 2, + height = 3, + key_ring_hole = true) +{ char_count = len(chars); - union() { - translate(v = [0,-block_size*8*char_count/2+block_size*8/2,3]) { + union() + { + translate(v = + [ 0, -block_size * 8 * char_count / 2 + block_size * 8 / 2, 3 ]) + { 8bit_str(chars, char_count, block_size, height); } - translate(v = [0,0,3/2]) { - color([0,0,1,1]) { - cube(size = [block_size * 8, block_size * 8 * char_count, 3], center = true); + translate(v = [ 0, 0, 3 / 2 ]) + { + color([ 0, 0, 1, 1 ]) + { + cube(size = [ block_size * 8, block_size * 8 * char_count, 3 ], + center = true); } } - if (key_ring_hole == true){ - translate([0, block_size * 8 * (char_count+1)/2, 3/2]) - difference(){ - cube(size = [block_size * 8, block_size * 8 , 3], center = true); - cube(size = [block_size * 4, block_size * 4 , 5], center = true); + if (key_ring_hole == true) { + translate([ 0, block_size * 8 * (char_count + 1) / 2, 3 / 2 ]) + difference() + { + cube(size = [ block_size * 8, block_size * 8, 3 ], center = true); + cube(size = [ block_size * 4, block_size * 4, 5 ], center = true); } } } diff --git a/text/string.scad b/text/string.scad index 5c2292b5..22f533a6 100644 --- a/text/string.scad +++ b/text/string.scad @@ -1,14 +1,35 @@ -function strToInt(str, base=10, i=0, nb=0) = (str[0] == "-") ? -1*_strToInt(str, base, 1) : _strToInt(str, base); -function _strToInt(str, base, i=0, nb=0) = (i == len(str)) ? nb : nb+_strToInt(str, base, i+1, search(str[i],"0123456789ABCDEF")[0]*pow(base,len(str)-i-1)); +function strToInt(str, base = 10, i = 0, nb = 0) = (str[0] == "-") + ? -1 * + _strToInt(str, base, 1) + : _strToInt(str, base); +function _strToInt(str, base, i = 0, nb = 0) = + (i == len(str)) ? nb + : nb + _strToInt(str, + base, + i + 1, + search(str[i], "0123456789ABCDEF")[0] * + pow(base, len(str) - i - 1)); -function strcat(v, car="") = _strcat(v, len(v)-1, car, 0); -function _strcat(v, i, car, s) = (i==s ? v[i] : str(_strcat(v, i-1, car, s), str(car,v[i]) )); +function strcat(v, car = "") = _strcat(v, len(v) - 1, car, 0); +function _strcat(v, i, car, s) = (i == s ? v[i] + : str(_strcat(v, i - 1, car, s), + str(car, v[i]))); -function substr(data, i, length=0) = (length == 0) ? _substr(data, i, len(data)) : _substr(data, i, length+i); -function _substr(str, i, j, out="") = (i==j) ? out : str(str[i], _substr(str, i+1, j, out)); +function substr(data, i, length = 0) = (length == 0) + ? _substr(data, i, len(data)) + : _substr(data, i, length + i); +function _substr(str, i, j, out = "") = (i == j) + ? out + : str(str[i], + _substr(str, i + 1, j, out)); -function fill(car, nb_occ, out="") = (nb_occ == 0) ? out : str(fill(car, nb_occ-1, out), car); +function fill(car, nb_occ, out = "") = (nb_occ == 0) + ? out + : str(fill(car, nb_occ - 1, out), car); -function getsplit(str, index=0, char=" ") = (index==0) ? substr(str, 0, search(char, str)[0]) : getsplit( substr(str, search(" ", str)[0]+1) , index-1, char); \ No newline at end of file +function getsplit(str, index = 0, char = " ") = + (index == 0) + ? substr(str, 0, search(char, str)[0]) + : getsplit(substr(str, search(" ", str)[0] + 1), index - 1, char); \ No newline at end of file diff --git a/text/test_name_tag.scad b/text/test_name_tag.scad index 85e5c707..7c17e3de 100644 --- a/text/test_name_tag.scad +++ b/text/test_name_tag.scad @@ -1,19 +1,18 @@ -include ; +include -translate([0,0,0]) -name_tag("name_tag"); +translate([ 0, 0, 0 ]) name_tag("name_tag"); -translate([20,0,0]) // 0 + 16/2 + 16/2 + 4 -name_tag("NAME_TAG"); +translate([ 20, 0, 0 ]) // 0 + 16/2 + 16/2 + 4 + name_tag("NAME_TAG"); -translate([52,0,0]) // 20 + 16/2 + 40/2 + 4 -name_tag("name_tag", block_size=5); +translate([ 52, 0, 0 ]) // 20 + 16/2 + 40/2 + 4 + name_tag("name_tag", block_size = 5); -translate([96,0,0]) // 52 + 40/2 + 40/2 + 4 -name_tag("NAME_TAG", block_size=5); +translate([ 96, 0, 0 ]) // 52 + 40/2 + 40/2 + 4 + name_tag("NAME_TAG", block_size = 5); -translate([130,0,0]) // 92 + 40/2 + 16/2 + 4 -name_tag("name_tag", height=30); +translate([ 130, 0, 0 ]) // 92 + 40/2 + 16/2 + 4 + name_tag("name_tag", height = 30); -translate([150,0,0]) // 130 + 16/2 + 16/2 + 4 -name_tag("NAME_TAG", height=30); +translate([ 150, 0, 0 ]) // 130 + 16/2 + 16/2 + 4 + name_tag("NAME_TAG", height = 30); diff --git a/units/metric.scad b/units/metric.scad index 0a457b22..d1bdcd70 100644 --- a/units/metric.scad +++ b/units/metric.scad @@ -1,8 +1,8 @@ // 1 2 3 4 5 6 7 -//3456789012345678901234567890123456789012345678901234567890123456789012 +// 3456789012345678901234567890123456789012345678901234567890123456789012 /* * Metric units. - * + * * Originally by Hans Häggström, 2010. With contributions from: * elmom (Elmo Mantynen ) * kr2 (Krallinger Sebastian ) @@ -21,8 +21,8 @@ function length_nm(quantity) = quantity * length_nm; //! Commented out until https://github.com/openscad/openscad/issues/737 //! is resolved. -//length_µm = 0.001 * length_mm; // micrometre -//function length_µm(quantity) = quantity * length_µm; +// length_µm = 0.001 * length_mm; // micrometre +// function length_µm(quantity) = quantity * length_µm; length_um = 0.001 * length_mm; // micrometre (alternate) function length_um(quantity) = quantity * length_um; @@ -60,9 +60,9 @@ function length_km(quantity) = quantity * length_km; //㎝ = length_cm; //㎞ = length_km; -X = [1, 0, 0]; -Y = [0, 1, 0]; -Z = [0, 0, 1]; +X = [ 1, 0, 0 ]; +Y = [ 0, 1, 0 ]; +Z = [ 0, 0, 1 ]; M3 = 3 * length_mm; M4 = 4 * length_mm; @@ -74,8 +74,8 @@ M8 = 8 * length_mm; // cutting, etc. //! Commented out until https://github.com/openscad/openscad/issues/737 //! is resolved. -//epsilon = 10.0 * length_µm; +// epsilon = 10.0 * length_µm; epsilon = 10.0 * length_um; -OS = epsilon; // Over size +OS = epsilon; // Over size include diff --git a/units/us.scad b/units/us.scad index 586a7af5..1960c09e 100644 --- a/units/us.scad +++ b/units/us.scad @@ -1,8 +1,8 @@ // 1 2 3 4 5 6 7 -//3456789012345678901234567890123456789012345678901234567890123456789012 +// 3456789012345678901234567890123456789012345678901234567890123456789012 /* * United States customary units. - * + * * Originally by McNeight (Neil McNeight ) * * Dual licenced under Creative Commons Attribution-Share Alike 3.0 and @@ -10,18 +10,19 @@ */ /* - * From http://en.wikipedia.org/wiki/United_States_customary_units#Other_names_for_U.S._customary_units - * + * From + * http://en.wikipedia.org/wiki/United_States_customary_units#Other_names_for_U.S._customary_units + * * The United States Code refers to these units as "traditional systems * of weights and measures". - * + * * Other common ways of referring to these systems in the United States * are: "Standard", "Customary", or, somewhat erroneously when considering * volume/tonnage, "Imperial", or "English", which refers to the pre-1824 * reform measures used throughout the British Empire. Another term is the * "foot-pound-second" (FPS) system (as opposed to centimeter-gram-second * (CGS) system). - * + * * Tools and fasteners with sizes measured in inches are sometimes called * "SAE bolts" or "SAE wrenches" to differentiate them from their metric * counterparts. The Society of Automotive Engineers originally developed @@ -68,42 +69,59 @@ function length_thou(quantity) = quantity * length_thou; length_mil = 0.001 * length_inch; function length_mil(quantity) = quantity * length_mil; -module inch_ruler(inches) -{ - difference() - { - // Body of ruler - color("Beige") - cube(size = [length_inch(inches), length_inch(1.125), length_thou(150)]); - // Inch markings - for (i = [0:length_inch(1):length_inch(inches) + epsilon]) - { - translate([i,length_inch(0.8875),length_thou(130)]) - color("Red") - cube(size = [length_thou(20), length_inch(0.475) + epsilon, length_thou(40) + epsilon], center = true); - } - // Half inch markings - for (i = [length_inch(0.5):length_inch(1):length_inch(inches)]) - { - translate([i,length_inch(0.93125),length_thou(135)]) - color("Red") - cube(size = [length_thou(20), length_inch(0.3875) + epsilon, length_thou(30) + epsilon], center = true); - } - // Quarter inch markings - for (i = [length_inch(0.25):length_inch(0.5):length_inch(inches)]) - { - translate([i,length_inch(1.0),length_thou(140)]) - color("Red") - cube(size = [length_thou(20), length_inch(0.25) + epsilon, length_thou(20) + epsilon], center = true); - } - // Eighth inch markings - for (i = [length_inch(0.125):length_inch(0.25):length_inch(inches)]) - { - translate([i,length_inch(1.0375),length_thou(145)]) - color("Red") - cube(size = [length_thou(20), length_inch(0.175) + epsilon, length_thou(10) + epsilon], center = true); - } - } +module inch_ruler(inches){ difference(){ + // Body of ruler + color("Beige") + cube(size = [ length_inch(inches), length_inch(1.125), length_thou(150) ]); +// Inch markings +for (i = [0:length_inch(1):length_inch(inches) + epsilon]) { + translate([ i, length_inch(0.8875), length_thou(130) ]) color("Red") + cube(size = + [ + length_thou(20), + length_inch(0.475) + epsilon, + length_thou(40) + + epsilon + ], + center = true); +} +// Half inch markings +for (i = [length_inch(0.5):length_inch(1):length_inch(inches)]) { + translate([ i, length_inch(0.93125), length_thou(135) ]) color("Red") + cube(size = + [ + length_thou(20), + length_inch(0.3875) + epsilon, + length_thou(30) + + epsilon + ], + center = true); +} +// Quarter inch markings +for (i = [length_inch(0.25):length_inch(0.5):length_inch(inches)]) { + translate([ i, length_inch(1.0), length_thou(140) ]) color("Red") + cube(size = + [ + length_thou(20), + length_inch(0.25) + epsilon, + length_thou(20) + + epsilon + ], + center = true); +} +// Eighth inch markings +for (i = [length_inch(0.125):length_inch(0.25):length_inch(inches)]) { + translate([ i, length_inch(1.0375), length_thou(145) ]) color("Red") + cube(size = + [ + length_thou(20), + length_inch(0.175) + epsilon, + length_thou(10) + + epsilon + ], + center = true); +} +} } *inch_ruler(4);