def bulge2arc(self, Ps, Pe, bulge): """ bulge2arc() """ c = (1 / bulge - bulge) / 2 #Berechnung des Mittelpunkts (Formel von Mickes!) #Calculation of the center (Micke's formula) O = Point(x=(Ps.x + Pe.x - (Pe.y - Ps.y) * c) / 2, \ y=(Ps.y + Pe.y + (Pe.x - Ps.x) * c) / 2) #Radius = Distance between the centre and Ps r = O.distance(Ps) #Kontrolle ob beide gleich sind (passt ...) #Check if they are equal (fits ...) #r=O.distance(Pe) #Unterscheidung f�r den �ffnungswinkel. #Distinction for the opening angle. ??? if bulge > 0: return ArcGeo(Ps=Ps, Pe=Pe, O=O, r=r) else: arc = ArcGeo(Ps=Pe, Pe=Ps, O=O, r=r) arc.reverse() return arc
def contains_point(self, point): """ Method to determine the minimal distance from the point to the shape @param point: a QPointF @return: minimal distance """ min_distance = float(0x7fffffff) ref_point = Point(point.x(), point.y()) t = 0.0 while t < 1.0: per_point = self.path.pointAtPercent(t) spline_point = Point(per_point.x(), per_point.y()) distance = ref_point.distance(spline_point) if distance < min_distance: min_distance = distance t += 0.01 return min_distance
def bulge2arc(self, Pa, Pe, bulge): """ bulge2arc() """ c = (1 / bulge - bulge) / 2 #Calculate the centre point (Micke's formula!) O = Point(x=(Pa.x + Pe.x - (Pe.y - Pa.y) * c) / 2, \ y=(Pa.y + Pe.y + (Pe.x - Pa.x) * c) / 2) #Radius = Distance between the centre and Pa r = O.distance(Pa) #Check if they are equal (fits ...) #r=O.distance(Pe) #Unterscheidung für den Öffnungswinkel. #Distinction for the opening angle. ??? if bulge > 0: return ArcGeo(Pa=Pa, Pe=Pe, O=O, r=r) else: arc = ArcGeo(Pa=Pe, Pe=Pa, O=O, r=r) arc.reverse() return arc
def bulge2arc(self, Ps, Pe, bulge): """ bulge2arc() """ c = (1 / bulge - bulge) / 2 #Calculate the centre point (Micke's formula!) O = Point(x=(Ps.x + Pe.x - (Pe.y - Ps.y) * c) / 2, \ y=(Ps.y + Pe.y + (Pe.x - Ps.x) * c) / 2) #Radius = Distance between the centre and Ps r = O.distance(Ps) #Check if they are equal (fits ...) #r=O.distance(Pe) #Unterscheidung f�r den �ffnungswinkel. #Distinction for the opening angle. ??? if bulge > 0: return ArcGeo(Ps=Ps, Pe=Pe, O=O, r=r) else: arc = ArcGeo(Ps=Pe, Pe=Ps, O=O, r=r) arc.reverse() return arc