コード例 #1
0
        /// <summary>
        /// Initializes values with previous and current values at n*dt sec
        /// </summary>
        /// <param name="n">number of steps passed</param>
        /// <param name="past">past values</param>
        /// <param name="current">current values</param>
        /// <param name="cblue">speed through current medium</param>
        public YValues(YValues past, YValues current, int cblue)
        {
            _values[0]   = 0;
            _values[254] = 0;

            double r2 = cblue * _dt / _dx;

            for (int i = 1; i < _values.Length / 2; i++)
            {
                _values[i] = 2 * (1 - (_r1 * _r1)) * current.Element(i) - past.Element(i) +
                             _r1 * _r1 * (current.Element(i + 1) + current.Element(i - 1));
            }
            for (int i = _values.Length / 2; i < _values.Length - 1; i++)
            {
                _values[i] = 2 * (1 - (r2 * r2)) * current.Element(i) - past.Element(i) +
                             r2 * r2 * (current.Element(i + 1) + current.Element(i - 1));
            }
        }
コード例 #2
0
        /// <summary>
        /// Draws the values to show the current set of values in a line.
        /// </summary>
        /// <param name="g">The drawer</param>
        private void DrawIt(Graphics g)
        {
            _timeShown.Text = _timeElapsed.ToString("E03");

            Pen leftPen  = new Pen(Brushes.Black, 5.0F);
            Pen rightPen = new Pen(Brushes.Blue, 5.0F);

            double heightDisplacement = this.Height / 2; // spacing from top
            double sizeMult           = 250;             // size multiplier

            double x1 = 0;
            double y1 = _ycurrent.Element(0);

            //Left Side
            for (int i = 0; i <= 254 / 2; i++)
            {
                g.DrawLine(leftPen, (float)(x1 * sizeMult), (float)(y1 * sizeMult + heightDisplacement),
                           (float)((i * _dx) * sizeMult), (float)(_ycurrent[i] * sizeMult + heightDisplacement));

                x1 = (i * _dx);
                y1 = _ycurrent[i];
            }


            //right side
            for (int i = 254 / 2; i < 255; i++)
            {
                g.DrawLine(rightPen, (float)(x1 * sizeMult), (float)(y1 * sizeMult + heightDisplacement),
                           (float)((i * _dx) * sizeMult), (float)(_ycurrent[i] * sizeMult + heightDisplacement));

                x1 = (i * _dx);
                y1 = _ycurrent[i];
            }

            leftPen.Dispose();
            rightPen.Dispose();
        }