memo: glm | Basics

OpenGL Mathematics (GLM)

Create Matrix

mat3

(2024-02-01)

Example: 3DGS

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#include <glm/glm.hpp>
#include<glm/gtx/string_cast.hpp>
#include <iostream>

int main(){
    glm::mat3 S = glm::mat3(1.0f);  // identity matrix

    // Make scaling matrix
    S[0][0] = 2;
    S[1][1] = 3;
    S[2][2] = 4;

    std::cout << glm::to_string(S) << std::endl;
    return 0;
}