public void rationalCurveAdaptiveSample() { Array <object> pts = new Array <object>(); pts.push(new Array <double>(new double[] { 5, 5, 0 })); pts.push(new Array <double>(new double[] { 10, 10, 0 })); pts.push(new Array <double>(new double[] { 20, 15, 0 })); pts.push(new Array <double>(new double[] { 35, 15, 0 })); pts.push(new Array <double>(new double[] { 45, 10, 0 })); pts.push(new Array <double>(new double[] { 50, 5, 0 })); Array <double> knots = new Array <double>(new double[] { 0.0, 0.0, 0.0, 0.0, 0.333333, 0.666667, 1.0, 1.0, 1.0, 1.0 }); Array <double> knots2 = new Array <double>(new double[] { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 }); Array <double> weights = new Array <double>(new double[] { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }); verb.geom.NurbsCurve curve = verb.geom.NurbsCurve.byKnotsControlPointsWeights(3, knots, pts, weights); verb.geom.NurbsCurve curve2 = verb.geom.NurbsCurve.byPoints(pts, 1); Array <object> p = verb.eval.Tess.rationalCurveAdaptiveSample(curve._data, 1e-6, null); _testOutput.WriteLine($"{p.length}"); for (int i = 0; i < p.length; i++) { _testOutput.WriteLine($"{p[i]}"); } }
public void CurveKnotRefine() { Array <object> pts = new Array <object>(); pts.push(new Array <double>(new double[] { 0.0, 10.0, 4.0 })); pts.push(new Array <double>(new double[] { 5.0, 10.0, 5.0 })); pts.push(new Array <double>(new double[] { 10.0, 10.0, 2.0 })); Array <double> knots = new Array <double>(new double[] { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 }); Array <double> weights = new Array <double>(new double[] { 1.0, 2.0, 1.0 }); Array <double> knotsToInsert = new Array <double>(new double[] { 0.5, 0.5, 0.5 }); verb.geom.NurbsCurve curve = verb.geom.NurbsCurve.byKnotsControlPointsWeights(2, knots, pts, weights); var after = verb.eval.Modify.curveKnotRefine(curve._data, knotsToInsert); _testOutput.WriteLine($"{after.controlPoints}"); }
public void rationalBezierCurveArcLength() { Array <object> pts = new Array <object>(); pts.push(new Array <double>(new double[] { 0, 0, 0, 1 })); pts.push(new Array <double>(new double[] { 0.5, 0, 0, 1 })); pts.push(new Array <double>(new double[] { 2.5, 0, 0, 1 })); pts.push(new Array <double>(new double[] { 3, 0, 0, 1 })); Array <double> knots = new Array <double>(new double[] { 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 2.0, 2.0 }); Array <double> weights = new Array <double>(new double[] { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }); verb.geom.NurbsCurve curve = verb.geom.NurbsCurve.byPoints(pts, 3); double res = verb.eval.Analyze.rationalBezierCurveArcLength(curve._data, 1, 16); _testOutput.WriteLine($"{res}"); }
public void CurveKnotRefine2() { Array <object> pts = new Array <object>(); for (int i = 0; i < 8; i++) { pts.push(new Array <double>(new double[] { i, 0, 0 })); } Array <double> knots = new Array <double>(new double[] { 0, 0, 0, 0, 1, 2, 3, 4, 5, 5, 5, 5 }); Array <double> weights = new Array <double>(new double[] { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }); Array <double> newKnots = new Array <double>(new double[] { 0.5 }); verb.geom.NurbsCurve curve = verb.geom.NurbsCurve.byKnotsControlPointsWeights(3, knots, pts, weights); var curveData = new verb.core.NurbsCurveData(3, knots, pts); var after = verb.eval.Modify.curveKnotRefine(curve._data, newKnots); _testOutput.WriteLine($"{after.controlPoints}"); }
public void DecomposeNurbsIntoBeziers() { Array <object> pts = new Array <object>(); pts.push(new Array <double>(new double[] { 0, 5, 5 })); pts.push(new Array <double>(new double[] { 0, 0, 0 })); pts.push(new Array <double>(new double[] { 4, 0, 0 })); pts.push(new Array <double>(new double[] { 5, 5, 5 })); pts.push(new Array <double>(new double[] { 0, 5, 0 })); verb.geom.NurbsCurve curve = verb.geom.NurbsCurve.byPoints(pts, 3); var res = verb.eval.Modify.decomposeCurveIntoBeziers(curve._data); for (int i = 0; i < res.length; i++) { _testOutput.WriteLine($"{res[i]}"); } }
public void AdaptiveSubdivision() { Array <object> pts = new Array <object>(); //pts.push(new Array<double>(new double[] { 100, 25, 0 })); //pts.push(new Array<double>(new double[] { 10, 90, 0 })); //pts.push(new Array<double>(new double[] { 110, 100, 0 })); //pts.push(new Array<double>(new double[] { 150, 195, 0 })); pts.push(new Array <double>(new double[] { 4.5, 2.5, 2.5 })); pts.push(new Array <double>(new double[] { 5, 5, 5 })); pts.push(new Array <double>(new double[] { 0, 5, 0 })); verb.geom.NurbsCurve curve = verb.geom.NurbsCurve.byPoints(pts, 2); var res = verb.eval.Tess.rationalCurveAdaptiveSample(curve._data, 1, true); _testOutput.WriteLine(res.length.ToString()); for (int i = 0; i < res.length; i++) { var r = res[i]; _testOutput.WriteLine($"{{{r}}}"); } }