示例#1
0
        public int CompareTo(Object obj)
        {
            if (obj.GetType() != this.GetType())
            {
                return(1);
            }

            Correlation <T> cor = (Correlation <T>)obj;

            double c1 = this.MbDist;
            double c2 = cor.MbDist;

            return(-c1.CompareTo(c2));
        }
示例#2
0
        protected Heap CorrelatePointsQT(Vector2[] points1, Vector2[] points2, bool[] filter1, bool[] filter2)
        {
            QuadTree <Vector2> qtree1 = new QuadTree <Vector2>();

            int len1 = points1.Length - 1;

            for (int i = 0; i <= len1; i++)
            {
                if (!filter1[i])
                {
                    qtree1.Insert(points1[i]);
                }
            }

            QuadTree <Vector2> qtree2 = new QuadTree <Vector2>();

            int len2 = points2.Length - 1;

            for (int i = 0; i <= len2; i++)
            {
                if (!filter2[i])
                {
                    qtree2.Insert(points2[i]);
                }
            }

            Heap correlations = new Heap();

            foreach (Vector2 point in points2)
            {
                Vector2 point1 = qtree1.FindNearestNeighbour(point, MAX_CORRELATIONDISTANCE);
                if (point1 != null)
                {
                    Vector2 point2 = qtree2.FindNearestNeighbour(point1, MAX_CORRELATIONDISTANCE);
                    if (!(point2 == null) && (point2 == point))
                    {
                        double d = MathHelper.GetDistance(point1, point2);
                        Correlation <Vector2> pair = new Correlation <Vector2>(point1, point2, d);
                        correlations.Add(pair);
                    }
                }
            }
            return(correlations);
        }
示例#3
0
        protected Correlation <Vector2>[] CorrelatePointsDM(Vector2[] points1, Vector2[] points2, bool[] filter1, bool[] filter2)
        {
            double maxdist = System.Math.Pow((double)this.MAX_CORRELATIONDISTANCE, 2.0);

            double[,] dists = new double[points1.Length, points2.Length];

            int[] marks1to2 = new int[points1.Length];

            int len1 = points1.Length - 1;
            int len2 = points2.Length - 1;

            for (int i = 0; i <= len1; i++)
            {
                double curdist = maxdist + 1.0;
                int    curmark = -1;
                for (int j = 0; j <= len2; j++)
                {
                    double dist = this.ComputeSquaredDistance(points1[i], points2[j]);
                    dists[i, j] = dist;
                    if ((((!filter1[i] && !filter2[j]) && ((dist < maxdist) && (dist < curdist))) ? 1 : 0) != 0)
                    {
                        curdist = dists[i, j];
                        curmark = j;
                    }
                }
                marks1to2[i] = curmark;
            }

            int matches = 0;
            List <Correlation <Vector2> > correlations = new List <Correlation <Vector2> >();

            int[] marks2to1 = new int[points2.Length];
            for (int j = 0; j <= len2; j++)
            {
                double curdist = maxdist + 1.0;
                int    curmark = -1;
                for (int i = 0; i <= len1; i++)
                {
                    if (marks1to2[i] == j)
                    {
                        double dist = dists[i, j];
                        if ((((dist < maxdist) && (dist < curdist)) ? 1 : 0) != 0)
                        {
                            curdist = dist;
                            curmark = i;
                        }
                    }
                }
                marks2to1[j] = curmark;
                if (curdist < maxdist)
                {
                    Correlation <Vector2> pair = new Correlation <Vector2>(points1[curmark], points2[j], curdist);
                    correlations.Add(pair);
                    matches++;
                }
            }

            int[,] pairs = new int[matches, 2];
            int p = 0;

            for (int j = 0; j <= len2; j++)
            {
                if (marks2to1[j] >= 0)
                {
                    pairs[p, 0] = marks2to1[j];
                    pairs[p, 1] = j;
                    p++;
                }
            }
            return(correlations.ToArray());
        }