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 feature lacking in GLM?
The dimensions of the matrices must be compatible, the number of rows of X must equal the number of columns of A. Recall that a vector is the special case of a matrix with a single column, v ∈Rm×1. The transpose of a vector is vT ∈R1×m a matrix with a single row, known as a row vector.
In general, the transpose of a matrix is a new matrix in which the rows and columns are interchanged. For vectors, transposing a row vector results in a column vector, and transposing a column vector results in a row vector. In MATLAB, the apostrophe (or single quote) is built-in as the transpose operator.
In general, no.
GLM is based on GLSL, where there's simply no need to transpose a vector. If you do vector/matrix multiplication, it will multiply the vector in the way that works for the size of the matrix (unless it would have to change the order of the multiplication). So if you have a mat4
and do mat4*vec4
, your vec4
is considered a column vector. If you do vec4*mat4
, it is considered a row vector. If you do mat2x4*vec4
, you get an error, while vec4*mat2x4
works (as a row vector).
So in general, there's no reason to need to "transpose" a vector. The system simply does whatever works.
As a reference for people looking for how to transpose a vector (primarily for calculating outer products - u vT) in GLSL/GLM; its:
glm::core::function::matrix::outerProduct(u, v)
Nicol's GLM link now 404s as their API links have changed format from:
OLD Link: http://glm.g-truc.net/api-0.9.4/a00133.html#ga5d896e8651512fc098a677dbe403eeac
New Link: http://glm.g-truc.net/0.9.4/api/a00133.html#ga5d896e8651512fc098a677dbe403eeac
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With