绘制以直线结尾的弧的公式,Y是X的函数,起始斜率,结束斜率,起点和弧半径? [英] Formula to draw arcs ending in straight lines, Y as a function of X, starting slope, ending slope, starting point and arc radius?

查看:214
本文介绍了绘制以直线结尾的弧的公式,Y是X的函数,起始斜率,结束斜率,起点和弧半径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个数学公式,在一个图形上绘制Y作为X的函数,在指定的起点(X的值,甚至更好的X和Y坐标)之前会有一定的斜率,那么之后它将绘制一个指定半径的圆弧,该圆弧在到达第二个指定的斜率时结束,从该点开始将是该第二个斜坡的另一条直线。

<我知道,因为Y是X的函数,所以斜率参数需要大于-90,小于90。我并不担心在(或超出)这些极端情况下的任何不当行为。其实,我会更加高兴一个公式,它需要一个起点和终点(2D坐标),以及起止斜率;并且在它们之间会有两个弧线(需要时它们之间有一条直线),将两条直线无缝地连接起来(显然,终点的X必须大于起点的X;我不在乎什么当情况并非如此时)。但我想象这样一个公式可能比我先问的难得多。






ps:by弧我的意思是一个圆的部分;如图所示,如果图的两个轴具有相同的比例,则圆弧对于相同半径的圆将具有正确的高宽比。

解决方案我看到它是这样的:




  1. compute P0



    作为行的交点 A + t * dA B - t * dB


  2. compute P1
    $ b

    它是翻译行 A-> P0 的交集。 B-> P0 通过半径 r 垂直。有两种可能性,所以选择正确的(这导致圆形部分的角度较小)。




  3. compute P2,P3



    只是行 A-P0 B- P0 和垂直线从 P1 加入它


  4. 曲线

      //一些常量首先
    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)...其中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;
    }



I'm looking for a math formula that on a graph plotting Y as a function of X, before a specified starting point (a value of X, or even better, X and Y coordinates) will have a certain slope, then after that it will draw an arc of a specified radius that will end when it reaches a second specified slope, and from the point on will be another straight line of that second slope.

I'm am aware that because it's Y as a function of X, the slope parameters would need to be bigger than exactly -90 and smaller than exactly 90 degrees; i'm not worried about any misbehavior at (or beyond) those extremes.


Actually, i would be even happier with a formula that takes a starting and ending points (2d coordinates), and starting and ending slopes; and will have two arcs in between (with a straight line between them when needed), connecting the two straight lines seamlessly (obviously the X of the ending point needs to be bigger than the X for the starting point; i don't care what happens when that isn't the case). But i imagine such a formula might be much harder to come up with than what i asked first.


ps: by "arc" i mean segment of a circle; as in, if both axes of the graph have the same scale, the arcs will have the correct aspect ratio for a circle of the same radius.

解决方案

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;
     }
    

这篇关于绘制以直线结尾的弧的公式,Y是X的函数,起始斜率,结束斜率,起点和弧半径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆