public Vector SmoothNormal(int index, double fraction, double cornerRadius) { if (cornerRadius > 0.0) { var num = Lengths[index]; if (MathHelper.IsVerySmall(num)) { var num2 = index - 1; if (num2 < 0 && IsClosed) { num2 = Count - 1; } var num3 = index + 1; if (IsClosed && num3 >= Count - 1) { num3 = 0; } if (num2 >= 0 && num3 < Count) { return(GeometryHelper.Lerp(Normals[num3], Normals[num2], 0.5).Normalized()); } return(Normals[index]); } var num4 = Math.Min(cornerRadius / num, 0.5); if (fraction <= num4) { var num5 = index - 1; if (IsClosed && num5 == -1) { num5 = Count - 1; } if (num5 >= 0) { var alpha = (num4 - fraction) / (2.0 * num4); return(GeometryHelper.Lerp(Normals[index], Normals[num5], alpha).Normalized()); } } else if (fraction >= 1.0 - num4) { var num7 = index + 1; if (IsClosed && num7 >= Count - 1) { num7 = 0; } if (num7 < Count) { var num8 = (fraction + num4 - 1.0) / (2.0 * num4); return(GeometryHelper.Lerp(Normals[index], Normals[num7], num8).Normalized()); } } } return(Normals[index]); }
public static SimpleSegment Create(Point point0, Point point1, Point point2) { var point = GeometryHelper.Lerp(point0, point1, 0.66666666666666663); var point3 = GeometryHelper.Lerp(point1, point2, 0.33333333333333331); var segment = new SimpleSegment { Type = SegmentType.CubicBeizer, Points = new[] { point0, point, point3, point2 } }; return(segment); }
public static void FlattenQuadratic(Point[] controlPoints, double errorTolerance, ICollection <Point> resultPolyline, bool skipFirstPoint, ICollection <double> resultParameters = null) { if (resultPolyline == null) { throw new ArgumentNullException(nameof(resultPolyline)); } if (controlPoints == null) { throw new ArgumentNullException(nameof(controlPoints)); } if (controlPoints.Length != 3) { throw new ArgumentOutOfRangeException(nameof(controlPoints)); } EnsureErrorTolerance(ref errorTolerance); Point[] pointArray = { controlPoints[0], GeometryHelper.Lerp(controlPoints[0], controlPoints[1], 0.66666666666666663), GeometryHelper.Lerp(controlPoints[1], controlPoints[2], 0.33333333333333331), controlPoints[2] }; FlattenCubic(pointArray, errorTolerance, resultPolyline, skipFirstPoint, resultParameters); }
public Point GetPoint(IList <Point> points) { return(GeometryHelper.Lerp(points[Index], points[Index + 1], Ratio)); }