Compare commits
3 Commits
8378d8d105
...
5ad9149ba8
Author | SHA1 | Date | |
---|---|---|---|
5ad9149ba8 | |||
b6c0bf985b | |||
64f4c01d71 |
11
SurfFins.json
Normal file
11
SurfFins.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"fileFormatVersion": "1",
|
||||||
|
"parameterSets": {
|
||||||
|
"New set 1": {
|
||||||
|
"$fn": "32",
|
||||||
|
"draw_fin": "true",
|
||||||
|
"draw_profile": "false",
|
||||||
|
"show_debug_layers": "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
299
SurfFins.scad
299
SurfFins.scad
@ -1,30 +1,15 @@
|
|||||||
|
|
||||||
include <BOSL2/std.scad>;
|
include <BOSL2/std.scad>;
|
||||||
include <BOSL2/beziers.scad>;
|
include <BOSL2/beziers.scad>;
|
||||||
|
include <BOSL2/rounding.scad>;
|
||||||
|
include <BOSL2/skin.scad>;
|
||||||
|
|
||||||
|
|
||||||
if (false) {
|
/************************************************/
|
||||||
|
/* Parameters */
|
||||||
bez = [[0,0], [30,30], [80,0]];
|
/************************************************/
|
||||||
debug_bezier(bez, N=len(bez)-1);
|
|
||||||
translate(bezier_points(bez, 0.3)) color("red") sphere(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (false) {
|
|
||||||
bez = [[0,0], [5,35], [60,-25], [80,0]];
|
|
||||||
debug_bezier(bez, N=len(bez)-1);
|
|
||||||
pts = bezier_points(bez, [0:0.2:1]);
|
|
||||||
rainbow(pts) move($item) sphere(1.5, $fn=12);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (false) {
|
|
||||||
|
|
||||||
bez = [[0,0], [5,15], [40,20], [60,-15], [80,0]];
|
|
||||||
move_copies(bezier_curve(bez, 8)) sphere(r=1.5, $fn=12);
|
|
||||||
debug_bezier(bez, N=len(bez)-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* [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
|
||||||
@ -40,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
|
||||||
|
|
||||||
@ -54,99 +37,267 @@ 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_extra_thickness=80;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* [Debugging] */
|
||||||
|
|
||||||
|
//Showing all layers
|
||||||
|
show_debug_layers = false;
|
||||||
|
|
||||||
|
// Draw master profile
|
||||||
|
draw_profile = false;
|
||||||
|
|
||||||
|
draw_fin = true;
|
||||||
|
|
||||||
|
|
||||||
|
$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;
|
||||||
|
|
||||||
|
|
||||||
|
control_points = [
|
||||||
pt = [100,0];
|
// *****************
|
||||||
bez = [
|
// 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
|
||||||
// *****************
|
// *****************
|
||||||
endHandle(fin_end_angle), // End Handle
|
endHandle(fin_end_angle), // End Handle
|
||||||
[fin_base,0] // End point
|
[fin_base,0] // End point
|
||||||
];
|
];
|
||||||
pos = bezpath_closest_point(bez, pt);
|
|
||||||
xy = bezpath_points(bez,pos[0],pos[1]);
|
|
||||||
debug_bezier(bez, N=3);
|
|
||||||
color("red") translate(pt) sphere(r=1);
|
|
||||||
color("blue") translate(xy) sphere(r=1);
|
|
||||||
|
|
||||||
|
|
||||||
echo ("pt1_x",pt1_x);
|
|
||||||
|
|
||||||
|
|
||||||
function counterTop(x,withdraw) = [x, x-withdraw ];
|
function counterTop(x,withdraw) = [x, x-withdraw ];
|
||||||
function handleStart(x,withdraw,angle,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];
|
||||||
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]
|
||||||
:
|
:
|
||||||
[fin_base - adj_ang_to_opp(fin_end_strength,angle-90),fin_end_strength]
|
[fin_base - adj_ang_to_opp(fin_end_strength,angle-90),fin_end_strength]
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
//function backPoint() = [fin_base-fin_base * fin_back_widthdraw/100]; //[155,80];
|
|
||||||
function backPoint() = [fin_base-(fin_back_widthdraw/100*fin_base),fin_back_height/100*fin_height];
|
function backPoint() = [fin_base-(fin_back_widthdraw/100*fin_base),fin_back_height/100*fin_height];
|
||||||
|
function handle(point,angle,strength) = [point[0] + adj_ang_to_opp(strength,angle),point[1] + (angle>0 ? strength :-strength)];
|
||||||
|
function decrease_y(points, percentage) = [ for (p = points) [p[0], p[1] * (1 - percentage/100)]];
|
||||||
|
|
||||||
|
function pathProfile(points) = bezpath_curve(points,N=3);
|
||||||
|
|
||||||
|
function remove_last(arr) = select(arr, 0, len(arr) - 2);
|
||||||
|
|
||||||
|
|
||||||
function handle(point,angle,strength)=
|
// Surf Fin profile
|
||||||
[
|
fin_profile = pathProfile( control_points );
|
||||||
point[0] + adj_ang_to_opp(strength,angle) ,
|
|
||||||
point[1] + (angle>0 ? strength : -strength)
|
// ****************
|
||||||
];
|
// * Slicing *
|
||||||
|
// ****************
|
||||||
|
|
||||||
|
layer_0 = addBase(fin_profile); // Master layer with base
|
||||||
|
layer_1 = offset(layer_0,delta=-10,chamfer=true);
|
||||||
|
//layer_2 = offset(layer_0,delta=-20,chamfer=true);
|
||||||
|
layer_2 = offset(layer_1,delta=-15,chamfer=true);
|
||||||
|
//layer_3 = offset(layer_2,delta=-2,chamfer=true);
|
||||||
|
|
||||||
|
layers= [layer_0,layer_1,layer_2];
|
||||||
|
echo ("Layers count ",len(layers));
|
||||||
|
|
||||||
|
|
||||||
//echo ("*** EndHandle",endHandle(70));
|
|
||||||
|
|
||||||
//echo ("*** test",[fin_base-(fin_back_widthdraw/100*fin_base),(fin_back_height/100*fin_height)]);
|
// ****************
|
||||||
|
// * Fin Drawing *
|
||||||
|
// ****************
|
||||||
|
if (draw_fin) {
|
||||||
|
difference(){
|
||||||
|
union() {
|
||||||
|
buildFinSide([layer_0,layer_1,layer_2],base_tickness/2);
|
||||||
|
zflip() buildFinSide([layer_0,layer_1,layer_2],base_tickness/2);
|
||||||
|
|
||||||
echo ("*** handle 0",handle(backPoint(),0,fin_back_strength));
|
}
|
||||||
echo ("*** handle +30",handle(backPoint(),fin_back_angle,fin_back_strength));
|
color("Red") cube([fin_base+20,base_extra_thickness+20,base_tickness+20],anchor=LEFT+BACK);
|
||||||
echo ("*** handle -30",handle(backPoint(),-fin_back_angle,fin_back_strength));
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build fin side
|
||||||
|
*
|
||||||
|
* @param layers - Layers path as array
|
||||||
|
* @param thickness - thickness of half fin
|
||||||
|
*/
|
||||||
|
module buildFinSide(layers,thickness,flip=false) {
|
||||||
|
//right(200)
|
||||||
|
color("Grey") skin(layers,slices=0,z=layerHeights(len(layers),thickness));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
echo ("layerHeights(3,thickness):",layerHeights(3,base_tickness/2));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (false) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
up (80) color("Green") polygon(path2);
|
||||||
|
|
||||||
|
//path2[0][1] = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
path2b = concat(
|
||||||
|
[[0, 0]], // New first point
|
||||||
|
[for (i = [1:len(path2)-1]) path2[i]] // Rest of the points unchanged
|
||||||
|
);
|
||||||
|
path3b = concat(
|
||||||
|
[[0, 0]], // New first point
|
||||||
|
[for (i = [1:len(path3)-1]) path3[i]] // Rest of the points unchanged
|
||||||
|
);
|
||||||
|
echo("path2",path2);
|
||||||
|
echo("path2b",path2b);
|
||||||
|
*/
|
||||||
|
|
||||||
|
//path2 = bezpath_curve(decrease_y(control_points,10),N=3);
|
||||||
|
|
||||||
|
//path2 = offset_path(path, -20, closed=true);
|
||||||
|
|
||||||
|
|
||||||
|
if (false) up (10) color("Red") %polygon(path2);
|
||||||
|
if (false) up (12) color("Blue") %polygon(path3);
|
||||||
|
|
||||||
|
|
||||||
|
if (false) up(50) color("Green") offset_sweep(path, height=20, bottom=os_circle(r=10), top=os_circle(r=10), steps=15);
|
||||||
|
|
||||||
|
sinwave = os_profile(points=[for(theta=[0:5:720]) [4*sin(theta), theta/700*15]]);
|
||||||
|
|
||||||
|
if (false) up(80) color("Yellow") offset_sweep(path, height=20, top=sinwave, $fn=32);
|
||||||
|
|
||||||
|
|
||||||
|
lin_path=[[300,0,0],[300,20,0],[300,100,0]];
|
||||||
|
//lin_path = [ [0, 0, 0], [33, 33, 33], [66, 33, 40], [100, 0, 0], [150,0,0] ];
|
||||||
|
|
||||||
|
//up(80) path_extrude(lin_path) circle(r=30, $fn=6); //path;
|
||||||
|
//up(80) path_extrude(lin_path) [polygon(path),polygon(path2)]; //path;
|
||||||
|
|
||||||
|
//skin([octagon(4), circle($fn=70,r=2)], z=[0,3], slices=10);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
path_extrude2d(path, caps=true, closed=false)
|
||||||
|
move_copies([[-3.5,1.5],[0.0,3.0],[3.5,1.5]])
|
||||||
|
circle(r=1.5);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (show_debug_layers) {
|
||||||
|
left(300) {
|
||||||
|
showDebugPath(layer_0);
|
||||||
|
showDebugPath(layer_1);
|
||||||
|
showDebugPath(layer_2);
|
||||||
|
}
|
||||||
|
//showDebugPath(layer_3);
|
||||||
|
|
||||||
|
}
|
||||||
|
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(path),"Path to show is not a path");
|
||||||
|
assert(is_path_simple(path),"Path is not simple");
|
||||||
|
rainbow(split_path_at_self_crossings(path))
|
||||||
|
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(path,[[fin_base,-base_extra_thickness],[0,-base_extra_thickness]]);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates heights for n layers where the first layer starts at 0 and the last at fin_thickness.
|
||||||
|
*
|
||||||
|
* @param n - Number of layers.
|
||||||
|
* @param fin_thickness - The total height to be divided.
|
||||||
|
* @return An array where each element represents the height of the top of each layer.
|
||||||
|
*/
|
||||||
|
function layerHeights(n, fin_thickness) =
|
||||||
|
let(
|
||||||
|
layer_height = fin_thickness / (n - 1)
|
||||||
|
)
|
||||||
|
[ for (i = [0 : n-1]) i * layer_height ];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user