Device Orientation Smoothing for Android

I more detailed explained our problem, why we started smoothing deviceOrientation camera here: Fixing DeviceOrientationCamera noize for android devices

We almost found out perfect solution, but we only have problem smoothing, when alpha value goes from 0 to 360 and from 360 to 0. We cant find a solution. It is really hard to average Quaternions. When alpha goes from 0->360 (x,y,-z,w) → (-x,y,-z,-w) and the other way around, but this just doesn’t smooth nice enough

Does anyone has a mathematical solution how to solve this problem in the code?

PLAYGROUND: https://www.babylonjs-playground.com/#14KRGG#619

cc @PolygonalSun

Right now, I’m suspecting that the reason why you have that random blip when moving from 0 to 360 degrees is that one of the points is getting adjusted before the average is being taken, throwing off the average [eg. (10 + (360 * 9)) = 325 != 361 = (370 + (360 * 9))]. I’d have to verify this first but that’s my initial thought on it.

(Tagging @RaananW for visibility, since he was a part of the previous thread).

1 Like