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
of the code (subject to verification by all the readers out there).
On Tue, Apr 28, 2009 at 1:55 PM, Gilles Sadowski <
[email protected]> wrote:
> > 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
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> I was thinking of that one. [Actually, I use it in unit tests...]
>
> [The L2-norm is already available through the "distance" method.]
>
>
> Gilles
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
--
Ted Dunning, CTO
DeepDyve
111 West Evelyn Ave. Ste. 202
Sunnyvale, CA 94086
www.deepdyve.com
858-414-0013 (m)
408-773-0220 (fax)