mirror of
https://github.com/nophead/NopSCADlib.git
synced 2025-08-07 07:56:30 +02:00
Merge branch 'open_belt' of https://github.com/SmoothieAq/NopSCADlib into SmoothieAq-open_belt
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
//! Because the tangents need to be calculated to find the length these can be calculated separately and re-used when drawing to save calculating them twice.
|
//! Because the tangents need to be calculated to find the length these can be calculated separately and re-used when drawing to save calculating them twice.
|
||||||
//
|
//
|
||||||
include <../utils/core/core.scad>
|
include <../utils/core/core.scad>
|
||||||
|
use <../utils/maths.scad>
|
||||||
|
|
||||||
function circle_tangent(p1, p2) = //! Compute the clockwise tangent between two circles represented as [x,y,r]
|
function circle_tangent(p1, p2) = //! Compute the clockwise tangent between two circles represented as [x,y,r]
|
||||||
let(
|
let(
|
||||||
@@ -41,19 +42,20 @@ function rounded_polygon_arcs(points, tangents) = //! Compute the arcs at the po
|
|||||||
len = len(points)
|
len = len(points)
|
||||||
) [ for (i = [0: len-1])
|
) [ for (i = [0: len-1])
|
||||||
let(
|
let(
|
||||||
p1 = tangents[(i - 1 + len) % len][1],
|
p1 = vec2(tangents[(i - 1 + len) % len][1]),
|
||||||
p2 = tangents[i][0],
|
p2 = vec2(tangents[i][0]),
|
||||||
p = points[i],
|
p = vec2(points[i]),
|
||||||
v1 = p1 - p,
|
v1 = p1 - p,
|
||||||
v2 = p2 - p,
|
v2 = p2 - p,
|
||||||
r = abs(p.z),
|
sr = points[i][2],
|
||||||
a = let( aa = acos((v1 * v2) / sqr(r)) ) cross(v1, v2)*sign(p.z) <= 0 ? aa : 360 - aa,
|
r = abs(sr),
|
||||||
|
a = r < 0.001 ? 0 : let( aa = acos((v1 * v2) / sqr(r)) ) cross(v1, v2)*sign(sr) <= 0 ? aa : 360 - aa,
|
||||||
l = PI * a * r / 180,
|
l = PI * a * r / 180,
|
||||||
v0 = [r, 0],
|
v0 = [r, 0],
|
||||||
v = let (
|
v = let (
|
||||||
vv = norm(v0-v2) < 0.001 ? 0 : abs(v2.y) < 0.001 ? 180 :
|
vv = norm(v0-v2) < 0.001 ? 0 : abs(v2.y) < 0.001 ? 180 :
|
||||||
let( aa = acos((v0 * v2) / sqr(r)) ) cross(v0, v2)*sign(p.z) <= 0 ? aa : 360 - aa
|
let( aa = acos((v0 * v2) / sqr(r)) ) cross(v0, v2)*sign(sr) <= 0 ? aa : 360 - aa
|
||||||
) p.z > 0 ? 360 - vv : vv - a
|
) sr > 0 ? 360 - vv : vv - a
|
||||||
) [a, v, l]
|
) [a, v, l]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user