# Tag Info

0

It looks like you need to define a function that requires a numerical argument before it will evaluate: bsf = BSplineFunction[{{1, 1}, {2, 3}, {3, 2}, {3, 1}}]; fun1[t_] := bsf[t][[1]] fun2[t_?NumericQ] := bsf[t][[1]] FindRoot[#[t] == 2, {t, .3}] & /@ {fun1, fun2} Output: {{t -> 2.}, {t -> 0.347296}}

0

Here is a solution that with the help of LibraryLink: CAGDBezierSurface[pts_, u_, v_] := Module[{m, n, row, col}, {m, n} = Dimensions[pts, 2] - 1; row = BezierNonzeroBasis[m, u]; col = BezierNonzeroBasis[n, v]; bezierSurf[row, col, pts] ] pts = Table[{ Cos[2 Pi u/6] Cos[v], Sin[2 Pi u/6] Cos[v], v}, {u, 6}, {v, -1, 1, 0.5}]; f = BezierFunction[...

1

Here is a solution via the Wolfram LibraryLink technique: First, let us make a comparison between BezierNonzeroBasis[n, u] and BernsteinBasis[n, Range[0, n], u] Do[BezierNonzeroBasis[10, 0.1], {10000}] // AbsoluteTiming Do[BernsteinBasis[10, Range[0, 10], 0.1], {10000}] // AbsoluteTiming BezierNonzeroBasis[10000, 0.1]; // AbsoluteTiming ...

2

Here, I will use LibraryLink technique to calculate the nonzero B-spline basis. About the C code, please see happy fish's revision. Firstly, I make a comparison with optimizedNonzeroBasis[], compiledNonzeroBasis[] and librarylinkNonzeroBasis[]. knots0 = Join[ConstantArray[0, 3001], Range[1, 5000], ConstantArray[5001, 3001]]; deg0 = 3000; i = 3002; ...

4

The error message tells everything: "NMaxValue::nnum: "The function value {-0.31322198} is not a number at {s,t} = {0.6524678079740285,0.04524817776440737}"" NMaxValue[First[f[s, t]], {s, t} ∈ Rectangle[{0, 0}, {1, 1}]]

2

I am going to copy-paste Simon Wood's answer of How to create a new “person curve”? param[x_, m_, t_] := Module[{f, n = Length[x], nf}, f = Chop[Fourier[x]][[;; Ceiling[Length[x]/2]]]; nf = Length[f]; Total[Rationalize[2 Abs[f]/Sqrt[n] Sin[Pi/2 - Arg[f] + 2. Pi Range[0, nf - 1] t], .01][[;; Min[m, nf]]]]] tocurve[Line[data_], m_, t_] := ...

Top 50 recent answers are included