#include <graphics.h> // diverse Includes #include <conio.h> #include<math.h> #include<stdio.h> #include<stdlib.h> void main(void) // Start Hauptprogramm { int treiber, modus, x,y,z; // Variablen initialisieren double sinuspos,a,f,frequenz,frequenzteil,u,udach,udachteil,sinus,faktor,bildpunkte,masy; char eingabe,text[10],text2[10]; detectgraph(&treiber , &modus) ; /*!!!! Modus abfragen */ initgraph (&treiber , &modus, "e:\\nt4\\tc\\bgi\\") ; /*!!!! Grafik initialisieren */ /*!!!! VGA-Treiber=9,VGAHI=2*/ printf("\t\tMit diesem Programm koennen Sie Sinusfunktionen\n"); printf("\t\tgrafisch darstellen"); getch(); for (a=0;a<=3;a++) printf("\n"); printf("\n\t\tBitte geben Sie folgende Eckdaten ein : \n\t\t"); printf("\n\n\t\tFrequenz der Spannung ?\n\t\t"); scanf("%lf",&frequenz); for (a=0;a<=2;a++) printf("\n"); printf("\n\t\tU Dach der Spannung ?\n\t\t"); scanf("%lf",&udach); for (a=0;a<=2;a++) printf("\n"); printf("\n\t\tWieviele Sinus sollen dargestellt werden ? (1-3 empfohlen)\n\t\t"); scanf("%lf",&sinus); for (a=0;a<=2;a++) printf("\n"); printf("\n\t\t(E)ine oder (d)rei Phasen darstellen ?"); eingabe=getch(); switch (eingabe) { case 'd': case 'D': for (a=0;a<=30;a++) printf("\n"); faktor=1/frequenz; bildpunkte=639/sinus; masy=150/udach; udachteil=udach/5; line (0,0,0,479);//y-Achse line (0,240,639,240);//x-Achse setlinestyle(0,0,3); // for (y=0;y<=639;y=y+bildpunkte/3)//Grad-Skalierung der x-Achse // { // line (y,235,y,245); // } setlinestyle(0,0,1); f=frequenz; frequenzteil=f/10*sinus; for (y=63.9;y<=640;y=y+64) { setcolor(YELLOW); line (y,230,y,250); moveto(y-40,250); itoa(frequenzteil,text2,10); setcolor(LIGHTGRAY); outtext(text2); frequenzteil=frequenzteil+f/10*sinus; } u=udach; for (y=90;y<=390;y=y+30)//Volt-Skalierung der y-Achse { setcolor(YELLOW); line (0,y,10,y); moveto(10,y); itoa(u,text,10); setcolor(LIGHTGRAY); outtext(text); u=u-udachteil; } setcolor(LIGHTGREEN); moveto(10,10); outtext("U/V"); moveto(590,270); outtext("f/Hz"); setlinestyle(0,0,1); moveto(0,240); setcolor(RED); for(x=0;x<=1278;x++) { sinuspos=(udach*sin(2*M_PI*frequenz*x*faktor/bildpunkte)); lineto (x,-(sinuspos*masy)+240); } moveto(-639/3*1,240); setcolor(GREEN); for(x=0;x<=1278;x++) { sinuspos=(udach*sin(2*M_PI*frequenz*x*faktor/bildpunkte)); lineto (x-bildpunkte/3,-(sinuspos*masy)+240); } moveto(-639/3*2,240); setcolor(BLUE); for(x=0;x<=1278;x++) { sinuspos=(udach*sin(2*M_PI*frequenz*x*faktor/bildpunkte)); ; lineto (x-bildpunkte/3*2,-(sinuspos*masy)+240); } getch(); break; case 'e': case 'E': for (a=0;a<=30;a++) printf("\n"); faktor=1/frequenz; bildpunkte=639/sinus; masy=150/udach; udachteil=udach/5; line (0,0,0,479);//y-Achse line (0,240,639,240);//x-Achse setlinestyle(0,0,3); // for (y=0;y<=639;y=y+bildpunkte/3)//Grad-Skalierung der x-Achse // { // line (y,235,y,245); // } setlinestyle(0,0,1); // f=frequenz; // frequenzteil=f/10*sinus; // for (y=63.9;y<=640;y=y+64) // { // setcolor(YELLOW); // line (y,230,y,250); // moveto(y-40,250); // itoa(frequenzteil,text2,10); // setcolor(LIGHTGRAY); // outtext(text2); // frequenzteil=frequenzteil+f/10*sinus; // } u=udach; for (y=90;y<=390;y=y+30)//Volt-Skalierung der y-Achse { setcolor(YELLOW); line (0,y,10,y); moveto(10,y); itoa(u,text,10); setcolor(LIGHTGRAY); outtext(text); u=u-udachteil; } setcolor(LIGHTGREEN); moveto(10,10); outtext("U/V"); setlinestyle(0,0,1); moveto(0,240); setcolor(RED); for(x=0;x<=1278;x++) { sinuspos=(udach*sin(2*M_PI*frequenz*x*faktor/bildpunkte)); lineto (x,-(sinuspos*masy)+240); } getch(); break; closegraph(); } }