4
$\begingroup$

The following:

ContourPlot3D[Sqrt[1 - x^2 - y^2] - z == 0, {x, -1, 1}, {y, -1, 1}, {z, 0, 1}]

produces an ugly wall around the half sphere.

enter image description here

Is there some kind of option that can rid of it?

Please note that:

  1. Switching to Surd[] did not help.
  2. I know that there are many other ways of plotting the top half of a sphere, but I am working with ContourPlot3D[] for other reasons, and would like to continue to use it.
  3. I noticed that with the constraint (the first argument) as: z == Sqrt[1 - x^2 - y^2], the offending artifact disappears. (However, as I am working with many types of constraints, I will not necessarily be able to isolate z each time.) What is the big difference in these two constraints??

Thank you.

$\endgroup$
3
  • $\begingroup$ For reference, running ContourPlot3D on Sqrt[1-x^2-y^2]==z yields the wall artifact while running z==Sqrt[1-x^2-y^2] gives a much nicer plot (although with some artifacts around the edges) on MMA 12.1.1 on macOS. I think this behavior is undesirable, if not an outright bug. $\endgroup$ – Sami Jun 21 '20 at 10:03
  • $\begingroup$ Thanx for that extra case. $\endgroup$ – Aharon Naiman Jun 21 '20 at 10:35
  • $\begingroup$ How about ContourPlot3D[1 - x^2 - y^2 == z^2, {x, -1, 1}, {y, -1, 1}, {z, 0, 1}]? Your range already limits it to the positive $z$. $\endgroup$ – MarcoB Jun 21 '20 at 18:04
2
$\begingroup$

produces an ugly wall around the half sphere.

Just use the first solution ?

sol[x_, y_] := First[Sqrt[1 - x^2 - y^2]]
ContourPlot3D[Evaluate[z == sol[x, y]], {x, -1, 1}, {y, -1, 1}, {z, 0, 1}]

Mathematica graphics

The wall was the second solution which you did not want.

$\endgroup$
3
  • $\begingroup$ Thank you, I see now that the artifact is coming from a separate solution. However, 1) I mentioned that I cannot depend on being able to isolate z each time. 2) With the ?NumericQ qualifier, I got lots of First::normal: Nonatomic expression expected at position 1 in First[0. +0.999714 I]. -- how did you avoid that? $\endgroup$ – Aharon Naiman Jun 21 '20 at 11:00
  • $\begingroup$ @AharonNaiman sorry, I added the _?NumericQ later here in the post without testing. Simply remove them and it works OK. As far as not able to isolate z issue, well, z has 2 solutions in your example. And you did not want to see one of them. I am not sure how to solve this otherwise. You either keep all solutions, or filter out the ones you do not want to see? What else do you suggest one could do? $\endgroup$ – Nasser Jun 21 '20 at 11:15
  • $\begingroup$ Thanx @Nasser, indeed I had removed the two ?NumericQs in order to run your example, thereby seeing the two solutions. Before you pointed out that it was due to the second solution, I was hoping that there might be some kind of Exclusions option to remove the edge of the half-sphere. $\endgroup$ – Aharon Naiman Jun 21 '20 at 13:06

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.