Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <complex>
- #include <graphics.h>
- using namespace std;
- /// Functia care verifica daca desenez un punct dat
- bool convergeJulia( complex<double> point, complex<double> c, double d, int precision )
- {
- complex<double> z;
- z = point;
- for( int i=1 ; i<=precision ; i++ )
- {
- z = pow(z,d) + c;
- if( abs(z) >= 2 )
- return false;
- }
- return true;
- }
- int main()
- {
- double length = 4;
- complex<double> center(0,0);
- int precision = 100;
- complex<double> parameter1(-0.8,0.156);
- double parameter2 = 2;
- /// Ca sa arate altfel schimba valoarile pt "parameter1" si "precision"
- /// Niste exemple sunt (-0.726,0.188) si precision 200
- /// (−0.835,-0.2321i) si precision 45
- /// (-0.618,0) si precision 70
- /// (0,-0.8) si precision 30
- /// (0.285,0.01) si precision 60
- /// (-0.4,0.6) si precision 60
- /// (-0.8,0.156) si precision 100
- /// Schimband "length" si "center" se va afisa o zona diferita din fractal,
- /// zona din patratul de latura length, centrata in punctul center.
- initwindow(800,800);
- /// Verific ce puncte trebuie desenate si le desenez
- for( double x = real(center)-length/2 ; x <= real(center)+length/2 ; x += length/getmaxx()/1.2 )
- for( double y = imag(center)-length/2 ; y <= imag(center)+length/2 ; y += length/getmaxy()/1.2 )
- {
- complex<double> point(x,y);
- if( convergeJulia(point,parameter1,parameter2,precision) )
- {
- /// afisare pe ecran
- putpixel((x-real(center)+length/2)*getmaxx()/length,(y-imag(center)+length/2)*getmaxy()/length,WHITE);
- }
- }
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment