static Point TangentIntersection(CurveTangent tangentA, CurveTangent tangentB) { Point x; Point.LineLineIntersection(tangentA.touchPoint, tangentA.touchPoint + tangentA.direction, tangentB.touchPoint, tangentB.touchPoint + tangentB.direction, out x); return(x); }
static IEnumerable <Point> PointsOnAroundPolyline(ICurve curve) { bool firstSide = true; CurveTangent prevTangent = null; CurveTangent firstCurveTangent = null; foreach (CurveTangent curveTangent in TangentsAroundCurve(curve)) { if (firstSide) { firstSide = false; firstCurveTangent = prevTangent = curveTangent; } else { if (!TangentsAreParallel(prevTangent, curveTangent)) { yield return(TangentIntersection(prevTangent, curveTangent)); } prevTangent = curveTangent; } } yield return(TangentIntersection(firstCurveTangent, prevTangent)); }
static bool TangentsAreParallel(CurveTangent a, CurveTangent b) { return(Math.Abs(a.direction.X * b.direction.Y - a.direction.Y * b.direction.X) < ApproximateComparer.DistanceEpsilon); }
static bool TangentsAreParallel(CurveTangent a, CurveTangent b) { return Math.Abs(a.direction.X * b.direction.Y - a.direction.Y * b.direction.X) < ApproximateComparer.DistanceEpsilon; }
static Point TangentIntersection(CurveTangent tangentA, CurveTangent tangentB) { Point x; Point.LineLineIntersection(tangentA.touchPoint, tangentA.touchPoint+tangentA.direction, tangentB.touchPoint, tangentB.touchPoint+tangentB.direction, out x); return x; }