예제 #1
0
        public override Value Invoke( List Arguments )
        {
            var list = Arguments.GetValues();
            if ( list[ 0 ] is Boolean )
            {
                var temp = new List<float>();
                for ( int i = 1 ; i < list.Count ; ++i )
                {
                    if ( list[ i ] is Number ) temp.Add( (float)( (Number)list[ i ] ).Val );
                }
                Polygon = new Polygon( ( (Boolean)list[ 0 ] ).Val, temp.ToArray() );
            } else throw new Exception( "First argument of the polygon constructor must be a boolean" );

            return this;
        }
예제 #2
0
 private bool PolygonContainsPoint(Polygon poly, Point point)
 {
     int count = 0;
     for (int i = 0; i < poly.Points.Count; ++i)
     {
         var first = poly.Points[i];
         var second = poly.Points[(i + 1) % poly.Points.Count];
         if (LineToRight(first, second, point)) count++;
     }
     return (count % 2) == 1;
 }