5
$\begingroup$

Mathematica provides an example of visualizing a Hilbert curve using splines as a Graphics object in this entry in its documentation system.

However, when one attempts to change the thickness, some graphical artifacts are generated (notice the seemingly arbitrarily placed sharp nubs on the main curve). The generating code and image are included below—notice the only difference between this line of code and the code in the documentation center is the argument for the thickness.

Is there a quick way to avoid/get rid of these?

Graphics[{Thickness[50/1500], HilbertCurve[4] /. Line -> BSplineCurve}]

enter image description here

$\endgroup$
5
  • 3
    $\begingroup$ See CapForm - either CapForm[None] or CapForm["Round"] fixes the issue $\endgroup$ Commented Feb 5, 2020 at 16:03
  • $\begingroup$ My Mathematica 12 for Linux draws the curve without artifacts. I suggest tagging the post as a bug. $\endgroup$ Commented Feb 5, 2020 at 16:07
  • 1
    $\begingroup$ @aooiiii. I don't think there is any bug; just the usual bad behavior that results from not having specified the best end cap form. $\endgroup$ Commented Feb 6, 2020 at 2:00
  • $\begingroup$ @m_goldberg, shouldn't Mathematica's output be invariant to the operating system it's running on? $\endgroup$ Commented Feb 6, 2020 at 10:43
  • $\begingroup$ @aooiiii. That would be ideal but I suspect the cost in time and money to achieve that goal is prohibitive. $\endgroup$ Commented Feb 8, 2020 at 2:44

1 Answer 1

6
$\begingroup$

I evaluated the OP's code with V12.0 running on MacOS 10.13.4. It reproduced his image as I thought it would. Some of the corners of the default "Square" end caps extend beyond the curve boundary causing the artifacts the OP observed. On the other hand, setting the end caps to None or "Butt" produced voids. So the only form I recommend is:

Graphics[{Thickness[50/1500], CapForm["Round"], HilbertCurve[4] /. Line -> BSplineCurve}]

curve

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.