How rafter length is worked out
A common rafter is the hypotenuse of a right triangle. The run is half the building width, the rise is that run multiplied by the pitch (a 6/12 roof rises 6 inches for every 12 inches of run), and the rafter length is the square root of run² + rise². The shortcut carpenters use is a per-foot multiplier: for a 6/12 roof it's about 1.118, so every foot of run needs about 1.118 feet of rafter. The overhang is added the same way — it's a horizontal projection, so it also gets multiplied by the pitch factor, not added flat. The count comes from the roof length divided by the on-center spacing, plus one for the end rafter, doubled because a gable roof has a rafter on each side of the ridge.
Two things this figure is not. It's the theoretical line length measured to the centre of the ridge, so you still have to subtract half the ridge board thickness at the top, and it doesn't include the birdsmouth seat cut or the plumb cut at the tail — mark those from the layout, not from the number. It also assumes a simple gable with equal slopes; hips, valleys, dormers and unequal pitches all need their own layout, and hip and valley rafters use a different multiplier because they run diagonally.
This is a layout and take-off aid, not a structural design. Rafter size, grade, spacing, bracing and connections are set by your local building code and by the snow, wind and dead loads at your site. Have the framing plan confirmed by your building department or a licensed engineer before you cut, and always test-fit one rafter as a pattern before cutting the rest.