Original Post
While studying many game books i have found that
sqrt is expensive in terms of CPU but no one has
explained it. Can u?
Thanks
quote:Weirdly enough, I used one in primary school. We also used tables of logarithms and other functions (to four significant figures, so they were called "four-figure tables") in primary and secondary school.
Original post by Anonymous Poster
He was so old they didn''t have slide rules? Hmmm? Very fast and easily accurate to 3 sig figs if you had a medium-big one. I guess you could get even more accuracy on a bigger one. Ah, the lost art of using a slide rule. They made you understand logarithms too.
quote:Which makes no difference if you call it several times per frame, now does it?
Originally posted by the Other Anonymous Poster
Be careful: square root is "expensive" in that it takes many more cycles than a typical 1-cycle instruction. But we''re still talking "insanely fast" on just about any computer made in the last ten years.
quote:
Original post by phongor
double SqRt ( double dNum, int iPrecision )
{
double dAns = 2.0;
double dHold = 0.0;
for( int i = 0; i < iPrecision; i++ )
{
dHold = dNum / dAns;
dAns = (dHold + dAns) / 2;
}
return dAns;
}
quote:
Original post by Anonymous Posterquote:
Original post by botman
I''m surprised that no one mentioned Carmack''s fast inverse square root...
<a href="http://www.math.purdue.edu/~clomont/Math/Papers/2003/InvSqrt.pdf">http://www.math.purdue.edu/~clomont/Math/Papers/2003/InvSqrt.pdf</a>
botman
Actually it has been mentioned, but it''s not really called "Carmack''s fast inverse square root" (although many people tend to call it that).
quote:
Original post by Cipher3D
speaking of square roots, how do they figure out the exact figures for trigonometric functions? Plug in random values for opposite and adjacent? Draw a gazillion triangles with all possible angles and measure? Or do they just interpolate linearly for angle values that are not integers?
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more