Layers skin implemented
This commit is contained in:
parent
b6c0bf985b
commit
5ad9149ba8
@ -3,8 +3,9 @@
|
||||
"parameterSets": {
|
||||
"New set 1": {
|
||||
"$fn": "32",
|
||||
"draw_profile": "true",
|
||||
"show_debug_layers": "false"
|
||||
"draw_fin": "true",
|
||||
"draw_profile": "false",
|
||||
"show_debug_layers": "true"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,11 +53,11 @@ 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;
|
||||
@ -109,23 +109,58 @@ function backPoint() = [fin_base-(fin_back_widthdraw/100*fin_base),fin_back_heig
|
||||
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);
|
||||
|
||||
|
||||
pathProfile = pathProfile( control_points );
|
||||
// Surf Fin profile
|
||||
fin_profile = pathProfile( control_points );
|
||||
|
||||
//base = square([fin_base,13 ], center=true);
|
||||
//base = [[0,0],[fin_base,0],[fin_base,-base_extra_thickness],[0,-base_extra_thickness]];
|
||||
//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]];
|
||||
// ****************
|
||||
// * 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));
|
||||
|
||||
|
||||
|
||||
// ****************
|
||||
// * 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);
|
||||
|
||||
}
|
||||
color("Red") cube([fin_base+20,base_extra_thickness+20,base_tickness+20],anchor=LEFT+BACK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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));
|
||||
|
||||
//path = concat(remove_last_item(pathProfile), base);
|
||||
//path = concat(pathProfile, base);
|
||||
path = addBase(path);
|
||||
|
||||
|
||||
|
||||
@ -134,8 +169,6 @@ if (false) {
|
||||
|
||||
|
||||
|
||||
path2 = offset(path,delta=-10,chamfer=true);
|
||||
path3 = offset(path2,delta=-10,chamfer=true);
|
||||
|
||||
|
||||
up (80) color("Green") polygon(path2);
|
||||
@ -178,7 +211,7 @@ if (false) {
|
||||
//up(80) path_extrude(lin_path) [polygon(path),polygon(path2)]; //path;
|
||||
|
||||
//skin([octagon(4), circle($fn=70,r=2)], z=[0,3], slices=10);
|
||||
skin([path,path2/*,path3*/],slices=0,z=[0,base_tickness/2/*,6*/]);
|
||||
|
||||
|
||||
|
||||
|
||||
@ -191,16 +224,20 @@ if (false) {
|
||||
|
||||
|
||||
if (show_debug_layers) {
|
||||
showDebugPath(path);
|
||||
left(300) {
|
||||
showDebugPath(layer_0);
|
||||
showDebugPath(layer_1);
|
||||
showDebugPath(layer_2);
|
||||
}
|
||||
//showDebugPath(layer_3);
|
||||
|
||||
}
|
||||
if (draw_profile) {
|
||||
// Draw fin profile
|
||||
// Draw fin profile
|
||||
drawProfile( control_points, true );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Displays debug information for a path by visualizing its self-crossings.
|
||||
*
|
||||
@ -211,12 +248,10 @@ if (draw_profile) {
|
||||
* - 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");
|
||||
paths = split_path_at_self_crossings(path);
|
||||
//left(100)
|
||||
rainbow(paths)
|
||||
rainbow(split_path_at_self_crossings(path))
|
||||
stroke($item, closed=false, width=1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -251,6 +286,18 @@ module drawProfile( points,debug = true ){
|
||||
* - 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]);
|
||||
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