mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-06 14:56:47 +02:00
added hull_polyline2d
This commit is contained in:
@@ -28,6 +28,7 @@ Some modules may depend on other modules. For example, the `polyline2d` module d
|
|||||||
- [rounded_square](https://openhome.cc/eGossip/OpenSCAD/lib-rounded_square.html)
|
- [rounded_square](https://openhome.cc/eGossip/OpenSCAD/lib-rounded_square.html)
|
||||||
- [line2d](https://openhome.cc/eGossip/OpenSCAD/lib-line2d.html)
|
- [line2d](https://openhome.cc/eGossip/OpenSCAD/lib-line2d.html)
|
||||||
- [polyline2d](https://openhome.cc/eGossip/OpenSCAD/lib-polyline2d.html)
|
- [polyline2d](https://openhome.cc/eGossip/OpenSCAD/lib-polyline2d.html)
|
||||||
|
- [hull_polyline2d](https://openhome.cc/eGossip/OpenSCAD/lib-hull_polyline2d.html)
|
||||||
- [circular_sector](https://openhome.cc/eGossip/OpenSCAD/lib-circular_sector.html)
|
- [circular_sector](https://openhome.cc/eGossip/OpenSCAD/lib-circular_sector.html)
|
||||||
- [arc](https://openhome.cc/eGossip/OpenSCAD/lib-arc.html)
|
- [arc](https://openhome.cc/eGossip/OpenSCAD/lib-arc.html)
|
||||||
- [hexagons](https://openhome.cc/eGossip/OpenSCAD/lib-hexagons.html)
|
- [hexagons](https://openhome.cc/eGossip/OpenSCAD/lib-hexagons.html)
|
||||||
|
BIN
docs/images/lib-hull_polyline2d-1.JPG
Normal file
BIN
docs/images/lib-hull_polyline2d-1.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
22
docs/lib-hull_polyline2d.md
Normal file
22
docs/lib-hull_polyline2d.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# hull_polyline2d
|
||||||
|
|
||||||
|
Creates a 2D polyline from a list of `[x, y]` coordinates. As the name says, it uses the built-in hull operation for each pair of points (created by the `circle` module). It's slow. However, it can be used to create metallic effects for a small `$fn`, large `$fa` or `$fs`.
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
- `points` : The list of `[x, y]` points of the polyline. The points are indexed from 0 to n-1.
|
||||||
|
- `width` : The line width.
|
||||||
|
- `$fa`, `$fs`, `$fn` : Check [the circle module](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#circle) for more details.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
include <hull_polyline2d.scad>;
|
||||||
|
|
||||||
|
$fn = 4;
|
||||||
|
|
||||||
|
hull_polyline2d(
|
||||||
|
points = [[1, 2], [-5, -4], [-5, 3], [5, 5]],
|
||||||
|
width = 1
|
||||||
|
);
|
||||||
|
|
||||||
|

|
36
src/hull_polyline2d.scad
Normal file
36
src/hull_polyline2d.scad
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/**
|
||||||
|
* hull_polyline2d.scad
|
||||||
|
*
|
||||||
|
* Creates a 2D polyline from a list of `[x, y]` coordinates.
|
||||||
|
* As the name says, it uses the built-in hull operation for each pair of points (created by the circle module).
|
||||||
|
* It's slow. However, it can be used to create metallic effects for a small $fn, large $fa or $fs.
|
||||||
|
*
|
||||||
|
* @copyright Justin Lin, 2017
|
||||||
|
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||||
|
*
|
||||||
|
* @see https://openhome.cc/eGossip/OpenSCAD/hull_polyline2d.html
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
module hull_polyline2d(points, width) {
|
||||||
|
half_width = width / 2;
|
||||||
|
leng = len(points);
|
||||||
|
|
||||||
|
module hull_line2d(index) {
|
||||||
|
hull() {
|
||||||
|
translate(points[index - 1])
|
||||||
|
circle(half_width);
|
||||||
|
translate(points[index])
|
||||||
|
circle(half_width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module polyline2d_inner(index) {
|
||||||
|
if(index < leng) {
|
||||||
|
hull_line2d(index);
|
||||||
|
polyline2d_inner(index + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
polyline2d_inner(1);
|
||||||
|
}
|
Reference in New Issue
Block a user