From: M DOT Czamai AT gmx DOT net (Martin Czamai) Newsgroups: comp.os.msdos.djgpp Subject: problem with fixed datatype (drawing simple arcs / pie segments) Date: 29 Jan 2003 04:45:47 -0800 Organization: http://groups.google.com/ Lines: 64 Message-ID: <76fdbced.0301290445.14f13d86@posting.google.com> NNTP-Posting-Host: 213.157.26.66 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1043844347 23282 127.0.0.1 (29 Jan 2003 12:45:47 GMT) X-Complaints-To: groups-abuse AT google DOT com NNTP-Posting-Date: 29 Jan 2003 12:45:47 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi all, my problem is, that I want to draw a something like a pie (circle segment) to some bitmap, but the current code doesn't work. Can somebody please tell me how to handle the fixed class correctly? This is extraction of the current code: typedef struct tagPOINT { int x; int y; }POINT; : typedef struct tagPIE { POINT ptCenter; // center of drawing the arc (pie) int nRadius; // inner radius int nDiameter; // width of arc (pie) float rBeginAngle; // start angle of pie float rEndAngle; // end angle of pie }PIE; : #define FACTOR_ANGLE_TO_ALLEGRO_ANGLE 0.7111111111 // 256/360 = 0.71111... : : somewhere in the code: : PIE pie; // this struct is filled with valid data somewhere else and //rBeginAngle < rEndAngle ! : fix fixBegin, fixEnd, fixAngle; fixBegin = ::ftofix(pie.rBeginAngle * FACTOR_ANGLE_TO_ALLEGRO_ANGLE); fixEnd = ::ftofix(pie.rEndAngle * FACTOR_ANGLE_TO_ALLEGRO_ANGLE); int nCntr = 0; nCoord[14400]; // draw contours of pie / circle segment only for(int nRadius=pie.nRadius; nRadius <= (pie.nRadius + pie.nDiameter); nRadius += pie.nDiameter) { // the following never starts to run - why?? for(fixAngle=fixBegin; fixAngle != fixEnd; fixAngle += ftofix(0.1)) { fix fixSIN = sin(fixAngle); fix fixCOS = cos(fixAngle); fix fixX = fixCOS * fix(nRadius); fix fixY = fixSIN * fix(nRadius); nCoord[nCntr++] = (int)pie.ptCenter.x + (int)fixX; nCoord[nCntr++] = (int)pie.ptCenter.y + (int)fixY; } } // use allegro's polygon function to draw the segment... polygon(bmpTarget, nCntr/2, nCoord, clColor); Maybe I'm too stupid, but I'm really interested in what's going wrong here. Please help! Thanks in advance, Martin