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


C# Polygon.VectorFrom方法代码示例

本文整理汇总了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;
        }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:20,代码来源:ShapeMerger.cs

示例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++;
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:67,代码来源:ShapeMerger.cs

示例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;
 }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:14,代码来源:Segment.cs


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