コード例 #1
0
		/// <summary>
		/// Initializes a new instance of the Explicit2DParameters class on the specified
		/// formula, left-top corner point, right-bottom corner point and area size.
		/// </summary>
		/// <param name="formula">Formula</param>
		/// <param name="pointA">Left-top corner point</param>
		/// <param name="pointB">Right-bottom corner point</param>
		/// <param name="size">Area size.</param>
		public Explicit3DParameters(string formula, Point2D pointA, Point2D pointB, Size size)
		{
			_formula = formula;
			_pointA = pointA;
			_pointB = pointB;
			_areaSize = size;
			InitCode();
		}
コード例 #2
0
		/// <summary>
		/// Initializes a new instance of the Explicit2DParameters class on the specified
		/// code, code language, left-top corner point, right-bottom corner point and area
		/// size.
		/// </summary>
		/// <param name="codeExpression">code</param>
		/// <param name="codeLanguage">Code language.</param>
		/// <param name="pointA">Left-top corner point</param>
		/// <param name="pointB">Right-bottom corner point</param>
		/// <param name="size">Area size.</param>
		public Explicit3DParameters(string codeExpression, CodeLanguage codeLanguage, Point2D pointA, Point2D pointB, Size size)
		{
			_code = codeExpression;
			_codeLanguage = codeLanguage;
			_pointA = pointA;
			_pointB = pointB;
			_areaSize = size;
		}
コード例 #3
0
		public double[] Plot (Point2D a, Point2D b, Size areaSize)
		{
			if (areaSize.Height == 0 || areaSize.Width == 0)
				throw new ArgumentException("Height or Width cannot be zero","areaSize");

			int numPoints = 1000;
			return Plot(Math.Min(a.X,b.X),Math.Max(a.X,b.X),Math.Abs(a.X - b.X) / (numPoints - 1),numPoints);
		}
コード例 #4
0
		/// <summary>
		/// Initializes a new instance of the <strong>Implicit2DParameters</strong> class on
		/// the specified code, code language, left-top corner point, right-bottom corner point,
		/// grid factor and area size.
		/// </summary>
		/// <param name="codeExpression">code</param>
		/// <param name="codeLanguage">Code language</param>
		/// <param name="pointA">Left-top corner point</param>
		/// <param name="pointB">Right-bottom corner point</param>
		/// <param name="gridFactor">
		/// This parameter specify graphics details. Increasing of this parameter give more
		/// detailed graphic but decrease speed of evaluation.
		/// </param>
		/// <param name="areaSize">Area size.</param>
		public Implicit2DParameters(string codeExpression, CodeLanguage codeLanguage, Point2D pointA, Point2D pointB, int gridFactor, Size areaSize)
		{
			_code = codeExpression;
			_codeLanguage = codeLanguage;
			_pointA = pointA;
			_pointB = pointB;
			_gridFactor = gridFactor;
			_areaSize = areaSize;
		}
コード例 #5
0
		/// <summary>
		/// Initializes a new instance of the <strong>Implicit2DParameters</strong> class on
		/// the specified formula, left-top corner point, right-bottom corner point, grid factor
		/// and area size.
		/// </summary>
		/// <param name="formula">Formula</param>
		/// <param name="pointA">Left-top corner point</param>
		/// <param name="pointB">Right-bottom corner point</param>
		/// <param name="gridFactor">
		/// This parameter specify graphics details. Increasing of this parameter give more
		/// detailed graphic but decrease speed of evaluation.
		/// </param>
		/// <param name="areaSize">formula, left-top corner point, right-bottom corner point and area size.</param>
		public Implicit2DParameters(string formula, Point2D pointA, Point2D pointB, int gridFactor, Size areaSize)
		{
			_formula = formula;
			_pointA = pointA;
			_pointB = pointB;
			_gridFactor = gridFactor;
			_areaSize = areaSize;
			InitCode();
		}
コード例 #6
0
		public Point2D[] Plot (Point2D a, Point2D b, Size areaSize)
		{
			if (areaSize.Height == 0 || areaSize.Width == 0)
				throw new ArgumentException("Height or Width cannot be zero","areaSize");


			_areaPointA = new Point2D(Math.Min(a.X,b.X),Math.Min(a.Y,b.Y));
			_areaPointB = new Point2D(Math.Max(a.X,b.X),Math.Max(a.Y,b.Y));

			_areaSize = areaSize;
			_areaMatrix = (bool[,])Array.CreateInstance(typeof(bool),areaSize.Height,areaSize.Width);
			_pixelSize = new SizeF((float)Math.Abs(_areaPointB.X - _areaPointA.X)/areaSize.Width,(float)Math.Abs(_areaPointB.Y - _areaPointA.Y)/areaSize.Height);
		
			CalculateMatrix();

			Point2D[] result = (Point2D[])Array.CreateInstance(typeof(Point2D),_totalPoints);

			if (_totalPoints > 0)
			{
				int curPoint = 0;

				double y = _areaPointA.Y + _pixelSize.Height / 2;
				for (int j = 0; j < _areaSize.Height; j++)
				{
					double x = _areaPointA.X + _pixelSize.Width / 2;
					for (int i = 0; i < _areaSize.Width; i++)
					{
						if (_areaMatrix[j,i])
						{
							result[curPoint] = new Point2D(x,y);
							curPoint++;
						}

						x += _pixelSize.Width;
					}
					y += _pixelSize.Height;
				}
			
			}

			return result;
		}
コード例 #7
0
		public double[,] Plot(Point2D p1 , Point2D p2 , Size grid)
		{
			if (grid.Height == 0 || grid.Width == 0)
				throw new ArgumentException("Height or Width cannot be zero","grid");

			double[,] result = (double[,])Array.CreateInstance(typeof(double),grid.Height,grid.Width);

			double gridStepX = Math.Abs(p2.X - p1.X) / ( grid.Width - 1 );
			double gridStepY = Math.Abs(p2.Y - p1.Y) / ( grid.Height - 1 );

			double y = p1.Y;
			for (int j = 0; j < grid.Height; j++)
			{
				double x = p1.X;
				for (int i = 0; i < grid.Width; i++)
				{
					result[j,i] = _function(x,y);
					x += gridStepX;
				}
				y += gridStepY;
			}

			return result;
		}
コード例 #8
0
		private void CalculateMatrixScope (Point2D p1, Point2D p2, double a, double b, double c, double d)
		{
			double sizeX = Math.Abs(p1.X - p2.X);
			double sizeY = Math.Abs(p1.Y - p2.Y);

			double halfSizeX = sizeX / 2;
			double halfSizeY = sizeY / 2;

			Point2D pCenter = new Point2D ( p1.X + halfSizeX , p1.Y + halfSizeY );

			if ((sizeX < _pixelSize.Width)&&(sizeY < _pixelSize.Height))
			{
				int gridX = (int)(( pCenter.X - _areaPointA.X) / _pixelSize.Width);
				int gridY = (int)(( pCenter.Y - _areaPointA.Y) / _pixelSize.Height);
				if (!_areaMatrix[gridY,gridX])
				{
					_areaMatrix[gridY,gridX] = true;
					_totalPoints++;
				}
				
				return;
			}

			double ab = _function( pCenter.X , p1.Y );
			double cd = _function( pCenter.X , p2.Y );
			double ac = _function( p1.X , pCenter.Y );
			double bd = _function( p2.X , pCenter.Y );
			double center = _function( pCenter.X , pCenter.Y );
			
			if (CheckScope(a , ab , ac , center))
			CalculateMatrixScope( p1 , pCenter , 
				a , ab , ac , center );
			
			if (CheckScope(center , bd , cd , d))
			CalculateMatrixScope( pCenter , p2 , 
				center , bd , cd , d );

			if (CheckScope(ab , b , center , bd))
			CalculateMatrixScope(new Point2D( pCenter.X , p1.Y ),
				new Point2D( p2.X , pCenter.Y ),
				ab , b , center , bd );

			if (CheckScope(ac , center , c , cd))
			CalculateMatrixScope(new Point2D( p1.X , pCenter.Y ),
				new Point2D( pCenter.X , p2.Y ),
				ac , center , c , cd );
		}
コード例 #9
0
ファイル: Point2D.cs プロジェクト: xuchuansheng/GenXSource
		public static double Distance(Point2D a, Point2D b)
		{
			return Math.Sqrt((a._x - b._x)*(a._x - b._x) + (a._y - b._y)*(a._y - b._y));
		}
コード例 #10
0
ファイル: Point2D.cs プロジェクト: xuchuansheng/GenXSource
		public static Point2D Subtract(Point2D a, Point2D b)
		{
			return new Point2D(a._x - b._x, a._y - b._y);
		}
コード例 #11
0
ファイル: Point2D.cs プロジェクト: xuchuansheng/GenXSource
		public static Point2D Add(Point2D a, Point2D b)
		{
			return new Point2D(a._x + b._x, a._y + b._y);
		}