8
$\begingroup$

Bug introduced in 10.0.0 and fixed in 10.2


When I enter the following command, half of the fourth-degree spline is missing from the graph (i.e. it doesn't touch the last point). Is this a bug in Mathematica or am I fundamentally misunderstanding something about Bézier curves?

Manipulate[
 Graphics[{BezierCurve[pts, SplineDegree -> 4], Dashed, Green, 
 Line[pts]}, PlotRange -> {{-.5, 1.5}, {-.5, 1.5}}, 
 Frame -> True], {{pts, {{0, 0}, {.5, 0}, {.5, .5}, {1, .5}, {1, 
 1}}}, Locator, LocatorAutoCreate -> True}]

Here's a screenshot of the output: missing part of fourth-degree Bézier curve

What makes me suspicious is that the same behavior shows up in Mathematica's own help file on BezierCurve.

screenshot of mathematica's help files on BezierCurve

$\endgroup$
  • 1
    $\begingroup$ This is probably a bug, cause on V10.1 on Win10 it shows the full curve as expected. $\endgroup$ – EventHorizon511 Aug 8 '15 at 17:00
  • 1
    $\begingroup$ It seems to be a bug. This behavior does not occur in Mathematica 9.0.1 or 8.0.4 running on Windows. As such, it would be very helpful if you would state in the question your OS platform and the version of Mathematica you are using. $\endgroup$ – Oleksandr R. Aug 8 '15 at 17:01
  • 1
    $\begingroup$ I see the same on OS X with version 10.1 - in fact, the bug seems to persist for all degrees above the default 3. So I've added the bugs tag. $\endgroup$ – Jens Aug 8 '15 at 22:02
  • 1
    $\begingroup$ It works in V10.2 (Mac OSX). $\endgroup$ – Michael E2 Aug 8 '15 at 23:13
  • 1
    $\begingroup$ In Linux I get whole curve in all Mathematica versions I have available: 8, 9, 10.0, 10.1, 10.2, so it seems this bug is OS specific. $\endgroup$ – jkuczm Aug 12 '15 at 9:50
8
$\begingroup$

Since there is really something wrong with the BezierCurve, I made this work-around:

Clear[bezierCurve];

bezierCurve[pts_] := 
 First@ParametricPlot[
   BezierFunction[pts, SplineDegree -> Length[pts] - 1][t], {t, 0, 1}]

Manipulate[
 Graphics[{bezierCurve[pts], Dashed, Green, Line[pts]}, 
  PlotRange -> {{-.5, 1.5}, {-.5, 1.5}}, 
  Frame -> True], {{pts, {{0, 0}, {.5, 0}, {.5, .5}, {1, .5}, {1, 
     1}}}, Locator, LocatorAutoCreate -> True}]

Since the spline degree is always one less than the length of the point list, I didn't adhere to the built-in syntax where the degree is specified separately through an option. I just let the function bezierCurve compute the appropriate degree automatically, to reduce the potential for error.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks! I just ended up hard-coding it by looking up the formulas in wikipedia. Your approach is certainly more elegant. :) $\endgroup$ – mimuller Aug 8 '15 at 22:49

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.