Оконное приложение для построения 3d-графиков квадратичной функции, страница 6

      return res;

}

double FI4 (double x)

{

      double res;

      res = b + a0 * x;

      res += alpha1 * abs (x - alpha1);

      res += alpha2 * abs (x - alpha2);

      res += alpha3 * abs (x - alpha3);

      return res;

}

#define th 1

#define h  1

double f (double x1, double x2)

{

      return sin ((x1 - x2)) * 20;

}

double result_func (double x1, double x2)

{

      return x2 - h / th * (FI2 (FI3 (FI4 (x1))) - FI2 (FI3 (FI4 (x2)))) + th * f (x1, x2);

}

void LFrameWnd::Set (void)

{

      Umn = (double**)malloc (M * sizeof (long));

      CUmn =(COLORREF**)malloc (M * sizeof (long));

      for (int i = 0; i < M; i++)

      {

            Umn[i] = (double*)malloc (N * sizeof (double));

            CUmn[i] =(COLORREF*)malloc (N * sizeof (double));

      }          

      for (int m = 0; m < M; m++)

      {

            Umn[m][0] = h * h * (M / 2 - m) * (M / 2 - m) / 10 - 1 * (M / 2 - m) * h/ 1 + 10;

            CUmn[m][0] = GetColour (Umn[m][0]);

      }

      for (int n = 0; n < N - 1; n++)

            for (int m = 0; m < M - 1; m++)

            {

                  Umn[m][n + 1] = result_func (Umn[m + 1][n], Umn[m][n]);

                  CUmn[m][n + 1] = GetColour (Umn[m][n + 1]);

            }

      return;

}

void LFrameWnd::DrawRhomb( void )

{

    CClientDC           ClientDC( this );

                                    // CLIENT area Device Context:

                                    //   device context to draw on

                                    //   in the client area

    CPen                NewPen;     // NEW PEN:

                                    //   new pen

                                    //   with desired attributes

    CPen *              pOldPen;    // Pointer to OLD PEN:

                                    //   pointer to the pen

                                    //   used in the device context