Path: utzoo!attcan!uunet!husc6!psuvax1!psuvm!cunyvm!ndsuvm1.bitnet!nu113738 From: NU113738@NDSUVM1.BITNET Newsgroups: comp.graphics Subject: Re: Line Math Message-ID: <2601NU113738@NDSUVM1> Date: 28 Jul 89 05:37:48 GMT References: <2578NU113738@NDSUVM1> Organization: North Dakota Higher Education Computer Network, Fargo, ND Lines: 33 Disclaimer: Author bears full responsibility for contents of this article. Ok, I was pointed out a problem in my last response, as sloppy as it was. I indicated no division was required but then went on to suggest the formula r = x / cos0. Obviously a division. But this is also equal to r = x * 1/cos0 and of course 1/cos0 = csc0. So by using csc and sec instead of sin/cos, division can be removed. Along this thought line, another item occurs in trying to speed up equation, mainly, to calculate csc0 or sec0, floating point math is required. What I did, in a situation where a sin/cos table of the values for each degree were required, is to create it as such, say the value of 23 degress is .3907311..... After calculation of this value for storage in the lookup table, I then used the idea that .390xxx = 390 x 10^-3. But instead of base 10, I used base 2. So I would take .3907311 x 4096 or 2048 or some power of 2 and store that value as an integer. Now, when I retrieve the value from the storage table, say I need (3*sin23) then the math is performed as: (3 *(lookup(23)) >> 11. The arthmethic shift by 11 is performed instead of a division by 2048... A much faster method and it required no floating point mathematics. Although, to store the intial value of .3907311, if you want a fairly accurate estimation, you need to use long integers since a word (assuming a IBMPC size word) is insufficient to store the value with out an overflow condition. In timing the differences in this elongated and somewhat sloppy method of division/multiplication/storage, it still kicks a floating point arithmetic time. (although, I don't know what would be the result with a coprocessor, so don't take my word in that case.) These are just some suggestions. I hope they help or give someone some ideas. Jeff Bakke NU113738@NDSUVM1.BITNET