给定3个点,如何构造穿过它们的弧?

发布于 2024-10-07 15:49:58 字数 454 浏览 1 评论 0原文

假设我有 3 个连续的点(P1P2P3),如何构建穿过所有 3 个点的弧?

圆弧必须具有以下 3 个属性:

  1. 起始弧度
  2. 结束弧度
  3. 中心点

圆弧以逆时针方式从起始弧度结束弧度绘制。

我已经尝试过此处的解决方案,但它不起作用,只是因为它假设 P1 必须对应于 Start Radian 并且 P3 必须对应于 end radian。但现实情况是,这并不总是有效。

Let's say I have 3 consecutive points (P1,P2, P3), how to construct an Arc that passes through all 3 points?

The arc must have the following 3 properties:

  1. Start Radian
  2. End Radian
  3. Center Point

The arc is drawn from Start Radian to End Radian in counter-clockwise manner.

I've tried with the solution here, but it doesn't work, simply because it assumes that P1 must correspond to Start Radian and P3 must correspond to end radian. But the reality is that this is not always valid.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

_蜘蛛 2024-10-14 15:49:58

按照您希望弧线采用的顺序在它们之间画两条线。将两条线一分为二,得到它们的法线。法线的交点是圆弧的中心。以给定的中心从一个端点到另一端点绘制圆弧。

Draw two lines between them, following the order you want the arc to take. Bisect both lines, coming up with their normals. The intersection of the normals is the center of the arc. Draw your arc from one endpoint to the other, with the given center.

如歌彻婉言 2024-10-14 15:49:58

我也有同样的问题。这是 C 语言的一个小片段。正如您所看到的,中心点有两个可能的点。我希望它有帮助。感谢我即将出生的伊格纳西奥:

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void)
{
    float x1,y1; //Punto A
    float x2,y2; //Punto B
    float x3,y3; //Punto medio
    float x,y;
    float z,t; //los otros posibles puntos
    float R; //Distancia

    printf("Introduce  Ax:\n");
    scanf ("%f",&x1);
    printf("Introduce  Ay:\n");
    scanf ("%f",&y1);
    printf("Introduce  Bx:\n");
    scanf ("%f",&x2);
    printf("Introduce  By:\n");
    scanf ("%f",&y2);
    printf("Introduce  Cx:\n");
    scanf ("%f",&x3);
    printf("Introduce  Cy:\n");
    scanf ("%f",&y3);
    printf("Introduce la distancia:\n");
    scanf ("%f",&R);


    x=-((-(x2*x2)+2*x1*x2-(x1*x1))*x3-(x3*y1*y1)+(2*x3*y1*y2)-(x3*y2*y2)+(y2-y1)*sqrt(y2*y2-2*y1*y2+y1*y1+x2*x2-2*x1*x2+x1*x1)*R)/(y2*y2-2*y1*y2+y1*y1+x2*x2-2*x1*x2+x1*x1);
    y=((y2*y2-2*y1*y2+y1*y1+x2*x2-2*x1*x2+x1*x1)*y3+(x2-x1)*sqrt(y2*y2-2*y1*y2+y1*y1+x2*x2-2*x1*x2+x1*x1)*R)/(y2*y2-2*y1*y2+y1*y1+x2*x2-2*x1*x2+x1*x1);
    printf ("x=%f\n",x);
    printf ("y=%f\n",y);

    z=((y2-y1)*sqrt((y2*y2)-2*y1*y2+y1*y1+x2*x2-2*x1*x2+x1*x1)*R+x3*y2*y2-2*x3*y1*y2+x3*y1*y1+(x2*x2-2*x1*x2+x1*x1)*x3)/(y2*y2-2*y1*y2+y1*y1+x2*x2-2*x1*x2+x1*x1);
    t=-((x2-x1)*sqrt(y2*y2-2*y1*y2+y1*y1+x2*x2-2*x1*x2+x1*x1)*R+(-(y2*y2)+2*y1*y2-(y1*y1)-(x2*x2)+2*x1*x2-(x1*x1)*y3))/(y2*y2-2*y1*y2+y1*y1+x2*x2-2*x1*x2+x1*x1);
    printf ("\nx=%f\n",z);
    printf ("y=%f\n",t);
    system("pause");

    return 0;
}

I had the same problem. Here is a small snippet in C for that. As you can see there are two possible points for the center point. I hope it helps. Credits to my soon Ignacio:

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void)
{
    float x1,y1; //Punto A
    float x2,y2; //Punto B
    float x3,y3; //Punto medio
    float x,y;
    float z,t; //los otros posibles puntos
    float R; //Distancia

    printf("Introduce  Ax:\n");
    scanf ("%f",&x1);
    printf("Introduce  Ay:\n");
    scanf ("%f",&y1);
    printf("Introduce  Bx:\n");
    scanf ("%f",&x2);
    printf("Introduce  By:\n");
    scanf ("%f",&y2);
    printf("Introduce  Cx:\n");
    scanf ("%f",&x3);
    printf("Introduce  Cy:\n");
    scanf ("%f",&y3);
    printf("Introduce la distancia:\n");
    scanf ("%f",&R);


    x=-((-(x2*x2)+2*x1*x2-(x1*x1))*x3-(x3*y1*y1)+(2*x3*y1*y2)-(x3*y2*y2)+(y2-y1)*sqrt(y2*y2-2*y1*y2+y1*y1+x2*x2-2*x1*x2+x1*x1)*R)/(y2*y2-2*y1*y2+y1*y1+x2*x2-2*x1*x2+x1*x1);
    y=((y2*y2-2*y1*y2+y1*y1+x2*x2-2*x1*x2+x1*x1)*y3+(x2-x1)*sqrt(y2*y2-2*y1*y2+y1*y1+x2*x2-2*x1*x2+x1*x1)*R)/(y2*y2-2*y1*y2+y1*y1+x2*x2-2*x1*x2+x1*x1);
    printf ("x=%f\n",x);
    printf ("y=%f\n",y);

    z=((y2-y1)*sqrt((y2*y2)-2*y1*y2+y1*y1+x2*x2-2*x1*x2+x1*x1)*R+x3*y2*y2-2*x3*y1*y2+x3*y1*y1+(x2*x2-2*x1*x2+x1*x1)*x3)/(y2*y2-2*y1*y2+y1*y1+x2*x2-2*x1*x2+x1*x1);
    t=-((x2-x1)*sqrt(y2*y2-2*y1*y2+y1*y1+x2*x2-2*x1*x2+x1*x1)*R+(-(y2*y2)+2*y1*y2-(y1*y1)-(x2*x2)+2*x1*x2-(x1*x1)*y3))/(y2*y2-2*y1*y2+y1*y1+x2*x2-2*x1*x2+x1*x1);
    printf ("\nx=%f\n",z);
    printf ("y=%f\n",t);
    system("pause");

    return 0;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文