GSDP:GAM100/CProcessing/CP Vector MatrixMultiply()

From Inside
Jump to: navigation, search

CP_Vector_MatrixMultiply()

Description

Creates a CP_Vector by multiplying (transforming) an input CP_Vector by an input CP_Matrix.

Parameters

CP_Vector_MatrixMultiply(CP_Matrix mat, CP_Vector vec)

  • mat - (CP_Matrix) - The transform matrix to apply to the input vector.
  • vec - (CP_Vector) - The vector to transform with the input matrix

Example

CP_Vector end_position;

void init()
{
  end_position = CP_Vector_Set(CP_System_GetWindowWidth() / 2.0f + 80.0f, CP_System_GetWindowHeight() / 2.0f + 80.0f);
}

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

  // Create transformation matrices
  CP_Matrix trans = CP_Matrix_Translate(CP_Vector_Set(CP_System_GetWindowWidth() / 2.0f, CP_System_GetWindowHeight() / 2.0f));
  CP_Matrix rotate = CP_Matrix_Rotate(5.0f);

  // Combine
  CP_Matrix transform = CP_Matrix_Multiply(trans, CP_Matrix_Multiply(rotate, CP_Matrix_Inverse(trans)));

  // Update the end point of the line
  end_position = CP_Vector_MatrixMultiply(transform, end_position);

  CP_Graphics_DrawLine(CP_System_GetWindowWidth() / 2.0f, CP_System_GetWindowHeight() / 2.0f, end_position.x, end_position.y);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>