Source cleanup and comments
This commit is contained in:
parent
64f4c01d71
commit
b6c0bf985b
10
SurfFins.json
Normal file
10
SurfFins.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"fileFormatVersion": "1",
|
||||||
|
"parameterSets": {
|
||||||
|
"New set 1": {
|
||||||
|
"$fn": "32",
|
||||||
|
"draw_profile": "true",
|
||||||
|
"show_debug_layers": "false"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
231
SurfFins.scad
231
SurfFins.scad
@ -5,6 +5,11 @@ include <BOSL2/rounding.scad>;
|
|||||||
include <BOSL2/skin.scad>;
|
include <BOSL2/skin.scad>;
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************/
|
||||||
|
/* Parameters */
|
||||||
|
/************************************************/
|
||||||
|
|
||||||
|
/* [Fin Specs] */
|
||||||
|
|
||||||
fin_height = 250; // 10 inches in mm
|
fin_height = 250; // 10 inches in mm
|
||||||
fin_width = 240; // Width at the base in mm
|
fin_width = 240; // Width at the base in mm
|
||||||
@ -20,8 +25,6 @@ fin_counter_strength = 20; // Length [Point 2]
|
|||||||
fin_base = 200; // Width at the base in mm
|
fin_base = 200; // Width at the base in mm
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fin_width_tip = 5; // Width at the tip in mm
|
fin_width_tip = 5; // Width at the tip in mm
|
||||||
fin_thickness = 5; // Thickness of the fin in mm
|
fin_thickness = 5; // Thickness of the fin in mm
|
||||||
|
|
||||||
@ -34,118 +37,57 @@ fin_back_widthdraw = 20; // Percent height
|
|||||||
fin_back_angle = 20; // back angle
|
fin_back_angle = 20; // back angle
|
||||||
fin_back_strength=30;
|
fin_back_strength=30;
|
||||||
|
|
||||||
|
/* [Base Specs] */
|
||||||
|
|
||||||
|
|
||||||
base_tickness=9.2;
|
base_tickness=9.2;
|
||||||
base_extra_thickness=40;
|
base_extra_thickness=80;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* [Debugging] */
|
||||||
|
|
||||||
|
//Showing all layers
|
||||||
|
show_debug_layers = false;
|
||||||
|
|
||||||
|
// Draw master profile
|
||||||
|
draw_profile = false;
|
||||||
|
|
||||||
|
/************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$fn=32;
|
||||||
|
|
||||||
|
|
||||||
pt1_x = adj_ang_to_opp(fin_height,fin_sweep)+fin_base/2;
|
pt1_x = adj_ang_to_opp(fin_height,fin_sweep)+fin_base/2;
|
||||||
pt1_y = fin_height;
|
pt1_y = fin_height;
|
||||||
|
|
||||||
$fn=32;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
control_points_new = [
|
|
||||||
// *****************
|
|
||||||
// Under POINT
|
|
||||||
// *****************
|
|
||||||
[0,-13], //Point init
|
|
||||||
[0,0], // Handle init point
|
|
||||||
// [0,0],
|
|
||||||
//[0,-13],
|
|
||||||
//[0,-13],
|
|
||||||
// *****************
|
|
||||||
// Init POINT
|
|
||||||
// *****************
|
|
||||||
|
|
||||||
//[opp_ang_to_adj(fin_height/3,fin_start_angle),-fin_height/3],
|
|
||||||
|
|
||||||
//[-50,0], // Point 0
|
|
||||||
|
|
||||||
|
|
||||||
//[0,50], // Start handle Init
|
|
||||||
[0,-13], // Start handle Init
|
|
||||||
[0,0], // Init point
|
|
||||||
[0,30], //
|
|
||||||
[0,50],
|
|
||||||
|
|
||||||
|
|
||||||
//[0,0],
|
|
||||||
//[0,0],
|
|
||||||
[opp_ang_to_adj(fin_height/3,fin_start_angle) , fin_height/3], //Point init
|
|
||||||
// Handle 0
|
|
||||||
|
|
||||||
// *****************
|
|
||||||
// TOP
|
|
||||||
// *****************
|
|
||||||
[pt1_x-100,pt1_y], // Handle 1 ()
|
|
||||||
[pt1_x,pt1_y], // Point 1
|
|
||||||
[pt1_x+30,pt1_y], // Handle 1 (End)
|
|
||||||
|
|
||||||
// *****************
|
|
||||||
// COUNTER POINT
|
|
||||||
// *****************
|
|
||||||
handleStart(fin_width,fin_top_withdraw,fin_counter_angle,fin_counter_strength),
|
|
||||||
counterTop(fin_width,fin_top_withdraw), // [250,220], // Point 2
|
|
||||||
handleEnd(fin_width,fin_top_withdraw,fin_counter_angle,fin_counter_strength),
|
|
||||||
|
|
||||||
// *****************
|
|
||||||
// BACK POINT
|
|
||||||
// *****************
|
|
||||||
handle(backPoint(),fin_back_angle,fin_back_strength),
|
|
||||||
backPoint(),
|
|
||||||
handle(backPoint(),-fin_back_angle,fin_back_strength),
|
|
||||||
|
|
||||||
// *****************
|
|
||||||
// END POINT
|
|
||||||
// *****************
|
|
||||||
endHandle(fin_end_angle), // End Handle
|
|
||||||
[fin_base,0], // End point
|
|
||||||
[fin_base,0],
|
|
||||||
// [fin_base,-20],
|
|
||||||
|
|
||||||
// *****************
|
|
||||||
// BASE LAST
|
|
||||||
// *****************
|
|
||||||
/*
|
|
||||||
[fin_base,-13],
|
|
||||||
[fin_base,-13],
|
|
||||||
[fin_base,-13]
|
|
||||||
*/
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
control_points = [
|
control_points = [
|
||||||
|
// *****************
|
||||||
|
// INITIAL POINT
|
||||||
|
// *****************
|
||||||
[0,0], // Point 0
|
[0,0], // Point 0
|
||||||
[opp_ang_to_adj(fin_height/3,fin_start_angle),fin_height/3], // Handle 0
|
[opp_ang_to_adj(fin_height/3,fin_start_angle),fin_height/3], // Handle 0
|
||||||
|
// *****************
|
||||||
|
// TOP POINT
|
||||||
[pt1_x-100,pt1_y], // Handle 1 ()
|
// *****************
|
||||||
//[220,250], // Point 1
|
[pt1_x-100,pt1_y], // Handle 1 (Start)
|
||||||
[pt1_x,pt1_y], // Point 1
|
[pt1_x,pt1_y], // Point 1
|
||||||
[pt1_x+30,pt1_y], // Handle 1 (End)
|
[pt1_x+30,pt1_y], // Handle 1 (End)
|
||||||
|
|
||||||
// *****************
|
// *****************
|
||||||
// COUNTER POINT
|
// COUNTER POINT
|
||||||
// *****************
|
// *****************
|
||||||
handleStart(fin_width,fin_top_withdraw,fin_counter_angle,fin_counter_strength),
|
handleStart(fin_width,fin_top_withdraw,fin_counter_angle,fin_counter_strength),
|
||||||
counterTop(fin_width,fin_top_withdraw), // [250,220], // Point 2
|
counterTop(fin_width,fin_top_withdraw), // [250,220], // Point 2
|
||||||
handleEnd(fin_width,fin_top_withdraw,fin_counter_angle,fin_counter_strength),
|
handleEnd(fin_width,fin_top_withdraw,fin_counter_angle,fin_counter_strength),
|
||||||
|
|
||||||
// *****************
|
// *****************
|
||||||
// BACK POINT
|
// BACK POINT
|
||||||
// *****************
|
// *****************
|
||||||
|
|
||||||
//[165,100], // Handle 2 (Start)
|
|
||||||
handle(backPoint(),fin_back_angle,fin_back_strength),
|
handle(backPoint(),fin_back_angle,fin_back_strength),
|
||||||
//[155,80], // Point 2
|
|
||||||
backPoint(),
|
backPoint(),
|
||||||
handle(backPoint(),-fin_back_angle,fin_back_strength),
|
handle(backPoint(),-fin_back_angle,fin_back_strength),
|
||||||
// [145,60], // Handle 2 (End)
|
|
||||||
|
|
||||||
|
|
||||||
//[250,230],
|
|
||||||
|
|
||||||
// *****************
|
// *****************
|
||||||
// END POINT
|
// END POINT
|
||||||
// *****************
|
// *****************
|
||||||
@ -154,12 +96,9 @@ control_points = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function counterTop(x,withdraw) = [x, x-withdraw ];
|
function counterTop(x,withdraw) = [x, x-withdraw ];
|
||||||
function handleStart(x,withdraw,angle,strength) = [x+adj_ang_to_opp(strength,angle), x-withdraw +strength];
|
function handleStart(x,withdraw,angle,strength) = [x+adj_ang_to_opp(strength,angle), x-withdraw +strength];
|
||||||
function handleEnd(x,withdraw,angle,strength) = [x-adj_ang_to_opp(strength,angle), x-withdraw -strength];
|
function handleEnd(x,withdraw,angle,strength) = [x-adj_ang_to_opp(strength,angle), x-withdraw -strength];
|
||||||
|
|
||||||
|
|
||||||
function endHandle(angle)=
|
function endHandle(angle)=
|
||||||
angle < 90 ?
|
angle < 90 ?
|
||||||
[fin_base + adj_ang_to_opp(fin_end_strength,90-angle),fin_end_strength]
|
[fin_base + adj_ang_to_opp(fin_end_strength,90-angle),fin_end_strength]
|
||||||
@ -171,47 +110,39 @@ function handle(point,angle,strength) = [point[0] + adj_ang_to_opp(strength,angl
|
|||||||
function decrease_y(points, percentage) = [ for (p = points) [p[0], p[1] * (1 - percentage/100)]];
|
function decrease_y(points, percentage) = [ for (p = points) [p[0], p[1] * (1 - percentage/100)]];
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Draw Profile
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
module drawProfile( points,debug = true ){
|
|
||||||
pt = [100,0];
|
|
||||||
pos = bezpath_closest_point(points, pt);
|
|
||||||
xy = bezpath_points(points,pos[0],pos[1]);
|
|
||||||
debug_bezier(points, N=3);
|
|
||||||
//color("red") translate(pt) sphere(r=6);
|
|
||||||
//color("blue") translate(xy) sphere(r=6);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw fin profile
|
|
||||||
drawProfile( control_points, true );
|
|
||||||
|
|
||||||
function pathProfile(points) = bezpath_curve(points,N=3);
|
function pathProfile(points) = bezpath_curve(points,N=3);
|
||||||
|
|
||||||
|
function remove_last(arr) = select(arr, 0, len(arr) - 2);
|
||||||
|
|
||||||
|
|
||||||
//path = bezpath_curve(control_points,N=3);
|
|
||||||
pathProfile = pathProfile( control_points );
|
pathProfile = pathProfile( control_points );
|
||||||
|
|
||||||
//base = square([fin_base,13 ], center=true);
|
//base = square([fin_base,13 ], center=true);
|
||||||
base = [[0,0],[fin_base,0],[fin_base,-base_extra_thickness],[0,-base_extra_thickness]];
|
//base = [[0,0],[fin_base,0],[fin_base,-base_extra_thickness],[0,-base_extra_thickness]];
|
||||||
path = concat(pathProfile, base);
|
//base = [/*[fin_base,0],*/[fin_base,-base_extra_thickness],[0,-base_extra_thickness],[0,0]];
|
||||||
|
//base = [/*[fin_base,0],*/[fin_base,-base_extra_thickness],[0,-base_extra_thickness]];
|
||||||
|
|
||||||
//up (40) polygon(path,);
|
//path = concat(remove_last_item(pathProfile), base);
|
||||||
//up (40) color("Red") polygon(base);
|
//path = concat(pathProfile, base);
|
||||||
up (40) color("Red") polygon(path);
|
path = addBase(path);
|
||||||
|
|
||||||
|
|
||||||
//stroke(path,dots=true,dots_color="red");
|
|
||||||
|
|
||||||
//up (0) polygon(path);
|
|
||||||
|
if (false) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
path2 = offset(path,delta=-10,chamfer=true);
|
path2 = offset(path,delta=-10,chamfer=true);
|
||||||
path3 = offset(path2,delta=-10,chamfer=true);
|
path3 = offset(path2,delta=-10,chamfer=true);
|
||||||
|
|
||||||
|
|
||||||
|
up (80) color("Green") polygon(path2);
|
||||||
|
|
||||||
//path2[0][1] = 0;
|
//path2[0][1] = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
path2b = concat(
|
path2b = concat(
|
||||||
[[0, 0]], // New first point
|
[[0, 0]], // New first point
|
||||||
[for (i = [1:len(path2)-1]) path2[i]] // Rest of the points unchanged
|
[for (i = [1:len(path2)-1]) path2[i]] // Rest of the points unchanged
|
||||||
@ -222,6 +153,7 @@ path3b = concat(
|
|||||||
);
|
);
|
||||||
echo("path2",path2);
|
echo("path2",path2);
|
||||||
echo("path2b",path2b);
|
echo("path2b",path2b);
|
||||||
|
*/
|
||||||
|
|
||||||
//path2 = bezpath_curve(decrease_y(control_points,10),N=3);
|
//path2 = bezpath_curve(decrease_y(control_points,10),N=3);
|
||||||
|
|
||||||
@ -255,3 +187,70 @@ path_extrude2d(path, caps=true, closed=false)
|
|||||||
move_copies([[-3.5,1.5],[0.0,3.0],[3.5,1.5]])
|
move_copies([[-3.5,1.5],[0.0,3.0],[3.5,1.5]])
|
||||||
circle(r=1.5);
|
circle(r=1.5);
|
||||||
*/
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (show_debug_layers) {
|
||||||
|
showDebugPath(path);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (draw_profile) {
|
||||||
|
// Draw fin profile
|
||||||
|
drawProfile( control_points, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays debug information for a path by visualizing its self-crossings.
|
||||||
|
*
|
||||||
|
* @param path - The input path to analyze for self-crossings.
|
||||||
|
*
|
||||||
|
* This module:
|
||||||
|
* - Splits the path at points where it intersects itself.
|
||||||
|
* - Renders each segment of the split path with different colors for easy identification.
|
||||||
|
*/
|
||||||
|
module showDebugPath(path) {
|
||||||
|
assert(is_path_simple(path),"Path is not simple");
|
||||||
|
paths = split_path_at_self_crossings(path);
|
||||||
|
//left(100)
|
||||||
|
rainbow(paths)
|
||||||
|
stroke($item, closed=false, width=1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a profile based on Bezier path points with optional debug visualization.
|
||||||
|
*
|
||||||
|
* @param points - Array of points defining the Bezier path.
|
||||||
|
* @param debug - Boolean flag to enable/disable debug visualization. Defaults to true.
|
||||||
|
*
|
||||||
|
* This module:
|
||||||
|
* - Calculates the closest point on the Bezier path to a fixed point.
|
||||||
|
* - Draws the Bezier path with debug information if debug is true.
|
||||||
|
* - Optionally shows spheres at specific points for debugging (currently commented out).
|
||||||
|
*/
|
||||||
|
module drawProfile( points,debug = true ){
|
||||||
|
pt = [100,0];
|
||||||
|
pos = bezpath_closest_point(points, pt);
|
||||||
|
xy = bezpath_points(points,pos[0],pos[1]);
|
||||||
|
debug_bezier(points, N=3);
|
||||||
|
//color("red") translate(pt) sphere(r=6);
|
||||||
|
//color("blue") translate(xy) sphere(r=6);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a base to the given path by extending it with additional points.
|
||||||
|
*
|
||||||
|
* @param path - The original path to which the base will be added.
|
||||||
|
* @return A new path with an added base.
|
||||||
|
*
|
||||||
|
* This function concatenates:
|
||||||
|
* - The original path (`pathProfile`).
|
||||||
|
* - A point `fin_base` which might represent the start or end of the base.
|
||||||
|
* - Points for additional thickness (`-base_extra_thickness`) at both ends of the base.
|
||||||
|
*/
|
||||||
|
function addBase(path) = concat(pathProfile,[fin_base,-base_extra_thickness],[0,-base_extra_thickness]);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user