本文整理汇总了C#中Point2.DistanceTo方法的典型用法代码示例。如果您正苦于以下问题:C# Point2.DistanceTo方法的具体用法?C# Point2.DistanceTo怎么用?C# Point2.DistanceTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point2
的用法示例。
在下文中一共展示了Point2.DistanceTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Check
public bool Check( Point2 start, Point2 end, float startT, float endT, ref float collisionT, ref Vector2 collisionNormal )
{
Line2Intersection intersection = Intersections2.GetLinePlaneIntersection( start, end, m_Plane );
if ( intersection == null )
{
PlaneClassification edgeClass = m_Plane.ClassifyPoint( start, PlaneTolerance );
if ( edgeClass == PlaneClassification.On )
{
edgeClass = m_Plane.ClassifyPoint( end, PlaneTolerance );
}
if ( edgeClass == PlaneClassification.InFront )
{
return ( m_InFront != null ) && m_InFront.Check( start, end, startT, endT, ref collisionT, ref collisionNormal );
}
else if ( edgeClass == PlaneClassification.Behind )
{
return ( m_Behind == null ) || m_Behind.Check( start, end, startT, endT, ref collisionT, ref collisionNormal );
}
return false;
}
float intersectionT = startT + ( endT - startT ) * ( intersection.Distance / start.DistanceTo( end ) );
collisionT = intersectionT;
collisionNormal = m_Plane.Normal;
if ( m_InFront != null )
{
if ( m_InFront.Check( start, intersection.IntersectionPosition, startT, intersectionT, ref collisionT, ref collisionNormal ) )
{
return true;
}
}
if ( m_Behind != null )
{
if ( m_Behind.Check( intersection.IntersectionPosition, end, intersectionT, endT, ref collisionT, ref collisionNormal ) )
{
return true;
}
}
else
{
return true;
}
return false;
}
示例2: DistancePointToCircle
/// <summary>
/// Returns the distance from a point to a circle. If the point is within the
/// circle, a negative distance is returned
/// </summary>
public static float DistancePointToCircle( Point2 pt, Point2 centre, float radius )
{
return pt.DistanceTo( centre ) - radius;
}