Date: Wed, 5 Mar 1997 13:19:25 -0500 (EST) From: Guess Cc: djgpp AT delorie DOT com Subject: Rotation problem In-Reply-To: <331c1847.1675577@ursa.smsu.edu> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII content-length: 0 Hello again! I have a small (?) problem. I'm plotting 100 points in mode 13h and rotating them in increments of 1 degree. It works, only the rotating pixels get smaller and smaller until it becomes a little dot on the screen. What am I doing wrong? :) I'm figuring it's due to the rounding error...or am I wrong? It seemed to work fine when i was rotating a triangle with the line() function. *Shrug* Here is the code..thank you in advance for any help! -- #include #include #include #include #include #define RAD_TO_DEG(x) ((x)*(180/3.14159265359)) #define DEG_TO_RAD(x) ((x)*(3.14159265359/180)) struct { float x, y; } pix[100]; float sin_t[360], cos_t[360]; void init(); void create_tables(); void create_tables() { int i; for(i = 0; i < 360; i++) { sin_t[i] = sin(DEG_TO_RAD(i)); cos_t[i] = cos(DEG_TO_RAD(i)); } } void init() { int i; for(i = 0; i < 100; i++) { pix[i].x = (rand() % 320) - 160; pix[i].y = (rand() % 200) - 100; } } void rotate() { int i; for(i = 0; i < 100; i++) { pix[i].x = pix[i].x * cos_t[1] - pix[i].y * sin_t[1]; pix[i].y = pix[i].y * cos_t[1] + pix[i].x * sin_t[1]; } } void draw() { int i; for(i = 0; i < 100; i++) putpixel(screen, 160+pix[i].x, 100+pix[i].y, 13); } int main() { int i; allegro_init(); set_gfx_mode(GFX_VGA, 320, 200, 0, 0); clear(screen); init(); create_tables(); while(!kbhit()) { clear(screen); draw(); rotate(); } allegro_exit(); return 0; } ---- The fountains mingle with the river, And the rivers with the ocean; The winds of heaven mix for ever With a sweet emotion; Nothing in the world is single; All things, by a law divine, In one another's being mingle-- Why not I with thine? -- P B Shelley, _Love's Philosophy_ http://www.clark.net/pub/times9 http://nothing.home.ml.org http://nowhere.base.org ftp://ftp.clark.net/pub/times9 SigGenre (signature and plan generator)