mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-11 17:24:20 +02:00
auto-calculating angles when angles is undef
This commit is contained in:
@@ -11,25 +11,48 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
include <__private__/__angy_angz.scad>;
|
||||||
|
|
||||||
module along_with(points, angles) {
|
module along_with(points, angles) {
|
||||||
module rotOrNot(i) {
|
function _path_angles(path_pts, leng_path_pts, i = 0) =
|
||||||
if(angles == undef) {
|
i == leng_path_pts - 1 ?
|
||||||
children(0);
|
[] :
|
||||||
} else {
|
concat(
|
||||||
rotate(angles[i])
|
[__angy_angz(path_pts[i], path_pts[i + 1])],
|
||||||
children(0);
|
_path_angles(path_pts, leng_path_pts, i + 1)
|
||||||
}
|
);
|
||||||
}
|
|
||||||
|
function path_angles(path_pts) =
|
||||||
|
let(
|
||||||
|
leng_path_pts = len(path_pts),
|
||||||
|
angs = _path_angles(path_pts, leng_path_pts)
|
||||||
|
)
|
||||||
|
concat(
|
||||||
|
[[0, -angs[0][0], angs[0][1]]],
|
||||||
|
[for(a = angs) [0, -a[0], a[1]]]
|
||||||
|
);
|
||||||
|
|
||||||
|
angles_defined = angles != undef;
|
||||||
|
angs = angles_defined ? angles : path_angles(path_pts);
|
||||||
|
|
||||||
|
module align(i) {
|
||||||
|
translate(points[i])
|
||||||
|
rotate(angs[i])
|
||||||
|
if(angles_defined) {
|
||||||
|
children(0);
|
||||||
|
} else {
|
||||||
|
rotate([90, 0, -90])
|
||||||
|
children(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($children == 1) {
|
if($children == 1) {
|
||||||
for(i = [0:len(points) - 1]) {
|
for(i = [0:len(points) - 1]) {
|
||||||
translate(points[i])
|
align(i) children(0);
|
||||||
rotOrNot(i) children(0);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(i = [0:min(len(points), $children) - 1]) {
|
for(i = [0:min(len(points), $children) - 1]) {
|
||||||
translate(points[i])
|
align(i) children(i);
|
||||||
rotOrNot(i) children(i);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user