Adding AK8975 geo-sensor info in sensors.xml.in required by geo-plugin
[platform/core/system/sensord.git] / src / sensor_fusion / standalone / test / quaternion_test / quaternion_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 "../../../quaternion.h"
21
22 int main()
23 {
24         float arr0[4] = {2344.98, 345.24, 456.12, 98.33};
25         float arr1[4] = {0.056, 0.34, -0.0076, 0.001};
26
27         vect<float> v0(4, arr0);
28         vect<float> v1(4, arr1);
29
30         quaternion<float> q0(v0);
31         quaternion<float> q1(v1);
32         quaternion<float> q2((float)2344.98, (float)345.24, (float)456.12, (float)98.33);
33         quaternion<float> q3(q1);
34         quaternion<float> q4;
35
36         cout << "Constructor tests\n";
37         cout << "input\t" << v0 << "\n";
38         cout << "output\t" << q0.m_quat << "\n\n";
39         cout << "input\t" << v1 << "\n";
40         cout << "output\t" << q1.m_quat << "\n\n";
41         cout << "input\t" << v0 << "\n";
42         cout << "output\t" << q2.m_quat << "\n\n";
43         cout << "input\t" << v1 << "\n";
44         cout << "output\t" << q3.m_quat << "\n\n";
45         cout << "default constructor\n";
46         cout << "output\t" << q4.m_quat << "\n\n";
47
48         cout << "Multiplication\n";
49         float val = 0.1;
50         quaternion<float> q5 = q0 * val;
51         cout << "input\t" << q0.m_quat << "\n" << 0.1 << "\n";
52         cout << "output\t" << q5.m_quat << "\n\n";
53         quaternion<float> q6 = q0 * q1;
54         cout << "input\t" << q0.m_quat << "\n" << q1.m_quat << "\n";
55         cout << "output\t" << q6.m_quat << "\n\n";
56
57         cout << "Addition\n";
58         quaternion<float> q7 = q0 + q1;
59         cout << "input\t" << q0.m_quat << "\n" << q1.m_quat << "\n";
60         cout << "output\t" << q7.m_quat << "\n\n";
61
62         cout << "Quaternion Normalization\n";
63         cout << "input\t" << q1.m_quat << "\n";
64         q1.quat_normalize();
65         cout << "output\t" << q1.m_quat << "\n\n";
66
67         cout << "Quaternion Conjugate\n";
68         quaternion<float> q9 = quat_conj(q1);
69         cout << "input\t" << q1.m_quat << "\n";
70         cout << "output\t" << q9.m_quat << "\n\n";
71 }
72