Exemplo n.º 1
0
        public float MinSegmentDist()
        {
            IReadOnlyList <Vector3> seq = this.curve.GetPoints();
            int   n    = this.Length();
            float min  = float.PositiveInfinity;
            int   endi = this.closed ? n - 3 : n - 4;

            for (int i = 0; i <= endi; i++)
            {
                int endj = (i == 0 || !this.closed) ? n - 2 : n - 1;
                for (int j = i + 2; j <= endj; j++)
                {
                    float dist = SegmentDist.SSDist(seq[i], seq[i + 1], seq[j], seq[(j + 1) % n]);
                    if (dist < min)
                    {
                        min = dist;
                    }
                }
            }

            return(min);
        }
Exemplo n.º 2
0
        public float CurveDistance(Curve curve)
        {
            float min  = float.PositiveInfinity;
            int   n1   = this.Length();
            int   n2   = curve.Length();
            int   end1 = this.closed ? n1 - 1 : n1 - 2;
            int   end2 = curve.closed ? n2 - 1 : n2 - 2;

            for (int i = 0; i <= end1; i++)
            {
                for (int j = 0; j <= end2; j++)
                {
                    float dist = SegmentDist.SSDist(this.points[i], this.points[(i + 1) % n1], curve.points[j], curve.points[(j + 1) % n2]);
                    if (dist < min)
                    {
                        min = dist;
                    }
                }
            }

            return(min);
        }
Exemplo n.º 3
0
        public float CurveDistance(HandCurve other)
        {
            IReadOnlyList <Vector3> thisPoints  = this.curve.GetPoints();
            IReadOnlyList <Vector3> otherPoints = other.curve.GetPoints();
            float min  = float.PositiveInfinity;
            int   n1   = this.Length();
            int   n2   = other.Length();
            int   end1 = this.closed ? n1 - 1 : n1 - 2;
            int   end2 = other.closed ? n2 - 1 : n2 - 2;

            for (int i = 0; i <= end1; i++)
            {
                for (int j = 0; j <= end2; j++)
                {
                    float dist = SegmentDist.SSDist(thisPoints[i], thisPoints[(i + 1) % n1], otherPoints[j], otherPoints[(j + 1) % n2]);
                    if (dist < min)
                    {
                        min = dist;
                    }
                }
            }

            return(min);
        }