41 lines
850 B
C#
41 lines
850 B
C#
using System;
|
|
|
|
namespace KDTree
|
|
{
|
|
// Token: 0x02000003 RID: 3
|
|
public class SquareEuclideanDistanceFunction : DistanceFunctions
|
|
{
|
|
// Token: 0x06000003 RID: 3 RVA: 0x00002050 File Offset: 0x00000250
|
|
public double Distance(double[] p1, double[] p2)
|
|
{
|
|
double num = 0.0;
|
|
for (int i = 0; i < p1.Length; i++)
|
|
{
|
|
double num2 = p1[i] - p2[i];
|
|
num += num2 * num2;
|
|
}
|
|
return num;
|
|
}
|
|
|
|
// Token: 0x06000004 RID: 4 RVA: 0x00002094 File Offset: 0x00000294
|
|
public double DistanceToRectangle(double[] point, double[] min, double[] max)
|
|
{
|
|
double num = 0.0;
|
|
for (int i = 0; i < point.Length; i++)
|
|
{
|
|
double num2 = 0.0;
|
|
if (point[i] > max[i])
|
|
{
|
|
num2 = point[i] - max[i];
|
|
}
|
|
else if (point[i] < min[i])
|
|
{
|
|
num2 = point[i] - min[i];
|
|
}
|
|
num += num2 * num2;
|
|
}
|
|
return num;
|
|
}
|
|
}
|
|
}
|