static bool MatchingShapes(EdgeShape probe, EdgeShape candidate)
        {
            int lengthDelta = probe.Length - candidate.Length;

            if (lengthDelta >= -Parameters.MaxDistanceError && lengthDelta <= Parameters.MaxDistanceError)
            {
                double complementaryAngleError = DoubleAngle.Complementary(Parameters.MaxAngleError);
                double referenceDelta          = DoubleAngle.Difference(probe.ReferenceAngle, candidate.ReferenceAngle);
                if (referenceDelta <= Parameters.MaxAngleError || referenceDelta >= complementaryAngleError)
                {
                    double neighborDelta = DoubleAngle.Difference(probe.NeighborAngle, candidate.NeighborAngle);
                    if (neighborDelta <= Parameters.MaxAngleError || neighborDelta >= complementaryAngleError)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        List <MinutiaPair> MatchPairs(NeighborEdge[] probeStar, NeighborEdge[] candidateStar)
        {
            double complementaryAngleError = DoubleAngle.Complementary(Parameters.MaxAngleError);
            var    results = new List <MinutiaPair>();
            int    start   = 0;
            int    end     = 0;

            for (int candidateIndex = 0; candidateIndex < candidateStar.Length; ++candidateIndex)
            {
                var candidateEdge = candidateStar[candidateIndex];
                while (start < probeStar.Length && probeStar[start].Length < candidateEdge.Length - Parameters.MaxDistanceError)
                {
                    ++start;
                }
                if (end < start)
                {
                    end = start;
                }
                while (end < probeStar.Length && probeStar[end].Length <= candidateEdge.Length + Parameters.MaxDistanceError)
                {
                    ++end;
                }
                for (int probeIndex = start; probeIndex < end; ++probeIndex)
                {
                    var    probeEdge     = probeStar[probeIndex];
                    double referenceDiff = DoubleAngle.Difference(probeEdge.ReferenceAngle, candidateEdge.ReferenceAngle);
                    if (referenceDiff <= Parameters.MaxAngleError || referenceDiff >= complementaryAngleError)
                    {
                        double neighborDiff = DoubleAngle.Difference(probeEdge.NeighborAngle, candidateEdge.NeighborAngle);
                        if (neighborDiff <= Parameters.MaxAngleError || neighborDiff >= complementaryAngleError)
                        {
                            var pair = Allocate();
                            pair.Probe     = probeEdge.Neighbor;
                            pair.Candidate = candidateEdge.Neighbor;
                            pair.Distance  = candidateEdge.Length;
                            results.Add(pair);
                        }
                    }
                }
            }
            return(results);
        }