Beispiel #1
0
        internal double Compare(GOwMtia gOwMtia)
        {
            double sum = 0.0;

            for (int i = 0; i < Segments.Length; i++)
            {
                for (int j = Math.Min(Segments[i].directions.Length, gOwMtia.Segments[i].directions.Length) - 1; j >= 0; j--)
                {
                    if (double.IsNaN(Segments[i].directions[j]) && !double.IsNaN(gOwMtia.Segments[i].directions[j]))
                    {
                        sum += Math.Pow(gOwMtia.Segments[i].directions[j], 2);
                    }
                    else
                    {
                        if (!double.IsNaN(Segments[i].directions[j]) && double.IsNaN(gOwMtia.Segments[i].directions[j]))
                        {
                            sum += Math.Pow(Segments[i].directions[j], 2);
                        }
                        else
                        if (!double.IsNaN(Segments[i].directions[j]) && !double.IsNaN(gOwMtia.Segments[i].directions[j]))
                        {
                            sum += Math.Pow(Segments[i].directions[j] - gOwMtia.Segments[i].directions[j], 2);
                        }
                    }
                }
                if (Segments[i].directions.Length > gOwMtia.Segments[i].directions.Length)
                {
                    for (int k = Segments[i].directions.Length - 1; k >= gOwMtia.Segments[i].directions.Length; k--)
                    {
                        if (!double.IsNaN(Segments[i].directions[k]))
                        {
                            sum += Math.Pow(Segments[i].directions[k], 2);
                        }
                    }
                }
                else
                if (Segments[i].directions.Length < gOwMtia.Segments[i].directions.Length)
                {
                    for (int k = gOwMtia.Segments[i].directions.Length - 1; k >= Segments[i].directions.Length; k--)
                    {
                        if (!double.IsNaN(gOwMtia.Segments[i].directions[k]))
                        {
                            sum += Math.Pow(gOwMtia.Segments[i].directions[k], 2);
                        }
                    }
                }
            }
            if (Math.Sqrt(sum) < threshold)
            {
                return((threshold - Math.Sqrt(sum)) / threshold);
            }
            return(0);
        }
 internal double Compare(GOwMtia gOwMtia)
 {
     double sum = 0.0;
     for (int i = 0; i < Segments.Length; i++)
     {
         for (int j = Math.Min(Segments[i].directions.Length, gOwMtia.Segments[i].directions.Length) - 1; j >= 0; j--)
         {
             if (double.IsNaN(Segments[i].directions[j]) && !double.IsNaN(gOwMtia.Segments[i].directions[j]))
                 sum += Math.Pow(gOwMtia.Segments[i].directions[j], 2);
             else
             {
                 if (!double.IsNaN(Segments[i].directions[j]) && double.IsNaN(gOwMtia.Segments[i].directions[j]))
                     sum += Math.Pow(Segments[i].directions[j], 2);
                 else
                     if (!double.IsNaN(Segments[i].directions[j]) && !double.IsNaN(gOwMtia.Segments[i].directions[j]))
                         sum += Math.Pow(Segments[i].directions[j] - gOwMtia.Segments[i].directions[j], 2);
             }
         }
         if (Segments[i].directions.Length > gOwMtia.Segments[i].directions.Length)
         {
             for (int k = Segments[i].directions.Length - 1; k >= gOwMtia.Segments[i].directions.Length; k--)
                 if (!double.IsNaN(Segments[i].directions[k]))
                     sum += Math.Pow(Segments[i].directions[k], 2);
         }
         else
             if (Segments[i].directions.Length < gOwMtia.Segments[i].directions.Length)
             {
                 for (int k = gOwMtia.Segments[i].directions.Length - 1; k >= Segments[i].directions.Length; k--)
                     if (!double.IsNaN(gOwMtia.Segments[i].directions[k]))
                         sum += Math.Pow(gOwMtia.Segments[i].directions[k], 2);
             }
     }
     if (Math.Sqrt(sum) < threshold)
         return (threshold - Math.Sqrt(sum)) / threshold;
     return 0;
 }