tikz — Snake like curves between straight lines











up vote
6
down vote

favorite
3












How do we draw a figure like this in tikz?



I am able to draw the straight lines, but these curves are too challenging -- how to draw them nice?



enter image description here



The minimal template is:



begin{tikzpicture}
draw[->] (0,0,0)--(0,8,0);
draw[->] (4,0,0)--(4,8,0);
end{tikzpicture}


I really appreciate your patience!










share|improve this question




















  • 1




    Very nice and good question for my opinion.
    – Sebastiano
    6 hours ago















up vote
6
down vote

favorite
3












How do we draw a figure like this in tikz?



I am able to draw the straight lines, but these curves are too challenging -- how to draw them nice?



enter image description here



The minimal template is:



begin{tikzpicture}
draw[->] (0,0,0)--(0,8,0);
draw[->] (4,0,0)--(4,8,0);
end{tikzpicture}


I really appreciate your patience!










share|improve this question




















  • 1




    Very nice and good question for my opinion.
    – Sebastiano
    6 hours ago













up vote
6
down vote

favorite
3









up vote
6
down vote

favorite
3






3





How do we draw a figure like this in tikz?



I am able to draw the straight lines, but these curves are too challenging -- how to draw them nice?



enter image description here



The minimal template is:



begin{tikzpicture}
draw[->] (0,0,0)--(0,8,0);
draw[->] (4,0,0)--(4,8,0);
end{tikzpicture}


I really appreciate your patience!










share|improve this question















How do we draw a figure like this in tikz?



I am able to draw the straight lines, but these curves are too challenging -- how to draw them nice?



enter image description here



The minimal template is:



begin{tikzpicture}
draw[->] (0,0,0)--(0,8,0);
draw[->] (4,0,0)--(4,8,0);
end{tikzpicture}


I really appreciate your patience!







tikz-pgf tikz-styles tikz-arrows technical-drawing draw






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 5 hours ago









Bernard

164k769192




164k769192










asked 6 hours ago









annie heart

23514




23514








  • 1




    Very nice and good question for my opinion.
    – Sebastiano
    6 hours ago














  • 1




    Very nice and good question for my opinion.
    – Sebastiano
    6 hours ago








1




1




Very nice and good question for my opinion.
– Sebastiano
6 hours ago




Very nice and good question for my opinion.
– Sebastiano
6 hours ago










2 Answers
2






active

oldest

votes

















up vote
7
down vote



accepted










That's a standard task for the knot library.



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{knots,arrows.meta}
begin{document}
begin{tikzpicture}
path (-0.5,6.5) coordinate (x1) (4.5,5) coordinate (x2)
(-0.5,3.5) coordinate (x3) (4.5,2.5) coordinate (x4);
begin{knot}%[draft mode=crossings]
strand[{Circle}-{Circle}] (0,0) -- (0,8);
strand[{Circle}-{Circle}] (4,0) -- (4,8);
strand[{Circle}-{Circle},looseness=0.5] (2,8) to[out=-90,in=90] (x1)
to[out=-90,in=90] (x2) to[out=-90,in=90] (x3)
to[out=-90,in=90] (x4) to[out=-90,in=90] (2,0);
flipcrossings{2,4,6,8}
end{knot}
end{tikzpicture}
end{document}


enter image description here



Or with the ordering as in your picture.



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{knots,arrows.meta}
begin{document}
begin{tikzpicture}
path (-0.5,6.5) coordinate (x1) (4.5,5) coordinate (x2)
(-0.5,3.5) coordinate (x3) (4.5,2.5) coordinate (x4);
begin{knot}%[draft mode=crossings]
strand[{Circle}-{Circle}] (0,0) -- (0,8);
strand[{Circle}-{Circle}] (4,0) -- (4,8);
strand[{Circle}-{Circle},looseness=0.5] (2,8) to[out=-90,in=90] (x1)
to[out=-90,in=90] (x2) to[out=-90,in=90] (x3)
to[out=-90,in=90] (x4) to[out=-90,in=90] (2,0);
flipcrossings{2,3,5,8}
end{knot}
end{tikzpicture}
end{document}


enter image description here



To find out which crossing has which number, uncomment [draft mode=crossings].






share|improve this answer























  • You are superfast! :-)
    – Sebastiano
    5 hours ago










  • Oh my god! I dont know this thing exist in tikz!!!! Thank you - (I was not aware and just posted another more technical question!)
    – annie heart
    5 hours ago


















up vote
3
down vote













Here's a version in plain Metapost featuring a useful idiom to find all the intersection points between two paths.



enter image description here



This is wrapped up in luamplib so compile it with lualatex (or work out how to adapt it for plain mpost).



documentclass[border=5mm]{standalone}
usepackage{luatex85}
usepackage{luamplib}
begin{document}
mplibtextextlabel{enable}
begin{mplibcode}
beginfig(1);
path s, t, a, b;
a = (down--up) scaled 164 shifted 72 left;
b = (down--up) scaled 164 shifted 72 right;
t = ((-36*4, 0) for x=-35 upto 36: .. (4x, 88 sind(10x)) endfor) rotated 90 reflectedabout(up, down);
s = point 0 of t shifted 20 down {up} .. {direction 2 of t} subpath (2,70) of t {direction 70 of t} .. point 72 of t shifted 20 up {up};

pickup pencircle scaled 1;

forsuffixes $=a, b, s:
draw $;
fill fullcircle scaled 4 shifted point 0 of $;
fill fullcircle scaled 4 shifted point infinity of $;
endfor

vardef over_and_under(expr a, b) =
save x, y, r, n, A, B, p;
path r; numeric n; picture A, B, p;
r := a;
n = 0;
forever:
r := r cutbefore b;
exitif length cuttings = 0;
r := subpath (epsilon, infinity) of r;
z[incr n] = point 0 of r;
endfor
A = image(draw a);
B = image(draw b);
for i=0 upto n:
if known z[i]:
unfill fullcircle scaled 10 shifted z[i];
p := if odd i: B else: A fi;
clip p to fullcircle scaled 10 shifted z[i];
draw p;
fi
endfor
enddef;

over_and_under(a, s);
over_and_under(b, s);

endfig;
end{mplibcode}
end{document}





share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f466275%2ftikz-snake-like-curves-between-straight-lines%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    7
    down vote



    accepted










    That's a standard task for the knot library.



    documentclass[tikz,border=3.14mm]{standalone}
    usetikzlibrary{knots,arrows.meta}
    begin{document}
    begin{tikzpicture}
    path (-0.5,6.5) coordinate (x1) (4.5,5) coordinate (x2)
    (-0.5,3.5) coordinate (x3) (4.5,2.5) coordinate (x4);
    begin{knot}%[draft mode=crossings]
    strand[{Circle}-{Circle}] (0,0) -- (0,8);
    strand[{Circle}-{Circle}] (4,0) -- (4,8);
    strand[{Circle}-{Circle},looseness=0.5] (2,8) to[out=-90,in=90] (x1)
    to[out=-90,in=90] (x2) to[out=-90,in=90] (x3)
    to[out=-90,in=90] (x4) to[out=-90,in=90] (2,0);
    flipcrossings{2,4,6,8}
    end{knot}
    end{tikzpicture}
    end{document}


    enter image description here



    Or with the ordering as in your picture.



    documentclass[tikz,border=3.14mm]{standalone}
    usetikzlibrary{knots,arrows.meta}
    begin{document}
    begin{tikzpicture}
    path (-0.5,6.5) coordinate (x1) (4.5,5) coordinate (x2)
    (-0.5,3.5) coordinate (x3) (4.5,2.5) coordinate (x4);
    begin{knot}%[draft mode=crossings]
    strand[{Circle}-{Circle}] (0,0) -- (0,8);
    strand[{Circle}-{Circle}] (4,0) -- (4,8);
    strand[{Circle}-{Circle},looseness=0.5] (2,8) to[out=-90,in=90] (x1)
    to[out=-90,in=90] (x2) to[out=-90,in=90] (x3)
    to[out=-90,in=90] (x4) to[out=-90,in=90] (2,0);
    flipcrossings{2,3,5,8}
    end{knot}
    end{tikzpicture}
    end{document}


    enter image description here



    To find out which crossing has which number, uncomment [draft mode=crossings].






    share|improve this answer























    • You are superfast! :-)
      – Sebastiano
      5 hours ago










    • Oh my god! I dont know this thing exist in tikz!!!! Thank you - (I was not aware and just posted another more technical question!)
      – annie heart
      5 hours ago















    up vote
    7
    down vote



    accepted










    That's a standard task for the knot library.



    documentclass[tikz,border=3.14mm]{standalone}
    usetikzlibrary{knots,arrows.meta}
    begin{document}
    begin{tikzpicture}
    path (-0.5,6.5) coordinate (x1) (4.5,5) coordinate (x2)
    (-0.5,3.5) coordinate (x3) (4.5,2.5) coordinate (x4);
    begin{knot}%[draft mode=crossings]
    strand[{Circle}-{Circle}] (0,0) -- (0,8);
    strand[{Circle}-{Circle}] (4,0) -- (4,8);
    strand[{Circle}-{Circle},looseness=0.5] (2,8) to[out=-90,in=90] (x1)
    to[out=-90,in=90] (x2) to[out=-90,in=90] (x3)
    to[out=-90,in=90] (x4) to[out=-90,in=90] (2,0);
    flipcrossings{2,4,6,8}
    end{knot}
    end{tikzpicture}
    end{document}


    enter image description here



    Or with the ordering as in your picture.



    documentclass[tikz,border=3.14mm]{standalone}
    usetikzlibrary{knots,arrows.meta}
    begin{document}
    begin{tikzpicture}
    path (-0.5,6.5) coordinate (x1) (4.5,5) coordinate (x2)
    (-0.5,3.5) coordinate (x3) (4.5,2.5) coordinate (x4);
    begin{knot}%[draft mode=crossings]
    strand[{Circle}-{Circle}] (0,0) -- (0,8);
    strand[{Circle}-{Circle}] (4,0) -- (4,8);
    strand[{Circle}-{Circle},looseness=0.5] (2,8) to[out=-90,in=90] (x1)
    to[out=-90,in=90] (x2) to[out=-90,in=90] (x3)
    to[out=-90,in=90] (x4) to[out=-90,in=90] (2,0);
    flipcrossings{2,3,5,8}
    end{knot}
    end{tikzpicture}
    end{document}


    enter image description here



    To find out which crossing has which number, uncomment [draft mode=crossings].






    share|improve this answer























    • You are superfast! :-)
      – Sebastiano
      5 hours ago










    • Oh my god! I dont know this thing exist in tikz!!!! Thank you - (I was not aware and just posted another more technical question!)
      – annie heart
      5 hours ago













    up vote
    7
    down vote



    accepted







    up vote
    7
    down vote



    accepted






    That's a standard task for the knot library.



    documentclass[tikz,border=3.14mm]{standalone}
    usetikzlibrary{knots,arrows.meta}
    begin{document}
    begin{tikzpicture}
    path (-0.5,6.5) coordinate (x1) (4.5,5) coordinate (x2)
    (-0.5,3.5) coordinate (x3) (4.5,2.5) coordinate (x4);
    begin{knot}%[draft mode=crossings]
    strand[{Circle}-{Circle}] (0,0) -- (0,8);
    strand[{Circle}-{Circle}] (4,0) -- (4,8);
    strand[{Circle}-{Circle},looseness=0.5] (2,8) to[out=-90,in=90] (x1)
    to[out=-90,in=90] (x2) to[out=-90,in=90] (x3)
    to[out=-90,in=90] (x4) to[out=-90,in=90] (2,0);
    flipcrossings{2,4,6,8}
    end{knot}
    end{tikzpicture}
    end{document}


    enter image description here



    Or with the ordering as in your picture.



    documentclass[tikz,border=3.14mm]{standalone}
    usetikzlibrary{knots,arrows.meta}
    begin{document}
    begin{tikzpicture}
    path (-0.5,6.5) coordinate (x1) (4.5,5) coordinate (x2)
    (-0.5,3.5) coordinate (x3) (4.5,2.5) coordinate (x4);
    begin{knot}%[draft mode=crossings]
    strand[{Circle}-{Circle}] (0,0) -- (0,8);
    strand[{Circle}-{Circle}] (4,0) -- (4,8);
    strand[{Circle}-{Circle},looseness=0.5] (2,8) to[out=-90,in=90] (x1)
    to[out=-90,in=90] (x2) to[out=-90,in=90] (x3)
    to[out=-90,in=90] (x4) to[out=-90,in=90] (2,0);
    flipcrossings{2,3,5,8}
    end{knot}
    end{tikzpicture}
    end{document}


    enter image description here



    To find out which crossing has which number, uncomment [draft mode=crossings].






    share|improve this answer














    That's a standard task for the knot library.



    documentclass[tikz,border=3.14mm]{standalone}
    usetikzlibrary{knots,arrows.meta}
    begin{document}
    begin{tikzpicture}
    path (-0.5,6.5) coordinate (x1) (4.5,5) coordinate (x2)
    (-0.5,3.5) coordinate (x3) (4.5,2.5) coordinate (x4);
    begin{knot}%[draft mode=crossings]
    strand[{Circle}-{Circle}] (0,0) -- (0,8);
    strand[{Circle}-{Circle}] (4,0) -- (4,8);
    strand[{Circle}-{Circle},looseness=0.5] (2,8) to[out=-90,in=90] (x1)
    to[out=-90,in=90] (x2) to[out=-90,in=90] (x3)
    to[out=-90,in=90] (x4) to[out=-90,in=90] (2,0);
    flipcrossings{2,4,6,8}
    end{knot}
    end{tikzpicture}
    end{document}


    enter image description here



    Or with the ordering as in your picture.



    documentclass[tikz,border=3.14mm]{standalone}
    usetikzlibrary{knots,arrows.meta}
    begin{document}
    begin{tikzpicture}
    path (-0.5,6.5) coordinate (x1) (4.5,5) coordinate (x2)
    (-0.5,3.5) coordinate (x3) (4.5,2.5) coordinate (x4);
    begin{knot}%[draft mode=crossings]
    strand[{Circle}-{Circle}] (0,0) -- (0,8);
    strand[{Circle}-{Circle}] (4,0) -- (4,8);
    strand[{Circle}-{Circle},looseness=0.5] (2,8) to[out=-90,in=90] (x1)
    to[out=-90,in=90] (x2) to[out=-90,in=90] (x3)
    to[out=-90,in=90] (x4) to[out=-90,in=90] (2,0);
    flipcrossings{2,3,5,8}
    end{knot}
    end{tikzpicture}
    end{document}


    enter image description here



    To find out which crossing has which number, uncomment [draft mode=crossings].







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 5 hours ago

























    answered 5 hours ago









    marmot

    83.8k493178




    83.8k493178












    • You are superfast! :-)
      – Sebastiano
      5 hours ago










    • Oh my god! I dont know this thing exist in tikz!!!! Thank you - (I was not aware and just posted another more technical question!)
      – annie heart
      5 hours ago


















    • You are superfast! :-)
      – Sebastiano
      5 hours ago










    • Oh my god! I dont know this thing exist in tikz!!!! Thank you - (I was not aware and just posted another more technical question!)
      – annie heart
      5 hours ago
















    You are superfast! :-)
    – Sebastiano
    5 hours ago




    You are superfast! :-)
    – Sebastiano
    5 hours ago












    Oh my god! I dont know this thing exist in tikz!!!! Thank you - (I was not aware and just posted another more technical question!)
    – annie heart
    5 hours ago




    Oh my god! I dont know this thing exist in tikz!!!! Thank you - (I was not aware and just posted another more technical question!)
    – annie heart
    5 hours ago










    up vote
    3
    down vote













    Here's a version in plain Metapost featuring a useful idiom to find all the intersection points between two paths.



    enter image description here



    This is wrapped up in luamplib so compile it with lualatex (or work out how to adapt it for plain mpost).



    documentclass[border=5mm]{standalone}
    usepackage{luatex85}
    usepackage{luamplib}
    begin{document}
    mplibtextextlabel{enable}
    begin{mplibcode}
    beginfig(1);
    path s, t, a, b;
    a = (down--up) scaled 164 shifted 72 left;
    b = (down--up) scaled 164 shifted 72 right;
    t = ((-36*4, 0) for x=-35 upto 36: .. (4x, 88 sind(10x)) endfor) rotated 90 reflectedabout(up, down);
    s = point 0 of t shifted 20 down {up} .. {direction 2 of t} subpath (2,70) of t {direction 70 of t} .. point 72 of t shifted 20 up {up};

    pickup pencircle scaled 1;

    forsuffixes $=a, b, s:
    draw $;
    fill fullcircle scaled 4 shifted point 0 of $;
    fill fullcircle scaled 4 shifted point infinity of $;
    endfor

    vardef over_and_under(expr a, b) =
    save x, y, r, n, A, B, p;
    path r; numeric n; picture A, B, p;
    r := a;
    n = 0;
    forever:
    r := r cutbefore b;
    exitif length cuttings = 0;
    r := subpath (epsilon, infinity) of r;
    z[incr n] = point 0 of r;
    endfor
    A = image(draw a);
    B = image(draw b);
    for i=0 upto n:
    if known z[i]:
    unfill fullcircle scaled 10 shifted z[i];
    p := if odd i: B else: A fi;
    clip p to fullcircle scaled 10 shifted z[i];
    draw p;
    fi
    endfor
    enddef;

    over_and_under(a, s);
    over_and_under(b, s);

    endfig;
    end{mplibcode}
    end{document}





    share|improve this answer



























      up vote
      3
      down vote













      Here's a version in plain Metapost featuring a useful idiom to find all the intersection points between two paths.



      enter image description here



      This is wrapped up in luamplib so compile it with lualatex (or work out how to adapt it for plain mpost).



      documentclass[border=5mm]{standalone}
      usepackage{luatex85}
      usepackage{luamplib}
      begin{document}
      mplibtextextlabel{enable}
      begin{mplibcode}
      beginfig(1);
      path s, t, a, b;
      a = (down--up) scaled 164 shifted 72 left;
      b = (down--up) scaled 164 shifted 72 right;
      t = ((-36*4, 0) for x=-35 upto 36: .. (4x, 88 sind(10x)) endfor) rotated 90 reflectedabout(up, down);
      s = point 0 of t shifted 20 down {up} .. {direction 2 of t} subpath (2,70) of t {direction 70 of t} .. point 72 of t shifted 20 up {up};

      pickup pencircle scaled 1;

      forsuffixes $=a, b, s:
      draw $;
      fill fullcircle scaled 4 shifted point 0 of $;
      fill fullcircle scaled 4 shifted point infinity of $;
      endfor

      vardef over_and_under(expr a, b) =
      save x, y, r, n, A, B, p;
      path r; numeric n; picture A, B, p;
      r := a;
      n = 0;
      forever:
      r := r cutbefore b;
      exitif length cuttings = 0;
      r := subpath (epsilon, infinity) of r;
      z[incr n] = point 0 of r;
      endfor
      A = image(draw a);
      B = image(draw b);
      for i=0 upto n:
      if known z[i]:
      unfill fullcircle scaled 10 shifted z[i];
      p := if odd i: B else: A fi;
      clip p to fullcircle scaled 10 shifted z[i];
      draw p;
      fi
      endfor
      enddef;

      over_and_under(a, s);
      over_and_under(b, s);

      endfig;
      end{mplibcode}
      end{document}





      share|improve this answer

























        up vote
        3
        down vote










        up vote
        3
        down vote









        Here's a version in plain Metapost featuring a useful idiom to find all the intersection points between two paths.



        enter image description here



        This is wrapped up in luamplib so compile it with lualatex (or work out how to adapt it for plain mpost).



        documentclass[border=5mm]{standalone}
        usepackage{luatex85}
        usepackage{luamplib}
        begin{document}
        mplibtextextlabel{enable}
        begin{mplibcode}
        beginfig(1);
        path s, t, a, b;
        a = (down--up) scaled 164 shifted 72 left;
        b = (down--up) scaled 164 shifted 72 right;
        t = ((-36*4, 0) for x=-35 upto 36: .. (4x, 88 sind(10x)) endfor) rotated 90 reflectedabout(up, down);
        s = point 0 of t shifted 20 down {up} .. {direction 2 of t} subpath (2,70) of t {direction 70 of t} .. point 72 of t shifted 20 up {up};

        pickup pencircle scaled 1;

        forsuffixes $=a, b, s:
        draw $;
        fill fullcircle scaled 4 shifted point 0 of $;
        fill fullcircle scaled 4 shifted point infinity of $;
        endfor

        vardef over_and_under(expr a, b) =
        save x, y, r, n, A, B, p;
        path r; numeric n; picture A, B, p;
        r := a;
        n = 0;
        forever:
        r := r cutbefore b;
        exitif length cuttings = 0;
        r := subpath (epsilon, infinity) of r;
        z[incr n] = point 0 of r;
        endfor
        A = image(draw a);
        B = image(draw b);
        for i=0 upto n:
        if known z[i]:
        unfill fullcircle scaled 10 shifted z[i];
        p := if odd i: B else: A fi;
        clip p to fullcircle scaled 10 shifted z[i];
        draw p;
        fi
        endfor
        enddef;

        over_and_under(a, s);
        over_and_under(b, s);

        endfig;
        end{mplibcode}
        end{document}





        share|improve this answer














        Here's a version in plain Metapost featuring a useful idiom to find all the intersection points between two paths.



        enter image description here



        This is wrapped up in luamplib so compile it with lualatex (or work out how to adapt it for plain mpost).



        documentclass[border=5mm]{standalone}
        usepackage{luatex85}
        usepackage{luamplib}
        begin{document}
        mplibtextextlabel{enable}
        begin{mplibcode}
        beginfig(1);
        path s, t, a, b;
        a = (down--up) scaled 164 shifted 72 left;
        b = (down--up) scaled 164 shifted 72 right;
        t = ((-36*4, 0) for x=-35 upto 36: .. (4x, 88 sind(10x)) endfor) rotated 90 reflectedabout(up, down);
        s = point 0 of t shifted 20 down {up} .. {direction 2 of t} subpath (2,70) of t {direction 70 of t} .. point 72 of t shifted 20 up {up};

        pickup pencircle scaled 1;

        forsuffixes $=a, b, s:
        draw $;
        fill fullcircle scaled 4 shifted point 0 of $;
        fill fullcircle scaled 4 shifted point infinity of $;
        endfor

        vardef over_and_under(expr a, b) =
        save x, y, r, n, A, B, p;
        path r; numeric n; picture A, B, p;
        r := a;
        n = 0;
        forever:
        r := r cutbefore b;
        exitif length cuttings = 0;
        r := subpath (epsilon, infinity) of r;
        z[incr n] = point 0 of r;
        endfor
        A = image(draw a);
        B = image(draw b);
        for i=0 upto n:
        if known z[i]:
        unfill fullcircle scaled 10 shifted z[i];
        p := if odd i: B else: A fi;
        clip p to fullcircle scaled 10 shifted z[i];
        draw p;
        fi
        endfor
        enddef;

        over_and_under(a, s);
        over_and_under(b, s);

        endfig;
        end{mplibcode}
        end{document}






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 4 hours ago

























        answered 4 hours ago









        Thruston

        25.8k24189




        25.8k24189






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f466275%2ftikz-snake-like-curves-between-straight-lines%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Morgemoulin

            Scott Moir

            Souastre