static bool IsWithinGapLimits(SkeletonMinutia end1, SkeletonMinutia end2) { int distanceSq = (end1.Position - end2.Position).LengthSq; if (distanceSq <= Integers.Sq(Parameters.MaxRuptureSize)) { return(true); } if (distanceSq > Integers.Sq(Parameters.MaxGapSize)) { return(false); } double gapDirection = DoubleAngle.Atan(end1.Position, end2.Position); double direction1 = DoubleAngle.Atan(end1.Position, AngleSampleForGapRemoval(end1)); if (DoubleAngle.Distance(direction1, DoubleAngle.Opposite(gapDirection)) > Parameters.MaxGapAngle) { return(false); } double direction2 = DoubleAngle.Atan(end2.Position, AngleSampleForGapRemoval(end2)); if (DoubleAngle.Distance(direction2, gapDirection) > Parameters.MaxGapAngle) { return(false); } return(true); }
public EdgeShape(ImmutableMinutia reference, ImmutableMinutia neighbor) { IntPoint vector = neighbor.Position - reference.Position; double quadrant = 0; int x = vector.X; int y = vector.Y; if (y < 0) { x = -x; y = -y; quadrant = Math.PI; } if (x < 0) { int tmp = -x; x = y; y = tmp; quadrant += DoubleAngle.HalfPi; } int shift = 32 - (int)Integers.LeadingZeros(((uint)x | (uint)y) >> PolarCacheBits); int offset = (y >> shift) * PolarCacheRadius + (x >> shift); Length = PolarDistanceCache[offset] << shift; double angle = PolarAngleCache[offset] + quadrant; ReferenceAngle = DoubleAngle.Difference(reference.Direction, angle); NeighborAngle = DoubleAngle.Difference(neighbor.Direction, DoubleAngle.Opposite(angle)); }