3
$\begingroup$

Found this beautiful plot here

plot

but I don't know how to write the code for the Mathematica plot... I found the parameterization

$\begin{pmatrix}x\\y\\z\end{pmatrix} = \begin{pmatrix}[2+\cos(u)]\cos(v)\\ [2 + \cos(u + 2 \pi / 3)] \cos(v + 2 \pi / 3) \\ [2 + {\rm{sign}}(F(u)) \sqrt{|F(u)|}] {\rm{sign}}(F(v)) \sqrt{|F(v)|} \end{pmatrix}$

where $F(s) = 1 - \cos(s)^2 - \cos(s + 2 \pi / 3)^2$ and $0\le u\le 2\pi$, $0\le v\le 2\pi$

It should be possible, but I just can't figure out how to do it.

Would be nice if someone could help me.


With your help I've come this far enter image description here

The Code I'm currently woriking with is

ParametricPlot3D[{(2 + Cos[u]) Cos[v], (2 + Cos[u + (2 \[Pi])/3]) Cos[
v + (2 \[Pi])/3], (2 + Sign[F[u]]) Sqrt[Abs[F[u]]]
Sign[F[v]] Sqrt[Abs[F[v]]]}, {u, 0, 2 \[Pi]}, {v, 0, 2 \[Pi]}, 
Mesh -> All, MeshFunctions -> Automatic, PlotPoints -> 200, 
Boxed -> False, Axes -> False, Exclusions -> None, 
PlotRangePadding -> None, ColorFunction -> Hue, 
PlotTheme -> "Simple"]

The Problem is, that I want the mesh to be coloured and the space between the lines to be empty. But that's not really working..

Has anyone a idea how to implement that?

Thanks

$\endgroup$
  • 3
    $\begingroup$ Use ParametricPlot3D. $\endgroup$ – Szabolcs Apr 11 '17 at 20:56
  • 5
    $\begingroup$ What's the source? Also, please give the equations in Mathematica syntax. $\endgroup$ – C. E. Apr 11 '17 at 21:25
6
$\begingroup$

directly drawing grid lines:

F[u_] = 1 - Cos[u]^2 - Cos[u + 2/3 Pi]^2;
g[u_, v_] = {
   (2 + Cos[u]) Cos[v],
   (2 + Cos[u + (2 \[Pi])/3]) Cos[v + (2 \[Pi])/3],
   (2 + Sign[F[u]]) Sqrt[Abs[F[u]]] Sign[F[v]] Sqrt[Abs[F[v]]]};
Graphics3D[
 {Table[Line[#, VertexColors -> (Hue /@ (#[[All, 1]]/3 /Pi))] &@ 
    Table[ g[u, v] , {u, 0, 2 Pi, Pi/40}], {v, 0, 2 Pi, Pi/40}],
  Table[Line[#, VertexColors -> (Hue /@ (#[[All, 1]]/3 /Pi))] &@ 
    Table[ g[u, v] , {v, 0, 2 Pi, Pi/40}], {u, 0, 2 Pi, Pi/40}]}, 
 Boxed -> False]

enter image description here

$\endgroup$
  • $\begingroup$ One could use ParametricPlot3D[] with an appropriate ColorFunction, too. $\endgroup$ – J. M. is away Apr 13 '17 at 15:05
4
$\begingroup$

Too long for a comment.

It is certainly very different from your plot, but this is what I got using your parametrisation and ParametricPlot3D as suggested by Szabolcs and Exclusions->None as suggested by J.M.:

enter image description here

F[s_] = 1 - Cos[s]^2 - Cos[s + 2 Pi/3]^2;
ParametricPlot3D[{(2 + Cos[u]) Cos[v], (2 + Cos[u + 2 Pi/3]) Cos[
    v + 2 Pi/3], (2 + Sign[F[u]])*
   Sqrt[Abs[F[u]]] Sign[F[v]] Sqrt[Abs[F[v]]]}, {u, 0, 2 Pi}, {v, 0, 
  2 Pi}, PlotPoints -> 200, Boxed -> False, Axes -> False, 
 Exclusions -> None, PlotRangePadding -> None]

For fun, we can add the following options taken from the documentation of ParametricPlot3D:

Mesh -> 100, MeshFunctions -> {#5 - 3 #4 &}, 
ColorFunction -> Function[{x, y, z, u, v}, Hue[u/(2 Pi)]], 
ColorFunctionScaling -> False,  MeshShading -> {Black, Automatic, Automatic},
MeshStyle -> None]

enter image description here

You might get further help by being more specific about what issues you are facing.

$\endgroup$
  • $\begingroup$ You might want to add Exclusions -> None. $\endgroup$ – J. M. is away Apr 12 '17 at 2:27
  • $\begingroup$ @J.M. Thanks, edited. $\endgroup$ – anderstood Apr 12 '17 at 2:40

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.