Menu

Asymptote 2.32, ubuntu 12.04, bug in arc drawing

Help
gummybears
2014-07-28
2014-07-28
  • gummybears

    gummybears - 2014-07-28

    There is a bug in the arc and Arc routine. For demonstration a short asy drawing.
    When the common pair is (0,0) the arc is draw correctly.
    However when using a non (0,0) pair, the arc is wrong.
    I made sure the length of both pairs are equal.

    Please advice.

    import graph;
    settings.outformat="pdf";
    settings.tex="pdflatex";
    size(4cm,4cm);

    // test of path arc(pair c, explicit pair z1, explicit pair z2, bool direction=CCW)
    // page 36 of asymptote manual
    picture lv_pic_a, lv_pic_b;

    pair C,A,B;
    dotfactor = 3;
    path lv_path;

    // picture A, wrong arc
    C = (1,1);
    A = (2,1);
    B = (2,1.5);

    lv_path = Arc(C,0.5unit(A),0.5unit(B));
    draw(lv_pic_a,lv_path,red);
    draw(lv_pic_a,C--A);
    draw(lv_pic_a,C--B);
    draw(lv_pic_a,A--B);
    label(lv_pic_a,"Wrong arc drawing", (0,2.5),fontsize(6pt));
    label(lv_pic_a,"$C (1,1)$",C,S,fontsize(6pt));
    label(lv_pic_a,"$A (2,1)$",A,E,fontsize(6pt));
    label(lv_pic_a,"$B (2,1.5)$",B,N,fontsize(6pt));
    dot(lv_pic_a,C, red);
    dot(lv_pic_a,A,blue);
    dot(lv_pic_a,B, green);
    add(lv_pic_a);

    // picture B, C is (0,0)
    // picture A, wrong arc
    C = (0,0);
    A = (1,0);
    B = (1,0.5);

    lv_path = Arc(C,0.5unit(A),0.5unit(B));
    draw(lv_pic_b,lv_path,green);
    draw(lv_pic_b,C--A);
    draw(lv_pic_b,C--B);
    draw(lv_pic_b,A--B);
    label(lv_pic_b,"Correct arc drawing", (0,2.5),fontsize(6pt));
    label(lv_pic_b,"$C (0,0)$",C,S,fontsize(6pt));
    label(lv_pic_b,"$A (1,0)$",A,E,fontsize(6pt));
    label(lv_pic_b,"$B (1,0.5)$",B,N,fontsize(6pt));
    dot(lv_pic_b,C, red);
    dot(lv_pic_b,A,blue);
    dot(lv_pic_b,B, green);
    add(shift( (0,-3) ) * lv_pic_b);

     
  • James

    James - 2014-07-28

    I think it's not a bug. The problem is that the "0.5unit(A)" and "0.5unit(B)" define pairs 1cm from the (0,0) origin. You want to define pairs 1cm from point C.

    Replace your first "lv_path = " command with the following.

    lv_path = arc(C,0.5unit(A-C)+C,0.5unit(B-C)+C);
    

    Good luck,
    James

     

Log in to post a comment.