예제 #1
0
        /// <summary>
        /// Zeichnet eine rationale Funktion f(x)=P(x)/Q(x)
        /// </summary>
        /// <param name="pFunc">Das Zähler-Polynom</param>
        /// <param name="qFunc">Das Nenner-Polynom</param>
        /// <param name="fillColor">Füllfarbe der Linie</param>
        /// <param name="stepAccuracy"><para>Genauigkeits-Multiplikator mit der f(x) gezeichnet wird</para><para></para><para>1.0 entspricht 1/200 Schrittweite</para></param>
        public void DrawRationalFunction(QuadPolynomial pFunc, QuadPolynomial qFunc, Color fillColor, float stepAccuracy = 10.0f)
        {
            // draw inside x-axis bounds
            float      xLeft         = Geometry.LowX;
            float      xRight        = Geometry.HighX;
            GraphCoord lastPoint     = new GraphCoord(-1f, -1f);
            float      stepIncrement = Geometry.Width / (200f * stepAccuracy);

            for (float xStep = xLeft; xStep <= xRight; xStep += stepIncrement)
            {
                // calculate y = f(x) = P(x) / Q(x)
                double pStep = pFunc.FunctionValue(xStep);
                double qStep = qFunc.FunctionValue(xStep);
                if (qStep == 0.0)
                {
                    continue;
                }
                float      yStep         = (float)(pStep / qStep);
                GraphCoord functionPoint = new GraphCoord(xStep, yStep);
                if (xStep > xLeft)
                {
                    DrawLine(lastPoint, functionPoint, fillColor, false);
                }
                lastPoint = functionPoint;
            }
        }
예제 #2
0
        /// <summary>
        /// Zeichnet eine polynomielle Funktion zweiten Grades f(x)=ax^2+bx+c
        /// </summary>
        /// <param name="polynomial">Quadratisches Polynom</param>
        /// <param name="fillColor">Füllfarbe der Linie</param>
        /// <param name="stepAccuracy"><para>Genauigkeits-Multiplikator mit der f(x) gezeichnet wird</para><para></para><para>1.0 entspricht 1/200 Schrittweite</para></param>
        public void DrawPolynomialFunction(QuadPolynomial polynomial, Color fillColor, float stepAccuracy = 10.0f)
        {
            // draw inside x-axis bounds
            float      xLeft         = Geometry.LowX;
            float      xRight        = Geometry.HighX;
            GraphCoord lastPoint     = new GraphCoord(-1f, -1f);
            float      stepIncrement = Geometry.Width / (200f * stepAccuracy);

            for (float xStep = xLeft; xStep <= xRight; xStep += stepIncrement)
            {
                // calculate y = f(x) = P(x) / Q(x)
                float      yStep         = polynomial.FunctionValue(xStep);
                GraphCoord functionPoint = new GraphCoord(xStep, yStep);
                if (xStep > xLeft)
                {
                    DrawLine(lastPoint, functionPoint, fillColor, false);
                    //System.Diagnostics.Debug.Print("zeichne linie: " + lastPoint.ToString() + "; " + functionPoint.ToString());
                }
                lastPoint = functionPoint;
            }
        }