Koordinatenachse & Graf

Ex-2MNd Forum
Verfügbare Informationen zu "Koordinatenachse & Graf"

  • Qualität des Beitrags: 0 Sterne
  • Beteiligte Poster: heavyraptor - jamflex - Schaa - vogel
  • Forum: Ex-2MNd Forum
  • Forenbeschreibung: Das ex-offizielle Forum der Klasse 2MNd des Gymnasiums Neufeld - offiziell: www.2mnd.ch.vu
  • aus dem Unterforum: Gymnasium
  • Antworten: 5
  • Forum gestartet am: Donnerstag 15.02.2007
  • Sprache: deutsch
  • Link zum Originaltopic: Koordinatenachse & Graf
  • Letzte Antwort: vor 15 Jahren, 9 Monaten, 29 Tagen, 9 Stunden, 13 Minuten
  • Alle Beiträge und Antworten zu "Koordinatenachse & Graf"

    Re: Koordinatenachse & Graf

    heavyraptor - 23.05.2007, 16:25

    Koordinatenachse & Graf
    Hiä isch mi Code wo no nid fertig isch ....

    Code: // Program: GRAPH.CPP
    // Date: 14-MAY-2007
    // Author:
    // Einführung in die Koordinatengraphik

    #include <champ.h>

    void koordinatenAchsen ( double xMin, double xMax, double yMin, double yMax );
    void graph( double xMin, double xMax, double yMin, double yMax );
    double f( double x );

    void gmain ()
    {
       ginit( "Funktionsgraph" , CP::WinBigSq );
       double x0, y0, xMin, xMax, yMin, yMax;


       // Eingabefenster erstellen für xMin, xMax, yMin, yMax
       CPInputDouble inXMin( "Eingabe", "Gib den minimalen x-Wert ein", xMin, -2 );
       CPInputDouble inXMax( "Eingabe", "Gib den maximalen x-Wert ein", xMax,  2 );
       CPInputDouble inYMin( "Eingabe", "Gib den minimalen y-Wert ein", yMin, -2 );
       CPInputDouble inYMax( "Eingabe", "Gib den maximalen y-Wert ein", yMax,  2 );

       // Eingabefenster anzeigen und Rückgabewerte testen.
       if ( inXMin.showModal() == IDOK && inXMax.showModal() == IDOK &&
            inYMin.showModal() == IDOK && inYMax.showModal() == IDOK &&
            xMin < xMax && yMin < yMax )
       {
          koordinatenAchsen( xMin, xMax, yMin, yMax );
          graph(xMin, xMax, yMin, yMax );
          CP::msgBox( "Programmende" );
       }
       else
          CP::msgBox( "Abbruch" );
       gend();
    }

    void koordinatenAchsen( double xMin, double xMax, double yMin, double yMax )
    {
       double w = xMax - xMin;
       double h = yMax - yMin;

       double wMin = xMin - w / 20, wMax = xMax + w / 20;
       double hMin = yMin - h / 20, hMax = yMax + h / 20;

       gwindow(wMin,wMax,hMin,hMax);
       gline(xMin - w / 30,0,xMax + w / 30,0);
       gline(0,yMin - h / 30,0,yMax + h / 30);

       double xs = w / 10,  ys = h / 10;
       double xl = h / 100, yl = w / 100;
       double x = xs, y = ys;

       while (x < xMax) {
         gline(x,-xl,x,xl);
         gtext(x - xs / 10,2 * xl) << x;
         x += xs;
       }

       x = -xs;
       while (x > xMin) {
         gline(x,-xl,x,xl);
         gtext(x - xs / 10,2 * xl) << x;
         x -= xs;
       }
       gtext(wMax - xs / 2,ys / 5,"x");

       while (y < yMax) {
         gline(-yl,y,yl,y);
         gtext(2 * yl,y - ys / 16) << y;
         y += ys;
       }

       y = -ys;
       while (y > yMin) {
         gline(-yl,y,yl,y);
         gtext(2 * yl,y - ys / 16) << y;
         y -= ys;
       }
       gtext(-xs / 5,yMax - ys / 2,"y");

       //*/
    }

    void graph( double xMin, double xMax, double yMin, double yMax )
    {
       for (double x = xMin; x < xMax; x += (xMax - xMin) / 10000)
         gdot(x,f(x),BLUE);
    }

    double f( double x )
    {
       return x*x-2*x-1;
    }



    Re: Koordinatenachse & Graf

    jamflex - 25.05.2007, 17:57


    gz



    Re: Koordinatenachse & Graf

    Schaa - 25.05.2007, 17:58


    gzgz



    Re: Koordinatenachse & Graf

    jamflex - 25.05.2007, 17:59


    lol



    Re: Koordinatenachse & Graf

    vogel - 30.05.2007, 15:24


    das isch gloub ziemlech fertig....

    Code: // Program: GRAPH.CPP
    // Date: 14-MAY-2007
    // Author:
    // Einführung in die Koordinatengraphik

    #include <champ.h>

    void koordinatenAchsen ( double xMin, double xMax, double yMin, double yMax );
    void graph( double xMin, double xMax, double yMin, double yMax );
    double f( double x );

    void gmain ()
    {
       ginit( "Funktionsgraph" , CP::WinBigSq );
       double x0, y0, xMin, xMax, yMin, yMax;


       // Eingabefenster erstellen für xMin, xMax, yMin, yMax
       CPInputDouble inXMin( "Eingabe", "Gib den minimalen x-Wert ein", xMin, -2 );
       CPInputDouble inXMax( "Eingabe", "Gib den maximalen x-Wert ein", xMax,  2 );
       CPInputDouble inYMin( "Eingabe", "Gib den minimalen y-Wert ein", yMin, -2 );
       CPInputDouble inYMax( "Eingabe", "Gib den maximalen y-Wert ein", yMax,  2 );

       // Eingabefenster anzeigen und Rückgabewerte testen.
       if ( inXMin.showModal() == IDOK && inXMax.showModal() == IDOK &&
            inYMin.showModal() == IDOK && inYMax.showModal() == IDOK &&
            xMin < xMax && yMin < yMax )
       {
          koordinatenAchsen( xMin, xMax, yMin, yMax );
          graph(xMin, xMax, yMin, yMax );
          CP::msgBox( "Programmende" );
       }
       else
          CP::msgBox( "Abbruch" );
       gend();
    }

    void koordinatenAchsen( double xMin, double xMax, double yMin, double yMax )
    {

       double xd = xMax-xMin;
       double yd = yMax-yMin;

       double xk;
       double yk;

       if( xMin > 0 )
          xk = xMin;
       else
          xk = 0;

       if( yMin > 0 )
          yk = yMin;
       else
          yk = 0;

       if( xMax < 0 )
          xk = xMax;

       if( yMax < 0 )
          yk = yMax;

       gwindow( xMin-(xd*0.05), xMax+(xd*0.05), yMin-(yd*0.05), yMax+(yd*0.05) );

       gpos( xMin, yk );
       gdraw( xMax, yk );

       gpos( xk, yMin );
       gdraw( xk, yMax );

       // X-Achsen-Einteilung

       double einteilungx = xd/10;

       double count = xk;
       count += einteilungx;
       while( count <= xMax )
       {
          gpos( count, -yd*0.005+yk );
          gdraw( count, yd*0.005+yk );
          gtext( count-0.015*xd, yd*0.005+yk )
          << setiosflags( ios::fixed ) << setprecision( 2 ) << count;
          count += einteilungx;
       }
       count = xk;
       count -= einteilungx;
       while( count >= xMin )
       {
          gpos( count, -yd*0.005+yk );
          gdraw( count, yd*0.005+yk );
          gtext( count-0.015*xd, yd*0.005+yk )
          << setiosflags( ios::fixed ) << setprecision( 2 ) << count;
          count -= einteilungx;
       }

       // Y-Achsen-Einteilung

       double einteilungy = yd/10;

       count = yk;
       count += einteilungy;
       while( count <= yMax )
       {
          gpos( -xd*0.005+xk, count );
          gdraw( xd*0.005+xk, count );
          gtext( xd*0.007+xk, count-0.008*yd )
          << setiosflags( ios::fixed ) << setprecision( 2 ) << count;
          count += einteilungy;
       }
       count = yk;
       count -= einteilungy;
       while( count >= yMin )
       {
          gpos( -xd*0.005+xk, count );
          gdraw( xd*0.005+xk, count );
          gtext( xd*0.007+xk, count-0.006*yd )
          << setiosflags( ios::fixed ) << setprecision( 2 ) << count;
          count -= einteilungy;
       }


    }

    void graph( double xMin, double xMax, double yMin, double yMax )
    {

       int set = 0;

       for( double count=xMin; count<=xMax; count+=0.00001 )
       {
          if( f(count) >= yMin && f(count) <= yMax )
          {
             if( set == 1 )
             {
                gdraw( count, f(count) );
             }
             else
             {
                gpos( count, f(count) );
                set = 1;
             }
          }
       }

    }

    double f( double x )
    {

       return x*x-2*x-1;
    }



    Mit folgendem Code, können Sie den Beitrag ganz bequem auf ihrer Homepage verlinken



    Weitere Beiträge aus dem Forum Ex-2MNd Forum

    öksnef - gepostet von jamflex am Mittwoch 01.08.2007
    DIR SIT HEUDÄ - gepostet von sven am Mittwoch 14.03.2007
    Wär wot Moderator si? - gepostet von heavyraptor am Donnerstag 06.09.2007



    Ähnliche Beiträge wie "Koordinatenachse & Graf"

    PotW -Mai- Graf Fuchien - Malchy (Freitag 25.05.2007)
    Graf vom Berg - belvedere (Sonntag 28.01.2007)
    Pay-Per-View: Breakdown [22.06.2008] - The Rock Bottom (Sonntag 22.06.2008)
    BEwerbung von GRaf OHlzbert - Anonymous (Montag 18.12.2006)
    Acc von Graf - NeoIceman (Donnerstag 26.07.2007)
    Graf Caramon Majere - Caramon Majere (Donnerstag 30.08.2007)
    Graf Bobby..... - Thomas (Freitag 03.11.2006)
    Graf dietmars dorf - Lorwy (Mittwoch 11.04.2007)
    Reli GK Graf - Crash (Samstag 04.11.2006)
    feuer in meiner seele - Spielkind (Sonntag 22.06.2008)