mirror of
https://github.com/kennetek/gridfinity-rebuilt-openscad.git
synced 2024-05-20 06:14:53 +00:00
Merge b0b483a172
into fd4db5aa9f
This commit is contained in:
commit
16b0369795
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
include <standard.scad>
|
||||
include <gridfinity-stacking-lip-constants.scad>
|
||||
|
||||
// ===== User Modules ===== //
|
||||
|
||||
|
@ -125,7 +126,6 @@ module gridfinityInit(gx, gy, h, h0 = 0, l = l_grid, sl = 0) {
|
|||
$dh = h;
|
||||
$dh0 = h0;
|
||||
$style_lip = sl;
|
||||
color("tomato") {
|
||||
difference() {
|
||||
color("firebrick")
|
||||
block_bottom(h0==0?$dh-0.1:h0, gx, gy, l);
|
||||
|
@ -133,9 +133,8 @@ module gridfinityInit(gx, gy, h, h0 = 0, l = l_grid, sl = 0) {
|
|||
}
|
||||
color("royalblue")
|
||||
block_wall(gx, gy, l) {
|
||||
if ($style_lip == 0) profile_wall();
|
||||
else profile_wall2();
|
||||
}
|
||||
if ($style_lip == 0) profile_wall(h);
|
||||
else profile_wall2(h);
|
||||
}
|
||||
}
|
||||
// Function to include in the custom() module to individually slice bins
|
||||
|
@ -362,51 +361,78 @@ module refined_hole() {
|
|||
}
|
||||
}
|
||||
|
||||
module profile_wall_sub_sub() {
|
||||
polygon([
|
||||
[0,0],
|
||||
[d_wall/2,0],
|
||||
[d_wall/2,$dh-1.2-d_wall2+d_wall/2],
|
||||
[d_wall2-d_clear,$dh-1.2],
|
||||
[d_wall2-d_clear,$dh+h_base],
|
||||
[0,$dh+h_base]
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* @brief Stacking lip with a chamfered top.
|
||||
* @details Based on https://gridfinity.xyz/specification/
|
||||
* Also includes a support base.
|
||||
*/
|
||||
module stacking_lip_chamfered() {
|
||||
// Replace 2D edge with a radius.
|
||||
// Method used: tangent, tangent, radius algorithm
|
||||
// See: https://math.stackexchange.com/questions/797828/calculate-center-of-circle-tangent-to-two-lines-in-space
|
||||
before_chamfer = stacking_lip_points[2];
|
||||
to_chamfer = stacking_lip_points[3]; // tip, Point to Chamfer
|
||||
after_chamfer = stacking_lip_points[4];
|
||||
|
||||
module profile_wall_sub() {
|
||||
difference() {
|
||||
profile_wall_sub_sub();
|
||||
color("red")
|
||||
offset(delta = d_clear)
|
||||
translate([r_base-d_clear,$dh,0])
|
||||
mirror([1,0,0])
|
||||
profile_base();
|
||||
chamfer_vectors = [
|
||||
to_chamfer - before_chamfer,
|
||||
after_chamfer - to_chamfer,
|
||||
];
|
||||
|
||||
to_chamfer_angle = 180 +
|
||||
atan2(
|
||||
cross(chamfer_vectors[0], chamfer_vectors[1]),
|
||||
chamfer_vectors[0] * chamfer_vectors[1]
|
||||
);
|
||||
half_angle = to_chamfer_angle / 2;
|
||||
|
||||
// Distance from tip to the center point of the circle.
|
||||
distance_from_edge = r_f1 / sin(half_angle);
|
||||
|
||||
// Circle's center point
|
||||
chamfer_center_vector = [
|
||||
distance_from_edge * sin(half_angle),
|
||||
distance_from_edge * cos(half_angle)
|
||||
];
|
||||
chamfer_center_point = to_chamfer - chamfer_center_vector;
|
||||
|
||||
// Exact point edges intersect the circle
|
||||
intersection_distance = distance_from_edge * cos(half_angle);
|
||||
|
||||
union() {
|
||||
// Rounded top chamfer
|
||||
translate(concat(chamfer_center_point, [0]))
|
||||
circle(r = r_f1);
|
||||
|
||||
// Stacking lip with cutout for circle to fit in
|
||||
difference(){
|
||||
polygon(stacking_lip_points);
|
||||
translate([to_chamfer.x, to_chamfer.y, 0])
|
||||
circle(r = intersection_distance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module profile_wall() {
|
||||
translate([r_base,0,0])
|
||||
mirror([1,0,0])
|
||||
difference() {
|
||||
profile_wall_sub();
|
||||
difference() {
|
||||
translate([0, $dh+h_base-d_clear*sqrt(2), 0])
|
||||
circle(r_base/2);
|
||||
offset(r = r_f1)
|
||||
offset(delta = -r_f1)
|
||||
profile_wall_sub();
|
||||
}
|
||||
// remove any negtive geometry in edge cases
|
||||
mirror([0,1,0])
|
||||
square(100*l_grid);
|
||||
/**
|
||||
* @brief External wall profile, with a stacking lip.
|
||||
* @details The "1.4" constant is to match old behavior.
|
||||
*/
|
||||
module profile_wall(height_mm) {
|
||||
assert(is_num(height_mm))
|
||||
translate([1.4, 0, 0]){
|
||||
translate([0, height_mm, 0])
|
||||
stacking_lip_chamfered();
|
||||
translate([stacking_lip_depth-d_wall/2, 0, 0])
|
||||
square([d_wall/2, height_mm]);
|
||||
}
|
||||
}
|
||||
|
||||
// lipless profile
|
||||
module profile_wall2() {
|
||||
module profile_wall2(height_mm) {
|
||||
assert(is_num(height_mm))
|
||||
translate([r_base,0,0])
|
||||
mirror([1,0,0])
|
||||
square([d_wall,$dh]);
|
||||
square([d_wall, height_mm]);
|
||||
}
|
||||
|
||||
module block_wall(gx, gy, l) {
|
||||
|
|
47
gridfinity-stacking-lip-constants.scad
Normal file
47
gridfinity-stacking-lip-constants.scad
Normal file
|
@ -0,0 +1,47 @@
|
|||
/**
|
||||
* @file gridfinity-stacking-lip-constants.scad
|
||||
* @brief Constants which define the stacking lip.
|
||||
* @copyright MIT License, Arthur Moore 2024.
|
||||
* See LICENSE for more information.
|
||||
*/
|
||||
|
||||
include <standard.scad>
|
||||
|
||||
//Based on https://gridfinity.xyz/specification/
|
||||
stacking_lip_inner_slope_height_mm = 0.7;
|
||||
stacking_lip_wall_height_mm = 1.8;
|
||||
stacking_lip_outer_slope_height_mm = 1.9;
|
||||
|
||||
stacking_lip_depth =
|
||||
stacking_lip_inner_slope_height_mm +
|
||||
stacking_lip_outer_slope_height_mm;
|
||||
stacking_lip_height =
|
||||
stacking_lip_inner_slope_height_mm +
|
||||
stacking_lip_wall_height_mm +
|
||||
stacking_lip_outer_slope_height_mm;
|
||||
|
||||
// Extracted from `profile_wall_sub_sub`.
|
||||
stacking_lip_support_wall_height_mm = 1.2;
|
||||
stacking_lip_support_height_mm =
|
||||
stacking_lip_support_wall_height_mm + d_wall2;
|
||||
|
||||
|
||||
|
||||
// Technique: Descriptive constant names are useful, but can be unweildy.
|
||||
// Use abbreviations if they are going to be re-used repeatedly in a small piece of code.
|
||||
// Python style _ to indicate this is an internal variable.
|
||||
_slishmm = stacking_lip_inner_slope_height_mm;
|
||||
|
||||
/**
|
||||
* @brief Points used to make a stacking lip polygon.
|
||||
* @details Also includes a support base.
|
||||
*/
|
||||
stacking_lip_points = [
|
||||
[0, 0], // Inner tip
|
||||
[_slishmm, _slishmm], // Go out 45 degrees
|
||||
[_slishmm, _slishmm + stacking_lip_wall_height_mm], // Vertical increase
|
||||
[stacking_lip_depth, stacking_lip_height], // Go out 45 degrees
|
||||
[stacking_lip_depth, -stacking_lip_support_height_mm], // Down to support bottom
|
||||
[0, -stacking_lip_support_wall_height_mm], // Up and in
|
||||
[0, 0] // Close the shape. Tehcnically not needed.
|
||||
];
|
|
@ -55,6 +55,7 @@ h_lip = 3.548;
|
|||
d_wall2 = r_base-r_c1-d_clear*sqrt(2);
|
||||
d_magic = -2*d_clear-2*d_wall+d_div;
|
||||
|
||||
|
||||
// Baseplate constants
|
||||
|
||||
// Baseplate bottom part height (part added with weigthed=true)
|
||||
|
|
Loading…
Reference in a new issue