GSDP:GAM100/CProcessing/CP Matrix



A CP_Matrix (3D matrix type) is a structure that can hold nine float values. This is used for linear algebra and transformation, but can be used for any purpose that requires nine float values. There are a series of operations that can be done using a 3D matrix that are also provided.


void update() 
  // create a transform and set it to initialized values
  CP_Matrix transform = CP_Matrix_Identity();

  // make the matrix a translation transform by (100, 100)
  transform = CP_Matrix_Translate((CP_Vector) { 100, 100 });

  // create a vec2 position
  CP_Vector position;
  position.x = 100;
  position.y = 100;

  // apply that matrix to the point and store it in the position
  position = CP_Matrix_MultiplyVector(transform, position);