Home > development > Email from friends (invsqrt)

Email from friends (invsqrt)

Don’t you just love getting email from your friends.  I am sure that as you read this you may think about past jokes and humerous anecdotes received.

I don’t get many like that, this is what I got from a friend of mine today,

How bout this for a fast invsqrt…

float InvSqrt(float x)
{
      float xhalf = 0.5f * x;
      int i = *(int *)&x;
      i = 0x5f3759df – (i >> 1);
      x = *(float *)&i;
      x = x * (1.5f – xhalf * x * x);
      return x;
}

Explanation given here (not for the faint of heartr)

http://www.math.purdue.edu/~clomont/Math/Papers/2003/InvSqrt.pdf

You have to see the explanation and Steve’s right its not for the faint of heart.

So any XNA peeps who stumble along here might you be interested.

Categories: development Tags:
  1. JDT
    September 28th, 2007 at 22:24 | #1

    For a better explanation about this, check out http://www.mceniry.net/papers/Fast%20Inverse%20Square%20Root.pdf

  1. No trackbacks yet.