Given 3 Points, How to Construct An Arc that Passe

2019-07-14 02:12发布

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.

标签: c# geometry
2条回答
狗以群分
2楼-- · 2019-07-14 02:51

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;
}
查看更多
ら.Afraid
3楼-- · 2019-07-14 02:54

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.

查看更多
登录 后发表回答