예제 #1
0
        public static bool IsArcIntersectWithRect(ArcBase arcBase, RectangleF rectangle, float thWidth)
        {
            bool      result = false;
            UnitPoint p1     = new UnitPoint(rectangle.Left, rectangle.Top);
            UnitPoint p2     = new UnitPoint(rectangle.Left, rectangle.Bottom);

            if (HitUtil.CircleIntersectWithLine(arcBase.Center, arcBase.Radius, p1, p2))
            {
                result = HitUtil.IsLineOnArc(p1, p2, arcBase.Center, arcBase.Radius, arcBase.StartAngle, arcBase.AngleSweep, arcBase.IsClockwise, thWidth);
                if (result)
                {
                    return(result);
                }
            }
            p1 = new UnitPoint(rectangle.Left, rectangle.Bottom);
            p2 = new UnitPoint(rectangle.Right, rectangle.Bottom);
            if (HitUtil.CircleIntersectWithLine(arcBase.Center, arcBase.Radius, p1, p2))
            {
                result = HitUtil.IsLineOnArc(p1, p2, arcBase.Center, arcBase.Radius, arcBase.StartAngle, arcBase.AngleSweep, arcBase.IsClockwise, thWidth);
                if (result)
                {
                    return(result);
                }
            }
            p1 = new UnitPoint(rectangle.Left, rectangle.Top);
            p2 = new UnitPoint(rectangle.Right, rectangle.Top);
            if (HitUtil.CircleIntersectWithLine(arcBase.Center, arcBase.Radius, p1, p2))
            {
                result = HitUtil.IsLineOnArc(p1, p2, arcBase.Center, arcBase.Radius, arcBase.StartAngle, arcBase.AngleSweep, arcBase.IsClockwise, thWidth);
                if (result)
                {
                    return(result);
                }
            }
            p1 = new UnitPoint(rectangle.Right, rectangle.Top);
            p2 = new UnitPoint(rectangle.Right, rectangle.Bottom);
            if (HitUtil.CircleIntersectWithLine(arcBase.Center, arcBase.Radius, p1, p2))
            {
                result = HitUtil.IsLineOnArc(p1, p2, arcBase.Center, arcBase.Radius, arcBase.StartAngle, arcBase.AngleSweep, arcBase.IsClockwise, thWidth);
                if (result)
                {
                    return(result);
                }
            }
            return(result);
        }
예제 #2
0
        public static bool IsPointOnArc(UnitPoint testPoint, float thWidth, ArcModelMini arcModel)
        {
            List <UnitPoint> temp = new List <UnitPoint>();

            temp.Add(new UnitPoint(testPoint.X + thWidth, testPoint.Y + thWidth));
            temp.Add(new UnitPoint(testPoint.X + thWidth, testPoint.Y - thWidth));
            temp.Add(new UnitPoint(testPoint.X - thWidth, testPoint.Y + thWidth));
            temp.Add(new UnitPoint(testPoint.X - thWidth, testPoint.Y - thWidth));
            for (int i = 0; i < temp.Count; i++)
            {
                if (HitUtil.IsLineOnArc(arcModel.Center, temp[i], arcModel.Center, arcModel.Radius, arcModel.StartAngle, arcModel.SweepAngle, arcModel.Clockwise, thWidth))
                {
                    double distance = HitUtil.Distance(arcModel.Center, testPoint);
                    if (distance <= arcModel.Radius + thWidth && distance >= arcModel.Radius - thWidth)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }