The plotting function implicit3 fails to render under certain conditions. Notably, for sphere larger than a certain amount.

3 views (last 30 days)
This renders properly :
a = 800;
ff = @(x,y,z) x.^2 + y.^2 + z.^2 - a^2;
fimplicit3(ff);
b = a*1.25;
xlim([-b b])
ylim([-b b])
zlim([-b b])
However,
a = 8000;
ff = @(x,y,z) x.^2 + y.^2 + z.^2 - a^2;
fimplicit3(ff);
b = a*1.25;
xlim([-b b])
ylim([-b b])
zlim([-b b])
does not render
  1 Comment
Adam Danz
Adam Danz on 10 Mar 2025
Hello @Vladimir, I ran your code above and the surface renders as expected.
Knowing the MATLAB release you're using and some more information about what you're seeing may help.

Sign in to comment.

Accepted Answer

Jack
Jack on 8 Mar 2025
Edited: Walter Roberson on 8 Mar 2025
The issue here is likely due to fimplicit3’s default mesh resolution not being sufficient when the plotting range becomes very large. When you set a = 8000, the region over which MATLAB samples the implicit function is huge, and the default number of sample points may be too sparse to accurately capture the surface of the sphere.
One workaround is to explicitly define the plotting region and increase the 'MeshDensity' so that more points are used in the evaluation. For example:
a = 8000;
ff = @(x,y,z) x.^2 + y.^2 + z.^2 - a^2;
b = a*1.25;
fimplicit3(ff, [-b b -b b -b b], 'MeshDensity', 100)
xlim([-b b])
ylim([-b b])
zlim([-b b])
This should provide a denser sampling of the implicit surface and render the sphere correctly.
Follow me so you can message me anytime with future MATLAB questions. If this helps, please accept the answer as well.
  9 Comments

Sign in to comment.

More Answers (1)

Adam Danz
Adam Danz on 10 Mar 2025
Edited: Adam Danz on 10 Mar 2025
I believe the problem is recreated when the axes limits are not set. In this case, the ImplicitFunctionSurface is larger than the default axes limits and since it does not update the axes limits automatically, there's nothing to render within the default axes. If this is the problem, you solved it by setting the axes limits.
a = 8000;
ff = @(x,y,z) x.^2 + y.^2 + z.^2 - a^2;
fimplicit3(ff);
It would be nice if the implicit graphics objects had an option to automatically adjust the axes limits. Many graphics objects have a property AffectAutoLimits that, when set to True, automatically adjust axes limits so that the object is within the axes. I recently wrote about this property in the Text object. However, the ImplicitFunctionSurface may be continuous along at least once axis which would make it difficult/impossible to automatically select axis limits in the continuous dimentions.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!