Matt McCarthy edited Our Prototype1.tex  about 10 years ago

Commit id: bbb876b87bd8f1841b243c2523d2f5a861d63bc5

deletions | additions      

       

Two boolean values are initialized to false within the application, used to determine whether values for the sensors have been initialised. On a sensor event, these values are set to true according to the sensor type.  Within the onSensorChanged method, if the event sensor is of type accelerometer, the variable for player speed is set relative to the value of the accelerometer z axis. If the event sensor type is rotation vector, the values are stored in the variable 'rotationValues'. Within the rotation vector sensor event, if both sensors have provided initial values, themethod  changeMapDirection method  is called. The changeMapDirection method handles updating the view of the map, orienting it in the direction of the rotation vector, and scrolling forward according to the speed value. In order to interpret the raw data given by the rotation vector sensor, this method calls the getOrientation method.  getOrientation uses built in methods within the SensorManager class to interpret the rotation vector values into a value for the rotation of the device around the x axis. It uses SensorManager.getRotationMatrixFromVector to get the rotation matrix from the 3 rotation vector values. It then uses SensorManager.getOrientation to calculate an array of rotations around each axis, from the rotation matrix. The method then returns the value of the x axis orientation + 90, since the orientation values start from a west heading, and the Google Maps API starts from north.