conversions.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Google Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef TANGO_GL_GL_TANGO_CONVERSIONS_H_
18 #define TANGO_GL_GL_TANGO_CONVERSIONS_H_
19 
20 #define GLM_FORCE_RADIANS
21 
22 #include "glm/glm.hpp"
24 #include "glm/gtc/quaternion.hpp"
25 
26 namespace tango_gl {
27 namespace conversions {
28 
33 inline glm::vec3 Vec3FromArray(const double* array) {
34  return glm::vec3(array[0], array[1], array[2]);
35 }
36 
41 inline glm::quat QuatFromArray(const double* array) {
42  // Note GLM expects arguments in order {w, x, y, z}.
43  return glm::quat(array[3], array[0], array[1], array[2]);
44 }
45 
54 inline glm::mat4 TransformFromArrays(const double* A_p_B, const double* A_q_B) {
55  glm::vec3 glm_A_p_B = Vec3FromArray(A_p_B);
56  glm::quat glm_A_q_B = QuatFromArray(A_q_B);
57  return glm::translate(glm::mat4(1.0f), glm_A_p_B) * glm::mat4_cast(glm_A_q_B);
58 }
59 
68 inline glm::mat4 TransformFromVecAndQuat(const glm::vec3& A_p_B, const glm::quat& A_q_B) {
69  return glm::translate(glm::mat4(1.0f), A_p_B) * glm::mat4_cast(A_q_B);
70 }
71 
81 inline glm::vec3 Vec3TangoToGl(const glm::vec3& tango_vec) {
82  return glm::vec3(tango_vec.x, tango_vec.z, -tango_vec.y);
83 }
84 
94 inline glm::vec3 Vec3GlToTango(const glm::vec3& gl_vec) {
95  return glm::vec3(gl_vec.x, -gl_vec.z, gl_vec.y);
96 }
97 
107 glm::quat QuatTangoToGl(const glm::quat& tango_q_any);
108 
115 
122 
129 
130 } // namespace conversions
131 } // namespace tango_gl
132 #endif // TANGO_GL_GL_TANGO_CONVERSIONS_H_
highp_vec3 vec3
Definition: type_vec.hpp:392
glm::vec3 Vec3TangoToGl(const glm::vec3 &tango_vec)
Convert (re-express, or rotate) a vector from the Tango ADF (or start- of-service) frame convention [...
Definition: conversions.h:81
f
glm::vec3 Vec3FromArray(const double *array)
Creates a glm::vec3 from double[3] = {x, y, z}. This is designed to work with the TangoPoseData...
Definition: conversions.h:33
highp_quat quat
Quaternion of default single-precision floating-point numbers.
Definition: fwd.hpp:68
glm::vec3 Vec3GlToTango(const glm::vec3 &gl_vec)
Convert (re-express, or rotate) a vector from the typical OpenGl world frame convention [right...
Definition: conversions.h:94
glm::mat4 color_camera_T_opengl_camera()
Definition: conversions.cpp:30
glm::mat4 depth_camera_T_opengl_camera()
Definition: conversions.cpp:38
GLM_FUNC_DECL detail::tmat4x4< T, P > mat4_cast(detail::tquat< T, P > const &x)
glm::mat4 TransformFromArrays(const double *A_p_B, const double *A_q_B)
Creates a glm::mat4 rigid-frame transformation matrix from two arrays. This is designed for the Tango...
Definition: conversions.h:54
glm::quat QuatTangoToGl(const glm::quat &tango_q_frame)
Given a quaternion representing the rotation matrix tango_R_any, returns the quaternion representing ...
Definition: conversions.cpp:44
glm::mat4 TransformFromVecAndQuat(const glm::vec3 &A_p_B, const glm::quat &A_q_B)
Creates a glm::mat4 rigid-frame transformation matrix from glm::vec3 and glm::quat. This is designed for the TangoPoseData translation and orientation fields.
Definition: conversions.h:68
glm::quat QuatFromArray(const double *array)
Creates a glm::quat from double[4] = {x, y, z, w}. This is designed to work with the TangoPoseData...
Definition: conversions.h:41
GLM_FUNC_DECL detail::tmat4x4< T, P > translate(detail::tmat4x4< T, P > const &m, detail::tvec3< T, P > const &v)
glm::mat4 opengl_world_T_tango_world()
Definition: conversions.cpp:22


rtabmap
Author(s): Mathieu Labbe
autogenerated on Wed Jun 5 2019 22:41:31