//###consider definig childFeature count in base class feature and exceptions in none ComplexFeature sub classes
        //and moving logic here to above function
        private int GetDistance(ComplexFeature featureOne, ComplexFeature featureTwo)
        {
            double runningSum = 0.0;

            for (int i = 0; i < featureOne.ChildFeaturesCount; i++)
            {
                runningSum += Math.Pow(featureOne.GetChildFeature(i).CalculateDistance(featureTwo.GetChildFeature(i)), 2);
            }
            return((int)Math.Sqrt(runningSum));
        }
Example #2
0
        //delete ######
        private int CalculateDistance(ComplexFeature otherFeature)
        {
            double distance = 0;

            for (int i = 0; i < this.childFeatures.Count; i++)
            {
                double tempDistance = this.distanceMetric.GetDistance(otherFeature.GetChildFeature(i), this.childFeatures.ElementAt(i));
                distance += Math.Pow(tempDistance, 2);
            }
            return((int)Math.Sqrt(distance));
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="otherFeature"></param>
        /// <returns></returns>
        public override Feature Sum(Feature otherFeature)
        {
            //#####check if otherFeature is null
            ComplexFeature feature    = (ComplexFeature)otherFeature;
            ComplexFeature newFeature = new ComplexFeature(this.distanceMetric);

            for (int i = 0; i < this.childFeatures.Count; i++)
            {
                newFeature.AddChildFeature(this.childFeatures.ElementAt(i).Sum(feature.GetChildFeature(i)));
            }
            return(newFeature);
        }