How to find the intersection of two `path3[]`











up vote
7
down vote

favorite
1












I'm using Asymptote to draw some figures and I need to put a dot on the intersection of two path3 but the command intersectionpoint() doesn't work for path3. What can I do?










share|improve this question






















  • I am not familiar with this package but those who are will need to see a minimum working example in order to trouble shot your problem. This includes the preamble, begin and end document, and a small re-creation of the issue.
    – dustin
    Jul 26 '13 at 14:45















up vote
7
down vote

favorite
1












I'm using Asymptote to draw some figures and I need to put a dot on the intersection of two path3 but the command intersectionpoint() doesn't work for path3. What can I do?










share|improve this question






















  • I am not familiar with this package but those who are will need to see a minimum working example in order to trouble shot your problem. This includes the preamble, begin and end document, and a small re-creation of the issue.
    – dustin
    Jul 26 '13 at 14:45













up vote
7
down vote

favorite
1









up vote
7
down vote

favorite
1






1





I'm using Asymptote to draw some figures and I need to put a dot on the intersection of two path3 but the command intersectionpoint() doesn't work for path3. What can I do?










share|improve this question













I'm using Asymptote to draw some figures and I need to put a dot on the intersection of two path3 but the command intersectionpoint() doesn't work for path3. What can I do?







intersections asymptote






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 26 '13 at 14:23









user2482876

3531312




3531312












  • I am not familiar with this package but those who are will need to see a minimum working example in order to trouble shot your problem. This includes the preamble, begin and end document, and a small re-creation of the issue.
    – dustin
    Jul 26 '13 at 14:45


















  • I am not familiar with this package but those who are will need to see a minimum working example in order to trouble shot your problem. This includes the preamble, begin and end document, and a small re-creation of the issue.
    – dustin
    Jul 26 '13 at 14:45
















I am not familiar with this package but those who are will need to see a minimum working example in order to trouble shot your problem. This includes the preamble, begin and end document, and a small re-creation of the issue.
– dustin
Jul 26 '13 at 14:45




I am not familiar with this package but those who are will need to see a minimum working example in order to trouble shot your problem. This includes the preamble, begin and end document, and a small re-creation of the issue.
– dustin
Jul 26 '13 at 14:45










1 Answer
1






active

oldest

votes

















up vote
9
down vote



accepted










enter image description here



Built-in three-dimensional version of the
function intersectionpoints returns an array of intersection points
of the two 3d paths. To get the intersections
of two path3 arrays,
a simple function intersectionpoints3 can be used,
that checks and accumulates all combinations of the intersection points:



import three;
currentprojection=orthographic(camera=(-5,1.5,4),up=Y,target=O,zoom=1);

triple intersectionpoints3(path3 p,path3 q){
triple r=new triple;
triple s;
for(path3 pk:p){
for(path3 qj:q){
s=intersectionpoints(pk,qj);
if(s.length>0)r.append(s);
}
}
return r;
}

size(200);
path3 p=box(O,(1,1,1));
path3 q=(-0.5,0,0.5)--(1.5,0,0.5)..(2,0.5,0.5)..(1.5,1,0.5)
^^(1.5,1,0.5)--(-0.5,1,0.5)..(-1,0.5,0.5)..(-0.5,0,0.5);

draw(p,darkblue);
draw(q,orange);

dot(intersectionpoints3(p,q),red);





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%2f125565%2fhow-to-find-the-intersection-of-two-path3%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    9
    down vote



    accepted










    enter image description here



    Built-in three-dimensional version of the
    function intersectionpoints returns an array of intersection points
    of the two 3d paths. To get the intersections
    of two path3 arrays,
    a simple function intersectionpoints3 can be used,
    that checks and accumulates all combinations of the intersection points:



    import three;
    currentprojection=orthographic(camera=(-5,1.5,4),up=Y,target=O,zoom=1);

    triple intersectionpoints3(path3 p,path3 q){
    triple r=new triple;
    triple s;
    for(path3 pk:p){
    for(path3 qj:q){
    s=intersectionpoints(pk,qj);
    if(s.length>0)r.append(s);
    }
    }
    return r;
    }

    size(200);
    path3 p=box(O,(1,1,1));
    path3 q=(-0.5,0,0.5)--(1.5,0,0.5)..(2,0.5,0.5)..(1.5,1,0.5)
    ^^(1.5,1,0.5)--(-0.5,1,0.5)..(-1,0.5,0.5)..(-0.5,0,0.5);

    draw(p,darkblue);
    draw(q,orange);

    dot(intersectionpoints3(p,q),red);





    share|improve this answer

























      up vote
      9
      down vote



      accepted










      enter image description here



      Built-in three-dimensional version of the
      function intersectionpoints returns an array of intersection points
      of the two 3d paths. To get the intersections
      of two path3 arrays,
      a simple function intersectionpoints3 can be used,
      that checks and accumulates all combinations of the intersection points:



      import three;
      currentprojection=orthographic(camera=(-5,1.5,4),up=Y,target=O,zoom=1);

      triple intersectionpoints3(path3 p,path3 q){
      triple r=new triple;
      triple s;
      for(path3 pk:p){
      for(path3 qj:q){
      s=intersectionpoints(pk,qj);
      if(s.length>0)r.append(s);
      }
      }
      return r;
      }

      size(200);
      path3 p=box(O,(1,1,1));
      path3 q=(-0.5,0,0.5)--(1.5,0,0.5)..(2,0.5,0.5)..(1.5,1,0.5)
      ^^(1.5,1,0.5)--(-0.5,1,0.5)..(-1,0.5,0.5)..(-0.5,0,0.5);

      draw(p,darkblue);
      draw(q,orange);

      dot(intersectionpoints3(p,q),red);





      share|improve this answer























        up vote
        9
        down vote



        accepted







        up vote
        9
        down vote



        accepted






        enter image description here



        Built-in three-dimensional version of the
        function intersectionpoints returns an array of intersection points
        of the two 3d paths. To get the intersections
        of two path3 arrays,
        a simple function intersectionpoints3 can be used,
        that checks and accumulates all combinations of the intersection points:



        import three;
        currentprojection=orthographic(camera=(-5,1.5,4),up=Y,target=O,zoom=1);

        triple intersectionpoints3(path3 p,path3 q){
        triple r=new triple;
        triple s;
        for(path3 pk:p){
        for(path3 qj:q){
        s=intersectionpoints(pk,qj);
        if(s.length>0)r.append(s);
        }
        }
        return r;
        }

        size(200);
        path3 p=box(O,(1,1,1));
        path3 q=(-0.5,0,0.5)--(1.5,0,0.5)..(2,0.5,0.5)..(1.5,1,0.5)
        ^^(1.5,1,0.5)--(-0.5,1,0.5)..(-1,0.5,0.5)..(-0.5,0,0.5);

        draw(p,darkblue);
        draw(q,orange);

        dot(intersectionpoints3(p,q),red);





        share|improve this answer












        enter image description here



        Built-in three-dimensional version of the
        function intersectionpoints returns an array of intersection points
        of the two 3d paths. To get the intersections
        of two path3 arrays,
        a simple function intersectionpoints3 can be used,
        that checks and accumulates all combinations of the intersection points:



        import three;
        currentprojection=orthographic(camera=(-5,1.5,4),up=Y,target=O,zoom=1);

        triple intersectionpoints3(path3 p,path3 q){
        triple r=new triple;
        triple s;
        for(path3 pk:p){
        for(path3 qj:q){
        s=intersectionpoints(pk,qj);
        if(s.length>0)r.append(s);
        }
        }
        return r;
        }

        size(200);
        path3 p=box(O,(1,1,1));
        path3 q=(-0.5,0,0.5)--(1.5,0,0.5)..(2,0.5,0.5)..(1.5,1,0.5)
        ^^(1.5,1,0.5)--(-0.5,1,0.5)..(-1,0.5,0.5)..(-0.5,0,0.5);

        draw(p,darkblue);
        draw(q,orange);

        dot(intersectionpoints3(p,q),red);






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 26 '13 at 18:12









        g.kov

        17.1k13975




        17.1k13975






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f125565%2fhow-to-find-the-intersection-of-two-path3%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

            サソリ

            広島県道265号伴広島線

            Accessing regular linux commands in Huawei's Dopra Linux