I'm looking for a way to draw an infinite line (a line with no end, also known as a ray) through 2 points. I can draw a line between 2 points with Line2D, no problem here.
Next the infinite part needed a look. With my simple mind I thought, lets multiply the x and y coordinates from the second point with 100 and redraw the line. This works, but only in simple cases.
For example here is a case in which it produces lines with different angles:
g.setColor(Color.red);
g2.setStroke(new BasicStroke(4.0f));
g2.draw(new Line2D.Double(0, 61.632653061218946, 944, 217.25510204080692));
g.setColor(Color.blue);
g2.setStroke(new BasicStroke(1.0f));
g2.draw(new Line2D.Double(0, 61.632653061218946, 944*10, 217.25510204080692*10));
This will first draw a fat red line, next it will draw a blue thin line.
The blue line has a different angle compared the the red line. Here's a screenshot to illustrate this effect:
Does somebody know a way to fix this, or maybe a better way to draw a infinite line through 2 points?