Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!cs.utexas.edu!sun-barr!newstop!exodus!peregrine!falk From: falk@peregrine.Sun.COM (Ed Falk) Newsgroups: comp.graphics Subject: Re: 2 3D Vectors: Get a 3rd perp. to 1st? (Also, renorm. matrices) Message-ID: <6251@exodus.Eng.Sun.COM> Date: 18 Jan 91 19:16:21 GMT References: <6613@crash.cts.com> <22365@well.sf.ca.us> <6660@crash.cts.com> <1991Jan15.233218.7646@watdragon.waterloo.edu> <7012@crash.cts.com> Sender: news@exodus.Eng.Sun.COM Organization: Sun Microsystems, Mt. View, Ca. Lines: 29 In article <7012@crash.cts.com> jcs@crash.cts.com (John Schultz) writes: >In <1991Jan15.233218.7646@watdragon.waterloo.edu> ccplumb@rose.uwaterloo.ca (Colin Plumb) writes: > > Yuck! First, I do two table lookups because I have sin and asin tabled >already for all possible cases. Can't do that for sqrt... Sure you can. Just have a table of all your sqrts from sqrt(1) to sqrt(4) at any resolution you want. Then: i = 0 ; while(x < 1.) x *= 4. , ++i ; while(x > 4.) x *= .25 , --i ; x = sqrt_table_lookup(x) ; while( i > 0 ) x *= .5 ; while( i < 0 ) x *= 2. ; (Optimization left as an excercise to the student. A smart compiler should be able to convert the multiplies into increments or decrements of the exponent.) -ed falk, sun microsystems sun!falk, falk@sun.com To be loyal to rags, to shout for rags, to worship rags, to die for rags -- that is a loyalty of unreason, it is pure animal (Mark Twain).