Formula to draw arcs ending in straight lines, Y as a function of X, starting slope, ending slope, starting point and arc radius?

帅比萌擦擦* 提交于 2019-11-28 14:47:54

Well I see it like this:

  1. compute P0

    as intersection of lines A + t*dA and B - t*dB

  2. compute P1 (center of circle)

    it is intersection of translated lines A->P0 and B->P0 perpendicular by radius r. There are 2 possibilities so choose the right one (which leads to less angle of circular part).

  3. compute P2,P3

    just an intersection between lines A-P0 and B-P0 and perpendicular line from P1 to it

  4. the curve

    // some constants first
    da=P2-A;
    db=B-P3;
    a2=atan2(P2.x-P1.x,P2.y-P1.y);
    a3=atan2(P3.x-P1.x,P3.y-P1.y);
    if (a2>a3) a3-=M_PI*2.0;
    dang=a3-a2;
    
    // now (x,y)=curve(t) ... where t = <0,3>
    if (t<=1.0)
     {
     x=A.x+t*da.x;
     y=A.y+t*da.y;
     }
    else if (t<=2.0)
     {
     t=a2+((t-1.0)*dang);
     x=P1.x+r*cos(t);
     y=P1.y+r*sin(t);
     }
    else
     {
     t=t-2.0;
     x=P3.x+t*db.x;
     y=P3.y+t*db.y;
     }
    
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!