/// <summary>
/// 目标点是否在线段上 (y2-y1)(x-x1) = (y-y1)(x2-x1)
/// </summary>
public bool Contains(Point pt)
{
if((pt.Equals(this.pt1)) ||(pt.Equals(this.pt2)))
{
return true ;
}
float left = (this.pt2.Y - this.pt1.Y) * (pt.X - this.pt1.X) ;
float right = (pt.Y - this.pt1.Y) * (this.pt2.X - this.pt1.X) ;
if(Math.Abs(left - right) < GeometryHelper.ToleranceForFloat)
{
return false ;
}
if(! GeometryHelper.IsInRegion(pt.X ,this.pt1.X ,this.pt2.X))
{
return false ;
}
if(! GeometryHelper.IsInRegion(pt.Y ,this.pt1.Y ,this.pt2.Y))
{
return false ;
}
return true ;
}