aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2024-04-23 23:27:55 +0200
committerkdx <kikoodx@paranoici.org>2024-04-23 23:28:45 +0200
commit518ce8941cd6da258443845c44a0c0fced87d961 (patch)
tree64e4281ba5b0096053fe6f0342b1a1b770a3ef41
parentd07415534fc917d904f17f6e06fc35d2d6c98b4b (diff)
downloadcminus-518ce8941cd6da258443845c44a0c0fced87d961.tar.gz
directional vectors
-rw-r--r--_.c6
-rw-r--r--_.h7
2 files changed, 7 insertions, 6 deletions
diff --git a/_.c b/_.c
index 98c1912..cf596a2 100644
--- a/_.c
+++ b/_.c
@@ -97,10 +97,6 @@ vec2 v2r(f32 x) {
return v2(x, x);
}
-vec2 v2_zero(void) {
- return v2(0.0f, 0.0f);
-}
-
bool v2_eq(vec2 a, vec2 b) {
return a.x == b.x && a.y == b.y;
}
@@ -171,7 +167,7 @@ vec2 v2_lerp(vec2 a, vec2 b, f32 x) {
}
vec2 v2_transform(vec2 v, mat3 m) {
- vec2 out = v2_zero();
+ vec2 out = v2_zero;
repeat (i, 2) {
out.a[i] = v.x * m.a[0][i] +
v.y * m.a[1][i] +
diff --git a/_.h b/_.h
index 18b5f89..60518e0 100644
--- a/_.h
+++ b/_.h
@@ -106,9 +106,14 @@ union vec2 {
f32 a[2];
};
+static const vec2 v2_zero = {{ 0, 0 }};
+static const vec2 v2_left = {{ -1, 0 }};
+static const vec2 v2_right = {{ 1, 0 }};
+static const vec2 v2_up = {{ 0, -1 }};
+static const vec2 v2_down = {{ 0, 1 }};
+
vec2 v2(f32 x, f32 y);
vec2 v2r(f32);
-vec2 v2_zero(void);
bool v2_eq(vec2, vec2);
vec2 v2_add(vec2, vec2);
vec2 v2_sub(vec2, vec2);