00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 package com.meapsoft;
00024
00033 public class EuclideanDist extends ChunkDist
00034 {
00035 public EuclideanDist() {}
00036 public EuclideanDist(ChunkDist o) { super(o); }
00037 public EuclideanDist(int[] i) { super(i); }
00038 public EuclideanDist(ChunkDist o, int[] i) { super(o,i); }
00039
00040 public double distance(Chunk ch1, Chunk ch2)
00041 {
00042 FeatChunk c1 = null;
00043 FeatChunk c2 = null;
00044
00045
00046 try
00047 {
00048 c1 = (FeatChunk)ch1;
00049 c2 = (FeatChunk)ch2;
00050 }
00051 catch(ClassCastException e)
00052 {
00053 return super.distance(ch1, ch2);
00054 }
00055
00056 double[] f1 = c1.getFeatures(featdim);
00057 double[] f2 = c2.getFeatures(featdim);
00058 double distSq = super.distance(c1, c2);
00059
00060 for(int i=0; i<f1.length; i++)
00061 distSq += (f1[i] - f2[i]) * (f1[i] - f2[i]);
00062
00063 return distSq;
00064 }
00065 }