private void CalcWidth(PathPoint p) { if (ControlPoints.Count < 3) { p.Width = p.ControlPoint.Width; } else { var myCP = p.ControlPoint; var next = p; while (next.ControlPoint == myCP) { next = next.Next; } var prev = p; while (prev.ControlPoint == myCP) { prev = prev.Prev; } var first = prev.Next; var firstDist = first.DistanceFromStart; if (firstDist > p.DistanceFromStart) { firstDist -= Length; } var nextDist = next.DistanceFromStart; if (nextDist < p.DistanceFromStart) { nextDist += Length; } var k = (p.DistanceFromStart - firstDist) / (nextDist - firstDist); p.Width = p.ControlPoint.Width * (1 - k) + next.ControlPoint.Width * k; } p.r2 = (p.Width / 2) * (p.Width / 2); }
public float DistanceBetweenPoints(PathPoint p1, PathPoint p2) { var d = Math.Abs(p2.DistanceFromStart - p1.DistanceFromStart); return(Math.Min(d, Math.Abs(d - Length))); }