如何找到在三维空间的C#给出三个点的圆的半径 [英] How to find the radius of a circle given three points in 3d space C#

查看:491
本文介绍了如何找到在三维空间的C#给出三个点的圆的半径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三点沿着圆的位置。 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 沿着圆,那么你可以使用图形化方法:

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

    你的圈子平面由你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. 路口是圆心

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

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

      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:

  1. 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 ...

  2. the intersection is center of circle

    So find the intersection of 2 axises and call it pt0

  3. 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

这篇关于如何找到在三维空间的C#给出三个点的圆的半径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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