I've got a poor quality when plot the implicit equation singu==0
, with
singu=1+ 2. y^5 z - 3. z^2 + 3. z^4 + x^5 (2. y + 2. z) +
y^3 (-1. z + 4. z^3) +
y^2 (-3. + 9. z^2 - 6. z^4 - 3. z Sqrt[1 - x^2 - y^2 - z^2]) +
x^4 (3. - 6. y^2 - 6. z^2 + 2. y Sqrt[1 - x^2 - y^2 - z^2] -
2. z Sqrt[1 - x^2 - y^2 - z^2]) +
y^4 (3. - 6. z^2 + 2. z Sqrt[1 - x^2 - y^2 - z^2]) +
y z (-1. - 1. z^2 + 2. z^4 + 3. z Sqrt[1 - x^2 - y^2 - z^2] -
2. z^3 Sqrt[1 - x^2 - y^2 - z^2]) +
x^3 (4. y^3 - 1. z + 4. y^2 z + 4. z^3 + y (-1. + 4. z^2)) +
x^2 (-3. - 6. y^4 + 4. y^3 z + 9. z^2 - 6. z^4 +
y^2 (9. - 12. z^2) + 3. z Sqrt[1 - x^2 - y^2 - z^2] +
y (2. z + 4. z^3 - 3. Sqrt[1 - x^2 - y^2 - z^2])) +
x (2. y^5 - 2. y^4 Sqrt[1 - x^2 - y^2 - z^2] + y (-1. + 2. z^2) +
y^3 (-1. + 4. z^2) +
y^2 (2. z + 4. z^3 + 3. Sqrt[1 - x^2 - y^2 - z^2]) +
z (-1. - 1. z^2 + 2. z^4 - 3. z Sqrt[1 - x^2 - y^2 - z^2] +
2. z^3 Sqrt[1 - x^2 - y^2 - z^2]))
or equivalently,
singu= 1 +2. y^5 z-3. z^2+3. z^4+x^5 (2. y+2. z)+y^3 z (-1.+4. z^2)+y^2 (-3.+9. z^2-6. z^4-3. z Sqrt[1-x^2-y^2-z^2])+x^4 (3. -6. y^2-6. z^2+2. y Sqrt[1-x^2-y^2-z^2]-2. z Sqrt[1-x^2-y^2-z^2])+y^4 (3. -6. z^2+2. z Sqrt[1-x^2-y^2-z^2])+x^3 (4. y^3-1. z+4. y^2 z+4. z^3+y (-1.+4. z^2))+x^2 (-3.-6. y^4+4. y^3 z+9. z^2-6. z^4+y^2 (9. -12. z^2)+3. z Sqrt[1-x^2-y^2-z^2]+y (2. z+4. z^3-3. Sqrt[1-x^2-y^2-z^2]))+y z (-1.+z (3. Sqrt[1-x^2-y^2-z^2]+z (-1.+2. z^2-2. z Sqrt[1-x^2-y^2-z^2])))+x (2. y^5-2. y^4 Sqrt[1-x^2-y^2-z^2]+y (-1.+2. z^2)+y^3 (-1.+4. z^2)+y^2 (2. z+4. z^3+3. Sqrt[1-x^2-y^2-z^2])+z (-1.+z (-3. Sqrt[1-x^2-y^2-z^2]+z (-1.+2. z^2+2. z Sqrt[1-x^2-y^2-z^2]))))
I used the following command:
Table[ContourPlot3D[
Evaluate@singu == 0, {x, -1, 1}, {y, -1, 1}, {z, -1, 1},
PerformanceGoal -> "Quality", MaxRecursion -> 1,
PlotPoints -> pp], {pp, {15}}]
which has a very poor quality, as shown in Fig[.
Theoretically the origin shouldn't be part of the surface, moreover, the surface in the figure is very broken. So is there anyway to improve the quality? I have tried increasing the number of MaxRecursion to 2, and more plotpoints, it takes much longer, but does not help much. This expression looks not too difficult to me, so I am a bit puzzled. Could someone give me some suggestions to improve the plot quality, and preferably tips to reduce the evaluation time? Thanks a lot!
Update: I tried to increase the number of plotpoints and maximumRecursion, and I found that the quality becomes better but some of broken parts still exists. Then I plotted the unit sphere, which is the constraint to make Sqrt[1-x^2-y^2-z^2] real. Then I notice that seems the desired surface might intersect the unit sphere, which might be the reason why the plot is broken.
So I wonder if it is possible to plot the equation only within the range of the unit sphere? is there anyway to specify this constraint to the ContourPlot3d command? Or is there any other way to realize this? Thanks a lot!
Update 2:
I have tried the FegionFunction to limit the figure within the unit sphere, however, the plot does not change, it seems that this does not affect the evaluation; then I tried collecting the square root term in the equation and put it into the form: a=-b Sqrt[1-x^2-y^2-z^2]
then square each side to obtain a new equation free of square root, but then I notice that the new plot includes some more regions corresponding to a=b Sqrt[1-x^2-y^2-z^2]
, and I can not distinguish them.
So is there anyway to deal with this?
Or do you suggest working on the original expression? and is there some way to deal with the broken parts, other than the RegionFunction or increasing the PlotPoints ? Thanks a lot!
Update 3: The solution from Michael E2 is quite satisfying, which solves the problem perfectly. I just have one more question: Is there a direct way to plot the surface generated by an equation involving the spherical coordinates?
I notice that in this algorithm, the graph is plotted first by ContourPlot3d in the CARTESIAN frame first, with the coordinates as r,theta,phi, then transformed in some way to make the frame coordinates into x,y,z. So there is not a direct way to plot the surface generated by an equation involving the spherical coordinates? Thanks a lot!
MaxRecursion
and using a lowPlotPoint
count. By settingMaxRecursion -> 1
, it can only add one extra layer of points. $\endgroup$ListContourPlot3D
. Basically, instead of using adaptive sampling it's using a fixed grid. It should actually be more expensive to get a similar quality figure using that method as compared to whatContourPlot3D
is doing. But MATLAB may be more efficient, so I'm not saying that you're wrong. $\endgroup$