From: Paul Hänsch Date: Fri, 29 Dec 2023 21:58:29 +0000 (+0100) Subject: improved yaw calculation X-Git-Url: https://git.plutz.net/?p=serve0;a=commitdiff_plain;h=8f4a82221dc72c6571048246497cebfba6bf063f improved yaw calculation --- diff --git a/stereoview.js b/stereoview.js index 3b0faa7..d2c4ec5 100644 --- a/stereoview.js +++ b/stereoview.js @@ -131,9 +131,13 @@ function stereoview(layout, video) { pitch = Math.asin((tz / 9.81 > 1)?1:(tz/9.81)) / Math.PI * 180; roll = - Math.asin((ty / 9.81 > 1)?1:(ty/9.81)) / Math.PI * 180; + yaw = pitch ? ( yaw + - event.rotationRate.alpha / 1000 * event.interval * Math.cos(pitch * Math.PI / 180) + - event.rotationRate.gamma / 1000 * event.interval * Math.sin(pitch * Math.PI / 180) + ) % 360 : yaw; + // pitch = (pitch + event.rotationRate.beta / 1000 * event.interval) % 360; // roll = (roll + event.rotationRate.gamma / 1000 * event.interval) % 360; - yaw = (yaw - event.rotationRate.alpha / 1000 * event.interval) % 360; // yaw = (yaw + ty) % 360; }; })());