问题描述
也许我只是在文档中缺少了一些东西,但是似乎GLM不可能对向量进行转置.我也没有看到mat3x1或mat1x3类型.另外glm :: transpose不适用于矢量.我是否缺少某些功能?或者这只是GLM中缺少的功能?
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?
推荐答案
GLM基于GLSL,在这里根本不需要转置向量.如果执行向量/矩阵乘法,它将以适合矩阵大小的方式乘以向量(除非必须更改乘法顺序).因此,如果您具有mat4
并执行mat4*vec4
,则您的vec4
被视为列向量.如果执行vec4*mat4
,则将其视为行向量.如果执行mat2x4*vec4
,则会出错,而vec4*mat2x4
可以工作(作为行向量).
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.
这篇关于GLM:如何转置向量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!