File:Color complex plot2.jpg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file (800 × 800 pixels, file size: 202 KB, MIME type: image/jpeg)

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description
English: Colour plot of complex function (x² - 1) * (x-2-I)² / (x² + 2 + 2I), hue represents the argument, sat and value represents the modulo. Contours distinguish intervals [e^i, e^(i+1)] where i=0,1,2... Shadow is on the higher modulus side.

Zeros have pin-wheel of colours, one cycle of the colour wheel for simple zero, two cycles for double zero etc.

Contours are approaching poles with the shadowed side, and the colours cycle in reverse order around a pole.
Date
Source Own work
Author Jan Winnicki
Other versions

Source code

[edit]

This is the source code used for image generation. It is a slightly modified version of File:Color complex plot.jpg. In this version the real axis is directing right. And contours bring more information.

#include <complex>
#include <fstream>
 
using namespace std;

void SetHSV(double h, double s, double v, unsigned char color[3]) {
  double r=0, g=0, b=0;
  if(s==0)
    r = g = b = v;
  else {
    h /= 60;
    int i = floor(h);
    double f = h - i;
    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 = rmi +(rma -rmi) *i /(dimx -1);
      complex<double> c(re, im);
      complex<double> v = fun(c); 
      double a = arg(v)*180/M_PI;
      if(a < 0) a += 360;
      
      double m = abs(v);
      double ranges;
      double rangee = 1;

      while(m>rangee){
          ranges = rangee;
          rangee *= M_E;
      }

      double k   = (m-ranges)/(rangee-ranges);
      double sat = k < 0.5 ? 1-2.8*k : 2.8*k-1.1;
      if(sat < 0.3) sat = 0.3;
      else if(sat > 1) sat = 1;

      double val = k < 0.5 ? 1.4-1.6*k : 1.6*k-0.6;
      if(val < 0.6) val = 0.6;
      else if(val > 1) val = 1;

      unsigned char color[3];
      SetHSV(a,sat,val,color);
      f.write(color,3);
    }
  }
  return 0;
}

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following licenses:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
GNU head Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.
You may select the license of your choice.
Annotations
InfoField
This image is annotated: View the annotations at Commons

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current22:58, 23 March 2013Thumbnail for version as of 22:58, 23 March 2013800 × 800 (202 KB)Yourmomblah (talk | contribs)Higher quality
02:02, 27 March 2010Thumbnail for version as of 02:02, 27 March 2010800 × 800 (234 KB)Jan Winnicki (talk | contribs){{Information |Description={{en|1=Colour plot of complex function (x² - 1) * (x² - I)² / (x² + 2 + 2I), hue represents the argument, sat and value represents the modulo. Contours distinguish intervals [e^i, e^(i+1)] where i=0,1,2... Shadow is on the h

File usage on other wikis

The following other wikis use this file: