5
$\begingroup$

Using SphericalPlot3D, I find I get two types of artifact:

  1. A discontinuity in the surface reflectance at $\theta=0,2\pi$
  2. Little edges, or perhaps gaps between faces, showing in some regions — this depends very much on the angle that the object is viewed from. If you run the code below, it might not show it without some rotation.

They can both be seen in this

Errors

How do I get rid of them?

Here's the code to reproduce the problem.

GreatCircleDistance[a_, b_] := ArcCos[(a.b)/(Norm[a, 2] Norm[b, 2])]

SphereToCart[{r_, ϕ_, θ_}] = r {Cos[θ] Sin[ϕ], Sin[θ] Sin[ϕ], Cos[ϕ]}

TotalDistance[θ_, ϕ_] := 
  3 + 
    Plus @@ 
      (Exp[-10 GreatCircleDistance[SphereToCart[{1, θ, ϕ}], #]^2] & /@
        (PolyhedronData["Icosahedron", "VertexCoordinates"] // N))

SphericalPlot3D[TotalDistance[θ, ϕ], {θ, 0, π}, {ϕ, 0, 2 π}, 
  PlotStyle -> Directive[Orange, Opacity[1], Specularity[White, 10]], 
  Mesh -> None, 
  PlotPoints -> 30]
$\endgroup$
4
  • $\begingroup$ What version are you using? $\endgroup$
    – Young
    Jul 24, 2016 at 3:48
  • 4
    $\begingroup$ Looks like a discontinuity in the computed normals. Using ParametricPlot3D[] instead works: With[{icos = N[PolyhedronData["Icosahedron", "VertexCoordinates"]]}, ParametricPlot3D[With[{sph = {Cos[ϕ] Sin[θ], Sin[θ] Sin[ϕ], Cos[θ]}}, (3 + Sum[Exp[-10 VectorAngle[sph, pts]^2], {pts, icos}]) sph], {θ, 0, π}, {ϕ, 0, 2 π}, Mesh -> None, PlotPoints -> 30, PlotStyle -> Directive[Orange, Specularity[1, 10]]]]. $\endgroup$ Jul 24, 2016 at 4:28
  • $\begingroup$ @Young Version 10.3 $\endgroup$
    – Lucas
    Jul 25, 2016 at 2:55
  • $\begingroup$ @J.M. I agree it is a problem with normals, I think it might count as an bone fide bug too (the normal calculation is probably missing a factor of two somewhere). $\endgroup$
    – Lucas
    Jul 25, 2016 at 3:00

1 Answer 1

2
$\begingroup$

Compute the normal manually (SphericalPlot does it from the polygons:

SphericalPlot3D[
 TotalDistance[θ, ϕ] /. Abs[x_]^2 -> x^2, {θ, 
  0, π}, {ϕ, 0, 2 π}, 
 PlotStyle -> Directive[Orange, Opacity[1], Specularity[White, 10]], 
 Mesh -> None, PlotPoints -> 30,
 NormalsFunction -> Function[{x, y, z, θ, ϕ, ρ},
   Evaluate@
    With[{r = 
       TotalDistance[θ, ϕ] /. Abs[a_]^2 :> a^2 // 
        Simplify},
     Cross @@ 
      Transpose@
       D[
        r {Sin[θ] Cos[ϕ], Sin[θ] Sin[ϕ], 
          Cos[θ]}, {{θ, ϕ}}]
     ]
   ]
 ]
$\endgroup$

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.