GSDP:GAM100/CProcessing/mat3 transpose()
From Inside
< GSDP:GAM100 | CProcessing
mat3_transpose()
Description
Creates a Mat3 matrix that is the transposition of the input matrix.
Parameters
mat3_inverse(Mat3 original)
- original - (Mat3) The matrix to transpose.
Example
Mat3 random_m;
Mat3 transpose_m;
void init()
{
textFont(defaultFont, 30.0f);
fill(color(0, 0, 0, 255));
// Create a random matrix
unsigned i, j;
for (i = 0; i < 3; ++i)
for (j = 0; j < 3; ++j)
random_m.m[i][j] = randomRangeInt(0, 50);
// Create a transpose of the random matrix
transpose_m = mat3_transpose(random_m);
}
void update()
{
background(color(255, 255, 255, 255));
// Print out the random matrix
text("Matrix: ", 0, 30);
char matrix[128] = {0};
sprintf_s(matrix, 128,"[%.0f, %.0f, %.0f]\n[%.0f, %.0f, %.0f]\n[%.0f, %.0f, %.0f]",
random_m.m00, random_m.m01, random_m.m02,
random_m.m10, random_m.m11, random_m.m12,
random_m.m20, random_m.m21, random_m.m22);
textBox(matrix, 175, 30, 200);
// Print out the transposed matrix
text("Transposed: ", 0, 150);
sprintf_s(matrix, 128, "[%.0f, %.0f, %.0f]\n[%.0f, %.0f, %.0f]\n[%.0f, %.0f, %.0f]",
transpose_m.m00, transpose_m.m01, transpose_m.m02,
transpose_m.m10, transpose_m.m11, transpose_m.m12,
transpose_m.m20, transpose_m.m21, transpose_m.m22);
textBox(matrix, 175, 150, 200);
}