Created
July 25, 2021 18:47
-
-
Save sjhalayka/c49b491a28589f95d420de5ae5630143 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <cmath> | |
| #include <vector> | |
| #include <complex> | |
| #include <algorithm> | |
| using namespace std; | |
| float iterate_Mandelbrot_2d(vector< complex<float> >& trajectory_points, | |
| const complex<float> C, | |
| const short unsigned int max_iterations, | |
| const float threshold) | |
| { | |
| trajectory_points.clear(); | |
| complex<float> Z(0, 0); | |
| //trajectory_points.push_back(Z); | |
| for (short unsigned int i = 0; i < max_iterations; i++) | |
| { | |
| Z = Z * Z + C; | |
| trajectory_points.push_back(Z); | |
| if (abs(Z) >= threshold) | |
| break; | |
| } | |
| return abs(Z); | |
| } | |
| int main(void) | |
| { | |
| vector< complex<float> > trajectory_points; | |
| const complex<float> C = complex<float>(-0.1258695628494024, 0.7545827310532331); | |
| const unsigned short int max_iterations = 2000; | |
| const float threshold = 4.0f; | |
| iterate_Mandelbrot_2d(trajectory_points, C, max_iterations, threshold); | |
| vector<complex<float>> new_points; | |
| for (size_t i = 0; i < trajectory_points.size(); i++) | |
| if (std::find(new_points.begin(), new_points.end(), trajectory_points[i]) == new_points.end()) | |
| new_points.push_back(trajectory_points[i]); | |
| cout << trajectory_points.size() << endl; | |
| trajectory_points = new_points; | |
| cout << trajectory_points.size() << endl; | |
| cout << endl; | |
| return 0; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment