Merge "Adding AK8975 geo-sensor info in sensors.xml.in required by geo-plugin" into...
[platform/core/system/sensord.git] / src / sensor_fusion / standalone / test / euler_angles_test / euler_angles_main.cpp
1 /*
2  * sensord
3  *
4  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #include "../../../euler_angles.h"
21
22 int main()
23 {
24         float arr0[3] = {234.98, 345.24, -56.12};
25         float arr1[3] = {56, -34, 76};
26         float arr2[4] = {0.6, 0.6, -.18, -.44};
27         float arr3[4] = {-0.5, -0.36, .43, .03};
28
29         vect<float> v0(3, arr0);
30         vect<float> v1(3, arr1);
31         vect<float> v2(4, arr2);
32         vect<float> v3(4, arr3);
33
34         quaternion<float> q1(v2);
35         quaternion<float> q2(v3);
36
37         euler_angles<float> e0(v0);
38         euler_angles<float> e1(v1);
39         euler_angles<float> e2((float)234.98, (float)345.24, (float)-56.12);
40         euler_angles<float> e3(e1);
41         euler_angles<float> e4;
42
43         cout << "Constructor tests\n";
44         cout << "input\t" << v0 << "\n";
45         cout << "output\t" << e0.m_ang << "\n\n";
46         cout << "input\t" << v1 << "\n";
47         cout << "output\t" << e1.m_ang << "\n\n";
48         cout << "input\t" << v0 << "\n";
49         cout << "output\t" << e2.m_ang << "\n\n";
50         cout << "input\t" << v1 << "\n";
51         cout << "output\t" << e3.m_ang << "\n\n";
52         cout << "default constructor\n";
53         cout << "output\t" << e4.m_ang << "\n\n";
54
55         cout << "Quaternion to Euler\n";
56         euler_angles<float> e5 = quat2euler(q1);
57         cout << "input\t" << q1.m_quat << "\n";
58         cout << "output\t" << e5.m_ang << "\n\n";
59         euler_angles<float> e8 = quat2euler(q2);
60         cout << "input\t" << q2.m_quat << "\n";
61         cout << "output\t" << e8.m_ang << "\n\n";
62
63         cout << "Radians to Degrees\n";
64         euler_angles<float> e6 = deg2rad(e0);
65         cout << "input\t" << e0.m_ang << "\n";
66         cout << "output\t" << e6.m_ang << "\n\n";
67
68         cout << "Degrees to Radians\n";
69         euler_angles<float> e7 = rad2deg(e6);
70         cout << "input\t" << e6.m_ang << "\n";
71         cout << "output\t" << e7.m_ang << "\n\n";
72 }
73