The sheet metal industry opened my mind to the power of math when building things. I often found that I needed to calculate the angle at which to bend a piece of metal hip cap to achieve a perfect fit for a new metal roof installation. Back when I was at Sinclair Community College I worked with one of my instructors there, Tom Wilson, to derive a standard formula to use to calculate the resulting "compounded" angle on the hip of a roof. This is often referred to as a dihedral angle or an angle between two adjacent roof planes. We used vector cross products and dot products and used values from standard assumptions about a roof's structural layout and ended up with a pretty clean formula.
A roof hip is the corner of a roof that is formed where two adjacent roof surfaces meet. A roof hip typically runs from the roof ridge to roof eave. It is most common that the eaves of two adjacent roof surfaces meet at a 90º angle from a bird's eye view or plan view. This formula only works if these two roof eaves meet at 90º. It is also most common that the slope of the two adjacent roof surfaces is congruent so this is assumed as well. First identify the slope (rise/run) of the roof sections. Let this value be equal to M. Let the dihedral hip angle be equal to A. Thus the formula that Mr. Wilson and I derived was this:
A = arccos( - 1 / (1+M^2) )
Looking at the photo below and to the right, we see that the eaves of adjacent roof surfaces meet at 90º and for convenience we will estimate the roof slope to be an 8:12 pitch (33.7º from horizontal).
M = 8÷12 = 2/3
A (Hip) = arccos( -1 / (1 + (2/3)^2))
A (Hip) = arccos( -1 / (1 + 4/9))
A (Hip) = arccos( -1 / (13/9))
A (Hip) = arccos( -9/13)
A (Hip) = 133.8º
However, to make this metal cap we would bend the metal cap at 46.2º which is the supplementary angle of 133.8º to achieve the perfect fit for an 8:12 slope. For comparison, a similar metal cap is made for the ridge and its dihedral angle must be calculated too. The calculation for the ridge dihedral angle is:
A (Ridge) = 180º - 2 * arctan(M)
For this example the dihedral angle at the ridge would be:
A (Ridge) = 180º - 2 * 33.7º = 112.6º
Please note that this is significantly different than the hip dihedral angle.