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;
|
}
|
|
|
}
|
}
|