GSDP:GAM100/CProcessing/CP Matrix FromVector()
From Inside
< GSDP:GAM100 | CProcessing
CP_Matrix_FromVector()
Description
Create a CP_Matrix by inputting each column of the matrix as CP_Vectors.
Parameters
CP_Matrix_FromVector(CP_Vector col1, CP_Vector col2, CP_Vector col3)
- colX - (CP_Vector) Each is used to make column X when constructing the 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_FromVector(CP_Vector_Set(1.0f, 0.0f),
CP_Vector_Set(0.0f, 1.0f),
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
- Main Page
- CP_Matrix
- CP_Matrix_Identity()
- CP_Matrix_FromVector()
- CP_Matrix_Scale()
- CP_Matrix_Translate()
- CP_Matrix_Rotate()
- CP_Matrix_RotateRadians()
- CP_Matrix_Transpose()
- CP_Matrix_Inverse()
- CP_Matrix_Multiply()
- CP_Vector_Set()
- CP_System_GetWindowWidth()
- CP_System_GetWindowHeight()
- CP_Settings_Background()
- CP_Color_Create()
- CP_Vector_MatrixMultiply()
- CP_Graphics_DrawLine()