PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Exact multi-precision arithmetic

I am currently working on some collision detection code, and numerical precision seems to be one of the major challenges. Given that pretty much all intersection and interpenetration tests can be reduced to sign of determinant comparisons, I was wondering if anyone in this forum has already implemented a suitable set of primitives, i.e. a set of functions that calculate the exact sign (no over/underflow etc.) of 2x2, 3x3 and 4x4 determinants of 15.16 fixed point input coordinates.

- HM
Hi,

Sorry I don’t have the answer you’re looking for,

but any information about combating over/underflows in this format would be useful to me, if available.
I've not run into any precision problems with collision detection. What precision fixed point are you using?

Dan East
What algorithm do you use to determine the sign of the determinant? Did you try LU factorization?

Tala
Dan East wrote:I've not run into any precision problems with collision detection. What precision fixed point are you using?

Dan East

Q15.16

I do not know what kind of collision detection you are using in Varium. I am just talking basic intersection primitives in 3D. But, say, to handle clipping (which is nothing but plane/line intersections) properly for Vincent (e.g. no underflow/overflow in the clipping tests), I had to add specific code to extend precision beyond the basic formats. But since debugging collision detection is really nasty, I'd like avoid the type of hack I used for Vincent, and rather would like to get the intersection primitives work properly from the get-go.

- HM
Tala wrote:What algorithm do you use to determine the sign of the determinant? Did you try LU factorization?

Tala

Unless you use division, which I'd like to avoid, the numbers you compute during the LU factorization will end up being mutliples of the determinent (you can look this up in Knuth Volume 2). So computing the determinants directly is actually the algorithm that requires the least number of signifcicant bits.

For my current 'toy game', I am reducing the accuracy of the models to Q7.8, but for the 'production version' of the engine I'd like to make sure I am not introducing such hacks.

- HM
I used the determinant method at first to see if a point was inside a poly. I don't remember any precision related problems at all with that technique - it seemed to work perfectly for line-poly collision detection.

I ended up using (precalculated) edge planes perpendicular to the poly normal. That works much better for volumetric collision.

Dan East