26

I'm trying to recreate this

enter image description here quack

But looking in this Meta question the only code provided doesn't give that output

%!TEX TS-program = xelatex
\documentclass{minimal}
\usepackage{pst-solides3d}

\begin{document} 

\psset{viewpoint=50 20 10 rtp2xyz,Decran=50}
\psset{unit=0.75}
\begin{pspicture}(-5,-5)(5,5)
\psSolid[object=sphere,r=4,action=draw*,ngrid=9 9,resolution=720]%
\defFunction[algebraic]{helicespherique}(t)%
  {4*cos(10*t)*cos(t)}%
  {4*sin(10*t)*cos(t)}%
  {4*sin(t)}
\psSolid[object=courbe,linecolor=blue,
        resolution=720,range=pi -2 div pi 2 div,
       function=helicespherique,r=0.05]
%\gridIIID[Zmin=-4,Zmax=4](-4,4)(-4,4)
\end{pspicture}

\end{document} 

enter image description here

But I know nothing about PSTricks

How can I reproduce the sphere in the backround of this site?

I'm looking for code (in TikZ, MetaPost, Asymptote or PStricks) to reproduce the image. An important thing is that what's behind the ball should be in another layer (thinner or gray). Like the image from this site.

In any case, this is what I ended up with a few changes from the code

\documentclass{standalone}
\usepackage{pst-solides3d}

\begin{document} 

\psset{viewpoint=50 20 40 rtp2xyz,Decran=50}
\psset{unit=0.75}
\begin{pspicture}(-5,-5)(5,5)
\psSolid[object=sphere,r=4,fillcolor=white,ngrid=14 14,resolution=720,linewidth=.1pt,linecolor=gray]%
\defFunction[algebraic]{helicespherique}(t)%
  {4*cos(2*t)*cos(t)}%
  {4*sin(2*t)*cos(t)}%
  {4*sin(t)}
\psSolid[object=courbe,linecolor=black,
        resolution=720,range=pi -2 div pi 2 div,
       function=helicespherique,r=0.0001]
\end{pspicture}

\end{document} 

enter image description here

Manuel
  • 27,118

5 Answers5

14

The (original) image was created using ePiX (available from CTAN). The source sphere.xp can be compiled using

elaps <options> sphere.xp

to produce

enter image description here

sphere.xp:

/* -*-ePiX-*- */
#include "epix.h"
using namespace ePiX;

const double k(2M_PI/(360sqrt(3))); // assume "degrees" mode

double exp_cos(double t) { return exp(kt)Cos(t); } double exp_sin(double t) { return exp(kt)Sin(t); } double minus_exp_cos(double t) { return -exp_cos(t); } double minus_exp_sin(double t) { return -exp_sin(t); }

int main() { picture(P(-1,-1), P(1,1), "2.5 x 2.5in");

begin(); degrees(); // set angle units camera.at(P(1, 2.5, 3));

sphere(); // draw unit sphere's horizon

pen(Blue(1.6)); // hidden portions of loxodromes backplot_N(exp_cos, exp_sin, -540, 540, 180); backplot_N(minus_exp_cos, minus_exp_sin, -540, 540, 180);

pen(Red(1.6)); backplot_N(exp_sin, minus_exp_cos, -540, 540, 180); backplot_N(minus_exp_sin, exp_cos, -540, 540, 180);

pen(Black(0.3)); // coordinate grid

for (int i=0; i<=12; ++i) { latitude(90-15i, 0, 360); longitude(30i, 0, 360); }

bold(Blue()); // visible portions of loxodromes frontplot_N(exp_cos, exp_sin, -540, 540, 360); frontplot_N(minus_exp_cos, minus_exp_sin, -540, 540, 360);

pen(Red()); frontplot_N(exp_sin, minus_exp_cos, -540, 540, 360); frontplot_N(minus_exp_sin, exp_cos, -540, 540, 360);

end(); }

Possible outputs:

Werner
  • 603,163
  • I was going to accept this answer. But may be if the question is not marked as answered more people propose other solutions with other programs? I will wait a few days and then accept it (because this is the answer). In any case, you could post this here in the Meta post. – Manuel Jun 24 '15 at 17:49
  • 1
    @Manuel Herbert also did this via PSTricks which is not so difficult for him too. But I can't find the answer. This is not how he did it . – percusse Jun 24 '15 at 17:59
7

Minimal Working Solution

\documentclass[pstricks,margin=1mm]{standalone}
\usepackage{pst-solides3d}

\psset{viewpoint=50 70 50 rtp2xyz,Decran=50,linewidth=0.5\pslinewidth}

\defFunction[algebraic]{helicespherique}(t)
        {0.5*cos(10*t)*cos(t)}
        {0.5*sin(10*t)*cos(t)}
        {0.5*sin(t)}    

\begin{document}
\begin{pspicture*}(-0.5,-0.5)(0.5,0.5)
    \psSolid
    [
        object=sphere,
        fillcolor=gray,
        opacity=.25,
        strokeopacity=.25,
        ngrid=30 30,
        r=0.5,
        grid=false,
    ]
    \psSolid
    [
        object=courbe,
        linewidth=0.05pt,
        range=pi -.5 mul 0.5 pi mul,
        function=helicespherique,
        r=0.005,
        grid=false,
    ]
\end{pspicture*}
\end{document}

enter image description here

6

The package pst-rubans draws a spiral ribbon on objects (cylinder, cone, torus, paraboloid, sphere).

pst-rubans – Draw three-dimensional ribbons

\documentclass{article}
\usepackage{pst-rubans}
\begin{document}
\begin{center}
\begin{pspicture}(-5,-5)(5,5)
\psframe*(-5,-5)(5,5)
\psset{viewpoint=50 20 40,Decran=50,resolution=720,lightsrc=viewpoint}
\psSphericalSpiral[incolor=yellow!20,R=4,fillcolor=orange,grid,dPHI=8]
\end{pspicture}
\end{center}
\end{document} 

enter image description here

user73104
  • 949
5
\documentclass{standalone}
\usepackage{pst-solides3d}
\begin{document} 

\psset{viewpoint=50 20 40 rtp2xyz,Decran=50,unit=0.75}
\begin{pspicture}(-5,-5)(5,5)
    \psSolid[object=sphere,r=4,ngrid=20 20,linewidth=.1pt,linecolor=black!10,
      action=draw]% don't use hidden lines
    \defFunction[algebraic]{helix}(t)%
        {4*cos(3*t)*cos(t)}%
        {4*sin(3*t)*cos(t)}%
        {4*sin(t)}
    \psSolid[object=courbe,linecolor=black,range=-0.33 1.57,
            function=helix,r=0.02]
    \psSolid[object=courbe,linecolor=black!30,range=-1.57 -0.33,
    function=helix,r=0.02]
\end{pspicture}

\end{document} 

enter image description here

5

Using the code with epix, please find a (non optimized) Asymptote version.

size(10cm);
import three;
import graph3;
import math;
import solids;
settings.render=0; 
settings.prc=false; // on se restreint à une vue 2d


currentprojection=orthographic(1,2.5,3);

real  k=2*pi/(360*sqrt(3));

real  exp_cos(real t) { return exp(k*t)*Cos(t); }
real  exp_sin(real t) { return exp(k*t)*Sin(t); }
real minus_exp_cos(real t) { return -exp_cos(t); }
real minus_exp_sin(real t) { return -exp_sin(t); }

triple f1(real t)
{
  real ss;
  triple ff;
  ss=exp_cos(t)^2+exp_sin(t)^2+1;
  ff=(2*exp_cos(t)/ss,2*exp_sin(t)/ss,(ss-2)/ss);
  return ff;
}


triple f2(real t)
{
  real ss;
  triple ff;
  ss=minus_exp_cos(t)^2+minus_exp_sin(t)^2+1;
  ff=(2*minus_exp_cos(t)/ss,2*minus_exp_sin(t)/ss,(ss-2)/ss);
  return ff;
}

triple f3(real t)
{
  real ss;
  triple ff;
  ss=exp_sin(t)^2+minus_exp_cos(t)^2+1;
  ff=(2*exp_sin(t)/ss,2*minus_exp_cos(t)/ss,(ss-2)/ss);
  return ff;
}


triple f4(real t)
{
  real ss;
  triple ff;
  ss=minus_exp_sin(t)^2+exp_cos(t)^2+1;
  ff=(2*minus_exp_sin(t)/ss,2*exp_cos(t)/ss,(ss-2)/ss);
  return ff;
}


revolution r=sphere(O,1);
draw(r,9,gray,longitudinalpen=nullpen,backpen=nullpen);
draw(r.silhouette());


for(int k=-2; k<5;++k) 
  draw(rotate(k*30,(0,0,1))*rotate(-90,(1,0,0))*r,1,gray,
       longitudinalpen=nullpen,backpen=nullpen);
int nbpts=280;
real step=1080/nbpts;


draw(graph(f1,-540,540,280,Spline),blue+gray);
draw(graph(f2,-540,540,280,Spline),blue+gray);
draw(graph(f3,-540,540,280,Spline),red+gray);
draw(graph(f4,-540,540,280,Spline),red+gray);


triple[] P1=new triple[nbpts];
triple[] P2=new triple[nbpts];
triple[] P3=new triple[nbpts];
triple[] P4=new triple[nbpts];

for(int i=0; i < nbpts; ++i) {
  real t=-540+i*step;
  P1[i]=f1(t);
  P2[i]=f2(t);
  P3[i]=f3(t);
  P4[i]=f4(t);

}

bool[] front1=new bool[nbpts];
bool[] front2=new bool[nbpts];
bool[] front3=new bool[nbpts];
bool[] front4=new bool[nbpts];


for(int i=0; i < nbpts; ++i) {
  front1[i]=dot(P1[i],currentprojection.camera) > 0;
  front2[i]=dot(P2[i],currentprojection.camera) > 0;
  front3[i]=dot(P3[i],currentprojection.camera) > 0;
  front4[i]=dot(P4[i],currentprojection.camera) > 0;
}
draw(segment(P1,front1,operator ..),blue+1bp);
draw(segment(P2,front2,operator ..),blue+1bp);
draw(segment(P3,front3,operator ..),red+1bp);
draw(segment(P4,front4,operator ..),red+1bp);

And the result.

enter image description here

O.G.
  • 3,375