Questions tagged [glm-math]

GLM is a C++ math library designed to mimic the OpenGL Shading Language's math functions and types (vectors, matrices) as closely as possible.

GLM is a C++ math library designed to mimic the OpenGL Shading Language's math functions and types (vectors, matrices) as closely as possible.

OpenGL Mathematics (GLM) is a header only C++ mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specifications.

Do not confuse the tags and (Generalized linear models)

1335 questions
15
votes
2 answers

Quaternion to Matrix using glm

I am trying to convert quat in glm to mat4. My code is : #include #include #include #include using namespace std; int main() { glm::mat4 MyMatrix=glm::mat4(); glm::quat…
Vishnu Murali
  • 240
  • 1
  • 2
  • 9
14
votes
2 answers

Why does glm::vec represent vec values as unions?

I was looking at vec4 glm's source code implementation, and I was wondering why they represent vector values with a union, instead of primitive data types like float or int? This is the code I found in vec4 implementation: union { T x, r, s;…
pureofpure
  • 1,060
  • 2
  • 12
  • 31
14
votes
3 answers

Quaternions -> Euler Angles -> Rotation Matrix trouble (GLM)

I'm writing a program that loads a file containing a scene description and then displays it using OpenGL. I'm using GLM for all of my math operations. Rotations in the scene file are stored in quaternion format. My scene management systems takes…
iondune
  • 283
  • 1
  • 2
  • 7
13
votes
1 answer

std::array incomplete type error with an array of std::tuple

I am getting some strange behaviour with a C++11 std::array. When I try to compile with std::array, 6> myTuples; as a member variable, I get these errors: mingw32\4.7.2\include\c++\array:-1: In instantiation of 'struct…
steve9164
  • 426
  • 2
  • 11
  • 22
12
votes
4 answers

glm::ivec2 as key in unordered map

lately I am more a user of the Scala Programming Language than C++, And now I am frustrated in porting a very simple line of code val map = new HashMap[Vec2i,Entity] it simply refuses to compile in C++ with strange template errors. The equivalent…
Arne
  • 7,921
  • 9
  • 48
  • 66
12
votes
1 answer

glm translate matrix does not translate the vector

I have crossed some very simple error while started using glm (in VS2010). I have got this short code: glm::mat4 translate = glm::translate(glm::mat4(1.f), glm::vec3(2.f, 0.f, 0.f)); glm::vec4 vector(1.f,1.f,1.f,0.f); glm::vec4 transformedVector =…
user2661133
  • 121
  • 1
  • 1
  • 5
11
votes
1 answer

Incorrect order of matrix values in glm?

I started using GLM library to do mathematics operations over OpenGL 3 and GLSL. I need an orthographic projection to draw 2D graphics, so I writed this simple code: glm::mat4 projection(1.0); projection = glm::ortho( 0.0f, 640.0f, 480.0f, 0.0f,…
Dani
  • 850
  • 2
  • 8
  • 14
11
votes
2 answers

Simple Oriented Bounding Box OBB collision detection explaining

I can implement the AABB method to detect collisions it is easy and cheap but I want to implement OBB for more accuracy so I create the bounding box with the model initialization it is consists of 8 bounding vertices and center, each frame I…
11
votes
2 answers

How to read the values from a glm::mat4

I have a glm::mat4 matrix and I need to get the values into a double[16] array. Any ideas on how to solve this problem??
Edvin
  • 1,841
  • 4
  • 16
  • 23
11
votes
1 answer

How can I transform a glm::vec3 by a glm::mat4

I want to transform a glm::vec3 (camera.target) by a glm::mat4 (camera.rotationMatrix). I try multiply this give me an error:error: no match for 'operator*' in 'originalTarget * ((Camera*)this)->Camera::rotationMatrix. I suppose that I can't…
user1873578
  • 111
  • 1
  • 1
  • 4
10
votes
1 answer

How to tell CMAKE to download some necessary header files (more precisely GLM math library) WITHOUT TRYING TO COMPILE THEM?

I am setting up a CMAKE project that uses a lot of ExternalProjects. To build one of them (CEGUI), I need to download the GLM (OpenGL Math Library). This Library is include only library, which means that you mustn't compile it. There are some test…
Danduk82
  • 769
  • 1
  • 10
  • 29
10
votes
5 answers

Converting glm::lookat matrix to quaternion and back

I am using glm to create a camera class, and I am running into some problems with a lookat function. I am using a quaternion to represent rotation, but I want to use glm's prewritten lookat function to avoid duplicating code. This is my lookat…
jbills
  • 694
  • 1
  • 7
  • 22
10
votes
3 answers

how to setup the GLM library in visual studio 2012

how do i setup the GLM Library in visual studio 2012? first i tried extract the glm librar directory to my VS 2012 project directory (the directory containing the glm library is named glm-0.9.4.4). then i tried to add glm-0.9.4.4 to PROJECT ->…
DontCareBear
  • 825
  • 2
  • 11
  • 25
10
votes
4 answers

How to optimize "u[0]*v[0] + u[2]*v[2]" code line with SSE or GLSL

I have the following function (from the opensource project "recast navigation"): /// Derives the dot product of two vectors on the xz-plane. (@p u . @p v) /// @param[in] u A vector [(x, y, z)] /// @param[in] v A vector [(x, y,…
myWallJSON
  • 9,110
  • 22
  • 78
  • 149
9
votes
2 answers

GLM: How to transpose a vector?

Maybe I'm just missing something in the docs, but it seem it's not possible with GLM to take the transpose of a vector. I also see no mat3x1 or mat1x3 types. Also glm::transpose doesn't work for vectors. Am I missing something or is this just a…
aeskreis
  • 1,923
  • 2
  • 17
  • 24
1
2
3
88 89