What I did:

cylinderPlot3D[f_ ,xys_:1] :=   ParametricPlot3D[{z,f[t,z] Cos[t],f[t,z] 
Sin[t]}, {t,-Pi, Pi},{z,-Pi,Pi}, Mesh->None,PlotPoints->50,PlotRange -> 
All,Exclusions->None, AxesLabel->{x,y,z},Lighting -> 
{{"Directional",RGBColor[1, 1, 1], {-4,0,4}}},PlotStyle -> 

f[t_,z_] := Cos[z/2]^0.5 * (0.9+HeavisideTheta[z-0.25 Pi]);cylinderPlot3D[f,0.6]

What I got, after reorientation:

enter image description here

showing dark at the pointer, as opposed to light as is correct, given that the ring is planar (reorient to see), the illumination is directional hence rays to all points on the ring should have the same angle of incidence hence intensity of illumination.

What I want: Correct illumination.

  • $\begingroup$ 1) What exactly would you consider "correct" lighting in this context? 2) Have you taken a look at reference.wolfram.com/language/ref/Lighting.html ? $\endgroup$
    – MarcoB
    Jul 29 '15 at 3:16
  • $\begingroup$ 1) In accord with "Directional light sources ... are taken to yield parallel simulated light rays" reference.wolfram.com/language/ref/Lighting.html 2) Yes :-) $\endgroup$
    – ChrisJJ
    Jul 29 '15 at 22:24

It appears to be a bug in computing the vertex normals at the step. Here's are the vertex normals:

c = cylinderPlot3D[f, 0.6];

normals = FirstCase[c, GraphicsComplex[pts_, __, VertexNormals -> vn_, ___] :>
 Line[Transpose@{pts, pts + vn}], -1];

Show[c, Graphics3D[{Opacity[0.1], normals}]]

enter image description here

It looks like the HeavisideTheta function is not being handled properly. A simple but imperfect workaround is to use a soft step function in its place. For example

step[x_] := (1 + Tanh[10 x])/2

f[t_, z_] := Cos[z/2]^0.5*(0.9 + step[z - 0.25 Pi]);

cylinderPlot3D[f, 0.6]

enter image description here

To get a more accurate result you should probably remove the Exclusions -> None and supply the missing part as a separate surface. I suggest reporting the problem to Wolfram if you haven't already.

  • 1
    $\begingroup$ Related: mathematica.stackexchange.com/a/89387 $\endgroup$
    – Michael E2
    Jul 29 '15 at 21:47
  • $\begingroup$ @Simon Thanks. The workaround suffers a lesser but still significant discrepancy in incident intensity, and supplying the missing part would need to be computationally, give f can vary. I'll report the bug and fingers crossed. $\endgroup$
    – ChrisJJ
    Jul 30 '15 at 0:02
  • $\begingroup$ @Simon, as an aside, is your first graphic really from the code shown? Here (on Programming Cloud) I get different: i.imgur.com/r59pAIm.png $\endgroup$
    – ChrisJJ
    Jul 30 '15 at 0:03
  • $\begingroup$ @Simon. Ah, I get that only after reorientation. I guess this bug: mathematica.stackexchange.com/questions/89472/… $\endgroup$
    – ChrisJJ
    Jul 30 '15 at 0:08

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.