Draft: re-added missing arcFrom2Pts function in DraftGeomUtils

This commit is contained in:
Yorik van Havre
2018-11-16 18:28:01 -02:00
parent 6d836ad7a5
commit fc5b6288c6

View File

@@ -2438,6 +2438,27 @@ def circleFrom2PointsRadius(p1, p2, radius):
else: return None
def arcFrom2Pts(firstPt,lastPt,center,axis=None):
'''Builds an arc with center and 2 points, can be oriented with axis'''
radius1 = firstPt.sub(center).Length
radius2 = lastPt.sub(center).Length
if round(radius1-radius2,4) != 0 : # (PREC = 4 = same as Part Module), Is it possible ?
return None
thirdPt = Vector(firstPt.sub(center).add(lastPt).sub(center))
thirdPt.normalize()
thirdPt.scale(radius1,radius1,radius1)
thirdPt = thirdPt.add(center)
newArc = Part.Edge(Part.Arc(firstPt,thirdPt,lastPt))
if not axis is None and newArc.Curve.Axis.dot(axis) < 0 :
thirdPt = thirdPt.sub(center)
thirdPt.scale(-1,-1,-1)
thirdPt = thirdPt.add(center)
newArc = Part.Edge(Part.Arc(firstPt,thirdPt,lastPt))
return newArc
#############################33 to include