mirror of
https://github.com/kennetek/gridfinity-rebuilt-openscad.git
synced 2024-05-19 22:04:52 +00:00
Use a more advanced chamfer algorithm for stacking_lip
Removes the need for "h_lip" within that function. Significantly reduces the number of operations. Which is helpful when importing to FreeCAD. Future Work: * Convert chamfer calculations to functions. * Use those functions to replace "h_lip" with a calculated value. * Genericize chamfer code to a module.
This commit is contained in:
parent
015daff2e8
commit
b0b483a172
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
include <standard.scad>
|
include <standard.scad>
|
||||||
|
include <gridfinity-stacking-lip-constants.scad>
|
||||||
|
|
||||||
// ===== User Modules ===== //
|
// ===== User Modules ===== //
|
||||||
|
|
||||||
|
@ -361,49 +362,53 @@ module refined_hole() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Stacking lip based on https://gridfinity.xyz/specification/
|
* @brief Stacking lip with a chamfered top.
|
||||||
* @details Also includes a support base.
|
* @details Based on https://gridfinity.xyz/specification/
|
||||||
|
* Also includes a support base.
|
||||||
*/
|
*/
|
||||||
module stacking_lip() {
|
module stacking_lip_chamfered() {
|
||||||
// Technique: Descriptive constant names are useful, but can be unweildy.
|
// Replace 2D edge with a radius.
|
||||||
// Use abbreviations if they are going to be re-used repeatedly in a small piece of code.
|
// Method used: tangent, tangent, radius algorithm
|
||||||
inner_slope = stacking_lip_inner_slope_height_mm;
|
// See: https://math.stackexchange.com/questions/797828/calculate-center-of-circle-tangent-to-two-lines-in-space
|
||||||
wall_height = stacking_lip_wall_height_mm;
|
before_chamfer = stacking_lip_points[2];
|
||||||
|
to_chamfer = stacking_lip_points[3]; // tip, Point to Chamfer
|
||||||
|
after_chamfer = stacking_lip_points[4];
|
||||||
|
|
||||||
support_wall = stacking_lip_support_wall_height_mm;
|
chamfer_vectors = [
|
||||||
s_total = stacking_lip_support_height_mm;
|
to_chamfer - before_chamfer,
|
||||||
|
after_chamfer - to_chamfer,
|
||||||
|
];
|
||||||
|
|
||||||
polygon([
|
to_chamfer_angle = 180 +
|
||||||
[0, 0], // Inner tip
|
atan2(
|
||||||
[inner_slope, inner_slope], // Go out 45 degrees
|
cross(chamfer_vectors[0], chamfer_vectors[1]),
|
||||||
[inner_slope, inner_slope+wall_height], // Vertical increase
|
chamfer_vectors[0] * chamfer_vectors[1]
|
||||||
[stacking_lip_depth, stacking_lip_height], // Go out 45 degrees
|
);
|
||||||
[stacking_lip_depth, -s_total], // Down to support bottom
|
half_angle = to_chamfer_angle / 2;
|
||||||
[0, -support_wall], // Up and in
|
|
||||||
[0, 0] // Close the shape. Tehcnically not needed.
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// Distance from tip to the center point of the circle.
|
||||||
* @brief Stacking lip with a rounded top.
|
distance_from_edge = r_f1 / sin(half_angle);
|
||||||
*/
|
|
||||||
module stacking_lip_rounded_top() {
|
// Circle's center point
|
||||||
radius_center_y = h_lip - r_f1;
|
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() {
|
union() {
|
||||||
// Create rounded top
|
// Rounded top chamfer
|
||||||
intersection() {
|
translate(concat(chamfer_center_point, [0]))
|
||||||
translate([0, radius_center_y, 0])
|
circle(r = r_f1);
|
||||||
square([stacking_lip_depth, stacking_lip_height]);
|
|
||||||
offset(r = r_f1)
|
// Stacking lip with cutout for circle to fit in
|
||||||
offset(delta = -r_f1)
|
|
||||||
stacking_lip();
|
|
||||||
}
|
|
||||||
// Remove pointed top
|
|
||||||
difference(){
|
difference(){
|
||||||
stacking_lip();
|
polygon(stacking_lip_points);
|
||||||
translate([0, radius_center_y, 0])
|
translate([to_chamfer.x, to_chamfer.y, 0])
|
||||||
square([stacking_lip_depth*2, stacking_lip_height*2]);
|
circle(r = intersection_distance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -416,7 +421,7 @@ module profile_wall(height_mm) {
|
||||||
assert(is_num(height_mm))
|
assert(is_num(height_mm))
|
||||||
translate([1.4, 0, 0]){
|
translate([1.4, 0, 0]){
|
||||||
translate([0, height_mm, 0])
|
translate([0, height_mm, 0])
|
||||||
stacking_lip_rounded_top();
|
stacking_lip_chamfered();
|
||||||
translate([stacking_lip_depth-d_wall/2, 0, 0])
|
translate([stacking_lip_depth-d_wall/2, 0, 0])
|
||||||
square([d_wall/2, height_mm]);
|
square([d_wall/2, height_mm]);
|
||||||
}
|
}
|
||||||
|
|
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,24 +55,6 @@ h_lip = 3.548;
|
||||||
d_wall2 = r_base-r_c1-d_clear*sqrt(2);
|
d_wall2 = r_base-r_c1-d_clear*sqrt(2);
|
||||||
d_magic = -2*d_clear-2*d_wall+d_div;
|
d_magic = -2*d_clear-2*d_wall+d_div;
|
||||||
|
|
||||||
// Stacking Lip
|
|
||||||
// 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;
|
|
||||||
|
|
||||||
|
|
||||||
// Baseplate constants
|
// Baseplate constants
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue