asmrobot
2019-08-31 013a5eb0380063717241a9d6705557d9a59adbfe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using RichCreator.Utility.Structs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace RichCreator.Utilitys
{
    public class Utils
    {
        /// <summary>
        /// 计算两点之间的距离
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public static double GetDistance(ZTPoint start, ZTPoint end)
        {
            Int32 subX = end.X - start.X;
            Int32 subY = end.Y - start.Y;
            return Math.Sqrt(subX * subX + subY * subY);
        }
 
        /// <summary>
        /// 指定点是否在方框内
        /// </summary>
        /// <param name="point"></param>
        /// <param name="rect"></param>
        /// <returns></returns>
        public static bool IsInRect(ZTPoint point, ZTRectangle rect)
        {
            if (point.Y >= rect.Start.Y &&
                point.Y <= rect.End.Y &&
                point.X >= rect.Start.X &&
                point.X <= rect.End.X)
            {
                return true;
            }
            return false;
        }
    }
}