- Glm scale matrix. x, s. A function that accepts up to three arguments. Take this Rotate function. m_transform = glm::translate(glm::mat4(1. The three parameters indicate the desired scale factor along each of the three axes. glm::mat4 scaleMatrix = glm::scale(glm::mat4(1. Type parameters: T Value type used to build the matrix. y, s,z)); While during the program I perform scale and translation operations, and then save p and s values back to the file. Object center coordinates aren't (0,0,0). hpp> need to be included to use these functionalities. y. Same with rotation, multiplying the two rotation matrices generates the combined matrix that contains the local rotation of the child which is then further rotated by the parent rotation value. Check out the implementation. 0f , 10. is rightmost when you're using column vectors, then you can simplify this to just look at the lengths of the transformed axis vectors. Transforms a matrix with a rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in degrees. y, angleAxis. You can find GLM at: a logical value indicating whether model frame should be included as a component of the returned value. tmat4x4<T, P> const & m, T angle, tvec3<T, P> const & v. Can be in sparse matrix format (inherit from class "sparseMatrix" as in package Matrix). The default constructor leaves the fields of the matrix uninitialized. This means that, in your definition, 1. Dec 27, 2021 · Hello I have a 4x4 model matrix m that transforms an object from local space to world space. Scale to have a width of 600 and a height of 100. m_mesh. 0f), glm::vec3(2. He used some old self-written lib for it. This is the rotation part, R. 250 0. matrix = p. y, p. The current matrix (see glMatrixMode) is multiplied by this scale matrix, and the product replaces the current matrix as if glMultMatrix were called with the following matrix as its Jan 13, 2011 · GLM is much simpler for doing the kinds of stuff that graphics work needs. Contribute to g-truc/glm development by creating an account on GitHub. 0f)*scale does not result in a valid scaling matrix. However, the term "scale" has been used inconsistently in GLM terminology and so is best Jun 17, 2021 · I have researched this a lot and so far all the examples, tutorials etc always use the following order: Scale * Rotate * Translate but for some reason this order must always be backwards in my Scene Graph. If you pass 0. 0f), glm::vec3(0. 4. I want to know if there are similar functions that will acheive the same outcome that take different parameters. These functions define a matrix and multiply the input matrix by the newly specified matrix. Dec 19, 2015 · None of the other answers are really complete answers because they don't treat special cases like cross(. The matrix is in column major like this: The matrix m has initial value equal to glm::mat4(1. However fast it might be, for graphics work, it isn’t particularly useful. Converts a pure rotation 4 * 4 matrix to a quaternion. GLM inherits from statsmodels. Note, the multiplication has to be "read" from the left to the right. 0f) but if camera goes 400 in y direction i want this matrix to be like glm::ortho(-410. In both cases, you specify the Identity matrix (glm::mat4(1. response variable. Passing null/undefined/no value for far will generate infinite projection matrix. I wanted to know if glm does zero initialise its classes and tried it. com/playlist?list=PLvv0ScY6vfd9zlZkIIqGDeG5TUWswkMox Find full courses on: https://courses. detail::tmat4x4<T> glm::scale. M_origin += C-A'. Scale and rotation share the upper left 3×3 submatrix; let's call this T for the following. 0 1 0) Note that to convert from degrees to radians, use glm::radians(degrees) That takes the Model matrix and applies rotation on top of all the operations that are already in there. Just as you should be doing in GLSL (unless you transposed the matrix on upload). 625 0. 5, 0. 0, 02/08/2015. I got some code from my teacher/prof and I need to implement this part of the code using glm. 0 in the last diagonal element, e. Up until the point where they started passing matrices to the vertex shader to translate the triangle they where drawing I was following along. This is the shader program where it starts to go wrong: vec4 v = vec4(vertexPosition_modelspace,1); // Transform an homogeneous 4D vector. So you start with a 4x4 matrix, the translation vector is the first 3 values in the last column. Oct 26, 2015 · Since GLM is designed to mimic GLSL and is designed to work with OpenGL, its matrices are column-major. GLM expects its angles in radians so we convert the degrees to radians Sep 4, 2016 · modelMatrix = glm::translate(modelMatrix, glm::vec3(p. But i cannot figure out how to calculate the rotation portion of the matrix. This array can be 1d or 2d. You are setting the whole model matrix there which has also scale and translation. FinalFanatic. GLM provides classes and functions designed and implemented with the same naming conventions and functionalities than GLSL so that anyone who knows GLSL, can use GLM as well in C++. 总结GLM库中glm::transform(位移), glm:scale(缩放), glm::rotate(旋转). e. There is this section: Oct 8, 2016 · Stack Overflow Public questions & answers; Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Talent Build your employer brand input matrix, of dimension nobs x nvars; each row is an observation vector. m_position); I can assign the camera position successfully, but not rotation. glm::mat4 is a lot shorter than tvmet::mat<float, 4, 4>. (See GLSL Programming/Vector and Matrix Operations) Swap the scale and the translation to solve your issue: glm::mat4 model(1. z)); model = glm::scale(model, scale); return model; } Currently I'm just passing on that rotation vec3 to that angleAxis quaternion parameter but that obviously doesn't work. log(μi) = log(γ) + δti = β0 Apr 1, 2020 · the matrix to scale: v: ReadonlyVec3: the vec3 to scale the matrix by: Source: mat4. You have to pass mModel as the input matrix. To keep it simple, each of these are 4x4 matrices. Jul 27, 2015 · glm::vec3 Translation; glm::vec3 Rotation; //Euler angles glm::vec3 Scale; And make a model view matrix, that way each time one of those three vectors is changed I can pass a shader a new model view matrix. Feb 15, 2024 · Yes, when no glTF animations are playing that target that node, the node's local translation / rotation / scale modifiers are in effect. lines or cylinders etc. A note about Matrix formatting. Jul 29, 2013 · glm::decompose(transformation, scale, rotation, translation, skew,perspective); Keep in mind that the resulting quaternion in not correct. Which is what you get. Oct 14, 2021 · The first two are simple to understand, the child component's world scale will be its own scale multiplied by the parent's scale. Decomposes a model matrix to translations, rotation and scale components. Then, using glm::inverseTranspose() on the 3x3 matrix should give you exactly what you need. Apr 24, 2017 · It is also now implemented in glm, as of version 0. youtube. Quantitative for family="gaussian", or family="poisson" (non-negative counts). this one is simple we just transform A with M without translation lets call it A' and then just correct the resulting position so it goes to C. T const a = angle; Jul 22, 2014 · 3. If you include that condition --- that it's known that the matrix can be written as a product of a single rotation and a single scale --- to the problem statement as an addendum, then I'll give you a complete answer. g. 0f)); Edit: I just stumbled over this page, and it looks as if there has been a glm:scale (float,float,float) overload in 0. 6666667 dat_glm_pred_response cats 0 1 0 0. Translate again -1. 0f, 600. hi! i’d like to create a mat4 from a translation vector, a quaternion and a scalar/vector representing scale. GLM expects its angles in radians so we convert the degrees to radians Transforms a matrix with a rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in degrees. Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping. depending on if you're looking for a pre or a post rotation scaling S. template<typename T > detail::tmat4x4< T > Dec 18, 2014 · The correct solution for your code sample would ( according to here) be. Parameters: m Input matrix multiplied by this translation matrix. A brain MR images tissue segmentation method, Gray Level Multiscale Network (GLM-Net), based on three-dimensional U-Net network, which fused the residual module and dilated convolution for multi-scale feature restoration in the upsampling process of the network decoder to segment the brainMR images into white matter, gray matter, cerebrospinal fluid and tumor. See also: gtc_matrix_transform Jan 5, 2020 · OpenGL Mathematics (GLM) is a header only C++ mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specifications. perspectiveNO(this, fovy, aspect, near, far From GLM_GTC_matrix_transform extension. Mar 5, 2014 · I know of glm::lookAt and understand how it works. mshah. 0f, 800. 0. Builds a translation 4 * 4 matrix created from a vector of 3 components. T = R · S. Then I wanted to understand how it is done and read the source of glm::mat4 template. If you use the opposite matrix multiplication convention (v * M) then you'd normalize the first three rows instead However, if you want to rotate an object around a certain point, then it is scale, point translation, rotation and lastly object translation. method. hpp header files that get compiled in with your source code. Dec 16, 2015 · Feed the values into glm::scale like so: modelMatrix = glm::scale(modelMatrix, glm::vec3(scale)); Remember, that storing matrices provides little benefit because they’re just numbers; they don’t indicate what you really want to do with them. This video shows how we can use this function argument to our Input matrix multiplied by this translation matrix. Then you rotate the axes so the translation takes place on the adjusted axes. Yes, you can wrap that in a typedef, but there’s no need with GLM. pptx. Generally a matrix ( m) is used to transform a vector (v' = m * v). f is the first column of your matrix. 2857143 0. s * c. scale = glm::vec3(1. x, p. 0f and -1. Obviously, because it's being expressed as a line (two points and a width) instead of as a rect (position and size) the way I'm calculating the translation matrix and scale matrix needs to be different to. 0f , 0. ) We have the following object: object. GLM provides classes and functions designed and implemented with the same naming conventions and functionality than GLSL so that anyone who knows GLSL, can use GLM as well in C++. 1. Jan 5, 2024 · Builds a rotation 4 * 4 matrix created from an axis vector and an angle. The first row of your matrix is 1. 技术标签: learnopengl. template<typename T > detail::tmat4x4< T > scale (detail::tvec3< T > const &v) Transforms a matrix with a scale 4 * 4 matrix created from a vector of 3 components. 0, which is rather useless. For each of the following built-in matrix functions, there is both a single-precision floating point version, where all arguments and return values are single precision, and a double-precision floating version, where all arguments and return values are double precision. My problem is that I only know how to tell glm how to translate/rotate at one parameter at a time. 0); Nov 23, 2016 · This is about understanding the glm source. Function Documentation Aug 18, 2018 · model = glm::rotate(model, angleAxis. From GLM_GTC_matrix_transform extension. Edit: As pointed out by sajas, there is a second overload of the glm Jun 12, 2013 · Let's go through an example: You have one child object c and its parent p. In the early stages of a disease epidemic, the rate at which new cases occur can often increase exponentially through time. 0f as the 4th element of the vector. Yes, glm::vec3 and glm::mat4 are initialized, even without providing a constructor value. To understand the math, you should look at the values that are in your rotation matrix. Sep 8, 2011 · I'm using the OpenGL Mathematics Library (glm. x, angleAxis. void Display::Translate( double x, double y, double z) {. fit" uses iteratively reweighted least squares (IWLS): the alternative "model. t * p. Jul 23, 2019 · data. float aaa[16]; glm::mat4 bbb(aaa); This doesn't work. Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question. io/ Join a In terms of matrix transformations, you can start with a scale and apply the glm::lookAt() matrix afterwards. base. ): Mar 29, 2012 · I have a glm::quat that holds the rotation and a glm::vec3 that holds the point to which it needs to be translated. The vertices resulting from the clipping are then undergoing the perspective divide, i. This is your x scale value. model); when I hand the data. For anyone interested in the issue, it was with: ortho = glm::ortho(0, width, height, 0, 0, 1000); Where the arguments are supplied as integers, not floats. axis Rotation axis, recommended to be normalized. GLM is a set of C++ classes and functions that fill in the programming gaps in writing the basic vector and matrix mathematics for computer graphics applications. The every method calls the predicate function for each element in the array until the predicate returns a value which is coercible to the Boolean value false, or until the end of the array. . 0)); trans = glm::scale (trans, glm::vec3(0. Determines whether all the members of an array satisfy the specified test. GLM isn’t a library – it is all specified in *. 0f) which is the identity matrix, and then it’s updated by rotation in this way: m = glm::rotate(m, radians, axis); and I’m trying to get the basis vectors Note, since you don't setup a projection matrix, the near and far plane are at -1 respectively at 1, because the normalized device space is in the range [-1, 1]. g-truc. 2. 0f) but I want to do this in the shader with matrix multiplication or addition Jul 16, 2021 · I implemented object outlining in OpenGL by following this tutorial, but the problem is that when I scale up the object, it doesn’t scale from it’s center and because of that the outline looks off. Such a model can be turned into GLM form, by using a log link so that. f, which when dot-producted by 5. We want the first 3 components to form a unit 3-vector, which they already do thanks to the normalization in the planeFromPointNormal function. or. f, 2. t * c. And if you have a column-major matrix, you left-multiply it with the vector. ,. Dec 27, 2018 · Short Answer. But I can only find transformation functions without simd vectors or matrix in examples like this the top right corner of the OpenGL image to represent coordinates (1586267400, 11900) In order to do that I plan to join three transformation matrices: Translate to the origin of coordinates x=1586266800 and y=11800. It returns its conjugate! To fix this add this to your code: rotation=glm::conjugate(rotation); answered Oct 13, 2016 at 15:08. This project isn Oct 29, 2022 · Full OpenGL Series Playlist: https://www. model. 0, 0. You do the LU decomposition of S, and try to be a little more general and go for an "LUD" decomposition (ie. : s 0 0 0 0 s 0 0 0 0 s 0 0 0 0 1 Jan 11, 2016 · But I don't understand how to calculate the rotation matrix needed. Yes, in generalized linear model (GLM) theory, you can assume that the "dispersion" parameter and the "scale" parameter are the same thing. May 7, 2021 · The 1st argument of glm::scale and glm::translate is the input matrix. Dec 22, 2014 · You can reduce the original 4x4 matrix to a 3x3 matrix by simply dropping the remaining elements. My train of thought is very simple and basic: glm::mat4 trans = glm::mat4(1. #include <glm/gtc/matrix_transform. OpenGL Mathematics (GLM). 1d array of endogenous response variable. #include <glm/gtc/type_ptr. It will also avoid having to use the somewhat awkward trick of adding 0. 0f, 2. The length of these axis are the scale values as with only rotation the length is 1. Rotation angle expressed in radians if GLM_FORCE_RADIANS is defined or degrees otherwise. Parameters: m Input matrix multiplied by this rotation matrix. Equivalent to Mat4. Translation and scaling looks good, but rotation is performed around ( Jan 13, 2012 · All you need to do is (see here) Model = glm::rotate(Model, angle_in_radians, glm::vec3(x, y, z)); // where x, y, z is axis of rotation (e. <glm/gtx/decomposition. Asking for help, clarification, or responding to other answers. Jan 18, 2022 · // We (and most of computer graphics) treat matrices in row-major order // But, internally, glm stores them in column-major order // Just go ahead and use glm as if you didn't know this and everything will work fine // The only time you need to actually know this is if you want to access the matrix by [col][row], such as when printing // This function prints your matrix in a way that is Nov 9, 2018 · $\begingroup$ I don't think that's "safe to assume" at all without a lot more context, but that's just me. A valid scaling matrix would contain the scaling value on the first three elements of the diagonal, but have a value of 1. LikelihoodModel. 1f, 100. actually the result is vec4, after multiplication, the last component is trimmed, if you need the result’s last component then don’t use this function and consider to use glm_mat4_mulv () Parameters: [in] m mat4 (affine transform) angle = +/- acos(dot(B-A,D-C) / |B-A|*|D-C|) translation. Jan 5, 2024 · Finally, if you are used to the old openFrameworks vector math classes you would multiply vector and matrices like: ofVec3 v; ofVec3f projected = v * model * view * projection; with glm as in glsl the multiplication order is the opposite so now you would do: glm::vec3 v; glm::vec3 projected = projection * view * model * v; detail_func_common. lower/upper/diagonal) (hard to find anything online on an LUD decomp). after the projection step), the primitives are clipped. model = glm::translate( model, position ); Description. T = S · R. 750 I used the scale function to see if it can help in gaining more accuracy: Generates a perspective projection matrix with the given bounds. The default method "glm. js, line 624; Returns: out Type mat4 May 16, 2023 · model = glm::mat4(1. angle Rotation angle expressed in radians. there is transform () to manipulate the translation part of a matrix but rotate () only accepts an axis and a rotation vector and not a quaternion to manipulate the orientation part of a Apr 11, 2016 · (where M is your composed matrix, T is a Translation matrix, R rotation, S scale, and v is a vector you want to transform using the matrix)then you can normalize the first three columns of the matrix to get just the T * R part. Aug 6, 2021 · glm::mat4 model = glm::mat4(1. HLSL vertex shader: Jan 9, 2015 · I am having trouble understanding a certain element of the GLM Matrix functions while trying to replicate some of its math to finish off my Matrix4 class for an assignment. Oct 29, 2013 · The OpenGL GLM math library's translate(), rotate(), and scale() calls take an initial matrix. z)); modelMatrix = glm::scale(modelMatrix, glm::vec3(s. I am encountering some issues using GLM, during the implementation of some matrix calculations. model = model_matrix * view_matrix * proj_matrix; data. This is how i currently calculate my front, up, and right vectors: Oct 4, 2019 · I am tying get a model matrix calculated that can be passed on to shaders. w * toRadians, glm::vec3(angleAxis. You should be able to do a matrix multiplication like this (I'm assuming that you've already transformed everything into scene space, defined all the variables etc. It’s better for a Sprite class to encapsulate a matrix so that it’s clear what they stand for. Requirement: nvars >1; in other words, x should have 2 or more columns. $\begingroup$ I know this post is 9 years old, but an additional detail: The scale matrix can be decomposed into shears and a diagonal, I think. 0); I am trying to scale a simple object using matrices. net) and want to initialize a glm::mat4 with a float-array. They each have translation t, rotation r, and scale s. Apr 18, 2019 · 在OpenGL中,使用glm库的scale函数可以对一个矩阵进行缩放变换。该函数的原型如下: ``` glm::mat4 glm::scale(const glm::mat4 &matrix, const glm::vec3 &scale) ``` 这个函数接受两个参数:一个是需要进行缩放变换的矩阵,另一个是缩放因子。 In the case of OpenGL they happen to be a 4-by-4 arrangement of numbers: You can multply a 4-vector by a 4×4 matrix: After reaching clip space (i. x, cam. Here is some of the original code for a better understanding: Mtx4x4 Mo = Mtx4x4(cam. 0f, 0. Specifically, a 4x4 matrix is an array of 16 contiguous floats with the 13th, 14th, and 15th elements representing the X, Y, and Z, translation components. Jul 12, 2010 · OpenGL. In addition, you have to know the order in which the rotations were applied to create your matrix in order to properly extract the values. 0); The player may have had scale, rotate, and move effects applied to it. From GLM_GTX_transform extension. angle Rotation angle expressed in radians if GLM_FORCE_RADIANS is defined or degrees otherwise. If supplied, each observation is expected to be [success, failure]. model = DirectX::XMMatrixTranspose(data. Jan 5, 2024 · Builds a rotation 3 * 3 matrix created from an angle. The outline is in red and it seems that it moves towards the positive Z axis. model = glm::scale(); model = glm::rotate(); model = glm::translate(); Now I need to set a new position for this player, not relative to the player itself (which is what the translate method does), but relative to the "world", that is For example if camera is zero , orho matrix is glm::ortho(-10. Roughly speaking, "scale" is the older GLIM terminology and "dispersion" is the newer R terminology. Binomial family models accept a 2d array with two columns. Beware that the translation should be set directly, not applying translation matrix. 0f , -10. answered Aug 6, 2014 at 20:11. 0f GLM. This causes that the translation is multiplied by the scale. Dec 26, 2014 · 4. : Apr 3, 2019 · Right now I can assign the position of the camera to my mesh, like this. 7142857 0. 5)); First we scale the container by 0. 9. Then solve the system of equations. I guess the solution is trivial, but I don't know how to do it. 3. 1, 1. Sep 23, 2018 · glm::mat rices are column-major. And if you access by mat[i] it will return you the ith column instead of the ith row. Jan 5, 2024 · glm::mat4 glm::scale(const glm::vec3 &v=P) Documentation from code comments Transforms a matrix with a scale 4 * 4 matrix created from a vector of 3 components. 0f), m_camera. From the GLM quaternion. f ); // displacement. Hence, if μi is the expected number of new cases on day ti, a model of the form μi = γ exp(δti) seems appropriate. I need it with GLM specified simd vectors and matrices according to their old version. I am not sure if this is intended due to transforming local matrix to world matrix or it is an inherent bug in my application. glm::mat4x3 mat will actually create a 3 by 4 matrix with 3 rows and 4 columns. model over to my HLSL shader, everything works fine and and I can change the pos vector to look at my cube from different angles. #include <glm/glm. glMatrix is modeled after the needs of WebGL, which in turn uses matrix conventions set by OpenGL. 0f); trans = glm::rotate (trans, glm::radians (90. the method to be used in fitting the model. Currently you do. I'm not familiar with glm, but I have used GLUT before. Then take the first 3 values of the first column and make it a vector, get the length of this vector. To fix your issue, add a projection matrix to the vertex shader: gl_Position = project* view * model * vec4(position, 0. hpp for quat_cast it says . 3333333 1 0. Vexator July 12, 2010, 12:32pm 1. To create an orthographic projection matrix we make use of GLM's built-in function glm::ortho: glm::ortho (0. Why: First you want to scale the object so that the translations work properly. Feb 21, 2005 · License. 0 as a single argument, all of the fields in the matrix are 0. glm::vec3 position; glm::quat orientation; glm::mat4 modelmatrix; <-- want to combine them both in here modelmatrix = glm::translate(glm::toMat4(orientation),position); Then at my render function, I do. Screenshot from 2021-07-16 12-13-49 1034×581 710 KB. gl_Position = MVP * v; . e. 375 1 0. 在使用下面所介绍的函数之前请记得包含相关头文件,一般包含这几个就够了:. Jun 9, 2018 · I'm trying to implement transformation of object using matrices, but it works weird. 1, 0. f is 23. Only the single-precision floating point version is Oct 9, 2018 · This means that the model matrix can be expressed as: model = scale * translate. glScale produces a nonuniform scaling along the x, y, and z axes. 0f , -410. Here is a rather complete solution that should work in every situation where you don't care about the orientation of the rotated object (ie. frame" returns the model frame and does no fitting. Therefore the integer division applied within glm::ortho was creating an incorrect orthographic projection matrix. I have two vectors: one a position and a facing direction one, here is the code: glm::mat4x4 model( 1. Full OpenGL Series Playlist: https://www. I need matrix 3D transformation, model transformation i. I couldn't find a good documentation about glm. I don't think that this terminology is correct. 01f, 4000. io/ Join a Sep 13, 2020 · An Identity matrix can be initialized by the single parameter 1. 0f so the center of the OpenGL is at the bottom left. Finally, you translate the object to its position. r * c. When you do matrix * vector, you get the rows of the matrix times the columns of the vector. e scale-rotate-translate and then that model into world space so model-projection-view matrices. 0f); The first two parameters specify the left and right coordinate of the frustum and the third and fourth parameter specify the bottom and top part of the frustum. hpp>. Generalized Linear Models. 7. s So imagine the local coordinate system of the child that's transformed by this matrix (xyz axes of Detailed Description. 0f)) for the inout matrix. right. 0f , 410. void glm_mat4_mulv3(mat4 m, vec3 v, float last, vec3 dest) multiply vec3 with mat4 and get vec3 as result. r * p. If the form of your matrix is restricted in such a way that nonuniform scale happens at most once and is the first transform applied, i. Aug 25, 2014 · dat_glm_pred_response cats 0 1 0 5 3 1 2 6 dat_glm_pred_response cats 0 1 0 0. What i expect is to assign the full camera transform to my mesh, or to extract the rotation independently and assign it to the mesh Apr 4, 2015 · Basically, the key thing is that the way how glm defines matrix is different from our conventional way. My 40 years with graphics software have made me cynical. Don't do that. I would appreciate some helpful links. Supported: half, float or double. f, 6. 0, 1. Provide details and share your research! But avoid …. The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1], which matches WebGL/OpenGL's clip volume. Builds a scale 3 * 3 matrix created from a vector of 2 components. To separate rotation from scaling, orthonormalize the upper left 3×3 matrix. )=0 or up||at-eye. f, 3. y, cam Jul 10, 2012 · This is actually done rather easy. When an animation plays, each of its outputs targets a particular channel of a particular node, overwriting the node's local transform for the duration of the animation. OpenGL Mathematics ( GLM) is a header only C++ mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specifications. 5 on each axis and then rotate the container 90 degrees around the Z-axis. Nov 28, 2021 · I was working out the math for a reflection matrix from first principles, and found it matches your code exactly, except that you normalize the plane 4-vector first. glm::mat4 trans = glm::mat4(1. The key insight is, that a homogenous transformation matrix consists 3 parts: The upper left 3×3 matrix is a rotation-scaling, the rightmost top 1×3 column is the translation, the bottom left 3×1 allows for affine scaling and the bottom right is 1. wo pp ic ue hy tp ge iw hm zn