private Point?GetNextPoint(Point currentPoint, Point directionPoint) { var diffX = directionPoint.X - currentPoint.X; var diffY = directionPoint.Y - currentPoint.Y; var startIndex = GetStartIndex(diffX, diffY); for (int index = startIndex; index < startIndex + PointRotation.Count; index++) { var rotationPoint = PointRotation.GetPoint(index); var x = (int)(currentPoint.X + rotationPoint.X); var y = (int)(currentPoint.Y + rotationPoint.Y); if (this.contourMap.IsSet(x, y)) { return(new Point(x, y, this.contourMap[x, y])); } } return(null); }