I am trying to clip a line segment between two parallel horizontal lines.
I know the location of the two vertices on the larger segment, but need to know the points at which it intersects the horizontal lines.

What is the best way to calculate this?
I am trying to clip a line segment between two parallel horizontal lines.
I know the location of the two vertices on the larger segment, but need to know the points at which it intersects the horizontal lines.

What is the best way to calculate this?
The equation of the diagonal line is $y-y_1=\frac{y_1-y_2}{x_1-x_2}(x-x_1)$, i.e. $y=\frac{y_1-y_2}{x_1-x_2}(x-x_1)+y_1$ So, the $x$ coordinate of the upper point satisfies $$75=\frac{y_1-y_2}{x_1-x_2}(x-x_1)+y_1$$ and the $x$ coordinate of the lower point satisfies $$25=\frac{y_1-y_2}{x_1-x_2}(x-x_1)+y_1.$$
Now you can solve these for $x$.