12

I want to make a tikzpicture to illustrate the construction of a spiral capacitor. These are made of spiral coiled films. So imagine a rectangular paper that you tail around one side. Thats basically how it looks like. Well I can programme this in MATLAB using cylindrical coordinates, then regrid to cathesian and then plot with pgfplots, but I think there must be a easier way. When I think of the possibilities of TikZ I think more about drawing a rectangle and tail it around a path I specified before. But sadly I found nothing about how to do that.

Anyone any idea?

  • 1
    It's a little hard to imagine... I think you should clarify what you want by posting a picture, e.g. one you found on the web. – John Wickerson May 23 '13 at 16:40
17

You could use PGFPlots for this:

\documentclass[tikz,border=12pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{
    colormap/outside/.style={
        colormap=
            {outside}{
            rgb255(0cm)=(235,235,235);
            rgb255(1cm)=(100,100,100);
            }
    },
    colormap/outside,
    colormap/inside/.style={
        colormap={inside}{
            rgb255(0cm)=(120,120,120);
            rgb255(1cm)=(255,255,255);
        }
    },
    colormap/inside
}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
    hide axis,
    axis equal image,
    z buffer=sort,
    view={30}{40},
    width=15cm
]
\addplot3 [
    surf,
    domain=0:3*360,
    samples=100,
    y domain=0:2000,
    samples y=2,
    line join=round,
    mesh/interior colormap name=inside,
    colormap/outside,
    shader=faceted,
    variable=\t,
    point meta={cos(t)},
    faceted color=black,
] ({cos(t)*1.1*t},{sin(t)*1.1*(t)},{y});
\end{axis}
\end{tikzpicture}
\end{document}
15

enter image description here

Asymptote version as an extruded surface from a spiral curve, spiral.asy:

size(300);
size3(300,300,300,IgnoreAspect);
import graph;
import solids;

currentprojection=orthographic(camera=(3640,2030,-0.8),up=(1.4,0.58,0.004),target=(0,0,0),zoom=0.618);

currentlight=light(gray(0.8),ambient=gray(0.1),specular=gray(0.7),
                     specularfactor=3,viewport=true,dir(42,48));

real a,b;
a=1;b=1;

pair spiral(real phi){
  real r=a+b*phi;
  return r*(Cos(phi),Sin(phi));
};
real phiMax=-90+3*360+20;
guide g=graph(spiral,0,phiMax,operator..);

pen bpen=rgb(0.75, 0.7, 0.1);
material m=material(diffusepen=0.7bpen
,ambientpen=bpen,emissivepen=0.3*bpen,specularpen=0.999white,shininess=1.0);

draw(extrude(g,(0,0,1)),m,render(merge=true));
  • This is extremely beautiful! – Gonzalo Medina May 23 '13 at 19:40
  • 1
    I agree with Gonzalo, this is amazing! I've finally installed asymptote after seeing this example. One question: I've put the code into an asy environment, and it seems there's a lot of white space around the spiral. Is there a way to automatically crop the canvas? – Jake May 23 '13 at 20:16
  • 1
    @Jake: Command asy -f pdf -noprc -render=0 spiral.asy results in a trimmed standalone spiral.pdf. – g.kov May 23 '13 at 20:42
  • Wow, Thank you so much. That's really nice.. Thank you so much for coding this! I hope sometime I am able to help other guys like you do! – Matthias Gräser May 23 '13 at 21:07
  • Your asymptote answers are amazing. Nice work. – Philipp Jun 7 '13 at 19:24
10

run with xelatex:

\documentclass{article}
\usepackage{pst-solides3d}
\begin{document}

\psframebox{%
\begin{pspicture}(-3,-4)(3,3)
\psset{lightsrc=viewpoint,viewpoint=10 -10 50 rtp2xyz,Decran=20}
\defFunction[algebraic]{G}(t)
   {0.15*t*cos(3*t)}{0.15*t*sin(3*t)}{-2}
\psSolid[object=cylindre,incolor=blue!30,
   range=-1 8,h=3,function=G,axe=0 0 1,ngrid=3 144]
\end{pspicture}}
%
\psframebox{%
\begin{pspicture}(-3,-2)(3,3)
\psset{lightsrc=15 5 10,viewpoint=10 -10 80 rtp2xyz,Decran=20}
\defFunction[algebraic]{G}(t)
   {0.15*t*cos(3*t)}{0.15*t*sin(3*t)}{-2}
\psSolid[object=cylindre,incolor=blue!30,
   range=-1 8,h=3,function=G,axe=0 0 1,ngrid=3 144]
\end{pspicture}}

\end{document}

change the equation G(t) with x=f(t), y=f(t), and z=f(t) to whatever you like.

enter image description here

  • Thank you for your solution, that's exactly what i was looking for! – Matthias Gräser May 23 '13 at 21: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.