[Rivet] Vector3 floating point precision issue with angles function

Ho, Yik Tung yik.tung.ho.11 at ucl.ac.uk
Sun Dec 14 14:47:11 GMT 2014


Hi,

We have been trying to use Rivet in our work and we have a question regarding the Vector3.hh header. I’m new to this and not a developer of Rivet itself nor have an account on Hepforge and I can’t seem to figure out how to open a ticket, so I’ll ask the question below:

For the function angle() defined at line 82 in Vector3.hh, line 84 and line 85 both use the function fuzzyEquals to deal with the limits of the dot product calculation.
However, the default tolerance for fuzzyEquals is 1e-5, which is reasonable when working with float numbers to protect against precision errors, but in this case it is insufficient as we are trying to work with angles quite close to these limits, such as 3.13782 (radians) (PI is 3.141…). The default fuzzyEquals tolerance is insufficient as the calculated dot product is -0.999993 which causes it to return Pi, the wrong angle in this case.

Since I believe there is enough precision in the member variables of Vector3 (they are of type double, no?) to work to a few more significant digits (say, setting the tolerance to 1e-8 solves our problem and returns the angles we require) is there any particular reason that the fuzzyEquals tolerance is left to default at 1e-5? We are bringing up the issue to see if this has been considered in the construction of the code as we believe this may cause problems with other applications of Rivet working with these small angles as well, since this “workaround” requires a modification of the Rivet header directly. If there is any misunderstanding of the issue of our part, please let us know.

Thank you for your time, and we kindly await for your reply.

Best Regards,

Yik Tung Ho
4th Year MSci Physics 
University College London


More information about the Rivet mailing list