triniwiz/native-script-accelerometer

Incorrect Calculations and Unit Quaternion

Closed this issue · 1 comments

The NativeScript-Accelerometer-Advanced plugin is coded incorrectly. Calculating the unit quaternion value q0 is not necessary as it is provided by the sensor on newer devices using event.values[3] for TYPE_ROTATION_VECTOR. Dividing by gravity (9.81 m/s^2) is not necessary as it is not included in the sensors used. Try this code to improve:

wrappedCallback({
values: event.values,
x: event.values[0],
y: event.values[1],
z: event.values[2],

Hey @josephcantrell14
Not sure If I understand completely your remarks. I've tried to keep the API and reported values consistent for IOS and Android and that is why I do the divide by gravity calculation on android.

However, If you think there is room for extending the data or the API with additional useful info - a PR will be more than welcome.