util.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_UTIL_H_
00018 #define TANGO_GL_GL_UTIL_H_
00019 #define GLM_FORCE_RADIANS
00020 
00021 #define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
00022 
00023 #include <stdlib.h>
00024 #include <jni.h>
00025 #include <android/log.h>
00026 #include <GLES2/gl2.h>
00027 #include <GLES2/gl2ext.h>
00028 
00029 #include "glm/glm.hpp"
00030 #include "glm/gtc/matrix_transform.hpp"
00031 #include "glm/gtc/quaternion.hpp"
00032 #include "glm/gtc/type_ptr.hpp"
00033 #include "glm/gtx/matrix_decompose.hpp"
00034 
00035 #define LOG_TAG "rtabmap"
00036 #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
00037 #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
00038 #define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__)
00039 #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
00040 
00041 #ifndef M_PI
00042 #define M_PI 3.1415926f
00043 #endif
00044 
00045 #define RADIAN_2_DEGREE 57.2957795f
00046 #define DEGREE_2_RADIANS 0.0174532925f
00047 
00048 namespace tango_gl {
00049 namespace util {
00050   void CheckGlError(const char* operation);
00051 
00052   GLuint CreateProgram(const char* vertex_source,
00053                        const char* fragment_source);
00054 
00055   void DecomposeMatrix(const glm::mat4& transform_mat,
00056                        glm::vec3& translation,
00057                        glm::quat& rotation,
00058                        glm::vec3& scale);
00059 
00060   // Get a 3x1 column from the upper 3x4 of a transformation matrix. Columns
00061   // 0, 1, 2 are the rotation/scale portion, and column 3 is the translation.
00062   glm::vec3 GetColumnFromMatrix(const glm::mat4& mat, const int col);
00063 
00064   // Get the translation component of a transformation matrix.
00065   glm::vec3 GetTranslationFromMatrix(const glm::mat4& mat);
00066 
00067   float Clamp(float value, float min, float max);
00068   void PrintMatrix(const glm::mat4& matrix);
00069   void PrintVector(const glm::vec3& vector);
00070   void PrintQuaternion(const glm::quat& quat);
00071 
00072   glm::vec3 LerpVector(const glm::vec3& x, const glm::vec3& y, float a);
00073   float DistanceSquared(const glm::vec3& v1, const glm::vec3& v2);
00074 
00075   bool SegmentAABBIntersect(const glm::vec3& aabb_min, const glm::vec3& aabb_max,
00076                         const glm::vec3& start, const glm::vec3& end);
00077 
00078   glm::vec3 ApplyTransform(const glm::mat4& mat, const glm::vec3& vec);
00079 }  // namespace util
00080 }  // namespace tango_gl
00081 #endif  // TANGO_GL_RENDERER_GL_UTIL


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