The desired trajectory is computed on the ground before launch. The rocket determines how well it is following the planned path, and may make some adjustments if required (Most notably the Falcon 9).
There are two reference points of interest. The first is how position is modeled, the second is how the attitude is modeled. Position references are usually done in a coordinate system called Earth Centered Inertial. This basically calls the center of the Earth 0,0,0 with axis being the poles, 0 and 90 degree longitude equator points. The I comes into effect because while the ECI coordinates are set at a point in time, they adjust based on the rotation of the Earth. So an object on the ground not moving will be moving with the rotational speed of the Earth. This is found either by a high precision accelerometer (Part of a device called an IMUIMU) or GPS. Usually the IMU is used for primary navigation, supported by GPS as a backup in case of serious problem.
As for the orientation, one can use a number of systems. For rockets, I believe the most common is Quaternions with a reference point of the position straight down. This can be measured by a number of methods, usually an IMU is used, which is a device that basically figures the difference in pointing from the start point.