如何找到在三维空间的C#给出三个点的圆的半径半径、空间

2023-09-08 10:31:32 作者:格格巫

我有三点沿着圆的位置。 PT1(X1,Y1,Z1) PT2(X2,Y2,Z2) PT3(X3,Y3,Z3)。和想找到圆的半径。我已经有一个函数来计算半径在二维空间,这我在这里将其复制

 公共静态双ComputeRadius(位置A,位置B,位置c)
        {
            双X1 = a.x;
            双Y1 = a.y;
            双X2 = b.x;
            双Y2 = b.y;
            双X3 = c.x;
            双Y3 = c.y;
            双MR =(双)((Y2  -  Y1)/(X2  -  X1));
            双MT =(双)((Y3  -  Y2)/(X3  -  X2));

            双XC =(双)((MR * MT *(Y3  -  Y1)+ M *(X2 + X3) -  MT *(X1 + X2))/(2 *(MR  -  MT)));

            双YC =(双)(( -  1 / MR)*(XC  - (X1 + X2)/ 2)+(Y1 + Y2)/ 2);
            双D =(XC  -  X1)*(XC  -  X1)+(YC  -  Y1)*(YC  -  Y1);

            返回的Math.sqrt(D);
        }
 

解决方案

如果您知道点的顺序 PT1,PT2,PT3 沿着圆,那么你可以使用图形化方法:

在圆的平面投正常轴系各线段的中间

你的圈子平面由你3点来定义。所以正常矢量

  N =(PT2-PT1)×(PT3-PT2)
 
三维点云处理技术三 三维空间变换

其中 X 是跨产品,所以你有2行(PT1,PT2)(PT2,PT3)黑色。此次以中间点是很容易

  P0 = 0.5 *(PT1 + PT2)
P1 = 0.5 *(PT2 + PT3)
 

的轴线方向可以通过叉积也得到

  DP0 =(PT2-PT1)×N个
DP1 =(PT3-PT2)×N个
 

让你有2轴系:

  PNT0(T)= P0 + DP0 * T
PNT1(U)= P1 + DP1 * U
 

其中, T,U 的标量参数 T,U =( - 天道酬勤,+ INF)这只是从中间出发点轴位置...

路口是圆心

于是找到2轴系中的交点称之为 PT0

中心,你的任何点之间的计算距离

  R = | PT1,PT0 |
 

抱歉形象为任何曲线(懒得重新绘制的圆形,因为它几乎是一样的)。如果你不知道分则2点是最遥远的对方是外点......如果他们是等距离的次序顺序无所谓任何正常

I have locations of three points along the circle. pt1(x1, y1,z1), pt2(x2, y2, z2), pt3(x3, y3,z3). and want to find the radius of the circle. Already I have a function to compute radius in 2d space, which I am copying it here

public static double ComputeRadius(Location a, Location b, Location c)
        {
            double x1 = a.x;
            double y1 = a.y;
            double x2 = b.x;
            double y2 = b.y;
            double x3 = c.x;
            double y3 = c.y;
            double mr = (double)((y2 - y1) / (x2 - x1));
            double mt = (double)((y3 - y2) / (x3 - x2));

            double xc = (double)((mr * mt * (y3 - y1) + mr * (x2 + x3) - mt * (x1 + x2)) / (2 * (mr - mt)));

            double yc = (double)((-1 / mr) * (xc - (x1 + x2) / 2) + (y1 + y2) / 2);
            double d = (xc - x1) * (xc - x1) + (yc - y1) * (yc - y1);

            return Math.Sqrt(d);
        }

解决方案

If you know the order of points pt1,pt2,pt3 along the circle then you can use graphical method:

cast normal axises from middle of each line segment in the plane of circle

your circle plane is defined by your 3 points. so the normal vector is

n = (pt2-pt1) x (pt3-pt2)

where the x is cross product so you have 2 lines (pt1,pt2) and (pt2,pt3) in black. The mid points are easy

p0=0.5*(pt1+pt2)
p1=0.5*(pt2+pt3)

the axis directions can be obtained also by cross product

dp0=(pt2-pt1) x n
dp1=(pt3-pt2) x n

so you got 2 axises:

pnt0(t)=p0+dp0*t
pnt1(u)=p1+dp1*u

Where t,u are scalar parameters t,u=(-inf,+inf) it is just position in axis from the starting mid point ...

the intersection is center of circle

So find the intersection of 2 axises and call it pt0

compute distance between center and any of your points

r=|pt1-pt0|

Sorry the image is for any curve (too lazy to repaint for circle as it is almost the same). If you do not know the order of points then the 2 points that are most distant to each other are the outer points ... In case they are equidistant the order does not matter any is OK