TITLE: Determining angle to cut two boards
QUESTION [9 upvotes]: I am building a small roof and I need to determine how to find the distance/angle in that I need to cut two 2x4's in order to make them fit together perfectly.  I've drawn a crude image below to illustrate.

Given that my base is 6', and I'd like to have the center of the roof  2' high from the base, what formula can I use to determine how long a and b will be as well as the angle that boards a and b will come together?

REPLY [5 votes]: If the base is $2c$ and the height is $h$, then
the roof framing cross sections are shown in blue below.
Note that the triangles with sides $ach$ & $bch$
are congruent (mirror images, reflections about $h$),
so really $a=b$ have the same length.
(We only confuse things by using two variable names for them!)
Furthermore, this length is the hypotenuse of a right triangle
with horizontal and vertical legs $c$ & $h$, respectively,
and we can use its trigonometry to find its
complementary interior acute angles, which I will call $\alpha$ and $\beta$.

Now the angle $\beta$ opposite $h$,
the roof's angle, has slope (or pitch) $\frac23$,
from which we get $\beta$
using the arctangent (inverse tangent) function
(with your calculator's angle mode set to degrees rather than radians):
$$
\tan\beta=\frac{h}{c}=\frac23\qquad\implies\qquad\beta
=\tan^{-1}\frac23=0.588\text{ rad}=33.69^\circ
$$
and the angle you want (opposite $c$ inside
each congruent triangle at the top) is
$$
\tan\alpha=\frac{c}{h}=\frac32\qquad\implies\qquad\alpha
=\tan^{-1}\frac32=0.9828\text{ rad}=56.31^\circ.
$$
That is, you need to cut an acute angle $\alpha=90^\circ-\beta$ on each
piece of wood, to get a total angle of $2\alpha$ at the top of the roof.
As to the lengths, they are given by the famous Pythagorean formula:
$$
\eqalign{
a^2=b^2&=h^2+c^2\\&=2^2+3^2\\&=4+9\\&=13
\\\\
a=b &=\sqrt{13} \approx 3.60555\text{ ft}
\\ &\approx 3\text{ ft }7.26661\text{ in}
\\ &\approx 3\text{ ft }7\tfrac4{15}\text{ in}
\\ &\approx 3\text{ ft }7\tfrac14\text{ in}
\\ &\approx 109.9\text{ cm}
}
$$
The alternate length unit and fraction are slightly more precise, but perhaps less convenient to work with.
Perhaps you should ask another question about how this roof pitch will look aesthetically and function, i.e. how it will reflect light and whether it will adequately absorb solar radiation (would you ever want to put a solar panel or passive heating unit there?) based on its orientation (map direction, for lighting source and relation to where people will be, for modeling sun shading and reflections) and your latitude and average yearly weather conditions.