conversions.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2014 Google Inc. All Rights Reserved.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef TANGO_GL_GL_TANGO_CONVERSIONS_H_
00018 #define TANGO_GL_GL_TANGO_CONVERSIONS_H_
00019 
00020 #define GLM_FORCE_RADIANS
00021 
00022 #include "glm/glm.hpp"
00023 #include "glm/gtc/matrix_transform.hpp"
00024 #include "glm/gtc/quaternion.hpp"
00025 
00026 namespace tango_gl {
00027 namespace conversions {
00028 
00033 inline glm::vec3 Vec3FromArray(const double* array) {
00034   return glm::vec3(array[0], array[1], array[2]);
00035 }
00036 
00041 inline glm::quat QuatFromArray(const double* array) {
00042   // Note GLM expects arguments in order {w, x, y, z}.
00043   return glm::quat(array[3], array[0], array[1], array[2]);
00044 }
00045 
00054 inline glm::mat4 TransformFromArrays(const double* A_p_B, const double* A_q_B) {
00055   glm::vec3 glm_A_p_B = Vec3FromArray(A_p_B);
00056   glm::quat glm_A_q_B = QuatFromArray(A_q_B);
00057   return glm::translate(glm::mat4(1.0f), glm_A_p_B) * glm::mat4_cast(glm_A_q_B);
00058 }
00059 
00068 inline glm::mat4 TransformFromVecAndQuat(const glm::vec3& A_p_B, const glm::quat& A_q_B) {
00069   return glm::translate(glm::mat4(1.0f), A_p_B) * glm::mat4_cast(A_q_B);
00070 }
00071 
00081 inline glm::vec3 Vec3TangoToGl(const glm::vec3& tango_vec) {
00082   return glm::vec3(tango_vec.x, tango_vec.z, -tango_vec.y);
00083 }
00084 
00094 inline glm::vec3 Vec3GlToTango(const glm::vec3& gl_vec) {
00095   return glm::vec3(gl_vec.x, -gl_vec.z, gl_vec.y);
00096 }
00097 
00107 glm::quat QuatTangoToGl(const glm::quat& tango_q_any);
00108 
00114 glm::mat4 opengl_world_T_tango_world();
00115 
00121 glm::mat4 color_camera_T_opengl_camera();
00122 
00128 glm::mat4 depth_camera_T_opengl_camera();
00129 
00130 }  // namespace conversions
00131 }  // namespace tango_gl
00132 #endif  // TANGO_GL_GL_TANGO_CONVERSIONS_H_


rtabmap
Author(s): Mathieu Labbe
autogenerated on Sat Jul 23 2016 11:44:15