0
$\begingroup$

I'm drawing a Bézier surface.

f = BezierFunction[pts]
Show[Graphics3D[{PointSize[Small], Red, Point /@ pts, Green}], 
     ParametricPlot3D[f[u, v], {u, 0, 1}, {v, 0, 1}, Mesh -> None]]

How can I convert parametric function to Cartesian ($(u,v)$ to $(x,y)$)?

$\endgroup$
5
$\begingroup$

The strategy outlined here can be used to generate the Cartesian equation, with the help of GroebnerBasis[]. To wit,

pts = {{{0, 0, 0}, {0, 1, 0}, {0, 2, 0}, {0, 3, 0}, {0, 4, 0}},
       {{1, 0, 0}, {1, 1, 1}, {1, 2, 1}, {1, 3, 0}, {1, 4, 1}},
       {{2, 0, 0}, {2, 1, 1}, {2, 2, 1}, {2, 3, 0}, {2, 4, 0}},
       {{3, 0, 0}, {3, 1, 0}, {3, 2, 0}, {3, 3, 0}, {3, 4, 1}}};

{m, n} = Most[Dimensions[pts]] - 1;

bf = BezierFunction[pts];

bf2[u_, v_] = PiecewiseExpand[Fold[#2.#1 &, pts,
                                   {BernsteinBasis[m, Range[0, m], u], 
                                    BernsteinBasis[n, Range[0, n], v]}],
                              {0 < u < 1 && 0 < v < 1}];

cart[x_, y_] = z /. First @ Solve[First[
     GroebnerBasis[Thread[{x, y, z} == bf2[u, v]], {x, y, z}, {u, v}]] == 0, z]
   (6912 x y - 2304 x^2 y - 2592 x y^2 + 864 x^2 y^2 + 81 x y^4 - 36 x^2 y^4 +
    4 x^3 y^4)/6912

{Plot3D[cart[x, y], {x, 0, 3}, {y, 0, 4}, BoxRatios -> Automatic], 
 ParametricPlot3D[bf[u, v], {u, 0, 1}, {v, 0, 1}]} // GraphicsRow

explicit versus parametric form

$\endgroup$
2
  • $\begingroup$ The problem is that I have ~1000 points and it takes realy long time. $\endgroup$ – Sergei Podlipaev Apr 2 '16 at 13:16
  • 1
    $\begingroup$ Then what's the point of converting to Cartesian? It is more convenient to keep it in parametric form in that case. $\endgroup$ – J. M.'s torpor Apr 2 '16 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.