Hi, I'm still new at programming but can anyone help sort out an angle problem I'm having. I'm trying to vary the launch angle of a skeet (ellipse) but the class is calculating the angle from coordinates (0,0) rather than from (520,350).
I'm using codeblocks to program in.
Can please someone help point me in the right direction?Code:#include <windows.h> #include <math.h> #define PI 3.14159265 LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); int c; int d; int e; class position { int y; int a; public: void set_values(int,int); double x() {return (y*tan(a*PI/180));} }; void position :: set_values(int b, int c){ y=b; a= c; } // Windows build parameters RESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { position pos1; position pos2; position pos3; HDC hdc; PAINTSTRUCT Ps; switch (message) /* handle the messages */ { case WM_PAINT: hdc = BeginPaint(hwnd, &Ps); MoveToEx(hdc, 500, 350, NULL); for (c=350; c>0; c--){ pos1.set_values(c,45); d = (int)pos1.x(); LineTo(hdc,c,d); } for (c=350; c>0; c--){ pos2.set_values(c,50); d = (int)pos2.x(); LineTo(hdc,c,d); } for (c=350; c>100; c--){ pos3.set_values(c,10); d = (int)pos3.x(); LineTo(hdc,c,d); EndPaint(hwnd, &Ps); } break;



LinkBack URL
About LinkBacks


