MAKE A MEME View Large Image Amoeba2.png Made by myself with C++ and matlab 2007-02-28 own assumed Oleg Alexandrov C++ code <source lang cpp > include <iostream> include <fstream> include <cmath> include <complex> using namespace std; double small 1e-14; double mylog ...
View Original:Amoeba2.png (1504x1446)
Download: Original    Medium    Small Thumb
Courtesy of:commons.wikimedia.org More Like This
Keywords: Amoeba2.png Made by myself with C++ and matlab 2007-02-28 own assumed Oleg Alexandrov C++ code <source lang cpp > include <iostream> include <fstream> include <cmath> include <complex> using namespace std; double small 1e-14; double mylog double ; int main double A -5 B 5; int N 1000; double h B-A / N-1 ; double theta0 2 M_PI/ N-1 0 ; ofstream mfile data txt ; for int i 0 ; i < N ; i++ double r exp A+i h ; for int j 0 ; j < N ; j++ double theta j theta0; complex<double> z2 polar r theta ; complex<double> root sqrt 25 0 z2 z2-12 0 z2 z2 z2+1 0 ; complex<double> z11 -5 0 z2+root /6 0; complex<double> z12 -5 0 z2-root /6 0; double a1 mylog abs z11 ; double a2 mylog abs z12 ; double b mylog abs z2 ; mfile << a1 << ' ' << b << endl; mfile << a2 << ' ' << b << endl; mfile close ; return 0; double mylog double x if x< 0 cerr << Error in log negative x << endl; exit 0 ; if x < small return log small ; return log x ; </source> Matlab code which reads the data output by the C++ code and graphs it <source lang Matlab > A load 'data txt' ; plot A 1 A 2 ' ' ; axis equal; axis off; axis -4 6 -5 5 saveas gcf 'amoeba2 eps' 'psc2' ; </source> derivative works Amoeba2 svg amoeba mathematics Images with C++ source code Files by User Oleg Alexandrov from en wikipedia Images with Matlab source code math
Terms of Use   Search of the Day