/// <summary> /// Interpolates a sequence of points. Used by InterpCurve Command /// This routine works best when degree=3. /// </summary> /// <param name="degree">The degree of the curve >=1. Degree must be odd.</param> /// <param name="points"> /// Points to interpolate. For periodic curves if the final point is a /// duplicate of the initial point it is ignored. (Count must be >=2) /// </param> /// <param name="knots"> /// Knot-style to use and specifies if the curve should be periodic. /// </param> /// <param name="startTangent">A starting tangent.</param> /// <param name="endTangent">An ending tangent.</param> /// <returns>interpolated curve on success. null on failure.</returns> public static Curve CreateInterpolatedCurve(IEnumerable<Point3d> points, int degree, CurveKnotStyle knots, Vector3d startTangent, Vector3d endTangent) { if (null == points) throw new ArgumentNullException("points"); int count; Point3d[] ptArray = Point3dList.GetConstPointArray(points, out count); if (count < 2) throw new InvalidOperationException("Insufficient points for an interpolated curve"); if (2 == count && !startTangent.IsValid && !endTangent.IsValid) return new LineCurve(ptArray[0], ptArray[1]); if (1 == degree && count > 2 && !startTangent.IsValid && !endTangent.IsValid) return PolylineCurve.FromArray(ptArray); IntPtr ptr = UnsafeNativeMethods.RHC_RhinoInterpCurve(degree, count, ptArray, startTangent, endTangent, (int)knots); return GeometryBase.CreateGeometryHelper(ptr, null) as NurbsCurve; }
/// <summary> /// Interpolates a sequence of points. Used by InterpCurve Command /// This routine works best when degree=3. /// </summary> /// <param name="degree">The degree of the curve >=1. Degree must be odd.</param> /// <param name="points"> /// Points to interpolate. For periodic curves if the final point is a /// duplicate of the initial point it is ignored. (Count must be >=2) /// </param> /// <param name="knots"> /// Knot-style to use and specifies if the curve should be periodic. /// </param> /// <returns>interpolated curve on success. null on failure.</returns> public static Curve CreateInterpolatedCurve(IEnumerable<Point3d> points, int degree, CurveKnotStyle knots) { return CreateInterpolatedCurve(points, degree, knots, Vector3d.Unset, Vector3d.Unset); }