Added matrix_transpose()

This commit is contained in:
Revar Desmera 2019-04-02 19:07:13 -07:00
parent b86206a80c
commit cc37b39344

View File

@ -1162,9 +1162,26 @@ function xyz_to_altaz(x,y=undef,z=undef) = let(
function ident(n) = [for (i = [0:n-1]) [for (j = [0:n-1]) (i==j)?1:0]];
// Create an identity matrix, for 3 axes.
//ident3 = ident(3);
//ident4 = ident(4);
// Function: matrix_transpose()
// Description: Returns the transposition of the given matrix.
// Example:
// m = [
// [11,12,13,14],
// [21,22,23,24],
// [31,32,33,34],
// [41,42,43,44]
// ];
// tm = matrix_transpose(m);
// // Returns:
// // [
// // [11,21,31,41],
// // [12,22,32,42],
// // [13,23,33,43],
// // [14,24,34,44]
// // ]
function matrix_transpose(m) = [for (i=[0:len(m[0])-1]) [for (j=[0:len(m)-1]) m[j][i]]];
// Function: mat3_to_mat4()
@ -1180,6 +1197,7 @@ function mat3_to_mat4(m) = concat(
);
// Function: matrix3_translate()
// Description:
// Returns the 3x3 matrix to perform a 2D translation.