1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 22:28:16 +01:00

refactor: re-orgnize formula

This commit is contained in:
Justin Lin 2022-05-01 16:19:40 +08:00
parent e16a869a3f
commit 7f4c25b9e3

View File

@ -8,13 +8,9 @@ function convex_offset(vertices, d) =
curr_p = vertices[i],
next_p = vertices[(i + 1) % leng_vertices],
pre_p = vertices[(i + leng_vertices - 1) % leng_vertices],
c = tri_incenter([curr_p, next_p, pre_p]),
v1 = c - curr_p,
v1 = tri_incenter([curr_p, next_p, pre_p]) - curr_p,
v2 = next_p - curr_p,
leng_v1 = norm(v1),
leng_v2 = norm(v2),
a = acos((v1 * v2) / (leng_v1 * leng_v2)),
leng = -d / sin(a)
s = -d / sqrt(v1 * v1 - (v1 * v2) ^ 2 / (v2 * v2))
)
v1 / leng_v1 * leng + curr_p
v1 * s + curr_p
];