本文整理汇总了C#中System.Vector2.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2.ToList方法的具体用法?C# Vector2.ToList怎么用?C# Vector2.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Vector2
的用法示例。
在下文中一共展示了Vector2.ToList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetIntersectedPolygon
/// <summary>
/// This clips the subject polygon against the clip polygon (gets the intersection of the two polygons)
/// </summary>
/// <remarks>
/// Based on the psuedocode from:
/// http://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman
/// </remarks>
/// <param name="subjectPoly">Can be concave or convex</param>
/// <param name="clipPoly">Must be convex</param>
/// <returns>The intersection of the two polygons (or null)</returns>
public static Vector2[] GetIntersectedPolygon(Vector2[] subjectPoly, Vector2[] clipPoly)
{
if (subjectPoly.Length < 3 || clipPoly.Length < 3)
{
throw new ArgumentException(string.Format("The polygons passed in must have at least 3 Vector2s: subject={0}, clip={1}", subjectPoly.Length.ToString(), clipPoly.Length.ToString()));
}
List<Vector2> outputList = subjectPoly.ToList();
// Make sure it's clockwise
if (!IsClockwise(subjectPoly))
{
outputList.Reverse();
}
// Walk around the clip polygon clockwise
foreach (Edge clipEdge in IterateEdgesClockwise(clipPoly))
{
List<Vector2> inputList = outputList.ToList(); // clone it
outputList.Clear();
if (inputList.Count == 0)
{
// Sometimes when the polygons don't intersect, this list goes to zero. Jump out to avoid an index out of range exception
break;
}
Vector2 S = inputList[inputList.Count - 1];
foreach (Vector2 E in inputList)
{
if (IsInside(clipEdge, E))
{
if (!IsInside(clipEdge, S))
{
Vector2? Vector2 = GetIntersect(S, E, clipEdge.From, clipEdge.To);
if (Vector2 == null)
{
throw new ApplicationException("Line segments don't intersect"); // may be colinear, or may be a bug
}
else
{
outputList.Add(Vector2.Value);
}
}
outputList.Add(E);
}
else if (IsInside(clipEdge, S))
{
Vector2? Vector2 = GetIntersect(S, E, clipEdge.From, clipEdge.To);
if (Vector2 == null)
{
throw new ApplicationException("Line segments don't intersect"); // may be colinear, or may be a bug
}
else
{
outputList.Add(Vector2.Value);
}
}
S = E;
}
}
// Exit Function
return outputList.ToArray();
}
示例2: GetProfileBaseDots
public List<Vector2> GetProfileBaseDots()
{
var result = new Vector2[7];
foreach (var rect in ProfileRects)
{
Vector2 a = rect.Points[0], b = rect.Points.Last();
var list = linkedPoints[rect.A];
a.Y = 0.0f;
foreach (var l in list)
a.Y += ShapeInfo.Points[l].Value.Y;
a.Y /= list.Count;
result[rect.A] = a;
list = linkedPoints[rect.B];
b.Y = 0.0f;
foreach (var l in list)
b.Y += ShapeInfo.Points[l].Value.Y;
b.Y /= list.Count;
result[rect.B] = a;
}
return result.ToList();
}