I am trying to calculate the (x1,y1), (x2,y2) coordinates of a line. From the image consider the rectangle of width w, height h, center c and angle θ.

If the same is given in a graph with X and Y axis then we can draw a tangent with angle θ from the center to the edge of the circle. To calculate the point using formula, I know I can use
x = cos(θ) * r
y = sin(θ) * r
Is there a formula to find the x1,x2,y1,y2?
From $x=r\cos \theta,\; y=r\sin\theta$ you get $x=y\cot\theta.$
Notice that $$y_1=\frac{h}{2},$$ from the above you obtain $$x_1=\frac{h}{2}\cot\theta.$$
Can you find $x_2$ and $y_2?$