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


C# Polygon.IsPointInsideParanoid方法代码示例

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


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

示例1: SplicedArc

        /// <summary>
        /// Helper to return a spliced arc.
        /// </summary>
        private static Segment SplicedArc( Polygon parent, Circle c, List<IntersectionPoint> iPoints, ref int pair, bool increment, ref int nextSegIndex )
        {
            Segment spliced = SmallerSplicedArc( c, iPoints, ref pair, increment, ref nextSegIndex );

            // This is heuristic, but works quite well.
            if( System.Math.Abs( spliced.Angle ) < System.Math.PI * .75 )
                return spliced;

            // Direction should actually be such that arc is inside the parent polygon,
            // which may not be the case for the segment above.

            // Now check to make sure the arc is indeed inside the parent polygon.
            double testAngle = spliced.Angle / 1000;
            if( spliced.Clockwise )
                testAngle *= -1;

            Vector3D t1 = spliced.P1;
            t1.RotateXY( spliced.Center, testAngle );

            // ZZZ - I don't like relying on our weak IsPointInside method.
            if( !parent.IsPointInsideParanoid( t1 ) )
                spliced.Clockwise = !spliced.Clockwise;

            return spliced;
        }
开发者ID:roice3,项目名称:Honeycombs,代码行数:28,代码来源:Slicer.cs

示例2: SlicePolygonInternal

        private static bool SlicePolygonInternal( Polygon p, Circle c, out List<Polygon> output )
        {
            // Our approach:
            // (1) Find the intersection points, and splice them into the polygon. (splicing in is the main diff from old algorithm.)
            // (2) From each intersection point, walk the polygon.
            // (3) When you are at an intersection point, always turn left, which may involve adding a new segment of the slicing circle.
            // (4) We'll have to check for duplicate polygons in the resulting list, and remove them.

            output = new List<Polygon>();

            // We must be a digon at a minimum.
            if( p.NumSides < 2 )
                return false;

            // XXX - Code assumes well-formed polygon: closed (has connected segments),
            //		 no repeated vertices.  Assert all this?
            // Code also assumes CCW orientation.
            if( !p.Orientation )
                p.Reverse();

            // Cycle through our segments and splice in all the intersection points.
            Polygon diced = new Polygon();
            List<IntersectionPoint> iPoints = new List<IntersectionPoint>();
            for( int i=0; i<p.NumSides; i++ )
            {
                Segment s = p.Segments[i];
                Vector3D[] intersections = c.GetIntersectionPoints( s );
                if( intersections == null )
                    continue;

                switch( intersections.Length )
                {
                    case 0:
                    {
                        diced.Segments.Add( s );
                        break;
                    }
                    case 1:
                    {
                        // ZZZ - check here to see if it is a tangent iPoint?  Not sure if we need to do this.
                        diced.Segments.Add( SplitHelper( s, intersections[0], diced, iPoints ) );
                        break;
                    }
                    case 2:
                    {
                        // We need to ensure the intersection points are ordered correctly on the segment.
                        Vector3D i1 = intersections[0], i2 = intersections[1];
                        if( !s.Ordered( i1, i2 ) )
                            Utils.SwapPoints( ref i1, ref i2 );

                        Segment secondToSplit = SplitHelper( s, i1, diced, iPoints );
                        Segment segmentToAdd = SplitHelper( secondToSplit, i2, diced, iPoints );
                        diced.Segments.Add( segmentToAdd );
                        break;
                    }
                    default:
                        Debug.Assert( false );
                        return false;
                }
            }

            // NOTE: We've been careful to avoid adding duplicates to iPoints.

            // Are we done? (no intersections)
            if( 0 == iPoints.Count )
            {
                output.Add( p );
                return true;
            }

            // We don't yet deal with tangengies,
            // but we're going to let this case slip through as unsliced.
            if( 1 == iPoints.Count )
            {
                output.Add( p );
                return true;
            }

            // We don't yet deal with tangencies.
            // We're going to fail on this case, because it could be more problematic.
            if( Utils.Odd( iPoints.Count ) )
            {
                Debug.Assert( false );
                return false;
            }

            if( iPoints.Count > 2 )
            {
                // We may need our intersection points to all be reorded by 1.
                // This is so that when walking from i1 -> i2 along c, we will be moving through the interior of the polygon.
                // ZZZ - This may need to change when hack in SplicedArc is improved.
                int dummy = 0;
                Segment testArc = SmallerSplicedArc( c, iPoints, ref dummy, true, ref dummy );
                Vector3D midpoint = testArc.Midpoint;

                if( !p.IsPointInsideParanoid( midpoint ) )
                {
                    IntersectionPoint t = iPoints[0];
                    iPoints.RemoveAt( 0 );
                    iPoints.Add( t );
//.........这里部分代码省略.........
开发者ID:roice3,项目名称:Honeycombs,代码行数:101,代码来源:Slicer.cs


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