Ejemplo n.º 1
0
        public yuan waijieyuan(point a, point b)
        {
            yuan y = new yuan();

            y.p      = a;
            y.R      = banjing(y.p, b);
            y.mianji = y.R * y.R * Math.PI;
            return(y);
        }
Ejemplo n.º 2
0
        //计算内切圆
        public yuan neiqie(point dian, point b, point c)
        {
            yuan y = new yuan();

            y.p.X    = dian.X;
            y.p.Y    = dian.Y;
            y.R      = PointToSegDist(zx(b, c), dian);
            y.mianji = y.R * y.R * Math.PI;
            return(y);
        }
Ejemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            double[] mj = new double[bianshu];
            double   R2;
            int      min = 0;

            yuan[] yan = new yuan[bianshu];
            bool   b   = true;

            point[] point1 = new point[points.Length + 3];
            for (int q = 0; q < points.Length; q++)
            {
                point1[q].X = points[q].X;
                point1[q].Y = points[q].Y;
            }
            point1[points.Length]     = point1[0];//将第一个加到最后一个上面
            point1[points.Length + 1] = point1[1];
            point1[points.Length + 2] = point1[2];
            for (int i = 0; i < points.Length; i++)
            {
                zhixian z1 = new zhixian();
                z1 = wj.zx(wj.zx(point1[i], point1[i + 1]), wj.zx(point1[i + 1], point1[i + 2]), point1[i + 1], point1, point1[i + 1]);
                zhixian z2 = new zhixian();
                z2 = wj.zx(wj.zx(point1[i + 1], point1[i + 2]), wj.zx(point1[i + 2], point1[i + 3]), point1[i + 2], point1, point1[i + 2]);

                yuan y = new yuan();
                y = wj.neiqie(wj.jiaodian(z1, z2), point1[i], point1[i + 1]);
                for (int n = 0; n < points.Length; n++)
                {
                    R2 = wj.banjing(y.p, point1[n]);
                    if (y.R > R2)
                    {
                        b = false;
                        break;
                    }
                    else
                    {
                        b = true;
                    }
                }
                if (!b)
                {
                    continue;
                }
                mj[i]  = y.mianji;
                yan[i] = y;
            }
            for (int j = 0; j < mj.Length; j++)
            {
                if (paidxu(chongpai(mj)) == mj[j])
                {
                    min = j;
                }
            }
            label1.Text = "外接圆的X坐标:" + yan[min].p.X + "  " + "外接圆的Y坐标:" + yan[min].p.Y + "  " + "外接圆的半径:" + yan[min].R;
            Graphics gra = this.pictureBox1.CreateGraphics();

            gra.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            Pen pen = new Pen(Color.Pink);                                                                                                            //画笔颜色

            gra.DrawEllipse(pen, (int)yan[min].p.X - (int)yan[min].R, (int)yan[min].p.Y - (int)yan[min].R, (int)yan[min].R * 2, (int)yan[min].R * 2); //画椭圆的方法,x坐标、y坐标、宽、高,如果是100,则半径为50
        }