FortuneVoronoi.Fortune.CircumCircleCenter C# (CSharp) Méthode

CircumCircleCenter() static private méthode

static private CircumCircleCenter ( Point A, Point B, Point C ) : Point
A Point
B Point
C Point
Résultat Point
        internal static Point CircumCircleCenter(Point A, Point B, Point C)
        {
            if(A==B || B==C || A==C)
                throw new Exception("Need three different points!");
            double tx = (A.X + C.X)/2;
            double ty = (A.Y + C.Y)/2;

            double vx = (B.X + C.X)/2;
            double vy = (B.Y + C.Y)/2;

            double ux,uy,wx,wy;

            if(A.X == C.X)
            {
                ux = 1;
                uy = 0;
            }
            else
            {
                ux = (C.Y - A.Y)/(A.X - C.X);
                uy = 1;
            }

            if(B.X == C.X)
            {
                wx = -1;
                wy = 0;
            }
            else
            {
                wx = (B.Y - C.Y)/(B.X - C.X);
                wy = -1;
            }

            double alpha = (wy*(vx-tx)-wx*(vy - ty))/(ux*wy-wx*uy);

            return new Point(tx+alpha*ux,ty+alpha*uy);
        }

Usage Example

Exemple #1
0
        public static VCircleEvent CircleCheckDataNode(VDataNode n, double ys)
        {
            var l = LeftDataNode(n);
            var r = RightDataNode(n);

            if (l == null || r == null || l.DataPoint == r.DataPoint || l.DataPoint == n.DataPoint || n.DataPoint == r.DataPoint)
            {
                return(null);
            }
            if (MathTools.ccw(l.DataPoint[0], l.DataPoint[1], n.DataPoint[0], n.DataPoint[1], r.DataPoint[0], r.DataPoint[1], false) <= 0)
            {
                return(null);
            }
            var center = Fortune.CircumCircleCenter(l.DataPoint, n.DataPoint, r.DataPoint);
            var vc     = new VCircleEvent {
                NodeN  = n,
                NodeL  = l,
                NodeR  = r,
                Center = center,
                Valid  = true
            };

            if (vc.Y > ys || Math.Abs(vc.Y - ys) < 1e-10)
            {
                return(vc);
            }
            return(null);
        }
All Usage Examples Of FortuneVoronoi.Fortune::CircumCircleCenter