1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 14:18:13 +01:00

added rounded_extrude

This commit is contained in:
Justin Lin 2017-05-14 17:07:52 +08:00
parent ea2b150fb5
commit 87828cef10
4 changed files with 106 additions and 8 deletions

View File

@ -74,14 +74,9 @@ Too many dependencies? Because OpenSCAD doesn't provide namespace management, I
- [box_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-box_extrude.html) - [box_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-box_extrude.html)
- [ellipse_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-ellipse_extrude.html) - [ellipse_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-ellipse_extrude.html)
- [stereographic_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-stereographic_extrude.html) - [stereographic_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-stereographic_extrude.html)
- [path_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-path_extrude.html) - [rounded_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-rounded_extrude.html)
- [ring_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-ring_extrude.html)
- [helix_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-helix_extrude.html)
- [golden_spiral_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-golden_spiral_extrude.html)
- [archimedean_spiral_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-archimedean_spiral_extrude.html)
- [sphere_spiral_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-sphere_spiral_extrude.html)
- Shape - 2D Shape
- [shape_taiwan](https://openhome.cc/eGossip/OpenSCAD/lib-shape_taiwan.html) - [shape_taiwan](https://openhome.cc/eGossip/OpenSCAD/lib-shape_taiwan.html)
- [shape_arc](https://openhome.cc/eGossip/OpenSCAD/lib-shape_arc.html) - [shape_arc](https://openhome.cc/eGossip/OpenSCAD/lib-shape_arc.html)
- [shape_pie](https://openhome.cc/eGossip/OpenSCAD/lib-shape_pie.html) - [shape_pie](https://openhome.cc/eGossip/OpenSCAD/lib-shape_pie.html)
@ -91,6 +86,14 @@ Too many dependencies? Because OpenSCAD doesn't provide namespace management, I
- [shape_pentagram](https://openhome.cc/eGossip/OpenSCAD/lib-shape_pentagram.html) - [shape_pentagram](https://openhome.cc/eGossip/OpenSCAD/lib-shape_pentagram.html)
- [shape_superformula](https://openhome.cc/eGossip/OpenSCAD/lib-shape_superformula.html) - [shape_superformula](https://openhome.cc/eGossip/OpenSCAD/lib-shape_superformula.html)
- 2D Shape Extrusion
- [path_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-path_extrude.html)
- [ring_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-ring_extrude.html)
- [helix_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-helix_extrude.html)
- [golden_spiral_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-golden_spiral_extrude.html)
- [archimedean_spiral_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-archimedean_spiral_extrude.html)
- [sphere_spiral_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-sphere_spiral_extrude.html)
- Other - Other
- [turtle2d](https://openhome.cc/eGossip/OpenSCAD/lib-turtle2d.html) - [turtle2d](https://openhome.cc/eGossip/OpenSCAD/lib-turtle2d.html)
- [turtle3d](https://openhome.cc/eGossip/OpenSCAD/lib-turtle3d.html) - [turtle3d](https://openhome.cc/eGossip/OpenSCAD/lib-turtle3d.html)

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -0,0 +1,28 @@
# rounded_extrude
Extrudes a 2D object roundly from 0 to 180 degrees.
## Parameters
- `size` : The size of A retangle which can cover the 2D object. Accepts single value, square with both sides this length. It also accepts 2 value array `[x, y]`, rectangle with dimensions `x` and `y`.
- `round_r` : The radius when extruding roundly.
- `angle` : 0 to 180 degrees. The default value is 90 degrees.
- `convexity`, `twist`: The same as respective parameters of `linear_extrude`.
- `$fa`, `$fs`, `$fn` : Used to control the round fragments. Check [the circle module](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#circle) for more details.
## Examples
include <rounded_extrude.scad>;
$fn = 48;
circle_r = 10;
round_r = 5;
rounded_extrude(circle_r * 2, round_r)
circle(circle_r);
translate([0, 0, round_r])
cylinder(h = 20, r1 = circle_r + round_r, r2 = 0);
![rounded_extrude](images/lib-rounded_extrude-1.JPG)

67
src/rounded_extrude.scad Normal file
View File

@ -0,0 +1,67 @@
/**
* 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();
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();
}