commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Dunning <ted.dunn...@gmail.com>
Subject Re: [math] "equals" in "Vector3D"
Date Tue, 28 Apr 2009 16:29:21 GMT
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, tolerance) = sqrt(sum((a-b)^2)) < tolerance
L-infinity norm: equals(a, b, tolerance) = max(abs(a-b)) < tolerance

All are useful.

Which did you think you wanted?

On Tue, Apr 28, 2009 at 6:23 AM, Gilles Sadowski <
gilles@harfang.homelinux.org> wrote:

>
> 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
> tolerance.
>
>
> Best,
> Gilles
>
> P.S. It seems that checking for exact equality (as the "equal(Object)"
>     method does) is not very useful: If the two vectors being compared
>     come from different computations, they will (most of the time) be
>     different although, at the precision-level, they should be considered
>     equal.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
Ted Dunning, CTO
DeepDyve

111 West Evelyn Ave. Ste. 202
Sunnyvale, CA 94086
www.deepdyve.com
858-414-0013 (m)
408-773-0220 (fax)

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message