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

104 lines
2.6 KiB
Markdown
Raw Normal View History

2017-04-23 11:16:34 +08:00
# along_with
2022-04-14 07:51:45 +08:00
If you want to place objects precisely, their points and angles are required. When you have only points or you don't care their precise angles, `along_with` puts children along the given path. If there's only one child, it will put the child for each point.
2017-04-23 11:16:34 +08:00
## Parameters
- `points` : The points along the path.
2019-06-07 10:51:12 +08:00
- `angles` : Rotate before translate each child. If not given, rotate children automatically according to `points` and `method`.
2017-05-19 13:50:51 +08:00
- `twist` : If given, each child will be twisted before applying each element of `points` and `angles`.
- `scale` : If given, each child will be scaled before applying each element of `points` and `angles`. It accepts a single value, `[sx, sy]` or `[sx, sy, sz]`.
2021-02-21 22:47:09 +08:00
- `method` : Which method does `along_with` take to **guess** how to rotate children if `angles` is not specified? It accepts two value, `"AXIS_ANGLE"` (default) and `"EULER_ANGLE"`. See `path_extrude` for more information. **Since:** 1.3
2017-04-23 11:16:34 +08:00
## Examples
2022-06-06 13:11:46 +08:00
use <along_with.scad>
use <shape_circle.scad>
2017-04-23 11:16:34 +08:00
$fn = 24;
2020-03-23 16:49:50 +08:00
points = shape_circle(radius = 50);
2017-04-23 11:16:34 +08:00
along_with(points)
2019-06-15 10:42:28 +08:00
sphere(5);
2017-04-23 11:16:34 +08:00
2021-02-21 22:47:09 +08:00
![along_with](images/lib3x-along_with-1.JPG)
2017-04-23 11:16:34 +08:00
2022-06-06 13:11:46 +08:00
use <along_with.scad>
use <shape_circle.scad>
2017-05-19 11:30:20 +08:00
2017-04-23 11:16:34 +08:00
$fn = 24;
2017-05-19 11:30:20 +08:00
2020-03-23 16:49:50 +08:00
points = shape_circle(radius = 50);
2017-05-19 11:30:20 +08:00
2017-04-23 11:16:34 +08:00
along_with(points) {
2017-05-19 11:30:20 +08:00
linear_extrude(10, center = true) text("A", valign = "center", halign = "center");
linear_extrude(5, center = true) circle(2);
sphere(1);
cube(5);
linear_extrude(10, center = true) text("A", valign = "center", halign = "center");
linear_extrude(5, center = true) circle(2);
sphere(1);
cube(5);
2017-04-23 11:16:34 +08:00
}
2021-02-21 22:47:09 +08:00
![along_with](images/lib3x-along_with-2.JPG)
2017-04-23 11:16:34 +08:00
2022-06-06 13:11:46 +08:00
use <along_with.scad>
use <golden_spiral.scad>
2017-05-03 16:29:10 +08:00
pts_angles = golden_spiral(
from = 5,
to = 11,
point_distance = 4
);
points = [for(p_a = pts_angles) p_a[0]];
angles = [for(p_a = pts_angles) p_a[1]];
along_with(points, angles)
2022-03-30 09:39:11 +08:00
rotate([90, 0, 0])
linear_extrude(1, center = true)
text("A", valign = "center", halign = "center");
2017-05-03 16:29:10 +08:00
2021-02-21 22:47:09 +08:00
![along_with](images/lib3x-along_with-3.JPG)
2017-05-19 11:24:43 +08:00
2022-06-06 13:11:46 +08:00
use <bezier_curve.scad>
use <along_with.scad>
2017-05-19 11:24:43 +08:00
module scales() {
module one_scale() {
rotate([0, 60, 0])
2022-03-30 09:39:11 +08:00
linear_extrude(1, center = true)
scale([2, 1])
circle(1.25, $fn = 24);
2017-05-19 11:24:43 +08:00
}
2022-03-30 09:17:27 +08:00
2017-05-19 12:59:52 +08:00
for(a = [0:30:330]) {
2017-05-19 11:31:36 +08:00
rotate(a)
2022-03-30 09:39:11 +08:00
translate([5, 0, 0])
one_scale();
2017-05-19 11:31:36 +08:00
rotate(a + 15)
2022-03-30 09:39:11 +08:00
translate([5, 0, 1.75])
one_scale();
2017-05-19 11:24:43 +08:00
}
}
t_step = 0.01;
p0 = [0, 0, 0];
p1 = [0, 50, 35];
p2 = [-100, 70, 0];
p3 = [30, 120, -35];
p4 = [30, 150, -40];
p5 = [0, 200, -3];
path_pts = bezier_curve(t_step,
[p0, p1, p2, p3, p4, p5]
);
2017-05-19 13:50:51 +08:00
along_with(path_pts, scale = 0.5)
2017-05-19 11:24:43 +08:00
scales();
2021-02-21 22:47:09 +08:00
![along_with](images/lib3x-along_with-4.JPG)