Grid matrix math fix
This commit is contained in:
parent
9b550856fb
commit
c0d84bae43
4 changed files with 80 additions and 34 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue