static double[] ToDoubleArray(Rhino.Geometry.Collections.NurbsCurveKnotList list, int degree) { var count = list.Count; var knots = new double[count + 2]; var min = list[0]; var max = list[count - 1]; var mid = 0.5 * (min + max); var factor = 1.0 / (max - min); // normalized // End knot knots[count + 1] = /*(list[count - 1] - max) * factor +*/ 1.0; for (int k = count - 1; k >= count - degree; --k) { knots[k + 1] = /*(list[k] - max) * factor +*/ 1.0; } // Interior knots (in reverse order) int multiplicity = degree + 1; for (int k = count - degree - 1; k >= degree; --k) { double current = list[k] <= mid ? (list[k] - min) * factor + 0.0 : (list[k] - max) * factor + 1.0; double next = knots[k + 2]; if (KnotAlmostEqualTo(next, current)) { multiplicity++; if (multiplicity > degree - 2) { current = KnotPrevNotEqual(next); } else { current = next; } } else { multiplicity = 1; } knots[k + 1] = current; } // Start knot for (int k = degree - 1; k >= 0; --k) { knots[k + 1] = /*(list[k] - min) * factor +*/ 0.0; } knots[0] = /*(list[0] - min) * factor +*/ 0.0; return(knots); }
//////////////////////////////////////////////////////////////////////////////////////////////////////得到节点的t值 public static List <double> curveKnot(Curve x) { NurbsCurve nc = x.ToNurbsCurve(); Rhino.Geometry.Collections.NurbsCurveKnotList knot = nc.Knots; List <double> knotT = new List <double>(); for (int i = 0; i < knot.Count; i++) { knotT.Add(knot.ElementAt(i)); } List <double> knots = knotT.Distinct().ToList(); return(knots); }
static internal IList <double> Convert(Rhino.Geometry.Collections.NurbsCurveKnotList knotList) { int knotListCount = knotList.Count; if (knotListCount > 0) { var knots = new List <double>(knotListCount + 2); knots.Add(knotList[0]); foreach (var k in knotList) { knots.Add(k); } knots.Add(knotList[knotListCount - 1]); return(knots); } return(new List <double>()); }