Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2118)

Unified Diff: chrome/browser/android/vr_shell/vr_shell.cc

Issue 2770353002: WebVR: add angular velocity estimate to pose (Closed)
Patch Set: Comment changes and reformatting as suggested Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | chrome/browser/android/vr_shell/vr_shell_gl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/vr_shell.cc
diff --git a/chrome/browser/android/vr_shell/vr_shell.cc b/chrome/browser/android/vr_shell/vr_shell.cc
index edcbb68f0fe05e2c0f75e96229e281b9e33a5b32..103e7278bc0e5ec10fd757e24e4ef581d94ec8ef 100644
--- a/chrome/browser/android/vr_shell/vr_shell.cc
+++ b/chrome/browser/android/vr_shell/vr_shell.cc
@@ -655,7 +655,9 @@ void VrShell::RegisterGamepadDataFetcher(
}
/* static */
-device::mojom::VRPosePtr VrShell::VRPosePtrFromGvrPose(gvr::Mat4f head_mat) {
+device::mojom::VRPosePtr VrShell::VRPosePtrFromGvrPose(gvr::Mat4f head_mat,
+ gvr::Mat4f head_mat_2,
+ int64_t epsilon_nanos) {
device::mojom::VRPosePtr pose = device::mojom::VRPose::New();
pose->orientation.emplace(4);
@@ -682,6 +684,37 @@ device::mojom::VRPosePtr VrShell::VRPosePtrFromGvrPose(gvr::Mat4f head_mat) {
pose->position.value()[2] = decomposed_transform.translate[2];
}
+ // The angular velocity is a 3-element vector pointing along the rotation
+ // axis with magnitude equal to rotation speed in radians/second.
+ //
+ // The spec isn't very clear on details, clarification requested in
+ // https://github.com/w3c/webvr/issues/212 .
+ //
+ // Assume we're using right-hand rule for direction and a headset-attached
+ // frame of reference with +X to the right, +Y up, and +Z backwards (towards
+ // back of head).
+ //
+ // Examples:
+ // - "look up" motion: (positive, 0, 0)
+ // - "turn left" motion: (0, positive, 0)
+ // - "lean head left" motion: (0, 0, positive)
+ //
+ // Assuming that pose prediction is simply based on adding a time * angular
+ // velocity rotation to the pose, we can approximate the angular velocity
+ // from the difference between two successive poses. This is a first order
+ // estimate that assumes small enough rotations so that we can do linear
+ // approximation.
+ pose->angularVelocity.emplace(3);
+ // Assume that epsilon is nonzero since it's a compile-time constant
+ // provided by the caller.
+ double epsilon_seconds = epsilon_nanos * 1e-9;
+ pose->angularVelocity.value()[0] =
billorr 2017/03/24 22:52:51 can you explain the math here in a comment? Looki
klausw 2017/03/27 02:25:52 I'm using https://en.wikipedia.org/wiki/Angular_ve
+ (head_mat_2.m[1][2] - head_mat.m[1][2]) / epsilon_seconds;
+ pose->angularVelocity.value()[1] =
+ -(head_mat_2.m[0][2] - head_mat.m[0][2]) / epsilon_seconds;
+ pose->angularVelocity.value()[2] =
+ (head_mat_2.m[0][1] - head_mat.m[0][1]) / epsilon_seconds;
+
return pose;
}
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | chrome/browser/android/vr_shell/vr_shell_gl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698