I am developing an application for Android to provide location within the university using the API’s compass, gps and camera.
Could also get some important data based on API’s mentioned above. This is not built-in functionality to Android or Java and requires some algorithm. I need to make a calculation that results in the position (x) that a balloon should appear on the screen as the direction of the mobile user is facing.
To perform the calculation I already have the following data:
- degrees: direction (degree) in which the cell phone is being directed by the user (obtained by using the compass);
- grausParaDestino: direction (degree) in that the balloon should be at the center of the screen (with calculations obtained from GPS points);
- width: width of the screen;
We know that one complete revolution of the user on its axis 360 degrees total.
I tried the calculus below, but is incorrect.
int position = Math.round (((width * grausParaDestino) / 360) + degrees);
I spent yesterday afternoon trying various ways of solving this calculation, but without success. If they can give me some help I appreciate it.
With this code i have positioned the balloom on the screem.
Thanks for all responses.