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

Side by Side Diff: content/browser/vr/vr_transform_util_unittest.cc

Issue 1200303002: Android WebVR implementation, Cardboard 0.5.5 SDK (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed feedback from jochen@ Created 5 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/vr/vr_transform_util.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace content {
9
10 void EXPECT_QUATERNION(
11 float x, float y, float z, float w,
12 const VRVector4Ptr& quat) {
13 EXPECT_NEAR(x, quat->x, 0.0001f);
14 EXPECT_NEAR(y, quat->y, 0.0001f);
15 EXPECT_NEAR(z, quat->z, 0.0001f);
16 EXPECT_NEAR(w, quat->w, 0.0001f);
17 }
18
19 TEST(VRTransformUtilTest, IdentityMatrixToQuaternion) {
20 float matrix[9] = {
21 1.0f, 0.0f, 0.0f,
22 0.0f, 1.0f, 0.0f,
23 0.0f, 0.0f, 1.0f
24 };
25
26 VRVector4Ptr orientation = MatrixToOrientationQuaternion(
27 &matrix[0], &matrix[3], &matrix[6]);
28
29 EXPECT_QUATERNION(0.0f, 0.0f, 0.0f, 1.0f, orientation);
30 }
31
32 TEST(VRTransformUtilTest, 90DegXMatrixToQuaternion) {
33 float rad = M_PI * 0.5f;
34 float matrix[9] = {
35 1.0f, 0.0f, 0.0f,
36 0.0f, cos(rad), -sin(rad),
37 0.0f, sin(rad), cos(rad)
38 };
39
40 VRVector4Ptr orientation = MatrixToOrientationQuaternion(
41 &matrix[0], &matrix[3], &matrix[6]);
42
43 EXPECT_QUATERNION(0.7071f, 0.0f, 0.0f, 0.7071f, orientation);
44 }
45
46 TEST(VRTransformUtilTest, 180DegYMatrixToQuaternion) {
47 float matrix[9] = {
48 cos(M_PI), 0.0f, sin(M_PI),
49 0.0f, 1.0f, 0.0f,
50 -sin(M_PI), 0.0f, cos(M_PI)
51 };
52
53 VRVector4Ptr orientation = MatrixToOrientationQuaternion(
54 &matrix[0], &matrix[3], &matrix[6]);
55
56 EXPECT_QUATERNION(0.0f, 1.0f, 0.0f, 0.0f, orientation);
57 }
58
59 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698