## Bresenham's Line Algorithm to Get Points Along Line Segment

I'm developing an application where each agent has a "line of sight" on an image. I attempted to implement Bresenham's line algorithm to identify each point along the line. However, I am also wondering if there are any better alternatives? Since I will have many agents in the application at a given time, I'm looking for efficient solutions. Any additional info is appreciated. ^_^

Here's what I'm doing at the moment...

Java Code:
```import java.util.ArrayList;
import java.util.List;

public class LineSegmentHelper
{
public static List<Coordinate> getPointsInLine(int x1, int y1, int x2, int y2)
{
final List<Coordinate> coords = new ArrayList<>();
final int dx = Math.abs(x2 - x1);
final int dy = Math.abs(y2 - y1);
final int sx = x1 < x2 ? 1 : -1;
final int sy = y1 < y2 ? 1 : -1;
// Verticle Line
if(dx == 0)
{
while(true)
{
final Coordinate c = new Coordinate(x1, y1);
if(!coords.contains(c))
if(y1 == y2)
break;
y1 += sy;
}
}
// Horizontal Line
else if(dy == 0)
{
while(true)
{
final Coordinate c = new Coordinate(x1, y1);
if(!coords.contains(c))
if(x1 == x2)
break;
x1 += sx;
}
}
// Other Line
else
{
int err = dx - dy;
while(true)
{
final Coordinate c = new Coordinate(x1, y1);
if(!coords.contains(c))
if(x1 == x2 || y1 == y2)
break;
int e2 = 2 * err;
if(e2 > -dy)
{
err -= dy;
x1 += sx;
}
if(e2 < dx)
{
err += dx;
y1 += sy;
}
}
}
return coords;
}
}```