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


C# Polygon.IsPointInside方法代码示例

本文整理汇总了C#中Polygon.IsPointInside方法的典型用法代码示例。如果您正苦于以下问题:C# Polygon.IsPointInside方法的具体用法?C# Polygon.IsPointInside怎么用?C# Polygon.IsPointInside使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Polygon的用法示例。


在下文中一共展示了Polygon.IsPointInside方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetPointsFromContactPointsAndVertices


//.........这里部分代码省略.........
                                {
                                    nextOtherIndex = 0;
                                }
                                nextOtherVector = otherVertices[nextOtherIndex] - cp.Position;
                            }

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

示例2: 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

示例3: CollideAgainst

        public bool CollideAgainst(Polygon polygon)
        {
            polygon.UpdateDependencies(TimeManager.CurrentTime);

            // Check if one of the segment's endpoints is inside the Polygon
            if (polygon.IsPointInside(Point1.X, Point1.Y))
            {
                polygon.mLastCollisionPoint = Point1;
                return true;
            }                                                  

            if (polygon.IsPointInside(Point2.X, Point2.Y))
            {
                polygon.mLastCollisionPoint = Point2;
                return true;
            }

            Point intersectionPoint;

            // Check if one of the polygon's edges intersects the line segment
            for (int i = 0; i < polygon.Points.Count - 1; i++)
            {
                if (Intersects(new Segment(
                      new Point(polygon.Position.X + polygon.Points[i].X,
                                polygon.Position.Y + polygon.Points[i].Y),
                      new Point(polygon.Position.X + polygon.Points[i + 1].X,
                                polygon.Position.Y + polygon.Points[i + 1].Y)), out intersectionPoint))
                {
                    polygon.mLastCollisionPoint = intersectionPoint;
                    return true;
                }
            }

            // No collision
            return false;
        }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:36,代码来源:Segment.cs

示例4: TryInsertHole

    static bool TryInsertHole(Polygon parent, Polygon hole)
    {
        //Can't go in.
        if (!parent.IsPointInside(hole[0]))
            return false;

        if (parent.Holes != null)
            foreach (var item in parent.Holes)
            {
                if (TryInsertHole(item, hole))
                    return true;
            }
        //it doesn't fit into any of the daughter holes.
        parent.AddHole(hole);
        return true;
    }
开发者ID:JapaMala,项目名称:armok-vision,代码行数:16,代码来源:ComplexPoly.cs

示例5: GenerateGridPoints

    public List<TriangulationPoint> GenerateGridPoints(Bounds bounds, float subdivLevel, Polygon _polygon)
    {
        List<TriangulationPoint> GridPoints = new List<TriangulationPoint> ();
        float numberDivisions = 6;

        float width = bounds.max.x - bounds.min.x;
        float height = bounds.max.y - bounds.min.y;

        float subdivWidth = width / (subdivLevel*numberDivisions);
        float subdivHeight = height / ((subdivLevel*numberDivisions) );

        float averagedLength = (subdivWidth + subdivHeight) / 2;
        float widthHeight = (width + height) / 2;

        for(int i=1;i<(subdivLevel*numberDivisions/widthHeight)*width;i++)
        {
            for(int j=1;j<(subdivLevel*numberDivisions/widthHeight)*height;j++)
            {
                float xPos = (i*averagedLength) + bounds.min.x;
                float yPos = (j*averagedLength) + bounds.min.y;
                TriangulationPoint t = new TriangulationPoint (xPos, yPos);
                if(_polygon.IsPointInside(t))
                    GridPoints.Add(t);

            }
        }
        return GridPoints;
    }
开发者ID:mofr,项目名称:FimbulWinter,代码行数:28,代码来源:Puppet2D_CreatePolygonFromSprite.cs

示例6: Check

 private static bool Check( Triangle tri, Polygon boundary )
 {
     if( boundary == null ||
         (boundary.IsPointInside( tri.a ) &&
         boundary.IsPointInside( tri.b ) &&
         boundary.IsPointInside( tri.c )) )
         return true;
     return false;
 }
开发者ID:roice3,项目名称:Honeycombs,代码行数:9,代码来源:Mesh.cs


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