mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-21 22:05:27 +02:00
added path_extrude
This commit is contained in:
@@ -41,6 +41,7 @@ Some modules may depend on other modules. For example, the `polyline2d` module d
|
||||
- [hull_polyline3d](https://openhome.cc/eGossip/OpenSCAD/lib-hull_polyline3d.html)
|
||||
- [function_grapher](https://openhome.cc/eGossip/OpenSCAD/lib-function_grapher.html)
|
||||
- [polysections](https://openhome.cc/eGossip/OpenSCAD/lib-polysections.html)
|
||||
- [path_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-path_extrude.html)
|
||||
|
||||
- Transformation
|
||||
- [along_with](https://openhome.cc/eGossip/OpenSCAD/lib-along_with.html)
|
||||
|
BIN
docs/images/lib-path_extrude-1.JPG
Normal file
BIN
docs/images/lib-path_extrude-1.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
BIN
docs/images/lib-path_extrude-2.JPG
Normal file
BIN
docs/images/lib-path_extrude-2.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
BIN
docs/images/lib-path_extrude-3.JPG
Normal file
BIN
docs/images/lib-path_extrude-3.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
127
docs/lib-path_extrude.md
Normal file
127
docs/lib-path_extrude.md
Normal file
@@ -0,0 +1,127 @@
|
||||
# path_extrude
|
||||
|
||||
It extrudes a 2D shape along a path. This module is suitable for a path created by a continuous function.
|
||||
|
||||
It depends on the rotate_p function and the polysections module. Remember to include "rotate_p.scad" and "polysections.scad".
|
||||
|
||||
When using this module, you should use points to represent the 2D shape. You need to provide indexes of triangles, too. This module provides two prepared triangles indexes. One is `"RADIAL"`. See [polysections](https://openhome.cc/eGossip/OpenSCAD/lib-polysections.html) for details.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `shape_pts` : A list of points represent a shape. See the example below.
|
||||
- `path_pts` : A list of points represent the path.
|
||||
- `triangles` : `"RADIAL"` (default), `"HOLLOW"` or user-defined indexes. See example below.
|
||||
|
||||
## Examples
|
||||
|
||||
include <rotate_p.scad>;
|
||||
include <polysections.scad>;
|
||||
include <path_extrude.scad>;
|
||||
include <bezier_curve.scad>;
|
||||
|
||||
t_step = 0.05;
|
||||
width = 2;
|
||||
|
||||
p0 = [0, 0, 0];
|
||||
p1 = [40, 60, 35];
|
||||
p2 = [-50, 70, 0];
|
||||
p3 = [20, 150, -35];
|
||||
p4 = [30, 50, -3];
|
||||
|
||||
shape_pts = [
|
||||
[10, 0, 0],
|
||||
[15, 10, 0],
|
||||
[18, 9, 0],
|
||||
[20, 0, 0]
|
||||
];
|
||||
|
||||
path_pts = bezier_curve(t_step,
|
||||
[p0, p1, p2, p3, p4]
|
||||
);
|
||||
|
||||
path_extrude(shape_pts, path_pts);
|
||||
|
||||

|
||||
|
||||
include <rotate_p.scad>;
|
||||
include <polysections.scad>;
|
||||
include <path_extrude.scad>;
|
||||
include <bezier_curve.scad>;
|
||||
|
||||
t_step = 0.05;
|
||||
width = 2;
|
||||
|
||||
p0 = [0, 0, 0];
|
||||
p1 = [40, 60, 35];
|
||||
p2 = [-50, 70, 0];
|
||||
p3 = [20, 150, -35];
|
||||
p4 = [30, 50, -3];
|
||||
|
||||
shape_pts = [
|
||||
// outer
|
||||
[10, 0, 0],
|
||||
[15, 10, 0],
|
||||
[18, 9, 0],
|
||||
[20, 0, 0],
|
||||
// inner
|
||||
[12, 2, 0],
|
||||
[15, 7, 0],
|
||||
[17, 7, 0],
|
||||
[18, 2, 0]
|
||||
];
|
||||
|
||||
path_pts = bezier_curve(t_step,
|
||||
[p0, p1, p2, p3, p4]
|
||||
);
|
||||
|
||||
path_extrude(shape_pts, path_pts, triangles = "HOLLOW");
|
||||
|
||||

|
||||
|
||||
include <rotate_p.scad>;
|
||||
include <polysections.scad>;
|
||||
include <path_extrude.scad>;
|
||||
include <bezier_curve.scad>;
|
||||
|
||||
t_step = 0.05;
|
||||
width = 2;
|
||||
|
||||
p0 = [0, 0, 0];
|
||||
p1 = [40, 60, 35];
|
||||
p2 = [-50, 70, 0];
|
||||
p3 = [20, 150, -35];
|
||||
p4 = [30, 50, -3];
|
||||
|
||||
shape_pts = [
|
||||
// outer
|
||||
[10, 0, 0],
|
||||
[15, 10, 0],
|
||||
[30, 0, 0],
|
||||
// inner
|
||||
[12, 1, 0],
|
||||
[15, 8, 0],
|
||||
[26, 1, 0],
|
||||
];
|
||||
|
||||
path_pts = bezier_curve(t_step,
|
||||
[p0, p1, p2, p3, p4]
|
||||
);
|
||||
|
||||
path_extrude(
|
||||
shape_pts,
|
||||
path_pts,
|
||||
triangles = [
|
||||
[0, 3, 4],
|
||||
[0, 4, 1],
|
||||
[1, 4, 5],
|
||||
[1, 5, 2],
|
||||
[2, 5, 3],
|
||||
[2, 3, 0]
|
||||
]
|
||||
);
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
|
@@ -1,8 +1,23 @@
|
||||
module path_extrude(shape_pts, points, triangles = "RADIAL") {
|
||||
/**
|
||||
* path_extrude.scad
|
||||
*
|
||||
* It extrudes a 2D shape along a path.
|
||||
* This module is suitable for a path created by a continuous function.
|
||||
* It depends on the rotate_p function and the polysections module.
|
||||
* Remember to include "rotate_p.scad" and "polysections.scad".
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib-path_extrude.html
|
||||
*
|
||||
**/
|
||||
|
||||
module path_extrude(shape_pts, path_pts, triangles = "RADIAL") {
|
||||
function first_section() =
|
||||
let(
|
||||
p1 = points[0],
|
||||
p2 = points[1],
|
||||
p1 = path_pts[0],
|
||||
p2 = path_pts[1],
|
||||
dx = p2[0] - p1[0],
|
||||
dy = p2[1] - p1[1],
|
||||
dz = p2[2] - p1[2],
|
||||
@@ -30,12 +45,12 @@ module path_extrude(shape_pts, points, triangles = "RADIAL") {
|
||||
];
|
||||
|
||||
|
||||
len_pts = len(points);
|
||||
len_path_pts = len(path_pts);
|
||||
|
||||
function path_extrude_inner(index) =
|
||||
index == len_pts ? [] :
|
||||
index == len_path_pts ? [] :
|
||||
concat(
|
||||
[section(points[index - 1], points[index])],
|
||||
[section(path_pts[index - 1], path_pts[index])],
|
||||
path_extrude_inner(index + 1)
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user