Re: [math] "equals" in "Vector3D"

2009-04-29 Thread Luc Maisonobe
Wolfgang Glas a écrit : > Gilles Sadowski schrieb: >> Hi. >> >>> There is a very good article on ieee754 equality under >>> >>> http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm >>> >>> which contains an excessive discussion about various "equality" approaches. >>> >>> I

Re: [math] "equals" in "Vector3D"

2009-04-29 Thread Wolfgang Glas
Gilles Sadowski schrieb: > Hi. > >> There is a very good article on ieee754 equality under >> >> http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm >> >> which contains an excessive discussion about various "equality" approaches. >> >> IMHO it should be moreover considere

Re: [math] "equals" in "Vector3D"

2009-04-29 Thread Gilles Sadowski
Hi. > There is a very good article on ieee754 equality under > > http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm > > which contains an excessive discussion about various "equality" approaches. > > IMHO it should be moreover considered to include the > "AlomostEqual

Re: [math] "equals" in "Vector3D"

2009-04-29 Thread Wolfgang Glas
Gilles Sadowski schrieb: >>> L1 norm: equals(a, b, tolerance) = sum(abs(a-b)) < tolerance >>> L2 norm: equals(a, b, tolerance) = sqrt(sum((a-b)^2)) < tolerance >>> L-infinity norm: equals(a, b, tolerance) = max(abs(a-b)) < tolerance >>> >>> All are useful. >> I'll guess for 3D vector the L2-norm is

Re: [math] "equals" in "Vector3D"

2009-04-28 Thread Ted Dunning
Absolutely. On Tue, Apr 28, 2009 at 2:10 PM, Gilles Sadowski < gil...@harfang.homelinux.org> wrote: > > I'll guess for 3D vector the L2-norm is the more useful as it is > > invariant when physical orthonormal frames are changed. > > I'll check in the variant you prefer. > > [Cf. my other reply.]

Re: [math] "equals" in "Vector3D"

2009-04-28 Thread Gilles Sadowski
> > L1 norm: equals(a, b, tolerance) = sum(abs(a-b)) < tolerance > > L2 norm: equals(a, b, tolerance) = sqrt(sum((a-b)^2)) < tolerance > > L-infinity norm: equals(a, b, tolerance) = max(abs(a-b)) < tolerance > > > > All are useful. > > I'll guess for 3D vector the L2-norm is the more useful as it

Re: [math] "equals" in "Vector3D"

2009-04-28 Thread Ted Dunning
How about: Vector3D { ... enum Norm { L_0, L_1, L_2, L_infinity}; static double distance(Vector3D a, Vector3D b, Norm n); ... } ? You can then use distance(a, b, Vector3D.Norm.L_infinity) < epsilon It gives you what you want and it should be very recognizable to the reader o

Re: [math] "equals" in "Vector3D"

2009-04-28 Thread Gilles Sadowski
> Among the definitions that are commonly used, you will find: > > L1 norm: equals(a, b, tolerance) = sum(abs(a-b)) < tolerance > L2 norm: equals(a, b, tolerance) = sqrt(sum((a-b)^2)) < tolerance > L-infinity norm: equals(a, b, tolerance) = max(abs(a-b)) < tolerance

Re: [math] "equals" in "Vector3D"

2009-04-28 Thread Ted Dunning
That sounds very reasonable, but I wasn't the person with the need. Also, for equality checking, especially in 3D, all of these will be very, very close to the same. For very high numbers of dimensions, the differences between boxes and balls becomes fairly extreme. In particular, the corners of

Re: [math] "equals" in "Vector3D"

2009-04-28 Thread Luc Maisonobe
Ted Dunning a écrit : > This is a generally useful thing to have, but there are multiple definitions > for how you apply the tolerance. You should file a JIRA and add a patch! > > Among the definitions that are commonly used, you will find: > > L1 norm: equals(a, b, tolerance) = sum(abs(a-b)) <

Re: [math] "equals" in "Vector3D"

2009-04-28 Thread Ted Dunning
This is a generally useful thing to have, but there are multiple definitions for how you apply the tolerance. You should file a JIRA and add a patch! Among the definitions that are commonly used, you will find: L1 norm: equals(a, b, tolerance) = sum(abs(a-b)) < tolerance L2 norm: equals(a, b, to

[math] "equals" in "Vector3D"

2009-04-28 Thread Gilles Sadowski
Hello. Could we have a boolean equals(Vector3D other, double tolerance) method? Or even static boolean equals(Vector3D v1, Vector3D v2, double tolerance) that would return true if the components are equal within the given toler