# Get angle between line formed from two points on two inclined rectangles and x axis.

I have two rectangles with known dimensions. And I know the angle they make with the horizontal axis which their lower right corner touch.

I want to get the angle the the dashed line (The line connecting the lower right point of the first rectangle with the upper left point of the second rectangle) makes with the horizontal axis.

I know I can get that angle by getting the vector representing the dashed line, but I was wondering if there is a better easier way to get it using geometric construction

We know the angles $\alpha$, $\theta$, and the dimensions of the rectangles $k$, $w$, and $h$.

My steps would be to calculate $|AB|$ with the sine rule, then work out $|AC|$, and finally use the cosine rule to calculate $|AE|$, the length you want.

In the triangle $ABD$, we know the angles $\angle BAD=90-\theta$ and $\angle ABD=90+\alpha$. Therefore $\angle ADB = 180-(90-\theta)-(90+\alpha)= \theta-\alpha$. The sine rule gives us:

$$\frac{\sin(\angle ADB)}{|AB|} = \frac{\sin(\angle ABD)}{|AD|} \\ |AB| = \frac{|AD| \sin(\angle ADB)}{\sin(\angle ABD)}\\ |AB| = \frac{k \sin(\theta-\alpha)}{\sin(90+\alpha)} = \frac{k \sin(\theta-\alpha)}{\cos(\alpha)}$$

The segment $BC$ is the hypotenuse of a right angle, which gives $|BC| = w/\cos(\alpha)$. Therefore

$$|AC|= |AB|+|BC| = \frac{w + k \sin(\theta-\alpha)}{\cos(\alpha)}$$

For the final step, look at triangle $ACE$. We just calculated $|AC|$. From Pythagoras we know $$|CE|=\sqrt{w^2+h^2}$$

Lastly, we can work out the angle between them:

$$\angle ACE = \alpha + \tan^{-1}(h/w)$$

So now you have a triangle of which you know side-angle-side, and you want to know the side opposite the angle, which cries out for the cosine rule.

$$|AE|^2 = |AC|^2 + |CE|^2 + 2 |AC| |CE| \cos (\angle ACE) \\ |AE| = \sqrt{|AC|^2 + |CE|^2 + 2 |AC| |CE| \cos (\angle ACE)}$$

Unfortunately the expression that results after substituting what we have for $|AC|$, $|AC|$, and $\angle ACE$ is rather horrible.

• Perhaps I didn't make it clear in the question, but I don't have the distance between both points, in fact, I am trying to get this distance using the law of sines using the angle I am asking about. – Omar Ahmad Aug 27 '17 at 13:02
• @OmarAhmad. I see. In that case you need to apply the sine rule on the triangle between the rectangles to get the base of that triangle. Then from that calculate the distance between the contact points. Finally do the cosine rule as in my answer. I'll see if I can edit my answer to explain in more detail. – Jaap Scherphuis Aug 27 '17 at 13:07
• I originally came up with the equation to compute the distance: $\frac{h \sin{(\alpha - \theta}) +\lambda}{\sin{(\alpha)}}$, where $h$ is the height of the first rectangle, $\alpha$ angle the blue rectangle make, $\theta$ is the angle the green rectangle make, $\lambda$ the width of the blue rectangle. The problem is, if the blue rectangle isn't tall enough, they won't be touching (Its extension will) like here: imgur.com/a/o3t6o So I can't really use the triangle the rectangles make if I want a generalized solution. – Omar Ahmad Aug 27 '17 at 13:13