Re: [Algorithms] floats, doubles, epsilons, joy
Brought to you by:
vexxed72
From: Pierre T. <p.t...@wa...> - 2000-09-01 06:23:46
|
Errr.............. Doubles notoriously are slower than floats. Moreover if you use D3D you really shouldn't be messing around with doubles. From the DX7 docs: "Applications that require double-precision accuracy can include the DDSCL_FPUPRESERVE flag when calling the IDirectDraw7::SetCooperativeLevel method to set the DirectDraw cooperative level. When the DDSCL_FPUPRESERVE flag is used, the system still uses single-precision mode, but it saves the state of the FPU prior to changing the precision mode, then restores the mode when it returns control to the application. (Calling the method again using the DDSCL_FPUSETUP flag returns Direct3D to its default behavior.) Obviously, this check, save, then restore process takes time and can noticeably affect performance. This flag should only be used when the application must have double-precision accuracy and you do not want to include code to manually set and restore the FPU mode as the application requires." And all in all, using doubles is just a way to hide a problem, not a way to fix it. No magic bullet there, it really depends on the piece of code involved I'm afraid. Pierre ----- Original Message ----- From: Jason Zisk <zi...@n-...> To: <gda...@li...> Sent: Thursday, August 31, 2000 7:14 PM Subject: [Algorithms] floats, doubles, epsilons, joy > I've been working on some collision stuff lately and I keep running into > problems with floating point inaccuracies. Specifically if the player is > standing on top of a triangle, the distance should be zero, but with float > it was very close to zero but not quite. So I converted all my code to use > double and its much better but I'm still not getting exactly zero. With > float they were large enough to cause unwanted movement, with double they > are tiny but I can easily imagine the player finding a way to make these > values be higher than my epsilon amount (0.00001). Just so everyone knows, > I'm doing ellipsoid vs. triangle collision with an algorithm I found on > Flipcode (http://www.flipcode.com/tutorials/tut_coll-ellipsoids.shtml). > > This is the first time I've run into this, I'm wondering if there are some > common ways to get around these types of problems? > > Also I was wondering if there was a down side to using doubles rather than > floats. This code doesn't use any ram so size doesn't matter, but is doing > floating point math with doubles much slower or have other unwanted side > effects? > > Thanks for any suggestions, > > - Jason Zisk > - nFusion Interactive LLC > > > > > > > > _______________________________________________ > GDAlgorithms-list mailing list > GDA...@li... > http://lists.sourceforge.net/mailman/listinfo/gdalgorithms-list |