def lineIntersects(self, A, B): v = B - A w = self.center - A t = Vector2.dot(v, w) / Vector2.dot(v, v) if t > 1: t = 1 elif t < 0: t = 0 closest = A + (v * t) return closest, self.pointIn(closest)
def lineIntersects(self,A,B): v = B - A w = self.center - A t = Vector2.dot(v,w) / Vector2.dot(v,v) if t > 1: t = 1 elif t < 0: t = 0 closest = A + (v*t) return closest,self.pointIn(closest)
def findDrawingPoints(p0, p1, p2, p3, t0, t1, insertionIndex, pointList): tMid = (t0 + t1) / 2 lp0 = calculateBezierPoint(p0, p1, p2, p3, t0) lp1 = calculateBezierPoint(p0, p1, p2, p3, t1) a = (lp0 - lp1).get_magnitude() if a <= 1: return 0 pMid = calculateBezierPoint(p0, p1, p2, p3, tMid) leftDirection = (lp0 - pMid) leftDirection.normalize() rightDirection = (lp1 - pMid) rightDirection.normalize() dotP = Vector2.dot(leftDirection, rightDirection) if dotP > -0.99: pointsAdded = 0 pointsAdded += findDrawingPoints(p0, p1, p2, p3, t0, tMid, insertionIndex, pointList) pointList.insert(len(pointList) - (insertionIndex + pointsAdded), pMid) pointsAdded += findDrawingPoints(p0, p1, p2, p3, tMid, t1, insertionIndex + pointsAdded, pointList) return pointsAdded return 0