private void FindNearestPixelInRing(Point2 coor, ref int nearestPixel, out int previous) { var wasNearestPixel = nearestPixel; if (ColorsManager.FindNearest( coor.X, P => Pixels[P].X, false, PrecisionGrad, nearestPixel + HealpixManager.PixelsCountInRing(Pixels[nearestPixel].Ring), ref nearestPixel)) // todo add approximation { previous = nearestPixel; } else { previous = nearestPixel - 1; if (nearestPixel == Pixels.Length || Pixels[nearestPixel].PixelInRing == 1 /*next ring*/) { var pixelsInRing = HealpixManager.PixelsCountInRing(Pixels[wasNearestPixel].Ring); if (wasNearestPixel == nearestPixel) { previous += pixelsInRing; } else { nearestPixel -= pixelsInRing; } } } }