Converting polar coordinates (degree) to Cartesian line coordinates

282 Views Asked by At

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 θ.

Image attached

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?

2

There are 2 best solutions below

0
On

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?$

0
On

Instead of using the formulas $x=r\cos \theta$, $y=r\sin\theta$, I suggest you just look at the triangle in your picture and use the definition of $\tan$ and $\cot$.

Case 1: $-\cot\frac{h}{w} \leq \theta \leq \cot\frac{h}{w}$. In this case, the green line intersects the right vertical red side. Note that $x_1=\frac{w}{2}$ and $y_1 = x_1 \tan\theta = \frac{w}{2}\tan\theta$.

Case 2: $\cot\frac{h}{w} \leq \theta \leq \pi - \cot\frac{h}{w}$. In this case, the green line intersects the upper horizontal red side. Note that $y_1=\frac{h}{2}$ and $x_1 = y_1 \cot\theta = \frac{h}{2}\cot\theta$.

The remaining two following cases are similar

Case 3: $\pi-\cot\frac{h}{w} \leq \theta \leq \pi+\cot\frac{h}{w}$.

Case 4: $\pi+\cot\frac{h}{w} \leq \theta \leq -\cot\frac{h}{w}$.