1
0
mirror of https://github.com/Irev-Dev/Round-Anything.git synced 2025-08-07 16:36:33 +02:00

Merge pull request #13 from Irev-Dev/irevdev-fix-find-point-to-deal-with-90-deg-angles

Fix findPoint to deal with 90 degree angles
This commit is contained in:
Kurt Hutten
2020-10-05 20:45:11 +11:00
committed by GitHub

View File

@@ -328,13 +328,14 @@ function parallelFollow(rp,thick=4,minR=1,mode=1)=
concat(cen,outR); concat(cen,outR);
function findPoint(ang1,refpoint1,ang2,refpoint2,r=0)= function findPoint(ang1,refpoint1,ang2,refpoint2,r=0)=
// finds the intersection of two lines given two angles and points on those lines
let( let(
m1=tan(ang1), m1=tan(ang1),
c1=refpoint1.y-m1*refpoint1.x, c1=refpoint1.y-m1*refpoint1.x,
m2=tan(ang2), m2=tan(ang2),
c2=refpoint2.y-m2*refpoint2.x, c2=refpoint2.y-m2*refpoint2.x,
outputX=(c2-c1)/(m1-m2), outputX=ang1==90?refpoint1.x:ang2==90?refpoint2.x:(c2-c1)/(m1-m2),
outputY=m1*outputX+c1 outputY=ang1==90?m2*outputX+c2:m1*outputX+c1
) )
[outputX,outputY,r]; [outputX,outputY,r];