Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-22-2007, 03:35 PM   #1
st33d
Registered User
 
Join Date: Oct 2006
Posts: 38
Default Inverse Square Root

I'm developing a physics engine based somewhat on Flade and the Tony Pa Vector tutorials (they Google well so I don't think I need to link them).

I've ported the engine to Java and found an inverse square root method that was originally written for Quake 3 and optimised by Chris Lomont. This allows you to calculate vector normals much faster.

Here's my Java version:
Code:
// Original C code by Chris Lomont <http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf>
  static float invSqrt(float x){
    float xhalf = 0.5f*x;
    int i = Float.floatToIntBits(x); // get bits for floating value
    i = 0x5f375a86- (i>>1); // gives initial guess y0
    x = Float.intBitsToFloat(i); // convert bits back to float
    x = x*(1.5f-xhalf*x*x); // Newton step, repeating increases accuracy
    return x;
  }
My trouble here is before I can test it for speed in Flash I need a method for getting the floating point value of x in and out of integer bit format. Can anyone help?
st33d is offline   Reply With Quote
Old 11-18-2007, 05:07 PM   #2
daniele guido
Registered User
 
Join Date: Nov 2007
Posts: 1
Default

hi!
I know it's a bit late, but..
I think who's searching for inverted sqrt would find it interesting:
http://blog.je2050.de/2007/10/01/con...nd-vice-versa/
daniele guido is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Restricting root calls to the one movie Oli-G ActionScript 2.0 2 06-02-2007 08:44 AM
Load a sound from root to inside a mc Damiano ActionScript 2.0 4 08-16-2006 07:59 PM
lineTo fade out effect ? mikewirth Other Flash General Questions 4 06-04-2006 03:16 PM
Database simulated with arrays on a cd-rom lecasn5 Components 61 09-07-2004 11:40 AM
square root Disjuku Simple Stuff (Newbies) 12 01-04-2004 06:39 PM


All times are GMT. The time now is 09:26 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.