From dc48c866c2449dfea5535f6333a9f3fb8c3a4076 Mon Sep 17 00:00:00 2001 From: Usu171 Date: Sun, 14 Dec 2025 01:26:55 +0800 Subject: [PATCH] feat: use rotation matrix to derive acceleration ax refs: https://www.w3.org/TR/orientation-event/#examples --- src/utils/deviceOrientationInteraction.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/utils/deviceOrientationInteraction.ts b/src/utils/deviceOrientationInteraction.ts index a983f06..ea45c93 100644 --- a/src/utils/deviceOrientationInteraction.ts +++ b/src/utils/deviceOrientationInteraction.ts @@ -64,10 +64,7 @@ export class DeviceOrientationInteraction { const g = 9.8; const toRad = Math.PI / 180; - this.ax = - alpha > 180 - ? g * Math.sin((gamma - 180) * toRad) - : g * Math.sin(gamma * toRad); + this.ax = g * Math.sin(gamma * toRad) * Math.cos(beta * toRad); this.ay = g * Math.sin(beta * toRad); }