Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C/C++ - programma frattali
Forum - C/C++ - programma frattali

Avatar
Yi (Normal User)
Newbie


Messaggi: 6
Iscritto: 09/03/2005

Segnala al moderatore
Postato alle 23:14
Martedì, 02/05/2006
Scusate qualcuno saprebbe dirmi dove sbaglio in questo piccolo programma che dovrebbe disegnare l'insieme di mandelbrot

Codice sorgente - presumibilmente C++

  1. #include <winbgim.h>
  2. #include <conio.h>
  3. #include <cstdlib>
  4. #include <iostream>
  5. #include <windows.h>
  6. #include<stdlib.h>
  7. #include<math.h>
  8.  
  9.  
  10. using namespace std;
  11.  
  12.  
  13. void  rivelrisoluzionegraf(int &width,int &height);
  14. void   mandelbord(int rx,int ry);
  15. float vx1,vx2,vy1,vy2;
  16.  
  17. int main(int argc, char *argv[])
  18. {
  19.   int rx,ry;  
  20. vx1= -5;
  21. vx2= 5;
  22. vy1= -4;
  23. vy2= 4;
  24.   rivelrisoluzionegraf(rx,ry);
  25.    mandelbord(rx,ry);
  26.    
  27.    
  28.     system("PAUSE");
  29.     return EXIT_SUCCESS;
  30. }
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37. void  rivelrisoluzionegraf(int &width,int &height)
  38.     {
  39.        
  40. tagRECT r;
  41.     HWND hWindow;
  42.         long ret;
  43.        
  44.  
  45.         hWindow = GetDesktopWindow ();
  46.  
  47.         ret = GetWindowRect(hWindow, &r);
  48.  
  49.         width = r.right;
  50.         height = r.bottom;
  51.  
  52. }
  53.  
  54.  
  55.  
  56.  
  57.  
  58. void mandelbord(int rx,int ry)
  59.  {
  60.     int px,py;
  61.     int itera,numIt;
  62.     int col;
  63.    
  64.     float Zrel,Zim,Crel,Cim,modZ;
  65.     float x,y,pxx,pyy,rx1,ry1;
  66.     px=0;
  67.     py=0;
  68.    
  69.    initwindow(rx,ry); //open  graphics window
  70.  while(!kbhit())
  71.  {  
  72.      
  73.    
  74.      
  75.      while(py<ry)
  76.      {
  77.          while(px<rx)
  78.             {
  79.                rx1=rx;
  80.                ry1=ry;
  81.                pxx=px;
  82.                pyy=py;    
  83.                pxx= (pxx/rx1);
  84.                pyy=(pyy/ry1);    
  85.                x=vx1+((pxx)*(vx2-vx1));
  86.                y=vy1+((pyy)*(vy2-vy1));
  87.                
  88.                Crel=x;
  89.                Cim=y;
  90.                Zrel=0;
  91.                Zim=0;
  92.                itera=0;
  93.                 numIt=60;
  94.                modZ=0;
  95.                
  96.                     while((modZ<4)&&(itera<numIt))            
  97.                         {
  98.                             Zrel=(((Zrel*Zrel)-(Zim*Zim))+Crel);
  99.                        
  100.                             Zim= ((2*Zrel*Zim)+Cim);
  101.                        
  102.                           modZ= ((Zrel*Zrel)+(Zim*Zim));
  103.                          
  104.                             itera++;
  105.                          }  
  106.                                                          
  107.                
  108.                modZ= ((Zrel*Zrel)+(Zim*Zim));
  109.              col=COLOR(255,(255-itera),(255-itera));
  110.              
  111.               if(modZ>4)
  112.                     {
  113.                     putpixel(px,py,col);
  114.                     }
  115.            
  116.               px++;
  117.             }
  118.            px=0;
  119.            py++;
  120.      }          
  121.      
  122.   while(!kbhit())
  123.   {
  124. }                
  125.    
  126.  
  127.      
  128. cleardevice();  
  129. }
  130.  
  131.       //wait for user to press a key
  132.       closegraph();       //close graphics window
  133.  
  134. }





Ultima modifica effettuata da pierotofy il 01/12/2007 alle 23:42
PM Quote
Avatar
Thief (Ex-Member)
Rookie


Messaggi: 58
Iscritto: 30/11/2005

Segnala al moderatore
Postato alle 19:00
Giovedì, 04/05/2006
Ke compilatore usi? Perkè ho notato ke hai scritto "#include <cstdlib>", mentre con il borland si usa: "#include <stdlib>" e il sorgente può cambiare in base al compilatore.

PM Quote
Avatar
Yi (Normal User)
Newbie


Messaggi: 6
Iscritto: 09/03/2005

Segnala al moderatore
Postato alle 19:30
Giovedì, 04/05/2006
Dev-C++ 4.9.9.2 Bloodshed

PM Quote
Avatar
Yin (Normal User)
Newbie


Messaggi: 1
Iscritto: 01/12/2007

Segnala al moderatore
Postato alle 5:07
Sabato, 01/12/2007
ni ye xue C++ me????? 8-|8-|

PM Quote