本文整理汇总了C#中Polygon.VectorFrom方法的典型用法代码示例。如果您正苦于以下问题:C# Polygon.VectorFrom方法的具体用法?C# Polygon.VectorFrom怎么用?C# Polygon.VectorFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon
的用法示例。
在下文中一共展示了Polygon.VectorFrom方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPointToStartAt
private static int GetPointToStartAt(Polygon polygon, Polygon otherPolygon)
{
int firstPointToStartAt = 0;
double furthestAwayDistance = otherPolygon.VectorFrom(polygon.mVertices[0].Position.X, polygon.mVertices[0].Position.Y).LengthSquared();
for (int i = 1; i < polygon.mVertices.Length - 1; i++)
{
double distance = otherPolygon.VectorFrom(polygon.mVertices[i].Position.X, polygon.mVertices[i].Position.Y).LengthSquared();
if(distance > furthestAwayDistance &&
!otherPolygon.IsPointInside(ref polygon.mVertices[i].Position))
{
firstPointToStartAt = i;
furthestAwayDistance = distance;
}
}
return firstPointToStartAt;
}
示例2: SetPointsFromContactPointsAndVertices
//.........这里部分代码省略.........
float thisVectorLength = nextThisVector.Length();
float otherVectorLength = nextOtherVector.Length();
float smallestDistance = System.Math.Min(thisVectorLength, otherVectorLength);
nextThisVector.Normalize();
nextOtherVector.Normalize();
nextThisVector *= smallestDistance / 2.0f;
nextOtherVector *= smallestDistance / 2.0f;
nextThisVector += cp.Position;
nextOtherVector += cp.Position;
if (nextThisVector == nextOtherVector)
{
forceUseThis = thisVectorLength < otherVectorLength;
forceUseOther = !forceUseThis;
break;
}
double minimumDistance = .00001;
if (polygon.IsPointInside(ref nextOtherVector))
{
distanceAwayFromThis = 0;
}
else
{
distanceAwayFromThis = polygon.VectorFrom(nextOtherVector.X, nextOtherVector.Y).Length();
if (distanceAwayFromThis < minimumDistance)
{
distanceAwayFromThis = 0;
}
}
if (otherPolygon.IsPointInside(ref nextThisVector))
{
distanceAwayFromOther = 0;
}
else
{
distanceAwayFromOther = otherPolygon.VectorFrom(nextThisVector.X, nextThisVector.Y).Length();
if (distanceAwayFromOther < minimumDistance)
{
distanceAwayFromOther = 0;
}
}
if (distanceAwayFromOther == distanceAwayFromThis)
{
// We need a tiebreaker. Let's move an extra index and see what happens, shall we?
nextThisIndex++;
if (nextThisIndex == thisVertices.Count - 1)
{
nextThisIndex = 0;
}
nextThisVector = thisVertices[nextThisIndex] - cp.Position;
nextOtherIndex++;
示例3: DistanceTo
public float DistanceTo(Polygon polygon)
{
float finalDistance = float.MaxValue;
//loop to check all segment vs. polygon vertices.
foreach (VertexPositionColor v in polygon.Vertices)
{
finalDistance = System.Math.Min(finalDistance, DistanceTo(v.Position.X, v.Position.Y));
}
//loop to check all segment endpoints vs. polygon edges.
finalDistance = System.Math.Min(finalDistance, (float)polygon.VectorFrom(Point1.X, Point1.Y).Length());
finalDistance = System.Math.Min(finalDistance, (float)polygon.VectorFrom(Point2.X, Point2.Y).Length());
//take the minimum distance and return.
return finalDistance;
}