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

added hull_polyline3d

This commit is contained in:
Justin Lin 2017-03-17 10:29:50 +08:00
parent 9ee6448667
commit 6320d439ca
5 changed files with 79 additions and 0 deletions

View File

@ -17,6 +17,7 @@ I've been using OpenSCAD for years and created some funny things. Some of them i
- 3D
- [line3d](https://openhome.cc/eGossip/OpenSCAD/lib-line3d.html)
- [polyline3d](https://openhome.cc/eGossip/OpenSCAD/lib-polyline3d.html)
- [hull_polyline3d](https://openhome.cc/eGossip/OpenSCAD/lib-hull_polyline3d.html)
- Transformations
- [hollow_out](https://openhome.cc/eGossip/OpenSCAD/lib-hollow_out.html)

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View File

@ -0,0 +1,41 @@
# hull_polyline3d
Creates a 3D polyline from a list of `[x, y, z]` coordinates. As the name says, it uses the built-in hull operation for each pair of points. It's slow. However, it can be used to create metallic effects when the `fn` parameter is small.
## Parameters
- `points` : The list of `[x, y, z]` points of the polyline. : A vector of 3 element vectors. The points are indexed from 0 to n-1.
- `thickness` : The line thickness.
- `fn` : It controlls the `$fn` value used by the `sphere` module. The default value is `3`.
## Examples
hull_polyline3d(
points = [
[1, 2, 3],
[4, -5, -6],
[-1, -3, -5],
[0, 0, 0]
],
thickness = 1,
fn = 3
);
![polyline3d](images/lib-hull_polyline3d-1.JPG)
r = 50;
points = [
for(a = [0:180])
[
r * cos(-90 + a) * cos(a),
r * cos(-90 + a) * sin(a),
r * sin(-90 + a)
]
];
for(i = [0:7]) {
rotate(45 * i)
hull_polyline3d(points, 2, 3);
}
![polyline3d](images/lib-hull_polyline3d-2.JPG)

37
src/hull_polyline3d.scad Normal file
View File

@ -0,0 +1,37 @@
/**
* hull_polyline3d.scad
*
* Creates a 3D polyline from a list of `[x, y, z]` coordinates.
* As the name says, it uses the built-in hull operation for each pair of points.
* It's slow. However, it can be used to create metallic effects when the fn parameter is small.
*
* @copyright Justin Lin, 2017
* @license https://opensource.org/licenses/lgpl-3.0.html
*
* @see https://openhome.cc/eGossip/OpenSCAD/hull_polyline3d.html
*
**/
module hull_polyline3d(points, thickness, fn = 3) {
$fn = fn;
half_thickness = thickness / 2;
leng = len(points);
module hull_line3d(index) {
hull() {
translate(points[index - 1])
sphere(half_thickness);
translate(points[index])
sphere(half_thickness);
}
}
module polyline3d_inner(index) {
if(index < leng) {
hull_line3d(index);
polyline3d_inner(index + 1);
}
}
polyline3d_inner(1);
}