declutter catear_v3

This commit is contained in:
djerun 2025-07-08 12:51:04 +02:00
commit 165c80b1d4
2 changed files with 30 additions and 21 deletions

View file

@ -13,33 +13,36 @@ EAR_ANGLE = 42;
WITH_RAKE = true;
DETAILS = true;
catear_v3_control_points = function (S, sf, bf, mn, a) let (s=S/2, R=rotation_matrix(a)) [
[ s , 0, 0],
[ S*bf, S*sf*mn, 0] * R,
[-S*bf, S*sf*mn, 0] * R,
[-s , 0, 0],
];
/**
* unsupported parameters: chamfer, chamfer_shape, details, end_caps
*/
module catear_v3(height, thickness, fractal=0, side_len=30, bend_factor=0.15, stretch_factor=1.2, debug=false, chamfer=CHAMFER, chamfer_shape=CHAMFER_SHAPE, details=true, end_caps=true, skew=2.0) {
S = side_len;
s = S/2;
sf = stretch_factor;
bf = bend_factor*2;
mn = 1.16; // magic number
f=skew*S*0.2;
a = skew*10;
R = [[cos(a), -sin(a), 0],
[sin(a), cos(a), 0],
[ 0, 0, 1]];
A = [ s , 0, 0];
B = [ S*bf, S*sf*mn, 0] * R;
C = [-S*bf, S*sf*mn, 0] * R;
D = [-s , 0, 0];
curve_vertices = bezier_curve_vertices([A, B, C, D], $fn);
module catear_v3(height, thickness, fractal=0, side_len=30, bend_factor=0.15, stretch_factor=1.2, debug=false, chamfer=CHAMFER, chamfer_shape=CHAMFER_SHAPE, details=true, end_caps=true, skew=2.0, $fn=$fn) {
control_points = catear_v3_control_points(
S=side_len,
sf=stretch_factor,
bf=bend_factor,
mn=1.16,
a=skew*10
);
curve_vertices = bezier_curve_vertices(control_points, $fn);
if (debug) {
translate([0, 0, 2*height]) rotate(90) bezier_curve_debug([A, B, C, D]);
translate([0, 0, 2*height]) rotate(90) bezier_curve_debug(control_points);
echo("curve_vertices: ", curve_vertices);
}
rotate(90) render_curve(curve_vertices, width=thickness, height=height, chamfer=chamfer, debug=debug);
rotate(90) render_curve(
curve_vertices,
width=thickness,
height=height,
chamfer=chamfer,
debug=debug
);
}
/**

View file

@ -14,6 +14,12 @@ mat_T = function (mat) [
]
];
rotation_matrix = function(a) [
[cos(a), -sin(a), 0],
[sin(a), cos(a), 0],
[ 0, 0, 1]
];
bezier_matrix = [[1, -3, 3, -1],
[0, 3, -6, 3],
[0, 0, 3, -3],