GSDP:GAM100/CProcessing/mat3 from vector()
From Inside
< GSDP:GAM100 | CProcessing
mat3_from_vector()
Description
Create a Mat3 by inputting each column of the matrix as Vec2s.
Parameters
mat3_from_vector(Vec2 col1, Vec2 col2, Vec2 col3)
- colX - (Vec2) Each is used to make column X when constructing the matrix.
Example
Vec2 end_position;
void init()
{
end_position = vec2_set(canvasWidth / 2.0f + 80.0f, canvasHeight / 2.0f + 80.0f);
}
void update()
{
background(color(255, 255, 255, 255));
// Create transformation matrices
Mat3 trans = mat3_from_vector(vec2_set(1.0f, 0.0f),
vec2_set(0.0f, 1.0f),
vec2_set(canvasWidth / 2.0f, canvasHeight / 2.0f));
Mat3 rotate = mat3_rotate(5.0f);
// Combine
Mat3 transform = mat3_concat(trans, mat3_concat(rotate, mat3_inverse(trans)));
// Update the end point of the line
end_position = mat3_mult_vec2(transform, end_position);
line(canvasWidth / 2.0f, canvasHeight / 2.0f, end_position.x, end_position.y);
}