Adding rotation matrix class implementation 77/23377/2
authorRamasamy <ram.kannan@samsung.com>
Tue, 24 Jun 2014 11:49:47 +0000 (17:19 +0530)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Mon, 30 Jun 2014 08:16:43 +0000 (01:16 -0700)
  - Adding rotation_matrix template class
  - Adding implementation for the rotation_matrix template class
  - Adding rotation_matrix class testing code

signed-off-by: Ramasamy <ram.kannan@samsung.com>
Change-Id: Ife6b6cefd6fa2801d037d6607c7518cc31dfb6b7

src/sensor_fusion/standalone/util/rotation_matrix.cpp [new file with mode: 0644]
src/sensor_fusion/standalone/util/rotation_matrix.h [new file with mode: 0644]
src/sensor_fusion/standalone/util/test/rotation_matrix_test/.cproject [new file with mode: 0644]
src/sensor_fusion/standalone/util/test/rotation_matrix_test/.project [new file with mode: 0644]
src/sensor_fusion/standalone/util/test/rotation_matrix_test/rotation_matrix_main.cpp [new file with mode: 0644]

diff --git a/src/sensor_fusion/standalone/util/rotation_matrix.cpp b/src/sensor_fusion/standalone/util/rotation_matrix.cpp
new file mode 100644 (file)
index 0000000..aecce4f
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+ * sensord
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#if defined (_ROTATION_MATRIX_H) && defined (_MATRIX_H)
+
+#define QUAT_LEN 4
+#define ROT_MAT_ROWS 3
+#define ROT_MAT_COLS 3
+
+template <typename T> T get_sign(T val)
+{
+       return (val >= (T) 0) ? (T) 1 : (T) -1;
+}
+
+template <typename TYPE>
+rotation_matrix<TYPE>::rotation_matrix() : m_rot_mat(ROT_MAT_ROWS, ROT_MAT_COLS)
+{
+
+}
+
+template <typename TYPE>
+rotation_matrix<TYPE>::rotation_matrix(const matrix<TYPE> m)
+{
+       m_rot_mat = m;
+}
+
+template <typename TYPE>
+rotation_matrix<TYPE>::rotation_matrix(const int rows, const int cols, TYPE *mat_data)
+{
+       matrix<TYPE> m(rows, cols, mat_data);
+       m_rot_mat = m;
+}
+
+template <typename TYPE>
+rotation_matrix<TYPE>::rotation_matrix(const rotation_matrix<TYPE>& rm)
+{
+       m_rot_mat = rm.m_rot_mat;
+}
+
+template <typename TYPE>
+rotation_matrix<TYPE>::~rotation_matrix()
+{
+
+}
+
+template <typename TYPE>
+rotation_matrix<TYPE> rotation_matrix<TYPE>::operator =(const rotation_matrix<TYPE>& rm)
+{
+       m_rot_mat = rm.m_rot_mat;
+
+       return *this;
+}
+
+template <typename T>
+rotation_matrix<T> quat2rot_mat(quaternion<T> q)
+{
+       T w, x, y, z;
+       T R[ROT_MAT_ROWS][ROT_MAT_COLS];
+
+       w = q.m_quat.m_vec[0];
+       x = q.m_quat.m_vec[1];
+       y = q.m_quat.m_vec[2];
+       z = q.m_quat.m_vec[3];
+
+       R[0][0] = (2 * w * w) - 1 + (2 * x * x);
+       R[0][1] = 2 * ((x * y) + (w * z));
+       R[0][2] = 2 * ((x * z) - (w * y));
+       R[1][0] = 2 * ((x * y) - (w * z));
+       R[1][1] = (2 * w * w) - 1 + (2 * y * y);
+       R[1][2] = 2 * ((y * z) + (w * x));
+       R[2][0] = 2 * ((x * z) + (w * y));
+       R[2][1] = 2 * ((y * z) - (w * x));
+       R[2][2] = (2 * w * w) - 1 + (2 * z * z);
+
+       rotation_matrix<T> rm(ROT_MAT_ROWS, ROT_MAT_COLS, &R[0][0]);
+
+       return rm;
+}
+
+template <typename T>
+quaternion<T> rot_mat2quat(rotation_matrix<T> rm)
+{
+       T q0, q1, q2, q3;
+
+       q0 = (rm.m_rot_mat.m_mat[0][0] + rm.m_rot_mat.m_mat[1][1] +
+                       rm.m_rot_mat.m_mat[2][2] + (T) 1) / (T) QUAT_LEN;
+       q1 = (rm.m_rot_mat.m_mat[0][0] - rm.m_rot_mat.m_mat[1][1] -
+                       rm.m_rot_mat.m_mat[2][2] + (T) 1) / (T) QUAT_LEN;
+       q2 = (-rm.m_rot_mat.m_mat[0][0] + rm.m_rot_mat.m_mat[1][1] -
+                       rm.m_rot_mat.m_mat[2][2] + (T) 1) / (T) QUAT_LEN;
+       q3 = (-rm.m_rot_mat.m_mat[0][0] - rm.m_rot_mat.m_mat[1][1] +
+                       rm.m_rot_mat.m_mat[2][2] + (T) 1) / (T) QUAT_LEN;
+
+       if(q0 < (T) 0)
+               q0 = (T) 0;
+       if(q1 < (T) 0)
+               q1 = (T) 0;
+       if(q2 < (T) 0)
+               q2 = (T) 0;
+       if(q3 < (T) 0)
+               q3 = (T) 0;
+
+       q0 = sqrt(q0);
+       q1 = sqrt(q1);
+       q2 = sqrt(q2);
+       q3 = sqrt(q3);
+
+       if (q0 >= q1 && q0 >= q2 && q0 >= q3)
+       {
+               q0 *= (T) 1;
+               q1 *= get_sign(rm.m_rot_mat.m_mat[2][1] - rm.m_rot_mat.m_mat[1][2]);
+               q2 *= get_sign(rm.m_rot_mat.m_mat[0][2] - rm.m_rot_mat.m_mat[2][0]);
+               q3 *= get_sign(rm.m_rot_mat.m_mat[1][0] - rm.m_rot_mat.m_mat[0][1]);
+       }
+       else if (q1 >= q0 && q1 >= q2 && q1 >= q3)
+       {
+               q0 *= get_sign(rm.m_rot_mat.m_mat[2][1] - rm.m_rot_mat.m_mat[1][2]);
+               q1 *= (T) 1;
+               q2 *= get_sign(rm.m_rot_mat.m_mat[1][0] + rm.m_rot_mat.m_mat[0][1]);
+               q3 *= get_sign(rm.m_rot_mat.m_mat[0][2] + rm.m_rot_mat.m_mat[2][0]);
+       }
+       else if (q2 >= q0 && q2 >= q1 && q2 >= q3)
+       {
+               q0 *= get_sign(rm.m_rot_mat.m_mat[0][2] - rm.m_rot_mat.m_mat[2][0]);
+               q1 *= get_sign(rm.m_rot_mat.m_mat[1][0] + rm.m_rot_mat.m_mat[0][1]);
+               q2 *= (T) 1;
+               q3 *= get_sign(rm.m_rot_mat.m_mat[2][1] + rm.m_rot_mat.m_mat[1][2]);
+       }
+       else if(q3 >= q0 && q3 >= q1 && q3 >= q2)
+       {
+               q0 *= get_sign(rm.m_rot_mat.m_mat[1][0] - rm.m_rot_mat.m_mat[0][1]);
+               q1 *= get_sign(rm.m_rot_mat.m_mat[2][0] + rm.m_rot_mat.m_mat[0][2]);
+               q2 *= get_sign(rm.m_rot_mat.m_mat[2][1] + rm.m_rot_mat.m_mat[1][2]);
+               q3 *= (T) 1;
+       }
+
+       quaternion<T> q(-q0, q1, q2, q3);
+
+       return quat_normalize(q);
+}
+
+#endif /* _ROTATION_MATRIX_H */
diff --git a/src/sensor_fusion/standalone/util/rotation_matrix.h b/src/sensor_fusion/standalone/util/rotation_matrix.h
new file mode 100644 (file)
index 0000000..7ded3e2
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * sensord
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _ROTATION_MATRIX_H
+#define _ROTATION_MATRIX_H
+
+#include "matrix.h"
+#include "quaternion.h"
+
+template <typename TYPE>
+class rotation_matrix {
+public:
+       matrix<TYPE> m_rot_mat;
+
+       rotation_matrix();
+       rotation_matrix(const matrix<TYPE> m);
+       rotation_matrix(const int rows, const int cols, TYPE *mat_data);
+       rotation_matrix(const rotation_matrix<TYPE>& rm);
+       ~rotation_matrix();
+
+       rotation_matrix<TYPE> operator =(const rotation_matrix<TYPE>& rm);
+
+       template<typename T> friend rotation_matrix<T> quat2rot_mat(quaternion<T> q);
+       template<typename T> friend quaternion<T> rot_mat2quat(rotation_matrix<T> rm);
+};
+
+#include "rotation_matrix.cpp"
+
+#endif /* _ROTATION_MATRIX_H */
diff --git a/src/sensor_fusion/standalone/util/test/rotation_matrix_test/.cproject b/src/sensor_fusion/standalone/util/test/rotation_matrix_test/.cproject
new file mode 100644 (file)
index 0000000..dd975a2
--- /dev/null
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+       <storageModule moduleId="org.eclipse.cdt.core.settings">
+               <cconfiguration id="cdt.managedbuild.config.gnu.exe.debug.1499373039">
+                       <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.1499373039" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+                               <externalSettings/>
+                               <extensions>
+                                       <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+                                       <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                               </extensions>
+                       </storageModule>
+                       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+                               <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.1499373039" name="Debug" parent="cdt.managedbuild.config.gnu.exe.debug">
+                                       <folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1499373039." name="/" resourcePath="">
+                                               <toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.1657640089" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
+                                                       <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.1403769458" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/>
+                                                       <builder buildPath="${workspace_loc:/rotation_matrix_test/Debug}" id="cdt.managedbuild.target.gnu.builder.exe.debug.1913337551" managedBuildOn="true" name="Gnu Make Builder.Debug" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
+                                                       <tool id="cdt.managedbuild.tool.gnu.archiver.base.1985823367" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+                                                       <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.81075479" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
+                                                               <option id="gnu.cpp.compiler.exe.debug.option.optimization.level.144458291" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
+                                                               <option id="gnu.cpp.compiler.exe.debug.option.debugging.level.1617676049" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
+                                                               <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1385045049" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1725272451" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug">
+                                                               <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.exe.debug.option.optimization.level.1066359890" superClass="gnu.c.compiler.exe.debug.option.optimization.level" valueType="enumerated"/>
+                                                               <option id="gnu.c.compiler.exe.debug.option.debugging.level.891955208" superClass="gnu.c.compiler.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
+                                                               <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.474334497" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.1680693541" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug"/>
+                                                       <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.500822673" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug">
+                                                               <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.458103081" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+                                                                       <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+                                                                       <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+                                                               </inputType>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.gnu.assembler.exe.debug.1991501392" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug">
+                                                               <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1939044056" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+                                                       </tool>
+                                               </toolChain>
+                                       </folderInfo>
+                               </configuration>
+                       </storageModule>
+                       <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+               </cconfiguration>
+               <cconfiguration id="cdt.managedbuild.config.gnu.exe.release.1458830237">
+                       <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.1458830237" moduleId="org.eclipse.cdt.core.settings" name="Release">
+                               <externalSettings/>
+                               <extensions>
+                                       <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+                                       <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                               </extensions>
+                       </storageModule>
+                       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+                               <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.1458830237" name="Release" parent="cdt.managedbuild.config.gnu.exe.release">
+                                       <folderInfo id="cdt.managedbuild.config.gnu.exe.release.1458830237." name="/" resourcePath="">
+                                               <toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.1682825129" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release">
+                                                       <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.830391551" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/>
+                                                       <builder buildPath="${workspace_loc:/rotation_matrix_test/Release}" id="cdt.managedbuild.target.gnu.builder.exe.release.653010452" managedBuildOn="true" name="Gnu Make Builder.Release" superClass="cdt.managedbuild.target.gnu.builder.exe.release"/>
+                                                       <tool id="cdt.managedbuild.tool.gnu.archiver.base.334338296" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+                                                       <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.2074310611" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release">
+                                                               <option id="gnu.cpp.compiler.exe.release.option.optimization.level.2090959282" superClass="gnu.cpp.compiler.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
+                                                               <option id="gnu.cpp.compiler.exe.release.option.debugging.level.1179038055" superClass="gnu.cpp.compiler.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
+                                                               <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.595665964" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.1085444945" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release">
+                                                               <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.1641075871" superClass="gnu.c.compiler.exe.release.option.optimization.level" valueType="enumerated"/>
+                                                               <option id="gnu.c.compiler.exe.release.option.debugging.level.740414662" superClass="gnu.c.compiler.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
+                                                               <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.346566956" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.gnu.c.linker.exe.release.943008387" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release"/>
+                                                       <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.174795412" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release">
+                                                               <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.414400585" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+                                                                       <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+                                                                       <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+                                                               </inputType>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.gnu.assembler.exe.release.1690399555" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release">
+                                                               <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1059040610" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+                                                       </tool>
+                                               </toolChain>
+                                       </folderInfo>
+                               </configuration>
+                       </storageModule>
+               </cconfiguration>
+       </storageModule>
+       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+               <project id="rotation_matrix_test.cdt.managedbuild.target.gnu.exe.2037625790" name="Executable" projectType="cdt.managedbuild.target.gnu.exe"/>
+       </storageModule>
+       <storageModule moduleId="scannerConfiguration">
+               <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+               <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.1458830237;cdt.managedbuild.config.gnu.exe.release.1458830237.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.2074310611;cdt.managedbuild.tool.gnu.cpp.compiler.input.595665964">
+                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+               </scannerConfigBuildInfo>
+               <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.1458830237;cdt.managedbuild.config.gnu.exe.release.1458830237.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.1085444945;cdt.managedbuild.tool.gnu.c.compiler.input.346566956">
+                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+               </scannerConfigBuildInfo>
+               <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1499373039;cdt.managedbuild.config.gnu.exe.debug.1499373039.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.81075479;cdt.managedbuild.tool.gnu.cpp.compiler.input.1385045049">
+                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+               </scannerConfigBuildInfo>
+               <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1499373039;cdt.managedbuild.config.gnu.exe.debug.1499373039.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1725272451;cdt.managedbuild.tool.gnu.c.compiler.input.474334497">
+                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+               </scannerConfigBuildInfo>
+       </storageModule>
+</cproject>
diff --git a/src/sensor_fusion/standalone/util/test/rotation_matrix_test/.project b/src/sensor_fusion/standalone/util/test/rotation_matrix_test/.project
new file mode 100644 (file)
index 0000000..6e760b0
--- /dev/null
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>rotation_matrix_test</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+                       <triggers>clean,full,incremental,</triggers>
+                       <arguments>
+                               <dictionary>
+                                       <key>?name?</key>
+                                       <value></value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.append_environment</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.autoBuildTarget</key>
+                                       <value>all</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.buildArguments</key>
+                                       <value></value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.buildCommand</key>
+                                       <value>make</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.buildLocation</key>
+                                       <value>${workspace_loc:/rotation_matrix_test/Debug}</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
+                                       <value>clean</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.contents</key>
+                                       <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+                                       <value>false</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.enableFullBuild</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.fullBuildTarget</key>
+                                       <value>all</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.stopOnError</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+                                       <value>true</value>
+                               </dictionary>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+                       <triggers>full,incremental,</triggers>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.tizen.nativecpp.apichecker.core.builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.cdt.core.cnature</nature>
+               <nature>org.eclipse.cdt.core.ccnature</nature>
+               <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+               <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+               <nature>org.tizen.nativecpp.apichecker.core.tizenCppNature</nature>
+       </natures>
+</projectDescription>
diff --git a/src/sensor_fusion/standalone/util/test/rotation_matrix_test/rotation_matrix_main.cpp b/src/sensor_fusion/standalone/util/test/rotation_matrix_test/rotation_matrix_main.cpp
new file mode 100644 (file)
index 0000000..fa1b639
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * sensord
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "../../rotation_matrix.h"
+
+int main()
+{
+       float arr1[3][3] = {{20.2, 40.5, 10.0}, {3.6, 52.0, 5.5}, {1.0, 45.5, 66.6}};
+       float arr2[3][3] = {{2.24, 0.5, 0.023}, {3.675, 5.32, 0.556}, {1.023, 45.75, 621.6}};
+       float arr3[3][3] = {{4.75, 0.65, 0.123}, {0.075, 5.302, 0.56}, {1.113, 0.475, 2.362}};
+
+       matrix<float> m1(3, 3, (float *) arr1);
+       matrix<float> m2(3, 3, (float *) arr2);
+       matrix<float> m3(3, 3, (float *) arr3);
+
+       rotation_matrix<float> rm0, rm5;
+       rotation_matrix<float> rm1(m1);
+       rotation_matrix<float> rm2(m2);
+       rotation_matrix<float> rm3(m3);
+       rotation_matrix<float> rm4(3, 3, (float *) arr1);
+
+       quaternion<float> q0(-0.612372, 0.456436, 0.456436, 0.456436);
+       quaternion<float> q1;
+
+       cout << "Constructor tests\n";
+       cout << "input\n" << m1 << "\n";
+       cout << "output\n" << rm1.m_rot_mat << "\n\n";
+       cout << "input\n" << m2 << "\n";
+       cout << "output\n" << rm2.m_rot_mat << "\n\n";
+       cout << "input\n" << m3 << "\n";
+       cout << "output\n" << rm3.m_rot_mat << "\n\n";
+       cout << "input\n" << m1 << "\n";
+       cout << "output\n" << rm4.m_rot_mat << "\n\n";
+       cout << "default constructor\n";
+       cout << "output\n" << rm0.m_rot_mat << "\n\n";
+
+       cout << "Quaternion to Rotation Matrix\n";
+       cout << "input\n" << q0.m_quat << "\n";
+       rm0 = quat2rot_mat(q0);
+       cout << "output\n" << rm0.m_rot_mat << "\n\n";
+
+       cout << "Rotation Matrix to Quaternion\n";
+       cout << "input\n" << rm0.m_rot_mat << "\n";
+       q1 = rot_mat2quat(rm0);
+       cout << "output\n" << q1.m_quat << "\n\n";
+}