Orientation
There are multiple sensors that can be used independently or in combination to get the orientation of a device. Many modern mobile PCs, from tablets to even laptops have some or all of these sensors built-in. WinRT allows access to the individual sensors, as well as a nice Orientation Sensor API that combines all of the provided data and does the math required to give you the angles you want in a simpler form. It's up to you what you use, depending on how much information you require.
Let's take a look at how to work with each sensor individually, and then look at the Orientation Sensor API, which takes data from all of these and gives you the information you need, saving you a lot of time.
Accelerometer
The accelerometer is a sensor that detects the direction and acceleration of the device. This can be used to determine if the device is moving, but sometimes it is used to determine the gravity direction to provide a reference to other sensors and determine orientation.
For example...