Humans tend to think of an airplane's orientation relative to the horizontal, and instruments such as the artificial horizon bear this out. In addition, many calculations (for example, gravity force) require the airplane's orientation relative to the local horizontal plane. There is not, however, much direct physical meaning to the aircraft's orientation relative to geocentric axes.
Therefore, the simulator specifies the aircraft's orientation relative to an intermediate axis system, rather than directly to geocentric axes. This intermediate system is referred to as the local axis system, sometimes called the local horizontal axis system. In local axes, the z-axis always points vertically down, while the x- and y-axes are always aligned with the local horizontal plane. Usually, the x-axis points north and the y-axis points east, but in some cases (such as near the poles) it may be convenient to have the x- and y-axes point in other directions.
Generally, it doesn't matter where the local axes originate, so long as the x-y-plane is parallel to the local horizontal plane. The local axes could be centered at the airplane's CG. They could originate directly below the airplane, at sea level. They could originate at a fixed point on the Earth's surface, close to where the airplane is flying. If the simulator uses a flat-Earth model, then the flat-Earth coordinate system serves as the local system.
Once the local reference frame is defined, the orientation of the airplane is given by the orientation of body axes relative to the local axes. The relative orientation is specified by a direction cosine matrix, whose components are the cosines of the angles between the respective body and local axes. The airplane's direction cosine matrix can transform a vector from the body reference frame to the local reference frame by premultiplying it. (Some references define the cosine matrix to do the opposite: to transform vectors from the local frame into the body frame. The orthogonality property of the cosine matrix, [C]-1 = [C]T, obviates the need to invert the cosine matrix, and so it does not matter which definition is used.)
Due to its orthogonality condition, the direction cosine matrix can be represented in general by three independent quantities. Euler angles and quarternions are two common ways to represent orientation. Flight simulators prefer Euler angles and quarternions over the direction cosine matrix for storing aircraft orientation, because there are fewer quantities to keep track of, and fewer constraints to satisfy.