Chebyshev2.png(201 × 201 pixels, taille du fichier : 27 kio, type MIME : image/png)

Ce fichier et sa description proviennent de Wikimedia Commons.

Transféré de en.wikipedia à Commons par Maksim.

La page de description originale était ici. Tous les noms d'utilisateur qui suivent se rapportent à en.wikipedia.

//

GNU head

Cette œuvre est un logiciel libre ; vous pouvez la redistribuer ou la modifier suivant les termes de la Licence publique générale GNU telle que publiée par la Free Software Foundation, soit la version 2 de cette License, soit une version ultérieure. Cette œuvre est distribuée dans l’espoir qu’elle sera utile, mais sans aucune garantie, pas même la garantie implicite de commercialisabilité ni celle d’adéquation à un besoin particulier. Consultez la version 2 et la version 3 de la GNU General Public License pour plus de détails.


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>

#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825
#define PI2 (PI*2)
#define SQ2 1.414213562373095048801688724209698078569671875376948073176679737990732478462
#define FI 1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204

#define SX 201
#define SY 201

#define BPL ((SX*3+3)&~3)

unsigned char bhdr[54]={
0x42, 0x4D, 0x36, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

unsigned char po[BPL];

double gr[SY][SX][3];

void drawit();

int main(int a, char **b) {
  FILE *o;
  int x, y, c;
  double t;
  char *p;

  srand(time(0));
  drawit();
  
  p=bhdr+2; *p++=x=54+BPL*SY; *p++=x>>=8; *p++=x>>=8; *p=x>>=8;
  p=bhdr+18; *p++=x=SX; *p++=x>>=8; *p++=x>>=8; *p++=x>>=8;
  *p++=x=SY; *p++=x>>=8; *p++=x>>=8; *p=x>>=8;

  if(!(o=fopen("func.bmp", "wb"))) {
    fclose(o);
    printf("Couldn't open output file.\n");
    return(0);
  }
  
  fwrite(bhdr, 54, 1, o);

  for(x=SX*3;x<BPL;++x) po[x]=0;
  
  for(y=SY-1;~y;--y) {
    for(x=0,p=po;x<SX;++x) for(c=2;~c;--c) *p++=(t=gr[y][x][c])<=0?0:(t>=1?255:t*255);
    fwrite(po, BPL, 1, o);
  }

  fclose(o);
  return(0);
}

double minx, miny, maxx, maxy, dlx, dly;

double cr, cg, cb;

void func(int f, double x, double *y, double *dydx) {
  double x2, x3, x4, x5, x6, x7;
  x2=x*x;
  x3=x2*x;
  x4=x3*x;
  x5=x4*x;
  x6=x5*x;
  x7=x6*x;
  switch(f) {
    //x
    case 0: *y=x; *dydx=1; break;
    //sinh(x)
    case 1: *y=(exp(x)-exp(-x))/2; *dydx=(exp(x)+exp(-x))/2; break;
    //cosh(x)
    case 2: *y=(exp(x)+exp(-x))/2; *dydx=(exp(x)-exp(-x))/2; break;
    //tanh(x)
    case 3: *y=(exp(x)-exp(-x))/(exp(x)+exp(-x)); *dydx=1-*y**y; break;
    //Chebyshev 0-7
    case 100: *y=1; *dydx=0; break;
    case 101: *y=x; *dydx=1; break;
    case 102: *y=2*x2-1; *dydx=4*x; break;
    case 103: *y=4*x3-3*x; *dydx=12*x2-3; break;
    case 104: *y=8*x4-8*x2+1; *dydx=32*x3-16*x; break;
    case 105: *y=16*x5-20*x3+5*x; *dydx=80*x4-60*x2+5; break;
    case 106: *y=32*x6-48*x4+18*x2-1; *dydx=192*x5-192*x3+38*x; break;
    case 107: *y=64*x7-112*x5+56*x3-7*x; *dydx=448*x6-560*x4+168*x2-7; break;
    //Weirdishev 0-7
    case 200: *y=1; *dydx=0; break;
    case 201: *y=2*x; *dydx=2; break;
    case 202: *y=4*x2-1; *dydx=8*x; break;
    case 203: *y=8*x3-4*x; *dydx=24*x2-4; break;
    case 204: *y=16*x4-12*x2+1; *dydx=64*x3-24*x; break;
    case 205: *y=32*x5-32*x3+6*x; *dydx=160*x4-96*x2+6; break;
    default: *y=100; *dydx=0; break;
  }
}

void subp(int x, int y, double r, double g, double b) {
  if(x>=0&&y>=0&&x<SX&&y<SY) {
    gr[y][x][0]-=r; gr[y][x][1]-=g; gr[y][x][2]-=b;
  }
}

void drawdot(double x, double y) {
  int ix, iy;
  double dx, dy, ax, ay;
  x=(x-minx)/(maxx-minx)*(SX-1)+.5;
  y=(y-maxy)/(miny-maxy)*(SY-1)+.5;
  ix=floor(x); dx=x-ix; iy=floor(y); dy=y-iy;
  ax=1-dx; ay=1-dy;
  subp(ix-1, iy-1, cr*ax*ay*.05, cg*ax*ay*.05, cb*ax*ay*.05);
  subp(ix  , iy-1, cr   *ay*.05, cg   *ay*.05, cb   *ay*.05);
  subp(ix+1, iy-1, cr*dx*ay*.05, cg*dx*ay*.05, cb*dx*ay*.05);
  subp(ix-1, iy  , cr*ax   *.05, cg*ax   *.05, cb*ax   *.05);
  subp(ix  , iy  , cr      *.05, cg      *.05, cb      *.05);
  subp(ix+1, iy  , cr*dx   *.05, cg*dx   *.05, cb*dx   *.05);
  subp(ix-1, iy+1, cr*ax*dy*.05, cg*ax*dy*.05, cb*ax*dy*.05);
  subp(ix  , iy+1, cr   *dy*.05, cg   *dy*.05, cb   *dy*.05);
  subp(ix+1, iy+1, cr*dx*dy*.05, cg*dx*dy*.05, cb*dx*dy*.05);
}

void drawhorz(double y) {
  int ix, iy;
  double dy, ay;
  y=(y-maxy)/(miny-maxy)*(SY-1)+.5;
  iy=floor(y); dy=y-iy;
  ay=1-dy;
  for(ix=0;ix<SX;++ix) {
    subp(ix  , iy-1, cr   *ay    , cg   *ay    , cb   *ay    );
    subp(ix  , iy  , cr          , cg          , cb          );
    subp(ix  , iy+1, cr   *dy    , cg   *dy    , cb   *dy    );
  }
}

void drawvert(double x) {
  int ix, iy;
  double dx, ax;
  x=(x-minx)/(maxx-minx)*(SX-1)+.5;
  ix=floor(x); dx=x-ix;
  ax=1-dx;
  for(iy=0;iy<SY;++iy) {
    subp(ix-1, iy  , cr*ax       , cg*ax       , cb*ax       );
    subp(ix  , iy  , cr          , cg          , cb          );
    subp(ix+1, iy  , cr*dx       , cg*dx       , cb*dx       );
  }
}

void drawaxes() {
  drawhorz(0);
  drawvert(0);
}

void drawgrid() {
  int a, b;
  for(a=ceil(miny/dly)-1;a<=floor(maxy/dly)+1;++a) drawhorz(a*dly);
  for(a=ceil(minx/dlx)-1;a<=floor(maxx/dlx)+1;++a) drawvert(a*dlx);
}

void drawfunc(int f) {
  double x, y, dydx, pfx, pfy;
  pfx=(maxx-minx)/(SX-1);
  pfy=(maxy-miny)/(SY-1);
  for(x=minx;x<maxx;x+=.1*pfx/sqrt(1+dydx*dydx/((pfy*pfy)/(pfx*pfx)))) {
    func(f, x, &y, &dydx);
    drawdot(x, y);
  }
}

void drawit() {
  int x, y, c;
  for(y=0;y<SY;++y) for(x=0;x<SY;++x) for(c=0;c<3;++c) gr[y][x][c]=1;


  
/*  //Chebyshev 0, 1, 2, 3, 4, 5//, 6, 7
  minx=miny=-5/4.; maxx=maxy=5/4.; dlx=dly=1;
  cr=.6; cg=.6; cb=.6;
  drawfunc(100);
  cr=.1; cg=.8; cb=.8;
  drawfunc(101);
  cr=.8; cg=.8; cb=.1;
  drawfunc(102);
  cr=.8; cg=.1; cb=.8;
  drawfunc(103);
  cr=.1; cg=.1; cb=.8;
  drawfunc(104);
  cr=.1; cg=.1; cb=.1;
  drawfunc(105);
  cr=.1; cg=.8; cb=.1;
  //drawfunc(106);
  cr=.8; cg=.1; cb=.1;
  //drawfunc(107);
  cr=cg=cb=.8;  drawaxes();
  cr=cg=cb=.1;  drawgrid();
  cr=cg=cb=.025; dlx=dly=.1;  drawgrid();
*/

  //Chebyshev polynomials of the weird kind 0, 1, 2, 3, 4, 5
  minx=miny=-5/4.; maxx=maxy=5/4.; dlx=dly=1;
  cr=.6; cg=.6; cb=.6;
  drawfunc(200);
  cr=.1; cg=.8; cb=.8;
  drawfunc(201);
  cr=.8; cg=.8; cb=.1;
  drawfunc(202);
  cr=.8; cg=.1; cb=.8;
  drawfunc(203);
  cr=.1; cg=.1; cb=.8;
  drawfunc(204);
  cr=.1; cg=.1; cb=.1;
  drawfunc(205);
  cr=cg=cb=.8;  drawaxes();
  cr=cg=cb=.1;  drawgrid();
  cr=cg=cb=.025; dlx=dly=.1;  drawgrid();

/* //sinh, cosh, tanh
  minx=miny=-5; maxx=maxy=5; dlx=dly=1;
  cr=.1; cg=cb=.8;
  drawfunc(1);
  cg=.1; cb=cr=.8;
  drawfunc(2);
  cb=.1; cr=cg=.8;
  drawfunc(3);
  cr=cg=cb=.8;  drawaxes();
  cr=cg=cb=.1;  drawgrid();
*/  
}
//
date/time username edit summary
21:09, 15 September 2004 en:User:Cyp (U_3 looked ugly, changing it to 8x³-4x so line looks prettier)
20:52, 15 September 2004 en:User:Cyp (Source)
20:52, 15 September 2004 en:User:Cyp (Graph of Chebyshev polynomials of the weird kind)

Journal des téléversements d’origine

Legend: (cur) = this is the current file, (del) = delete this old version, (rev) = revert to this old version.

Click on date to download the file or see the image uploaded on that date.

  • (del) (cur) 21:07, 15 September 2004 . . en:User:Cyp Cyp ( en:User_talk:Cyp Talk) . . 201x201 (27360 bytes) (U_3 looked ugly, changing it to 8x³-4x so line looks prettier)
  • (del) (rev) 20:52, 15 September 2004 . . en:User:Cyp Cyp ( en:User_talk:Cyp Talk) . . 201x201 (24737 bytes) (Graph of Chebyshev polynomials of the weird kind)

Légendes

Ajoutez en une ligne la description de ce que représente ce fichier

Éléments décrits dans ce fichier

dépeint

image/png

4d47bc0e7b2cd01a970fcb9ed16b3a327304c566

27 360 octet

201 pixel

201 pixel

Historique du fichier

Cliquer sur une date et heure pour voir le fichier tel qu'il était à ce moment-là.

Date et heureVignetteDimensionsUtilisateurCommentaire
actuel18 mars 2006 à 20:02Vignette pour la version du 18 mars 2006 à 20:02201 × 201 (27 kio)MaksimLa bildo estas kopiita de wikipedia:en. La originala priskribo estas: //{{GPL}}<pre> #include <stdio.h> #include <math.h> #include <stdlib.h> #include <time.h> #define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089

La page suivante utilise ce fichier :

Usage global du fichier

Les autres wikis suivants utilisent ce fichier :