Brian Hayes in American Scientist:
Having run out of sheep the other night, I found myself counting the ways to flip a mattress. Earlier that day I had flipped the very mattress on which I was not sleeping, and the chore had left a residue of puzzled discontent. If you’re going to bother at all with such a fussbudget bit of housekeeping, it seems like you ought to do it right, rotating the mattress to a different position each time, so as to pound down the lumps and fill in the sags on all the various surfaces. The trouble is, in the long interval between flips I always forget which way I flipped it last time. Lying awake that night, I was turning the problem over in my head, searching for a golden rule of mattress flipping…
To make sense of all this turning and flipping, the first thing we need is some clear notation. A mattress can be rotated around any of three orthogonal axes. I could label the axes x, y and z, but I’d just forget which is which, so it seems better to adopt the terminology of aviation. If you think of a mattress as an airplane flying toward the headboard of the bed, then the three axes are designated roll, pitch and yaw as shown in the illustration to the right. The roll axis is parallel to the longest dimension of the mattress, the pitch axis runs along the next-longest dimension, and the yaw axis passes through the shortest dimension.