4
$\begingroup$

I'm trying to texture a set of concentric annuli over ParametricPlot3D surfaces of various functions but the mapping is not centered and not covering the entire surface I wish to texture. Here is a simple example of texturing a few annuli over $\sqrt{z}$ which shows the problem:

    p1 = Graphics@{Red, Annulus[{0, 0}, {1/4, 3/4}, {-Pi/2, Pi/6}]};
p2 = Graphics@{Blue, Annulus[{0, 0}, {1/4, 3/4}, {Pi/6, 3 Pi/4}]};
p3 = Graphics@{Green, Annulus[{0, 0}, {1/4, 3/4}, {3 Pi/4, 2 Pi}]};
plotB = Show[{p1, p2, p3}];
ParametricPlot3D[{Re@z, Im@z, Re@Sqrt[z]} /. z -> r Exp[I t], {r, 0, 
  3/4}, {t, -Pi, Pi}, PlotStyle -> {Texture[plotB]}, 
 TextureCoordinateFunction -> ({#1, #2} &), BoxRatios -> {1, 1, 1}, 
 Mesh -> None]

enter image description here

and I don't understand TextureCoordinateFunction enough to solve the problem if this is the cause. Note also if I just download an example:

ParametricPlot3D[{Re@z, Im@z, Re@Sqrt[z]} /. z -> r Exp[I t], {r, 0, 
  3/4}, {t, -Pi, Pi}, 
 PlotStyle -> {Texture[ExampleData[{"ColorTexture", "Roof"}]]}, 
 TextureCoordinateFunction -> ({#1, #2} &), BoxRatios -> {1, 1, 1}, 
 Mesh -> None]

The texture successfully covers the entire plot:

enter image description here

Can someone help me with this problem please? Couldn't find any similar example in the forum or in the help files nor various attempts at manipulating the Texture coorinates.

Thanks.

$\endgroup$

2 Answers 2

7
$\begingroup$

We set the PlotRange and the Background to Black in order to full fill the graphics region.

texture = 
 Graphics[{{Red, Annulus[{0, 0}, {1/4, 3/4}, {-Pi/2, Pi/6}]}, {Blue, 
    Annulus[{0, 0}, {1/4, 3/4}, {Pi/6, 3 Pi/4}]}, {{Green, 
     Annulus[{0, 0}, {1/4, 3/4}, {3 Pi/4, 2 Pi}]}}}, PlotRange -> .75,
   PlotRangeClipping -> True, Background -> Black]

enter image description here

ParametricPlot3D[{Re@z, Im@z, Re@Sqrt[z]} /. z -> r Exp[I t], {r, 0, 
  3/4}, {t, -Pi, Pi}, PlotStyle -> {Texture[texture]}, 
 TextureCoordinateFunction -> ({#1, #2} &), BoxRatios -> {1, 1, 1}, 
 Mesh -> None]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks a lot. That did it. I found didn't need the BackGround->Black however, I was passing a Show object to Texture rather than a pure Graphics object as you do above and not using the PlotRangeClipping->True as well. Surprised the texture does not bleed-across branch-cuts but has sharp discontinuities which is what I want. $\endgroup$
    – josh
    Aug 19, 2022 at 18:35
1
$\begingroup$

The principal problem is PlotRange, as cvgmt shows, but I'd solve the problem with MeshShading.

PlotRange:

p1 = Graphics@{Red, Annulus[{0, 0}, {1/4, 3/4}, {-Pi/2, Pi/6}]};
p2 = Graphics@{Blue, Annulus[{0, 0}, {1/4, 3/4}, {Pi/6, 3 Pi/4}]};
p3 = Graphics@{Green, Annulus[{0, 0}, {1/4, 3/4}, {3 Pi/4, 2 Pi}]};
plotB = Show[{p1, p2, p3}, PlotRange -> 3/4];
ParametricPlot3D[{Re@z, Im@z, Re@Sqrt[z]} /. z -> r Exp[I t], {r, 0, 
  3/4}, {t, -Pi, Pi}, PlotStyle -> {Texture[plotB]}, 
 TextureCoordinateFunction -> ({#1, #2} &), BoxRatios -> {1, 1, 1}, 
 Mesh -> None]

MeshShading:

ParametricPlot3D[{Re@z, Im@z, Re@Sqrt[z]} /. z -> r Exp[I t], {r, 0, 
  3/4}, {t, -Pi, Pi},
 Mesh -> {{1/4, 3/4}, 
   NumericalSort@Mod[{Pi/6, 3 Pi/4, 2 Pi}, 2 Pi, -Pi]},
 MeshShading -> 
  Transpose@{{White, White, White}, {Green, Red, Blue}},
 MeshStyle -> None,
 BoxRatios -> {1, 1, 1}, Mesh -> None]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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