GSDP:GAM100/CProcessing/CP Matrix Transpose()

From Inside
Jump to: navigation, search

CP_Matrix_Transpose()

Description

Creates a CP_Matrix matrix that is the transposition of the input matrix.

Parameters

CP_Matrix_Transpose(CP_Matrix original)

  • original - (CP_Matrix) The matrix to transpose.

Example

CP_Matrix random_m;
CP_Matrix transpose_m;

void init()
{
  CP_Font_Set(CP_Font_GetDefault(), 30.0f);
  CP_Settings_Fill(CP_Color_Create(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] = CP_Random_RangeInt(0, 50);

  // Create a transpose of the random matrix
  transpose_m = CP_Matrix_Transpose(random_m);
}

void update()
{
  CP_Settings_Background(CP_Color_Create(255, 255, 255, 255));

  // Print out the random matrix
  CP_Font_DrawText("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);
  CP_Font_DrawTextBox(matrix, 175, 30, 200);

  // Print out the transposed matrix
  CP_Font_DrawText("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);
  CP_Font_DrawTextBox(matrix, 175, 150, 200);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>