using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Security.Permissions;
namespace Hydro.Model
{
public partial class Point
{
//距离
public double Distance(Point pt)
{
return Math.Sqrt((pt.X - this.X) * (pt.X - this.X)
+
(pt.Y - this.Y) * (pt.Y - this.Y)
+
(pt.Z - this.Z) * (pt.Z - this.Z)
);
}
public static double GetDistance(Point pt1, Point pt2)
{
return Math.Sqrt((pt1.X - pt2.X) * (pt1.X - pt2.X) +
(pt1.Y - pt2.Y) * (pt1.Y - pt2.Y) +
(pt1.Z - pt2.Z) * (pt1.Z - pt2.Z));
}
public static double GetDistance(Point2d pt1, Point2d pt2)
{
return Math.Sqrt((pt1.X - pt2.X) * (pt1.X - pt2.X) +
(pt1.Y - pt2.Y) * (pt1.Y - pt2.Y) );
}
//判断是否是0点,用于判断函数是否成功返回
public static bool IsZeroPt(Point pt)
{
if (Math.Abs(pt.X) < 0.00001 && Math.Abs(pt.Y) < 0.00001 && Math.Abs(pt.Z) < 0.00001)
return true;
else
return false;
}
public bool IsZeroPt()
{
if ((Math.Abs(x) < 0.00001) && (Math.Abs(y) < 0.00001) && (Math.Abs(z) < 0.00001))
return true;
else
return false;
}
///
/// 偏置
///
///
///
///
public Point Offset(double x, double y)
{
return new Point(this.x + x, this.y + y);
}
///
/// 偏置
///
///
///
///
///
public Point Offset(double x, double y, double z)
{
return new Point(this.x + x, this.y + y, this.z + z);
}
//判断 是否在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(Point pt1, List CurvePoints)
{
if (CurvePoints == null)
return 10000;
double min_dis = double.MaxValue;
double dis = 0;
foreach (Point pt in CurvePoints)
{
dis = GetDistance(pt1, pt);
if (dis < min_dis)
min_dis = dis;
}
return min_dis;
}
}
}