Distance in a shootem up 2D

Posts: 370
Joined: 2002.04
Post: #16
Quote:Originally posted by OneSadCookie
so you might as well multiply by the inverse of the square root[/b]

This would likely be a perfect place for fresqrt, as that's exactly what it gives you Wink

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Post: #17
Thanks! That's been something I've had commented out for a very long time now, and it's great to finally have it working. Every sqrt() function that I was forced to leave in my main loop code made it feel that much more dirtied Rasp

just to recap what I had to do to get this working:

#include <ppc_intrinsics.h>

float qsqrt(register float arg)
register float res;

if (arg == 0.0f)
return 0.0f;

res = __frsqrtes (arg);
res += 0.5f * res * (1.0f - arg * res * res);
res += 0.5f * res * (1.0f - arg * res * res);
return res * arg;

and in my active target settings, under gcc options, I had to add:
to other c compiler flags.

Thanks for the help OSC! I'll add a qrsqrt function to eliminate the extraneous mult. divide I was doing for normalisation as well.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Fast Distance formula? mikey 11 13,591 Nov 23, 2009 10:43 AM
Last Post: mikey
  calculating X and Y coordinates w/ an angle and distance ferum 13 21,563 Jun 25, 2008 10:53 PM
Last Post: rosenth
  Signed distance fields imikedaman 16 14,886 Jul 20, 2007 07:13 PM
Last Post: imikedaman
  Speed distance velocity and other headaches Thinker 6 5,938 Jul 3, 2003 09:55 AM
Last Post: Thinker