public void MarkSegmentOnMap(List <DirectionLineSegment>[,] segmentsCount, int width, int height) { double angle = DirectionLine.GetAngleBetweenLines(Line, new DirectionLine(new Vector2d(0, 0), new Vector2d(1, 0))); if (angle > Math.PI / 4.0 && angle < Math.PI * 3.0 / 4.0) { int start = (int)(BeginPoint.Y < EndPoint.Y ? BeginPoint.Y : EndPoint.Y); double end = BeginPoint.Y > EndPoint.Y ? BeginPoint.Y : EndPoint.Y; for (int y = start; y < end; y++) { int x = (int)Line.GetPointByY(y).X; if (x >= 0 && x < width) { segmentsCount[y, x].Add(this); } } } else { int start = (int)(BeginPoint.X < EndPoint.X ? BeginPoint.X : EndPoint.X); double end = BeginPoint.X > EndPoint.X ? BeginPoint.X : EndPoint.X; for (int x = start; x < end; x++) { int y = (int)Line.GetPointByX(x).Y; if (y >= 0 && y < height) { segmentsCount[y, x].Add(this); } } } }
public LineSortHelper(DirectionLine lineSegment) { this.lineSegment = lineSegment; DirectionLine oxLine = new DirectionLine(new Vector2d(0, 0), new Vector2d(1, 0)); OXAngle = (int)(DirectionLine.GetAngleBetweenLines(lineSegment, oxLine) * tolerance / Math.PI); }
private List <double> CalculateSegmentPoints() { List <double> positions = new List <double>(); int width = ImageContext.Width; int height = ImageContext.Height; double angle = DirectionLine.GetAngleBetweenLines(Line, new DirectionLine(new Vector2d(0, 0), new Vector2d(1, 0))); byte colorSearch = 0; if (angle > Math.PI / 4.0 && angle < Math.PI * 3.0 / 4.0) { for (int y = 0; y < height; y++) { int x = (int)Line.GetPointByY(y).X; if (x >= 0 && x < width) { if (ImageContext.Data[y, x, 0] == colorSearch) { positions.Add(Line.GetPositionOfY(y)); colorSearch = (byte)(255 - colorSearch); } } } } else { for (int x = 0; x < width; x++) { int y = (int)Line.GetPointByX(x).Y; if (y >= 0 && y < height) { if (ImageContext.Data[y, x, 0] == colorSearch) { positions.Add(Line.GetPositionOfX(x)); colorSearch = (byte)(255 - colorSearch); } } } } return(positions); }