mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-05 14:27:45 +02:00
fixed variable problem and refactored
This commit is contained in:
@@ -5,7 +5,7 @@ Puts children along the given path. If there's only one child, it will put the c
|
|||||||
## Parameters
|
## Parameters
|
||||||
|
|
||||||
- `points` : The points along the path.
|
- `points` : The points along the path.
|
||||||
- `angles` : If it's given, rotate before translate each child.
|
- `angles` : Rotate before translate each child. If not given, `angles` will be calculated automatically according to `points`.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
@@ -60,4 +60,44 @@ Puts children along the given path. If there's only one child, it will put the c
|
|||||||
linear_extrude(1, center = true)
|
linear_extrude(1, center = true)
|
||||||
text("A", valign = "center", halign = "center");
|
text("A", valign = "center", halign = "center");
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
include <bezier_curve.scad>;
|
||||||
|
include <along_with.scad>;
|
||||||
|
|
||||||
|
module scales() {
|
||||||
|
module one_scale() {
|
||||||
|
rotate([0, 60, 0])
|
||||||
|
linear_extrude(1, center = true)
|
||||||
|
scale([2, 1])
|
||||||
|
circle(1.25, $fn = 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(a = [0:30:360 - 15]) {
|
||||||
|
rotate(a)
|
||||||
|
translate([5, 0, 0])
|
||||||
|
one_scale();
|
||||||
|
rotate(a + 15)
|
||||||
|
translate([5, 0, 1.75])
|
||||||
|
one_scale();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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]
|
||||||
|
);
|
||||||
|
|
||||||
|
along_with(path_pts)
|
||||||
|
scales();
|
||||||
|
|
||||||
|

|
@@ -14,26 +14,25 @@
|
|||||||
include <__private__/__angy_angz.scad>;
|
include <__private__/__angy_angz.scad>;
|
||||||
|
|
||||||
module along_with(points, angles) {
|
module along_with(points, angles) {
|
||||||
function _path_angles(path_pts, leng_path_pts, i = 0) =
|
leng_points = len(points);
|
||||||
i == leng_path_pts - 1 ?
|
|
||||||
|
function _path_angles(i = 0) =
|
||||||
|
i == leng_points - 1 ?
|
||||||
[] :
|
[] :
|
||||||
concat(
|
concat(
|
||||||
[__angy_angz(path_pts[i], path_pts[i + 1])],
|
[__angy_angz(points[i], points[i + 1])],
|
||||||
_path_angles(path_pts, leng_path_pts, i + 1)
|
_path_angles(i + 1)
|
||||||
);
|
);
|
||||||
|
|
||||||
function path_angles(path_pts) =
|
function path_angles(points) =
|
||||||
let(
|
let(angs = _path_angles())
|
||||||
leng_path_pts = len(path_pts),
|
|
||||||
angs = _path_angles(path_pts, leng_path_pts)
|
|
||||||
)
|
|
||||||
concat(
|
concat(
|
||||||
[[0, -angs[0][0], angs[0][1]]],
|
[[0, -angs[0][0], angs[0][1]]],
|
||||||
[for(a = angs) [0, -a[0], a[1]]]
|
[for(a = angs) [0, -a[0], a[1]]]
|
||||||
);
|
);
|
||||||
|
|
||||||
angles_defined = angles != undef;
|
angles_defined = angles != undef;
|
||||||
angs = angles_defined ? angles : path_angles(path_pts);
|
angs = angles_defined ? angles : path_angles(points);
|
||||||
|
|
||||||
module align(i) {
|
module align(i) {
|
||||||
translate(points[i])
|
translate(points[i])
|
||||||
|
Reference in New Issue
Block a user