excessive / cpml

Cirno's Perfect Math Library: Just about everything you need for 2D/3D games. Hopefully.

Home Page:https://excessive.github.io/cpml/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cpml.mat4.to_vec4s() and cpml.mat4.to_vec4s_cols() are reversed

leonardus opened this issue · comments

CPML documentation states that cpml matrices are column-major.

local testmatrix = cpml.mat4.new{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}

This should be the matrix:

[1  5  9  13]
[2  6  10 14]
[3  7  11 15]
[4  8  12 16]

If so, this prints the opposite results from what is expected:

for _, row in pairs(cpml.mat4.to_vec4s(testmatrix)) do
	print("row: ", row[1], row[2], row[3], row[4])
end
for _, col in pairs(cpml.mat4.to_vec4s_cols(testmatrix)) do
	print("col: ", col[1], col[2], col[3], col[4])
end
row:    1       2       3       4
row:    5       6       7       8
row:    9       10      11      12
row:    13      14      15      16
col:    1       5       9       13
col:    2       6       10      14
col:    3       7       11      15
col:    4       8       12      16