C# 判断一个坐标点是否在圆内

        /// <summary>
        /// 连点之间距离公式判断坐标是否在圆内,√[(x1-x2)²+(y1-y2)²]
        /// </summary>
        /// <param name="p"></param>
        /// <param name="f"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public string inoutCircle(PointF p, PointF f, double r)
        {
            double distanceBetPoints;//两点之间距离
            distanceBetPoints = Math.Pow(Math.Pow(p.X - f.X, 2) + Math.Pow(p.Y - f.Y, 2), 0.5);
            if (distanceBetPoints <= r)
            {
                return "in";
            }
            else
            {
                return "out";
            }
        }

 

posted @ 2022-07-19 11:26  芈璐  阅读(1059)  评论(0编辑  收藏  举报