From: Frederick Haab Newsgroups: comp.os.msdos.djgpp,comp.graphics.algorithms Subject: Re: Test Gone Bad.. Ideas? Date: Sun, 12 Oct 1997 21:28:43 -0400 Organization: Turner Broadcasting Lines: 70 Message-ID: <3441794B.41C6@turner.com> References: <343E42A9 DOT FDD57A58 AT sampo DOT creighton DOT edu> NNTP-Posting-Host: efx7.turner.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Thomas Charron wrote: > ... supposed to merely slowly rotate a box, > just so I could see it.. Only one problem, it's definitely NOT doing > THAT.. It seems to be moving at an angle, changing it's size, getting > thinner on the x, and longer on the Y.. Here's a copy of the source, > and I've attached the exe so you can see.. First of all, I'll also start by scolding you about posting a binary on a non-binary newsgroup. But I won't go balistic about it either. Second, what graphic mode are you running in? The VGA is capable of many non-square pixel aspect ratio modes, and that can definately account for a lot of weird problems like "thinner on the x, and longer on the Y...". Third, you also realize that this square you have defined is definately not rotating about *its* center, it's rotating about the screen 0,0 location, which is probably in the upper or lower left corner of your screen. Now, put your finger in the middle of your screen, and rotate it around the corner of your screen, keeping the same distance from that corner, like a compass with the pointy part at the corner of the screen. Looks mostly like it's moving across or down, because your only seeing a part of that rotation. Fourth, you cannot cheap out by using only two x values and two y values...you need 4 distinct pairs of points. If you only rotate the box around it's center, you can cheap out with 2 pairs, but that's more work and so much less flexible and so unexpandable that it's not worth even trying to do it that way. The very next thing you should do is find the graphics faq, which must be lying around somewhere...I don't know where, however. But it has the answers to many questions for beginner to intermediate graphics programming...maybe more these days. Then the next thing you should get accustomed to doing is using the old transformation matrix. There are speedier ways to do things, but it's the most general and most common way to represent a *series* of transformations. If you wanted that box to rotate around it's center, for example, you would translate the box to the "world" center, (0,0), then rotate it, then translate it back. Matrices are a wonderful thing, and by compounding a series of transformation allow you to do wonderful things. For example, if you wanted to both rotate around zero and around it's center, you could compound the rotation - tranlation - rotation - translation into one matrix. I can't express enough how important it is to find a book that gives this basic overview. Another thing is to distinguish between "world" and "screen" space. That'll be described in any book. One last thing...I know you say you only dabble in programming "just hacks to do something real quick", but your programming style is very freshmen, and leads to all sorts of programming dilemas down the road. You should at least, for example, have a "rotate" function so that that code isn't repeated. Then having 4 pairs of points wouldn't be so bad, would it? Again, it's not like you're trying to change careers, but one good book would probably give you all the functions (at least in psuedo-code) that you would need. Good luck, have fun exploring the wonderful world of computer graphics. Fred -- - Frederick Haab - Software Developer - Turner Production -