Message Boards Message Boards

0
|
3225 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Reparametrization of Bezier Curve into Cartesian functions

Posted 9 years ago

I found this code online

bezier[pts_List] := 
 With[{n = Length[pts] - 1}, 
  Evaluate@ Sum[Binomial[n, i] (1 - #)^(n - i) #^i pts[[i + 1]], {i, 0, n}] &]

And than

yfn[pts_] :=
 Piecewise[
  Function[pp,
    Select[
      y /. 
         N@Solve[
           Rationalize[bezier[pp][t] == {x, y} && pp[[1, 1]] <= x <= pp[[-1, 1]], 0],
           {y}, {t}, Reals, Method -> Reduce] /. 
        Less -> LessEqual // Expand,
      # == pp[[1, 2]] /. x -> pp[[1, 1]] &] /. 
     ConditionalExpression -> Sequence
    ] /@ Partition[pts, 4, 3, 1, {}],
  Indeterminate
  ]

Rationalize and N is used, because that's what Solve would do, except Solve would issue warning messages about it. And finally

{y1, y2} = yfn /@ {Transpose[{data[[All, 1]], data[[All, 3]]}], 
    Transpose[{data[[All, 1]], data[[All, 2]]}]};

BUT since whoever wrote this online a couple of months ago uses mathematica 10.1, while I am still at 10.0.0.0, therefore the code doesn't work for me. Here is my printscreen

It looks as if the Solve in 10.1 version returns the result in different form than version 10.0 does. Since this is way beyond my knowledge of mathematica, could somebody please let me know how to edit the code so that it would work in version 10.0 ?

POSTED BY: Mitja Jan?i?
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract