Re: [Algorithms] floats, doubles, epsilons, joy
Brought to you by:
vexxed72
From: Jason Z. <zi...@n-...> - 2000-08-31 21:28:21
|
A bit of buffer, good idea. So the general algorithm would be: after I find the distance to collision make sure its always at least X (maybe 0.01 like Steve suggested) units. If its larger than X units, move X-0.01 units instead of the full X. This sounds like it will make the system much more robust, thanks again. - Jason Zisk - nFusion Interactive LLC ----- Original Message ----- From: "Gil Gribb" <gg...@ma...> To: <gda...@li...> Sent: Thursday, August 31, 2000 3:36 PM Subject: Re: [Algorithms] floats, doubles, epsilons, joy > I wouldn't use doubles, they just obscure the problem but don't eliminate > it. If an algorithm is unstable with floats, it is usually unstable with > doubles too. > > So, how to solve the problem? The only solution is carefully analize the > situation and do things robustly. That isn't very helpful, but it is true, > you gotta really think about the situation to solve the problem. > > I solve your collision problem like this typically. I don't attempt to rest > directly on the floor, I attempt to hover .1 inches or so off the floor. > Therefore, even with floating point inaccuracy, I never find I am IN the > floor at the start of the next round. This does use a tolerence, but it is > subtly different than your approach. Your approach attempts to correct the > problem after is occurs and my approach is proactive, insuring the problem > does not occur. (This all assumes finding yourself in the floor is the > problem). > > Even if you get this problem licked, if you are doing anything interesting, > like say having things push the player, you will run into half a dozen other > more subtle problems. You gotta think through each one to figure out how to > solve the problem with inexact arithmatic. It is really really hard work. > > -Gil > > > > 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 > > _______________________________________________ > GDAlgorithms-list mailing list > GDA...@li... > http://lists.sourceforge.net/mailman/listinfo/gdalgorithms-list |