ningshuxia
2025-04-16 a67da735b33be01b24845ce03ae7551cf55ddbbc
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using IStation.Model;
using System;
using System.Collections.Generic;
 
namespace IStation.Common
{
    public static class PointHelper
    {
        public static double GetDistance(CurvePoint pt1, CurvePoint pt2)
        {
            return Math.Sqrt((pt1.X - pt2.X) * (pt1.X - pt2.X) + (pt1.Y - pt2.Y) * (pt1.Y - pt2.Y));
        }
 
 
        //判断是否是0点,用于判断函数是否成功返回
        public static bool IsZeroPoint(CurvePoint pt)
        {
            if (pt.X < 0.01 && pt.Y < 0.01)
                return true;
            else
                return false;
        }
 
 
 
 
        //判断 是否在2个数之间
        public static bool IsMiddlePt(double pt1, double pt2, double p)
        {
            if (p > pt1 && p < pt2)
                return true;
 
            if (p < pt1 && p > pt2)
                return true;
 
            return false;
        }
 
 
        //点到线的距离
        public static double GetDistance(CurvePoint pt1, List<CurvePoint> CurvePoints)
        {
            if (CurvePoints == null)
                return 10000;
 
            double min_dis = double.MaxValue;
            double dis = 0;
            foreach (CurvePoint pt in CurvePoints)
            {
                dis = GetDistance(pt1, pt);
                if (dis < min_dis)
                    min_dis = dis;
            }
 
            return min_dis;
        }
 
 
    }
}