Inheritance: TriangulationPoint
Esempio n. 1
0
        public static Polygon.Polygon RandomCircleSweep(double scale, int vertexCount)
        {
            PolygonPoint point;
            PolygonPoint[] points;
            double radius = scale/4;

            points = new PolygonPoint[vertexCount];
            for (int i = 0; i < vertexCount; i++)
            {
                do
                {
                    if (i%250 == 0)
                    {
                        radius += scale/2*(0.5 - RNG.NextDouble());
                    }
                    else if (i%50 == 0)
                    {
                        radius += scale/5*(0.5 - RNG.NextDouble());
                    }
                    else
                    {
                        radius += 25*scale/vertexCount*(0.5 - RNG.NextDouble());
                    }
                    radius = radius > scale/2 ? scale/2 : radius;
                    radius = radius < scale/10 ? scale/10 : radius;
                } while (radius < scale/10 || radius > scale/2);
                point = new PolygonPoint(radius*Math.Cos((PI_2*i)/vertexCount),
                                         radius*Math.Sin((PI_2*i)/vertexCount));
                points[i] = point;
            }
            return new Polygon.Polygon(points);
        }
Esempio n. 2
0
        /// <summary>
        /// Removes a point from the polygon.
        /// </summary>
        /// <param name="p"></param>
        public void RemovePoint(PolygonPoint p)
        {
            PolygonPoint next, prev;

            next          = p.Next;
            prev          = p.Previous;
            prev.Next     = next;
            next.Previous = prev;
            _points.Remove(p);
        }
Esempio n. 3
0
        /// <summary>
        /// Inserts newPoint after point.
        /// </summary>
        /// <param name="point">The point to insert after in the polygon</param>
        /// <param name="newPoint">The point to insert into the polygon</param>
        public void InsertPointAfter(PolygonPoint point, PolygonPoint newPoint)
        {
            // Validate that
            int index = this._points.IndexOf(point);

            if (index == -1)
            {
                throw new ArgumentException(
                          "Tried to insert a point into a Polygon after a point not belonging to the Polygon", "point");
            }
            newPoint.Next       = point.Next;
            newPoint.Previous   = point;
            point.Next.Previous = newPoint;
            point.Next          = newPoint;
            this._points.Insert(index + 1, newPoint);
        }
Esempio n. 4
0
        /// <summary>
        /// Inserts list (after last point in polygon?)
        /// </summary>
        /// <param name="list"></param>
        public void AddPoints(IEnumerable <PolygonPoint> list)
        {
            PolygonPoint first;

            foreach (PolygonPoint p in list)
            {
                p.Previous = this._last;
                if (this._last != null)
                {
                    p.Next          = this._last.Next;
                    this._last.Next = p;
                }
                this._last = p;
                this._points.Add(p);
            }
            first           = (PolygonPoint)this._points[0];
            this._last.Next = first;
            first.Previous  = this._last;
        }
Esempio n. 5
0
        /// <summary>
        /// Inserts list (after last point in polygon?)
        /// </summary>
        /// <param name="list"></param>
        public void AddPoints(IEnumerable <PolygonPoint> list)
        {
            PolygonPoint first;

            foreach (PolygonPoint p in list)
            {
                p.Previous = _last;
                if (_last != null)
                {
                    p.Next     = _last.Next;
                    _last.Next = p;
                }
                _last = p;
                _points.Add(p);
            }
            first          = (PolygonPoint)_points[0];
            _last.Next     = first;
            first.Previous = _last;
        }
Esempio n. 6
0
		/// <summary>
		/// Removes a point from the polygon.
		/// </summary>
		/// <param name="p"></param>
		public void RemovePoint( PolygonPoint p )
		{
			PolygonPoint next, prev;

			next = p.Next;
			prev = p.Previous;
			prev.Next = next;
			next.Previous = prev;
			_points.Remove( p );
		}
Esempio n. 7
0
		/// <summary>
		/// Adds a point after the last in the polygon.
		/// </summary>
		/// <param name="p">The point to add</param>
		public void AddPoint( PolygonPoint p )
		{
			p.Previous = _last;
			p.Next = _last.Next;
			_last.Next = p;
			_points.Add( p );
		}
Esempio n. 8
0
		/// <summary>
		/// Inserts list (after last point in polygon?)
		/// </summary>
		/// <param name="list"></param>
		public void AddPoints( IEnumerable<PolygonPoint> list )
		{
			PolygonPoint first;
			foreach( PolygonPoint p in list )
			{
				p.Previous = _last;
				if( _last != null )
				{
					p.Next = _last.Next;
					_last.Next = p;
				}
				_last = p;
				_points.Add( p );
			}
			first = (PolygonPoint)_points[0];
			_last.Next = first;
			first.Previous = _last;
		}
Esempio n. 9
0
		/// <summary>
		/// Inserts newPoint after point.
		/// </summary>
		/// <param name="point">The point to insert after in the polygon</param>
		/// <param name="newPoint">The point to insert into the polygon</param>
		public void InsertPointAfter( PolygonPoint point, PolygonPoint newPoint )
		{
			// Validate that 
			int index = _points.IndexOf( point );
			if( index == -1 )
				throw new ArgumentException(
					"Tried to insert a point into a Polygon after a point not belonging to the Polygon", "point" );
			newPoint.Next = point.Next;
			newPoint.Previous = point;
			point.Next.Previous = newPoint;
			point.Next = newPoint;
			_points.Insert( index + 1, newPoint );
		}