8
$\begingroup$

My version (below) of the "Valentine Formula" that appeared in today's New York Times, has some ugly artifacts that don't appear in the NYT (Java) version:

enter image description here

How do I remove these artifacts?


Manipulate[
    ContourPlot3D[(x^2+((1+b)*y)^2+z^2-1)^3-x^2*z^3-a*y^2*z^3 ==0,
        {x,-scale,scale},{y,-scale,scale},{z,-scale,scale},
        Mesh->None,Axes->None,Boxed->False,
        ContourStyle->Directive[Red,Opacity[0.8],Specularity[White,30]],
        PerformanceGoal->"Quality"
    ],
    {{a,.1},.0001,1},
    {{b,1},.00001,5},
    {{scale,1.25},1,5},
    SynchronousUpdating->False]
$\endgroup$
6
$\begingroup$

RegionPlot3D can sometimes give cleaner results out of the box. I also upped the PlotPoints manually.

Manipulate[
 RegionPlot3D[(x^2 + ((1 + b)*y)^2 + z^2 - 1)^3 - x^2*z^3 - 
    a*y^2*z^3 <= 0, {x, -scale, scale}, {y, -scale, 
   scale}, {z, -scale, scale}, Mesh -> None, Axes -> None, 
  Boxed -> False, 
  PlotStyle -> Directive[Red, Opacity[0.8], Specularity[White, 30]], 
  PlotPoints -> ControlActive[Automatic, 40]], {{a, .1}, .0001, 
  1}, {{b, 1}, .00001, 5}, {{scale, 1.25}, 1, 5}, 
 SynchronousUpdating -> False]

$\endgroup$
  • $\begingroup$ That's much nicer! $\endgroup$ – orome Feb 14 at 16:40
2
$\begingroup$

Adding the ContourPlot3D option PlotPoints -> n where n is some number greater than or equal to 100 improved things considerably for me. There is still a very faint ring around the lower portion of the heart when I do this, but it's a considerable improvement.

The PlotPoints argument tells Mathematica how many points to use when initially sampling the plot. Many functions (including 2D functions like DensityPlot) accept this argument. For whatever reason, the default is often quite low for functions/plots with rapid changes or singularities.

Demo:

First, without any additional argument: enter image description here

Then with PlotPoints -> 200. with argument

$\endgroup$
  • $\begingroup$ That doesn't do anything for me. $\endgroup$ – orome Feb 14 at 16:38
  • $\begingroup$ @orome I bet you place the option in the Directive again. $\endgroup$ – xzczd Feb 14 at 16:39
  • $\begingroup$ @xzczd: Yep! (God I hate Mathematica's inadequate syntax checking!) $\endgroup$ – orome Feb 14 at 16:42
  • $\begingroup$ @orome I'm also surprised that Mathematica doesn't give any warning in this case :D $\endgroup$ – xzczd Feb 14 at 16:43
  • $\begingroup$ It shows improvement now, but still shows (as you point out) artifacts that ruin it. $\endgroup$ – orome Feb 14 at 16:46

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.