home *** CD-ROM | disk | FTP | other *** search
/ Chip Hitware 8 / Chip_Hitware_Vol_08.iso / chiphit8 / multmedi / 95iterat / _setup.1 / Fracsub2.cpp < prev    next >
C/C++ Source or Header  |  1996-11-29  |  6KB  |  288 lines

  1. //////////////////////////////////////////////////////////////////
  2. // fracsub2.cpp
  3. // This file is an extension of CIterationsview and 'fracsub1.cpp'
  4. // Class Function implementations
  5. //
  6. //
  7.  
  8. #include "stdafx.h"                                                            
  9. #include "itriazon.h"
  10. #include "itriadoc.h"
  11. #include "itriavw.h"
  12. #include "external.h"
  13. #include "math.h"
  14.  
  15. ////////////////////////////////////////////////////
  16. void CIterationsView::Pattern5_Case07()
  17. {
  18. }
  19.  
  20. void CIterationsView::Pattern5_Case08()
  21. {
  22.     /////////////////////////////////////////////////////////
  23.     // Roger T. Stevens Methods
  24.     // Legendre Polynomial Fractal
  25.  
  26.     P = cx;  // Column
  27.     Q = cy;  // Row        (Backwards ?)
  28.  
  29.     for (i = 0; (i < NMAX) && ((xsquared + ysquared) < dBailout) ; i++)
  30.   {
  31.         temp = 0.5*(5.0*x*x*x - 15.0*x*y*y - 3.0*x) + P;
  32.         y = 0.5*(15.0*x*x*y - 5.0*y*y*y) + Q;
  33.         x = temp;
  34.         xsquared = x*x;
  35.         ysquared = y*y;
  36.         if (nFilter) Delta_z((double)x, (double)y);
  37.     }
  38.     if (nFilter) Filter_Complete();
  39.  
  40.   if (i >= NMAX)
  41.       b_MAX = TRUE;
  42.   else
  43.       b_MAX = FALSE;     
  44.           
  45.     i %= NMAX-1;
  46.     i = abs(i);
  47.     if (i < 0 || i > NMAX)
  48.     {     
  49.         AfxMessageBox("1: error, i out of range");
  50.     Row = 0;
  51.   }  
  52. }
  53.  
  54. void CIterationsView::Pattern5_Case10()
  55. {
  56.     /////////////////////////////////////////////////////////
  57.     // Roger T. Stevens Methods
  58.     // 3rd Order Newton
  59.  
  60.     x = cx;
  61.     y = cy;
  62.  
  63.     old_x = old_y = 42;
  64.     for (i=0 ; i<NMAX ; i++)
  65.     {
  66.         sqdif = (x - y) * (x + y);
  67.         xsquared = x*x;
  68.         ysquared = y*y;
  69.         denom = 3.0 * (sqdif*sqdif + 4.0*xsquared*ysquared);
  70.         if (denom == 0)
  71.             denom = 1E-10;
  72.         y = 0.6666667*y - 2.0*x*y/denom;
  73.         x = 0.6666667*x + sqdif/denom;
  74.         if (fabsl(old_x - x) < 1E-10 && (fabsl(old_y - y) < 1E-10))
  75.             break;
  76.         old_x = x;
  77.         old_y = y;        
  78.         if (nFilter) Delta_z((double)x, (double)y);
  79.     }        
  80.     if (nFilter) Filter_Complete();
  81.  
  82.     //char cstr[81];
  83.     //wsprintf(cstr,"i=%d",i);
  84.     //GetParent()->SetWindowText(cstr);
  85.                 
  86.     if (i >= NMAX) 
  87.         b_MAX = TRUE;
  88.     else
  89.         b_MAX = FALSE;
  90.  
  91.     i %= NMAX-1;
  92.     i = abs(i);
  93.     if (i < 0 || i > NMAX)
  94.     {     
  95.         AfxMessageBox("2: error, i out of range");
  96.     Row = 0;
  97.   }  
  98. }
  99.  
  100. void CIterationsView::Pattern5_Case11()
  101. {
  102.     /////////////////////////////////////////////////////////
  103.     // Roger T. Stevens Methods
  104.     // 7nth Order Newton
  105.  
  106.     x = cx;
  107.     y = cy;
  108.  
  109.     old_x = old_y = 42;
  110.     for (i=0 ; i<NMAX ; i++)
  111.     {
  112.         xsquared = x*x;
  113.         ysquared = y*y;
  114.         sqsum = xsquared + ysquared;
  115.         denom = 7.0 * (sqsum*sqsum*sqsum*sqsum*sqsum*sqsum);
  116.         if ((denom > -.00004) && (denom < .00004))
  117.             denom = .00004;
  118.         ytemp = 0.85714285*y - (6.0*x*x*x*x*x*y - 
  119.                       20.0*x*x*x*y*y*y + 6.0*x*y*y*y*y*y)/denom;
  120.         x =         0.85714285*x + (x*x*x*x*x*x - 
  121.                         15.0*x*x*x*x*y*y + 
  122.                         15.0*x*x*y*y*y*y -
  123.                         y*y*y*y*y*y)/denom;
  124.         y = ytemp;
  125.         if (fabsl(old_x - x) < 1E-10 && (fabsl(old_y - y) < 1E-10))
  126.             break;
  127.         old_x = x;
  128.         old_y = y;        
  129.         if (nFilter) Delta_z((double)x, (double)y);
  130.     }        
  131.     if (nFilter) Filter_Complete();
  132.  
  133.     //char cstr[81];
  134.     //wsprintf(cstr,"i=%d",i);
  135.     //GetParent()->SetWindowText(cstr);
  136.                 
  137.     if (i >= NMAX) 
  138.         b_MAX = TRUE;
  139.     else
  140.         b_MAX = FALSE;
  141.  
  142.     i %= NMAX-1;
  143.     i = abs(i);
  144.     if (i < 0 || i > NMAX)
  145.     {     
  146.         AfxMessageBox("3: error, i out of range");
  147.     Row = 0;
  148.   }  
  149. }
  150.  
  151. void CIterationsView::Pattern5_Case06()
  152. {
  153. }
  154.  
  155. void CIterationsView::Pattern5_Case12()
  156. {
  157. }    
  158.  
  159. void CIterationsView::Pattern5_Case13()
  160. {
  161. }    
  162.  
  163. void CIterationsView::Pattern5_Case14()
  164. {
  165. }    
  166.  
  167. void CIterationsView::Pattern5_Case15()
  168. {
  169.     // Roger T. Stevens method for the Tchebychev C5 Fractal
  170.  
  171.     x = P = cx;  // Column
  172.     y = Q = cy;  // Row        (Backwards ?)
  173.     old_x = old_y = 0;
  174.  
  175.     for (i = 0; (i < NMAX) && ((xsquared + ysquared) < dBailout) ; i++)
  176.   {
  177.         temp_x =          x*x*x*x*x -
  178.                         10.0*x*x*x*y*y +
  179.                          5.0*x*y*y*y*y -
  180.                          5.0*x*x*x +
  181.                         15.0*x*y*y +
  182.                          5.0*x;
  183.                          
  184.         temp_y = 5.0*x*x*x*x*y -
  185.                         10.0*x*x*y*y*y +
  186.                                  y*y*y*y*y -
  187.                         15.0*x*x*y +
  188.                          5.0*y*y*y +
  189.                          5.0*y; 
  190.         x = P*temp_x - Q*temp_y;
  191.         y = Q*temp_x + P*temp_y;
  192.         
  193.         xsquared = x*x;
  194.         ysquared = y*y;
  195.         if (nFilter) Delta_z((double)x, (double)y);
  196.     }                             
  197.     if (nFilter) Filter_Complete();
  198.                          
  199.     if (i >= NMAX)
  200.         b_MAX = TRUE;
  201.     else
  202.         b_MAX = FALSE;    
  203.  
  204.     i %= NMAX-1;
  205.     i = abs(i);
  206.     if (i < 0 || i > NMAX)
  207.     {     
  208.         AfxMessageBox("4: error, i out of range");
  209.     Row = 0;
  210.   }  
  211. }
  212.  
  213. // Color map the iteration data
  214. void CIterationsView::Pattern5_Case17()
  215. {                               
  216.     if (idata == NULL)
  217.     {
  218.         delete idata;
  219.                 
  220.         // create a data array for the rows
  221.         // AfxMessageBox("Creating New iter data array");
  222.         idata = new short [dim.cx];
  223.     }    
  224.  
  225.     if (px == 0)
  226.     {
  227.         // AfxMessageBox("Reading a new row");
  228.         // Read a row from the iteration data file
  229.          TRY
  230.         {
  231.             itrData.Read(idata, dim.cx*2);
  232.         }
  233.             CATCH( CFileException, e )
  234.         {                                                          
  235.             itrData.Close();
  236.              AfxMessageBox( "Error reading from file: itrdata.itr");
  237.       }
  238.         END_CATCH
  239.     }    
  240.     
  241.     if (px >= dim.cx || px < 0)
  242.         AfxMessageBox("Error: 'px' is out of range");
  243.  
  244.     // transfer the data one data point at a time
  245.     i = (int) idata[px];
  246.  
  247.     //char cstr1[81];
  248.     //wsprintf(cstr1, "i=%X", i);
  249.     //if (AfxMessageBox(cstr1, IDOK || IDCANCEL) == IDCANCEL)
  250.     //    return;
  251.  
  252.     if (i < 0 || i > NMAX)
  253.     {
  254.         //AfxMessageBox("Error, iteration data is out of range");
  255.         //char cstr[81];
  256.         //wsprintf(cstr,"Error: px=%d,idata=%d",px, i);
  257.         //AfxMessageBox(cstr);
  258.         i = 0;
  259.         //GetParent()->SetWindowText(cstr);
  260.     }    
  261. }
  262.  
  263. // Color map the iteration data
  264. //void CIterationsView::Pattern5_Case18()
  265. //{
  266. //    // AfxMessageBox("Case 18");
  267. //
  268. //    pITR = (LPSTR) ::GlobalLock((HGLOBAL) hITR_DATA);
  269. //
  270. //    itr_data = (short int huge *) pITR + 4;
  271. //    
  272. //     i = itr_data[(DWORD) (((DWORD) (dim.cy - 1 - py)
  273. //                                         * (DWORD) dim.cx) + (DWORD) px)];
  274. //
  275. //    if (i < 0 || i > NMAX)
  276. //    {
  277. //        //AfxMessageBox("Error, iteration data is out of range");
  278. //        char cstr[81];
  279. //        wsprintf(cstr,"Error: px=%d,idata=%d",px, i);
  280. //        //AfxMessageBox(cstr);
  281. //        i = 0;
  282. //        GetParent()->SetWindowText(cstr);
  283. //    }    
  284. //
  285. //    ::GlobalUnlock((HGLOBAL) hITR_DATA);
  286. //}
  287.  
  288.