I am writing a physics simulator in C++ and am concerned about robustness. I've read that catastrophic cancellation can occur in floating point arithmetic when the difference of two numbers of almost equal magnitude is calculated. It occurred to me that this may happen in the simulator when the dot product of two almost orthogonal vectors is calculated. However, the references I have looked at only discuss solving the problem by rewriting the equation concerned (eg the quadratic formula can be rewritten to eliminate the problem) - but this doesn't seem to apply when calculating a dot product? I guess I'd be interested to know if this is typically an issue in physics engines and how it is addressed.

Edit
Report