I'm trying to draw lines at a specific angle and the algorithm I'm using is :
x1,y1 - start coordinates of the line
x2 = x1 + l * cos(angle)
y2 = y1 + l * sin(angle)
My problem is that l, which is the length of the line is a fixed variable and if I want to add limits to the line end points. If I put the start points of the line in a rectangle is there a way to calculate the length of it, before I draw it so that it will not leave the rectangle's limits. Basicly I want to avoid that from happening.
