mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 14:18:13 +01:00
refactor: reuse matrix
This commit is contained in:
parent
dce855611c
commit
fc5965267f
@ -17,22 +17,29 @@ function __polytransversals(transversals) =
|
|||||||
|
|
||||||
function _az(p1, p2) = let(v = p2 - p1) -90 + atan2(v.y, v.x);
|
function _az(p1, p2) = let(v = p2 - p1) -90 + atan2(v.y, v.x);
|
||||||
|
|
||||||
|
function _rz_matrix(p1, p2) =
|
||||||
|
let(v = p2 - p1, a = -90 + atan2(v.y, v.x), c = cos(a), s = sin(a))
|
||||||
|
[
|
||||||
|
[ c, s],
|
||||||
|
[-s, c],
|
||||||
|
];
|
||||||
|
|
||||||
function _first_stroke(stroke_pts, path_pts) =
|
function _first_stroke(stroke_pts, path_pts) =
|
||||||
let(
|
let(
|
||||||
p1 = path_pts[0],
|
p1 = path_pts[0],
|
||||||
p2 = path_pts[1],
|
p2 = path_pts[1],
|
||||||
a = _az(p1, p2)
|
m = _rz_matrix(p1, p2)
|
||||||
)
|
)
|
||||||
[for(p = stroke_pts) ptf_rotate(p, a) + p1];
|
[for(p = stroke_pts) p * m + p1];
|
||||||
|
|
||||||
function _stroke(stroke_pts, p1, p2, scale_step, i) =
|
function _stroke(stroke_pts, p1, p2, scale_step, i) =
|
||||||
let(
|
let(
|
||||||
leng = norm(__to3d(p2) - __to3d(p1)),
|
leng = norm(__to3d(p2) - __to3d(p1)),
|
||||||
a = _az(p1, p2),
|
m = _rz_matrix(p1, p2),
|
||||||
s = 1 + scale_step * i,
|
s = 1 + scale_step * i,
|
||||||
off_p = [0, leng]
|
off_p = [0, leng]
|
||||||
)
|
)
|
||||||
[for(p = stroke_pts) ptf_rotate(p * s + off_p, a) + p1];
|
[for(p = stroke_pts * s) (p + off_p) * m + p1];
|
||||||
|
|
||||||
function _inner(stroke_pts, path_pts, leng_path_pts, scale_step) =
|
function _inner(stroke_pts, path_pts, leng_path_pts, scale_step) =
|
||||||
[
|
[
|
||||||
|
Loading…
x
Reference in New Issue
Block a user