mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-21 14:04:53 +02:00
fix error tri_incenter
This commit is contained in:
@@ -1,21 +1,18 @@
|
||||
use <triangle/tri_incenter.scad>;
|
||||
|
||||
function convex_offset(vertices, d) =
|
||||
let(
|
||||
c = tri_incenter(vertices),
|
||||
leng_vertices = len(vertices)
|
||||
)
|
||||
let(leng_vertices = len(vertices))
|
||||
[
|
||||
for(i = [0:leng_vertices - 1])
|
||||
let(
|
||||
curr_p = vertices[i],
|
||||
next_p = vertices[(i + 1) % leng_vertices],
|
||||
v1 = c - curr_p,
|
||||
pre_p = vertices[(i + leng_vertices - 1) % leng_vertices],
|
||||
v1 = 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)
|
||||
a = acos((v1 * v2) / (norm(v1) * norm(v2))),
|
||||
leng = -d * sin(a / 2),
|
||||
v = tri_incenter([curr_p, next_p, pre_p]) - curr_p
|
||||
)
|
||||
v1 / leng_v1 * leng + curr_p
|
||||
v / norm(v) * leng + curr_p
|
||||
];
|
Reference in New Issue
Block a user