mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-11 09:14:29 +02:00
I deleted wrong file XD
This commit is contained in:
73
src/rounded_extrude.scad
Normal file
73
src/rounded_extrude.scad
Normal file
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* rounded_extrude.scad
|
||||
*
|
||||
* Extrudes a 2D object roundly from 0 to 180 degrees.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib-rounded_extrude.html
|
||||
*
|
||||
**/
|
||||
|
||||
include <__private__/__frags.scad>;
|
||||
include <__private__/__is_vector.scad>;
|
||||
|
||||
module rounded_extrude(size, round_r, angle = 90, twist = 0, convexity = 10) {
|
||||
|
||||
is_vt = __is_vector(size);
|
||||
x = is_vt ? size[0] : size;
|
||||
y = is_vt ? size[1] : size;
|
||||
|
||||
q_corner_frags = __frags(round_r) / 4;
|
||||
|
||||
step_a = angle / q_corner_frags;
|
||||
twist_step = twist / q_corner_frags;
|
||||
|
||||
module layers(pre_x, pre_y, pre_h = 0, i = 1) {
|
||||
module one_layer(current_a) {
|
||||
wx = pre_x;
|
||||
wy = pre_y;
|
||||
|
||||
h = (round_r - pre_h) - round_r * cos(current_a);
|
||||
|
||||
d_leng =
|
||||
round_r * (sin(current_a) - sin(step_a * (i - 1)));
|
||||
|
||||
sx = (d_leng * 2 + wx) / wx;
|
||||
sy = (d_leng * 2 + wy) / wy;
|
||||
|
||||
translate([0, 0, pre_h])
|
||||
rotate(-twist_step * (i - 1))
|
||||
linear_extrude(
|
||||
h,
|
||||
slices = 1,
|
||||
scale = [sx, sy],
|
||||
convexity = convexity,
|
||||
twist = twist_step
|
||||
) scale([wx / x, wy / y])
|
||||
children();
|
||||
|
||||
test_rounded_extrude_data(i, wx, wy, pre_h, sx, sy);
|
||||
|
||||
layers(wx * sx, wy * sy, h + pre_h, i + 1)
|
||||
children();
|
||||
|
||||
}
|
||||
|
||||
if(i <= q_corner_frags) {
|
||||
one_layer(i * step_a)
|
||||
children();
|
||||
} else if(i - q_corner_frags < 1) {
|
||||
one_layer(q_corner_frags * step_a)
|
||||
children();
|
||||
}
|
||||
}
|
||||
|
||||
layers(x, y)
|
||||
children();
|
||||
}
|
||||
|
||||
module test_rounded_extrude_data(i, wx, wy, pre_h, sx, sy) {
|
||||
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
include <unittest.scad>;
|
||||
|
||||
module test_rounded_extrude() {
|
||||
echo("==== test_rounded_extrude ====");
|
||||
|
||||
include <rounded_extrude.scad>;
|
||||
|
||||
expected_data =
|
||||
[
|
||||
[],
|
||||
[20, 20, 0, 1.06526, 1.06526],
|
||||
[21.3053, 21.3053, 0.0427757, 1.06022, 1.06022],
|
||||
[22.5882, 22.5882, 0.170371, 1.05484, 1.05484],
|
||||
[23.8268, 23.8268, 0.380602, 1.04924, 1.04924],
|
||||
[25, 25, 0.669873, 1.0435, 1.0435],
|
||||
[26.0876, 26.0876, 1.03323, 1.0377, 1.0377],
|
||||
[27.0711, 27.0711, 1.46447, 1.03186, 1.03186],
|
||||
[27.9335, 27.9335, 1.95619, 1.02602, 1.02602],
|
||||
[28.6603, 28.6603, 2.5, 1.02019, 1.02019],
|
||||
[29.2388, 29.2388, 3.08658, 1.01438, 1.01438],
|
||||
[29.6593, 29.6593, 3.7059, 1.0086, 1.0086],
|
||||
[29.9144, 29.9144, 4.34737, 1.00286, 1.00286]
|
||||
];
|
||||
|
||||
module test_rounded_extrude_data(i, wx, wy, pre_h, sx, sy) {
|
||||
data = [wx, wy, pre_h, sx, sy];
|
||||
|
||||
for(j = [0:4]) {
|
||||
expected = round_n(expected_data[i][j]);
|
||||
actual = round_n(data[j]);
|
||||
assertEqual(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
$fn = 48;
|
||||
|
||||
circle_r = 10;
|
||||
round_r = 5;
|
||||
|
||||
rounded_extrude(circle_r * 2, round_r)
|
||||
circle(circle_r);
|
||||
}
|
||||
|
||||
test_rounded_extrude();
|
||||
|
||||
|
Reference in New Issue
Block a user