/**************/ /* teht2_2.c */ /* Projektiin tulee: simplew.def simplew.c teht2_2.c */ #include #include #include "koord.h" #define MoveTo(h,x,y) MoveToEx(h,x,y,NULL) char *WindowName = "Sinikuva"; #define XSIIRTO 250 #define YSIIRTO 150 #define XKERROIN 30 #define YKERROIN -30 /* a11 a12 x sx * = a21 a22 y sy */ int sx(double x) { return (int)(XSIIRTO + XKERROIN*x); } int sy(double y) { return (int)(YSIIRTO + YKERROIN*y); } typedef double (* tfunk)(double x); /****************************************************************************/ void kuva(HDC hDC,tfunk f,double x1, double x2, double dx) { double x; MoveTo(hDC,sx(x1),sy(f(x1))); for(x=x1;x<=x2;x+=dx) { LineTo(hDC,sx(x),sy(f(x))); } } void MyDraw(HWND hWnd,HDC hDC) { #pragma argsused Koordinaatisto(hWnd, hDC, 0, 0, 1, 1, -2*M_PI, 2*M_PI, -2, 2); kuva(hDC,sin,0,2*M_PI,0.1); }