11
$\begingroup$

I want to recreate a ball with mesh like this, use different style for the front and back. enter image description here

I tried using MeshShading, but the mesh lines looked too thick, can I draw the mesh smaller?

n = 40; 
ParametricPlot3D[{Sin[u]  Cos[v], Sin[u]  Sin[v], Cos[u]}, {u, 0, Pi}, {v, 0, 2 Pi},
PlotStyle -> Directive[FaceForm[Cyan, Gray]], MeshStyle -> None,
 MeshShading -> {{Automatic, Automatic}, {None, Automatic}}, 
 Mesh -> {Range[0., Pi, Pi/n], Rest@Range[0., 2 Pi, 2 Pi/n]}, 
 Boxed -> False, Axes -> False, ImageSize -> Large
 ]

enter image description here

$\endgroup$

3 Answers 3

9
$\begingroup$
jj = Flatten@Table[{i, i + .03}, {i, 0, \[Pi], \[Pi]/50}];
kk = Flatten@Table[{i, i + .1}, {i, 0, 2 \[Pi], 2 \[Pi]/50}];
ParametricPlot3D[{Sin[u] Cos[v], Sin[u] Sin[v], Cos[u]}, {u, 0, 
  Pi}, {v, 0, 2 Pi}, PlotStyle -> Directive[FaceForm[Cyan, Gray]], 
 MeshStyle -> None, 
 MeshShading -> {{Automatic, Automatic}, {None, Automatic}}, 
 Mesh -> {jj, kk}, Boxed -> False, Axes -> False, ImageSize -> Large]

enter image description here

$\endgroup$
15
$\begingroup$
  • Besides of the Mesh method, here we provide a region method.
  • We construct some holes in the Parameter {u,v}-domain. d is the thickness of the belts (the thickness of the top, bottom,left and right is d/2)
  • 0< d < Min[(xmax - xmin)/ m, (ymax - ymin)/n].
Clear["Global`*"];
{{xmin, xmax}, {ymin, ymax}} = {{0, π}, {0, 2  π}};
{m, n} = {19, 17};
d = .3 Min[(xmax - xmin)/ m, (ymax - ymin)/n];
x = (xmax - xmin)/m - d;
y = (ymax - ymin)/n - d;
datax = Accumulate@
   Flatten@Join[{xmin, d/2}, Table[{x, d}, m - 1], {x, d/2}];
regx = MeshRegion[List /@ datax, 
   Line /@ Partition[Range[2, Length@datax], 2, 2]];
datay = Accumulate@
   Flatten@Join[{ymin, d/2}, Table[{y, d}, n - 1], {y, d/2}];
regy = MeshRegion[List /@ datay, 
   Line /@ Partition[Range[2, Length@datay], 2, 2]];
rectangle = 
  BoundaryDiscretizeRegion[Rectangle[{xmin, ymin}, {xmax, ymax}]];
reg = RegionDifference[rectangle, RegionProduct[regx, regy]]

enter image description here

ParametricPlot3D[{Sin[u]Cos[v], Sin[u]Sin[v], Cos[u]}, {u, v} ∈ reg, 
 PlotStyle -> Directive[FaceForm[Cyan, Gray]], Mesh -> None, 
 Boxed -> False, Axes -> False, ImageSize -> Large, PlotRange -> All]

enter image description here

  • The datax,datay can be set as Mesh.
ParametricPlot3D[{Sin[u] Cos[v], Sin[u] Sin[v], Cos[u]}, {u, xmin, 
  xmax}, {v, ymin, ymax}, 
 PlotStyle -> Directive[FaceForm[Cyan, Gray]], Mesh -> {datax, datay},
  MeshStyle -> None, 
 MeshShading -> {{None, Automatic}, {Automatic, Automatic}}, 
 Boxed -> False, Axes -> False, ImageSize -> Large, PlotRange -> All]
  • test the example by @eldo
Clear["Global`*"];
{{xmin, xmax}, {ymin, ymax}} = {{-2, 2}, {-2, 2}};
{m, n} = {19, 17};
d = .3 Min[(xmax - xmin)/ m, (ymax - ymin)/n];
x = (xmax - xmin)/m - d;
y = (ymax - ymin)/n - d;
datax = Accumulate@
   Flatten@Join[{xmin, d/2}, Table[{x, d}, m - 1], {x, d/2}];
regx = MeshRegion[List /@ datax, 
   Line /@ Partition[Range[2, Length@datax], 2, 2]];
datay = Accumulate@
   Flatten@Join[{ymin, d/2}, Table[{y, d}, n - 1], {y, d/2}];
regy = MeshRegion[List /@ datay, 
   Line /@ Partition[Range[2, Length@datay], 2, 2]];
rectangle = 
  BoundaryDiscretizeRegion[Rectangle[{xmin, ymin}, {xmax, ymax}]];
reg = RegionDifference[rectangle, RegionProduct[regx, regy]]
enneper = {u - (u^3/3) + u    v^2, v - (v^3/3) + u^2    v, 
   u^2 - v^2};
plot1 = ParametricPlot3D[enneper, {u, v} \[Element] reg, 
  ImageSize -> Large, Lighting -> "ThreePoint", Mesh -> None, 
  PlotPoints -> 64, 
  PlotStyle -> Directive[FaceForm[Red, Darker@Green]]]; plot2 = 
 ParametricPlot3D[enneper, {u, -2, 2}, {v, -2, 2}, ImageSize -> Large,
   Lighting -> "ThreePoint", MeshStyle -> None, 
  MeshShading -> {{None, Automatic}, {Automatic, Automatic}}, 
  Mesh -> {datax, datay}, PlotPoints -> 64, 
  PlotStyle -> Directive[FaceForm[Red, Darker@Green]]];
{plot1, plot2}

enter image description here

$\endgroup$
1
  • $\begingroup$ +1 - Perforated regions like this should be very useful in many cases $\endgroup$
    – eldo
    Commented May 12 at 9:36
6
$\begingroup$

Using kglr's answer to Jeener's Flower

Width of the mesh bands

w = 1/3;

Number of mesh bands

n = 25;

mesh = 
  Rescale[#, MinMax @ #, {0, 2 Pi}] & @
    Accumulate[Flatten @ ConstantArray[{1, w}, n]];

ParametricPlot3D[
 {Sin[u] Cos[v], Sin[u] Sin[v], Cos[u]},
 {u, 0, Pi}, {v, 0, 2 Pi},
 Boxed -> False,
 Axes -> False,
 MeshStyle -> None,
 MeshShading -> {{Automatic, Automatic}, {None, Automatic}},
 Mesh -> {mesh, Rest @ mesh},
 ImageSize -> Large,
 PlotStyle -> Directive[FaceForm[Cyan, Gray]]]

enter image description here

w = 1/10;

n = 5;

mesh = 
  Rescale[#, MinMax @ #, {0, 2 Pi}] & @
    Accumulate[Flatten @ ConstantArray[{1, w}, n]];

ParametricPlot3D[
 {Sin[u] Cos[v], Sin[u] Sin[v], Cos[u]}, 
 {u, 0,  Pi}, {v, 0, 2 Pi},
 Boxed -> False,
 Axes -> False,
 Lighting -> "ThreePoint",
 MeshStyle -> None,
 MeshShading -> {{Automatic, Automatic}, {None, Automatic}},
 Mesh -> {mesh, Rest @ mesh},
 ImageSize -> Large,
 PlotPoints -> 64,
 PlotStyle -> Directive[FaceForm[Darker @ Red, Yellow]]]

enter image description here

mesh also functions with more complicated surfaces where normal mesh - instructions would produce ragged borders.

enneper = {u - (u^3/3) + u v^2, v - (v^3/3) + u^2 v, u^2 - v^2};

mesh = 
  Rescale[#, MinMax @ #, {-2, 2}] & @
    Accumulate[Flatten @ ConstantArray[{1, 1/2}, 15]];

ParametricPlot3D[enneper, {u, -2, 2}, {v, -2, 2},
 ImageSize -> Large,
 Lighting -> "ThreePoint",
 MeshStyle -> None,
 MeshShading -> {{Automatic, Automatic}, {None, Automatic}},
 Mesh -> {mesh, Rest @ mesh},
 PlotPoints -> 64,
 PlotStyle -> Directive[FaceForm[Red, Darker @ Green]]]

enter image description here

$\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.