Domain coloring 复数变量函数的美化
2014-09-11 11:46
148 查看
来自维基
维基英文Domain coloring
Domain coloring is a technique for
visualizing functions of a complex
variable. The term "domain coloring" was coined by Frank Farris possibly around 1998.[1][2] There
were many earlier uses of color to visualize complex functions, typically mapping argument (phase) to hue.[3] The
technique of using continuous color to map points from domain to codomain or image plane was used in 1999 by George Abdo and Paul Godfrey[4] and
colored grids were used in graphics by Doug
Arnold that he dates to 1997.[5]
C++代码的例子
C++代码的输出结果:
维基英文Domain coloring
Domain coloring is a technique for
visualizing functions of a complex
variable. The term "domain coloring" was coined by Frank Farris possibly around 1998.[1][2] There
were many earlier uses of color to visualize complex functions, typically mapping argument (phase) to hue.[3] The
technique of using continuous color to map points from domain to codomain or image plane was used in 1999 by George Abdo and Paul Godfrey[4] and
colored grids were used in graphics by Doug
Arnold that he dates to 1997.[5]
C++代码的例子
#include <complex> #include <fstream> using namespace std; const double PI = 3.1415926535897932384626433832795; const double E = 2.7182818284590452353602874713527; void SetHSV(double h, double s, double v, unsigned char color[3]) { double r, g, b; if(s==0) r = g = b = v; else { if(h==1) h = 0; double z = floor(h*6); int i = int(z); double f = double(h*6 - z); double p = v*(1-s); double q = v*(1-s*f); double t = v*(1-s*(1-f)); switch(i){ case 0: r=v; g=t; b=p; break; case 1: r=q; g=v; b=p; break; case 2: r=p; g=v; b=t; break; case 3: r=p; g=q; b=v; break; case 4: r=t; g=p; b=v; break; case 5: r=v; g=p; b=q; break; } } int c; c = int(256*r); if(c>255) c = 255; color[0] = c; c = int(256*g); if(c>255) c = 255; color[1] = c; c = int(256*b); if(c>255) c = 255; color[2] = c; } complex<double> fun(complex<double>& c ){ const complex<double> i(0., 1.); return (pow(c,2) -1.) *pow(c -2. -i, 2) /(pow(c,2) +2. +2. *i); } int main(){ const int dimx = 800; const int dimy = 800; const double rmi = -3; const double rma = 3; const double imi = -3; const double ima = 3; ofstream f("complex.ppm", ios::binary); f << "P6" << endl << dimx << " " << dimy << endl << "255" << endl; for(int j=0; j < dimy; ++j){ double im = ima - (ima -imi) *j /(dimy -1); for(int i=0; i < dimx; ++i){ double re = rma -(rma -rmi) *i /(dimx -1); complex<double> c(re, im); complex<double> v = fun(c); double a = arg(v); while(a<0) a += 2*PI; a /= 2*PI; double m = abs(v); double ranges = 0; double rangee = 1; while(m>rangee){ ranges = rangee; rangee *= E; } double k = (m-ranges)/(rangee-ranges); double sat = k < 0.5 ? k *2: 1 -(k -0.5) *2; sat = 1 - pow(1-sat, 3); sat = 0.4 + sat*0.6; double val = k < 0.5 ? k *2: 1 -(k -0.5) *2; val = 1 - val; val = 1 - pow(1-val, 3); val = 0.6 + val*0.4; unsigned char color[3]; SetHSV(a,sat,val,color); f.write((const char*)color,3); } } return 0; }
C++代码的输出结果:
相关文章推荐
- 漂亮的peaks函数的domain coloring
- 领域驱动设计(Domain Driven Design)
- 美化input type="file" 文件上传表单
- tuxedo之domain应用入门
- NSURLErrorDomain Code=-999(转)
- warning: do not list domain haha.com.cn in BOTH mydestination and virtual_mailbox_domains
- input file美化
- sudo /etc/init.d/apache2 restart时出现Could not reliably determine the server’s fully qualified domain
- 【深度学习】论文导读:无监督域适应(Deep Transfer Network: Unsupervised Domain Adaptation)
- 【网页设计】分享40个网页美化模板PSD(11~20)
- EasyUI 1.5.1 美化主题 EasyUI 1.5.1 Of Insdep Theme 1.0
- 【网页设计】分享40个网页美化模板PSD(31~40完)
- 留言板v1.1(加了界面美化和内容检查。php+mysql)
- 使用SkinMagic美化MFC的窗口
- CSS学习笔记12:伪类和超链接的美化
- 一键美化QQ
- 《Qt》part 7 QSS参考样式表——界面美化2
- Silverlight入门:第六部分 - 美化用户界面的样式与模板
- 美化CSDN博客--markdown编辑器中段落缩进、换行,改变字体、字号与颜色等
- C#中运用AppDomain动态加载程序集详解