ගොනුව:Color complex plot.jpg

Page contents not supported in other languages.
විකිපීඩියා වෙතින්

මුල් ගොනුව(800 × 800 පික්සල, ගොනු විශාලත්වය: 203 කි.බ., MIME ශෛලිය: image/jpeg)

මෙම ගොනුව Wikimedia Commons වෙතින් වන අතර අනෙකුත් ව්‍යාපෘතීන් විසින්ද භාවිතා කල හැක. එහි ගොනු විස්තර පිටුව තුල අඩංගු විස්තර මෙහි පහත දැක්වෙයි.

සාරාංශය

විස්තරය Color plot of complex function (x^2-1) * (x-2-I)^2 / (x^2+2+2I), hue represents the argument, sat and value represents the modulus
දිනය
මූලාශ්‍රය ස්වයං නිර්මාණයකි
කර්තෘ Claudio Rocchini
අවසරය
(මෙම ගොනුව නැවත භාවිතා කරමින්)
CC-BY 2.5
අනෙකුත් අනුවාදයන්

Source Code

C++

This is the complete C++ source code for image generation (you must change the fun funcion to plot another one). You need some complex class implementation.

#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

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <complex.h>// floor 

/* 
based on 
c++ program from :
[[:File:Color_complex_plot.jpg]]
by  	Claudio Rocchini

gcc d.c -lm -Wall

http://en.wikipedia.org/wiki/Domain_coloring



*/
 
const double PI = 3.1415926535897932384626433832795;
const double E  = 2.7182818284590452353602874713527;
 

/*

complex domain coloring 
Given a complex number z=re^{ i \theta}, 


hue represents the argument ( phase, theta ), 

sat and value represents the modulus

*/
int GiveHSV( double complex z, double HSVcolor[3] )
{
 //The HSV, or HSB, model describes colors in terms of hue, saturation, and value (brightness).
 
 // hue = f(argument(z))
 //hue values range from .. to ..
 double a = carg(z); //
 while(a<0) a += 2*PI; a /= 2*PI;


 // radius of z
 double m = cabs(z); // 
 double ranges = 0;
 double rangee = 1;
 while(m>rangee){
   ranges = rangee;
   rangee *= E;
      }
 double k = (m-ranges)/(rangee-ranges);

 // saturation = g(abs(z))
 double sat = k<0.5 ? k*2: 1 - (k-0.5)*2;
 sat = 1 - pow( (1-sat), 3); 
 sat = 0.4 + sat*0.6;

 // value = h(abs(z))
 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;
 
 HSVcolor[0]= a;
 HSVcolor[1]= sat;
 HSVcolor[2]= val;
return 0;
}
  
 
int GiveRGBfromHSV( double HSVcolor[3], unsigned char RGBcolor[3] ) {
        double r,g,b;
        double h; double s; double v;
        h=HSVcolor[0]; // hue 
        s=HSVcolor[1]; //  saturation;
        v = HSVcolor[2]; // = value;

        if(s==0)
                r = g = b = v;
        else {
                if(h==1) h = 0;
                double z = floor(h*6); 
                int i = (int)z;
                double f = (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; RGBcolor[0] = c;
        c = (int)(256*g); if(c>255) c = 255; RGBcolor[1] = c;
        c = (int)(256*b); if(c>255) c = 255; RGBcolor[2] = c;
  return 0;
}

int GiveRGBColor( double complex z, unsigned char RGBcolor[3])
{
  static double HSVcolor[3];
  GiveHSV( z, HSVcolor );
  GiveRGBfromHSV(HSVcolor,RGBcolor);
  return 0;
}

//  
double complex fun(double complex c ){
  return (cpow(c,2)-1)*cpow(c-2.0- I,2)/(cpow(c,2)+2+2*I);} // 
 
int main(){
        // screen (integer ) coordinate
        const int dimx = 800; const int dimy = 800;
        // world ( double) coordinate
        const double reMin = -2; const double reMax =  2;
        const double imMin = -2; const double imMax =  2;
        
        static unsigned char RGBcolor[3];
        FILE * fp;
        char *filename ="complex.ppm";
        fp = fopen(filename,"wb");
        fprintf(fp,"P6\n%d %d\n255\n",dimx,dimy);
 


        int i,j;
        for(j=0;j<dimy;++j){
                double im = imMax - (imMax-imMin)*j/(dimy-1);
                for(i=0;i<dimx;++i){            
                        double re = reMax - (reMax-reMin)*i/(dimx-1);
                        double complex z= re + im*I; // 
                        double complex v = fun(z); //     
                        GiveRGBColor( v, RGBcolor);
                        
                        fwrite(RGBcolor,1,3,fp);
                }
        }
        fclose(fp);
        printf("OK - file %s saved\n", filename);

        return 0;
}

බලපත්‍රීකරණය

I, මෙම කාර්යයේ ප්‍රකාශන අයිතිය දරන්නා,පහත බලපත්‍රය යටතේ එය ප්‍රකාශයට පත් කරනු ලබයි:
GNU head Free Software Foundation විසින් ප්‍රකාශිත GNU Free Documentation License බලපත්‍රයෙහි 1.2 හෝ ඊට අලුත් පිටපත්වල කොන්දේසිවලට යටත්ව මෙම ගොනුව පිටපත් කෙරුමට, නැවත බෙදාහාරුමට සහ/හෝ වෙනස් කෙරුමට අවසර දී ඇත; ඒ වෙනස් අංශ නොමැතිව, මුල් පිටු පෙළ නොමැතිව, පසු පිටු පෙළ නොමැතිවය. බලපත්‍රයේ පිටපතක් GNU Free Documentation License නම් අංශයේ දැක්වේ.
w:en:Creative Commons
attribution share alike
මෙම ගොනුව ක්‍රියේටිව් කොමන්ස් Attribution-Share Alike 3.0 Unported වරපත යටතේ අවසර ලබා ඇත.
ඔබ නිදහස්:
  • බෙදාහදා ගැනීමට – කාර්යය පිටපත් කිරීමට,බෙදා හැරීමට සහ සම්ප්‍රේෂණය කිරීමට
  • නැවත සංකලනය කිරීමට – කාර්යයට අනුවර්තනය වීමට
පහත කොන්දේසිවලට යටත්ව:
  • attribution – වරපත වෙත බැඳියක්ද සපයමින් ඔබ විසින් සුදුසු කර්තෘභාරය ප්‍රදානය කල යුතු අතර, කිසියම් වෙනස්වීම් සිදුකලේ නම් එයද සඳහන් කල යුතු වෙයි. ඕනෑම සුදුසු ආකාරයට මෙය ඔබ විසින් සිදුකල හැකි මුත්, වරපත්දායකයා විසින් ඔබ හෝ ඔබගේ භාවිතය හෝ පිටසන් කරන බවට ඇඟවෙන ලෙසින් එය සිදු නොකල යුතු වෙයි.
  • share alike – මෙම විෂය කාරණා භාවිතා කොට නැවත සංකලනය, ප්‍රතියෝජනය හෝ වැඩිදියුණුව කලේ නම්, ඉන්පසු ඔබගේ දායකත්වය ඔබ විසින් බෙදාහැරිය යුත්තේ මුල් වරපත හා සමාන ‌හෝ සංගතික හෝ වරපතක් භාවිතා කරමිනි.
GFDL බලපත්‍ර යාවත්කාල කෙරුමහි කොටසක් ලෙස මෙම ගොනුවට බලපත්‍ර ටැගය එක් කෙරිනි.
w:en:Creative Commons
attribution
මෙම ගොනුව නිර්මාණශීලී පොදුවූවන් Attribution 2.5 Generic බලපත්‍රය යටතේ අවසර ලබා ඇත.
ඔබ නිදහස්:
  • බෙදාහදා ගැනීමට – කාර්යය පිටපත් කිරීමට,බෙදා හැරීමට සහ සම්ප්‍රේෂණය කිරීමට
  • නැවත සංකලනය කිරීමට – කාර්යයට අනුවර්තනය වීමට
පහත කොන්දේසිවලට යටත්ව:
  • attribution – වරපත වෙත බැඳියක්ද සපයමින් ඔබ විසින් සුදුසු කර්තෘභාරය ප්‍රදානය කල යුතු අතර, කිසියම් වෙනස්වීම් සිදුකලේ නම් එයද සඳහන් කල යුතු වෙයි. ඕනෑම සුදුසු ආකාරයට මෙය ඔබ විසින් සිදුකල හැකි මුත්, වරපත්දායකයා විසින් ඔබ හෝ ඔබගේ භාවිතය හෝ පිටසන් කරන බවට ඇඟවෙන ලෙසින් එය සිදු නොකල යුතු වෙයි.
ඔබට අභිමත වරපත තෝරාගත හැක.

Captions

මෙම ගොනුව නිරූපණය කරන්නෙඑ කුමක්දැයි තනි පේළියේ පැහැදිළි කිරීමක් එක් කරන්න.
Color wheel graph of the function f(x) = (x^2 − 1)(x + 2 − i)2 / (x^2 + 2 - 2i).

Items portrayed in this file

depicts ඉංග්‍රීසි

some value

author name string ඉංග්‍රීසි: Claudio Rocchini
Wikimedia username ඉංග්‍රීසි: Rocchini

copyright status ඉංග්‍රීසි

copyrighted ඉංග්‍රීසි

copyright license ඉංග්‍රීසි

inception ඉංග්‍රීසි

7 අගෝස්තු 2007

source of file ඉංග්‍රීසි

original creation by uploader ඉංග්‍රීසි

MIME type ඉංග්‍රීසි

image/jpeg

checksum ඉංග්‍රීසි

c0f2c797263ef24ef3cb2d39a22f86ee3e4ca071

determination method ඉංග්‍රීසි: SHA-1 ඉංග්‍රීසි

data size ඉංග්‍රීසි

208,178 byte

800 pixel

width ඉංග්‍රීසි

800 pixel

ගොනු ඉතිහාසය

එම අවස්ථාවෙහිදී ගොනුව පැවැති ආකාරය නැරඹීමට දිනය/වේලාව මත ක්ලික් කරන්න.

දිනය/වේලාවකුඩා-රූපයමානපරිශීලකපරිකථනය
වත්මන්23:06, 22 මාර්තු 2013 23:06, 22 මාර්තු 2013වන විට අනුවාදය සඳහා කුඩා-රූපය800 × 800 (203 කි.බ.)YourmomblahHigher quality
09:46, 7 අගෝස්තු 2007 09:46, 7 අගෝස්තු 2007වන විට අනුවාදය සඳහා කුඩා-රූපය800 × 800 (59 කි.බ.)Rocchini{{Information |Description=Color plot of complex function (x^2-1) * (x-2-I)^2 / (x^2+2+2I), hue represents the argument, sat and value represents the modulo |Source=Own work |Date=2007-08-07 |Author=Claudio Rocchini |Permission=CC-BY 2.5 }}

පහත දැක්වෙන පිටු 2 ක් විසින් මෙම ගොනුව භාවිතා කෙරෙයි:

ගෝලීය ගොනු භාවිතය

පහත දැක්වෙන අනෙකුත් විකියන් මගින් මෙම ගොනුව භාවිතා කරයි:

"https://si.wikipedia.org/wiki/ගොනුව:Color_complex_plot.jpg" වෙතින් සම්ප්‍රවේශනය කෙරිණි