Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This problem is probably pretty basic, but I can't find a solution anywhere.

Here's a closed surface with a nice yummy flavor :

SphericalPlot3D[
8Cos[4phi]Sin[theta]^4 - 35 - 28Cos[2theta] - Cos[4theta],
{theta, 0, Pi}, {phi, 0, 2 Pi},
ColorFunction -> Function[{x, y, z, theta, phi, r}, ColorData["Rainbow"][r]],
PlotPoints -> {32, 24},
BoundaryStyle -> None,
PlotRange -> All,
Boxed -> False,
Axes -> False,
SphericalRegion -> True,
Method -> {"RotationControl" -> "Globe"},
ImageSize -> {500, 500}
]

Now turn around it. You should notice a vertical "fold-like" line all along the surface. This is apparently a "cut" (turning the BoundaryStyle to True should reveal the border with a black line).

This is very annoying. How should I remove that cut "fold" on the surface (which should be perfectly smooth everywhere) ?

share|improve this question
    
If this help, try start theta with less than 0. Try this {theta, -Pi, Pi} – Algohi Mar 8 at 1:04
    
@Algohi, it cannot be ! Theta is a spherical angle, from 0 to Pi. Changing the interval to -Pi to Pi will double the surface. I tried it, and it also add some glitches at the poles. That cut line appears to be between phi = 0 and phi = 2Pi, which should be "glued" (or identified) in some way which I don't know. – Cham Mar 8 at 1:10
    
Cham as @Algohi suggested, you should try setting {theta, -Pi, Pi}; in order to remove the resulting glitches, increase MaxRecursion (e.g. to MaxRecursion -> 4). Your PlotPoints setting may also need to be adjusted. – MarcoB Mar 8 at 1:45
    
@MarcoB, using {theta, -Pi, Pi} gives ugly artifacts at the poles (a kind of polar pinch effect). The problem appears to be between phi = 0 and phi = 2Pi. Both values should be identified. – Cham Mar 8 at 1:53
    
@Cham The following was obtained setting {theta, -Pi, Pi}, eliminating any PlotPoints directive, and setting MaxRecursion -> 5; I don't see artifacts at the poles: image. I am on Win 7-64 and MMA 10.4. – MarcoB Mar 8 at 1:58
up vote 9 down vote accepted

The reason for the line you see is probably that the surface normals aren't calculated correctly at the stitching line. Surface normals are used to give a smooth rendering even for low number of polygons. This can be fixed by specifying a NormalsFunction as follows:

f[theta_, phi_] := 
 8 Cos[4 phi] Sin[theta]^4 - 35 - 28 Cos[2 theta] - Cos[4 theta]

n[θ_, ϕ_] = 
  Apply[Cross, 
   D[f[θ, ϕ] {Cos[ϕ] Sin[θ], 
        Sin[ϕ] Sin[θ], 
        Cos[θ]}, #] & /@ {θ, ϕ}];

 SphericalPlot3D[f[theta, phi], {theta, 0, Pi}, {phi, 0, 2 Pi}, 
 NormalsFunction -> (n[#4, #5] &), 
 ColorFunction -> 
  Function[{x, y, z, theta, phi, r}, ColorData["Rainbow"][r]], 
 PlotPoints -> {32, 24}, BoundaryStyle -> None, PlotRange -> All, 
 Boxed -> False, Axes -> False, SphericalRegion -> True, 
 Method -> {"RotationControl" -> "Globe"}, ImageSize -> {500, 500}]

The resulting plot looks like the original one, but has no defective line on my system (Mac OS X, Mathematica version 10.3.1).

The only change I made was the option NormalsFunction -> (n[#4, #5] &), no change to the number of plot points was made. To construct the normals, I defined your plot function as f, and then calculated its surface normal from the spherical-coordinate parametrization using the Cross product of the tangent vectors. The latter are obtained by differentiation with respect to the angles. This is done in the function n, which returns the normal vector.

share|improve this answer
    
It appears to work ! Thanks a lot ! I'll study this interesting solution tomorrow, since now I'm too tired to understand anything :-( – Cham Mar 8 at 4:18
    
Very nice. +1 or more – Dr. belisarius Mar 8 at 4:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.