math
Class RectilinearMetric

java.lang.Object
  extended by math.RectilinearMetric
All Implemented Interfaces:
Metric

public class RectilinearMetric
extends java.lang.Object
implements Metric

The rectilinear metric (i.e., the sum of the absolute values of the differences between the elements). This is sometimes also called the Manhattan metric (because it is the distance you have to walk between two points in a city that is layed out on a grid).

See Also:
"The Design and Implementation of Multimedia Software © 2011"

Constructor Summary
RectilinearMetric()
           
 
Method Summary
 double distance(double[] x, double[] y)
          Calculate the distance between two n-dimensional points (required by Metric) Note: For simplicity, this method does not confirm that the two arrays are the same size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RectilinearMetric

public RectilinearMetric()
Method Detail

distance

public double distance(double[] x,
                       double[] y)
Calculate the distance between two n-dimensional points (required by Metric) Note: For simplicity, this method does not confirm that the two arrays are the same size. It uses the smaller size.

Specified by:
distance in interface Metric
Parameters:
x - One n-dimensional point
y - Another n-dimensional point
Returns:
The distance


Design and Implementation of Multimedia Software, Jones and Bartlett Publishers