I have a case where I know the coordinates $(x,y)$ of the center of the rectangle and its edges where the line is dropped anywhere on the edges $a(x_1,y_1),b(x_2,y_1),c(x_1,y_2),d(x_2,y_2)$.
Say I start drawing a line from center towards any edge of the rectangle and rotate it by a arbitrary angle $ \theta$. I need to know that line vector i.e distance from center to the point on the edge or corner vertex which is connected by the line. Any takers?
This is not an answer to your question, but I just think it helps to visualize the situation, I need to be sure that this is the situation you describe:
To calculate the distance from say $(x,y)$ to $d$, you will need to use the distance formula: $$\text{distance}=\sqrt{(x-x_2)^2 + (y-y_2)^2}$$