Chromium Code Reviews| 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; |
| } |