1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-19 13:01:37 +02:00

refactor: use tf matrix

This commit is contained in:
Justin Lin
2022-03-23 17:53:42 +08:00
parent 6a9da8be00
commit 66c0b70417

View File

@@ -23,10 +23,24 @@ function _cells_lt_before_intersection(shape, size, points, pt, half_region_size
let(
v = p - pt,
offset = (pt + p) / 2 - v / norm(v) * half_region_size,
a = atan2(v.y, v.x)
a = atan2(v.y, v.x),
cosa = cos(a),
sina = sin(a),
m = [
[1, 0, offset.x],
[0, 1, offset.y],
[0, 0, 1]
]
*
[
[cosa, -sina, 0],
[sina, cosa, 0],
[0, 0, 1]
]
)
[
for(sp = shape)
ptf_rotate(sp, a) + offset
let(transformed = m * [each sp, 1])
[transformed.x, transformed.y]
]
];