Grid matrix math fix

This commit is contained in:
Synthasmagoria 2026-08-30 14:01:17 +02:00
commit c0d84bae43
4 changed files with 80 additions and 34 deletions

View file

@ -289,13 +289,31 @@ rect_get_size :: proc {rect2_get_size, irect2_get_size}
/// ## LINEAR ALGEBRA ## ///
matrix3_translate2 :: proc "contextless" (translation: v2) -> mat3 {
return {
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
translation.x, translation.y, 1.0,
1.0, 0.0, translation.x,
0.0, 1.0, translation.y,
0.0, 0.0, 1.0,
}
}
matrix3_transform_v2 :: proc "contextless" (m: mat3, v: v2) -> v2 {
matrix3_scale2 :: proc "contextless" (scale: v2) -> mat3 {
return {
scale.x, 0.0, 0.0,
0.0, scale.y, 0.0,
0.0, 0.0, 1.0,
}
}
matrix3_rotate2 :: proc "contextless" (ang: f32) -> mat3 {
a := linalg.cos(ang)
b := linalg.sin(ang)
return {
a, b, 0,
-b, a, 0,
0, 0, 1,
}
}
matrix3_transform_xy :: proc "contextless" (m: mat3, v: v2) -> v2 {
return (m * v3{**v, 1.0}).xy
}