Added position children used for drilling holes on sheets.

This commit is contained in:
Chris Palmer 2020-06-20 15:04:03 +01:00
parent bf5b6d7c30
commit d9fa8c8668
3 changed files with 22 additions and 12 deletions

View File

@ -110,12 +110,9 @@ function fixing_block_positions(type) = let(
function side_holes(type) = [for(p = fixing_block_positions(type), q = fixing_block_holes(bbox_screw(type))) p * q]; function side_holes(type) = [for(p = fixing_block_positions(type), q = fixing_block_holes(bbox_screw(type))) p * q];
module drill_holes(type, t) module bbox_drill_holes(type, t)
for(list = [corner_holes(type), side_holes(type)], p = list) position_children(concat(corner_holes(type), side_holes(type)), t)
let(q = t * p) drill(screw_clearance_radius(bbox_screw(type)), 0);
if(abs(transform([0, 0, 0], q).z) < eps)
multmatrix(q)
drill(screw_clearance_radius(bbox_screw(type)), 0);
module bbox_base_blank(type) { //! 2D template for the base module bbox_base_blank(type) { //! 2D template for the base
dxf(str(bbox_name(type), "_base")); dxf(str(bbox_name(type), "_base"));
@ -123,7 +120,7 @@ module bbox_base_blank(type) { //! 2D template for the base
difference() { difference() {
sheet_2D(bbox_base_sheet(type), bbox_width(type), bbox_depth(type), 1); sheet_2D(bbox_base_sheet(type), bbox_width(type), bbox_depth(type), 1);
drill_holes(type, translate(bbox_height(type) / 2)); bbox_drill_holes(type, translate(bbox_height(type) / 2));
} }
} }
@ -136,7 +133,7 @@ module bbox_top_blank(type) { //! 2D template for the top
translate([0, t / 2]) translate([0, t / 2])
sheet_2D(bbox_top_sheet(type), bbox_width(type) + 2 * t, bbox_depth(type) + t); sheet_2D(bbox_top_sheet(type), bbox_width(type) + 2 * t, bbox_depth(type) + t);
drill_holes(type, translate(-bbox_height(type) / 2)); bbox_drill_holes(type, translate(-bbox_height(type) / 2));
} }
} }
@ -154,7 +151,7 @@ module bbox_left_blank(type, sheet = false) { //! 2D template for the left side
translate([-t / 2, -bb / 2]) translate([-t / 2, -bb / 2])
sheet_2D(subst_sheet(type, sheet), bbox_depth(type) + t, bbox_height(type) + bb); sheet_2D(subst_sheet(type, sheet), bbox_depth(type) + t, bbox_height(type) + bb);
drill_holes(type, rotate([0, 90, 90]) * translate([bbox_width(type) / 2, 0])); bbox_drill_holes(type, rotate([0, 90, 90]) * translate([bbox_width(type) / 2, 0]));
} }
} }
@ -168,7 +165,7 @@ module bbox_right_blank(type, sheet = false) { //! 2D template for the right sid
translate([t / 2, -bb / 2]) translate([t / 2, -bb / 2])
sheet_2D(subst_sheet(type, sheet), bbox_depth(type) + t, bbox_height(type) + bb); sheet_2D(subst_sheet(type, sheet), bbox_depth(type) + t, bbox_height(type) + bb);
drill_holes(type, rotate([0, 90, 90]) * translate([-bbox_width(type) / 2, 0])); bbox_drill_holes(type, rotate([0, 90, 90]) * translate([-bbox_width(type) / 2, 0]));
} }
} }
@ -183,7 +180,7 @@ module bbox_front_blank(type, sheet = false, width = 0) { //! 2D template for th
translate([0, (bt - bb) / 2]) translate([0, (bt - bb) / 2])
sheet_2D(subst_sheet(type, sheet), max(bbox_width(type) + 2 * t, width), bbox_height(type) + bb + bt); sheet_2D(subst_sheet(type, sheet), max(bbox_width(type) + 2 * t, width), bbox_height(type) + bb + bt);
drill_holes(type, rotate([-90, 0, 0]) * translate([0, bbox_depth(type) / 2])); bbox_drill_holes(type, rotate([-90, 0, 0]) * translate([0, bbox_depth(type) / 2]));
} }
} }
@ -197,7 +194,7 @@ module bbox_back_blank(type, sheet = false) { //! 2D template for the back
translate([0, -bb / 2]) translate([0, -bb / 2])
sheet_2D(subst_sheet(type, sheet), bbox_width(type), bbox_height(type) + bb); sheet_2D(subst_sheet(type, sheet), bbox_width(type), bbox_height(type) + bb);
drill_holes(type, rotate([-90, 0, 0]) * translate([0, -bbox_depth(type) / 2])); bbox_drill_holes(type, rotate([-90, 0, 0]) * translate([0, -bbox_depth(type) / 2]));
} }
} }

View File

@ -5231,6 +5231,11 @@ Maths utilities for manipulating vectors and matrices.
| ```vec3(v)``` | Return a 3 vector with the first three elements of ```v``` | | ```vec3(v)``` | Return a 3 vector with the first three elements of ```v``` |
| ```vec4(v)``` | Return a 4 vector with the first three elements of ```v``` | | ```vec4(v)``` | Return a 4 vector with the first three elements of ```v``` |
### Modules
| Module | Description |
|:--- |:--- |
| ```position_children(list, t)``` | Position children if they are on the Z = 0 plane when transformed by t |
![maths](tests/png/maths.png) ![maths](tests/png/maths.png)

View File

@ -90,6 +90,14 @@ function euler(R) = let(ay = asin(-R[2][0]), cy = cos(ay)) //! Convert a rotatio
cy ? [ atan2(R[2][1] / cy, R[2][2] / cy), ay, atan2(R[1][0] / cy, R[0][0] / cy) ] cy ? [ atan2(R[2][1] / cy, R[2][2] / cy), ay, atan2(R[1][0] / cy, R[0][0] / cy) ]
: R[2][0] < 0 ? [atan2( R[0][1], R[0][2]), 180, 0] : R[2][0] < 0 ? [atan2( R[0][1], R[0][2]), 180, 0]
: [atan2(-R[0][1], -R[0][2]), -180, 0]; : [atan2(-R[0][1], -R[0][2]), -180, 0];
module position_children(list, t) //! Position children if they are on the Z = 0 plane when transformed by t
for(p = list)
let(q = t * p)
if(abs(transform([0, 0, 0], q).z) < 0.01)
multmatrix(q)
children();
// Matrix inversion: https://www.mathsisfun.com/algebra/matrix-inverse-row-operations-gauss-jordan.html // Matrix inversion: https://www.mathsisfun.com/algebra/matrix-inverse-row-operations-gauss-jordan.html
function augment(m) = let(l = len(m), n = identity(l)) [ //! Augment a matrix by adding an identity matrix to the right function augment(m) = let(l = len(m), n = identity(l)) [ //! Augment a matrix by adding an identity matrix to the right