当前位置: 首页>>代码示例>>C#>>正文


C# Vector2.ToList方法代码示例

本文整理汇总了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();
        }
开发者ID:WaveEngine,项目名称:Samples,代码行数:78,代码来源:BuoyancyBehavior.cs

示例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();
 }
开发者ID:reward-hunters,项目名称:PrintAhead,代码行数:21,代码来源:AutodotsShapeHelper.cs


注:本文中的System.Vector2.ToList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。