summaryrefslogtreecommitdiff
path: root/src/ray.c
diff options
context:
space:
mode:
authorTyler Murphy <tylerm@tylerm.dev>2023-04-22 21:47:58 -0400
committerTyler Murphy <tylerm@tylerm.dev>2023-04-22 21:47:58 -0400
commitf56f28c7218f465f4ad5579a6b0fe0f41ea13fd5 (patch)
treed96cd6845c56f9fd68cad404422bf4512ffbfc49 /src/ray.c
parentmove raycastign to its own file (diff)
downloadraycaster-f56f28c7218f465f4ad5579a6b0fe0f41ea13fd5.tar.gz
raycaster-f56f28c7218f465f4ad5579a6b0fe0f41ea13fd5.tar.bz2
raycaster-f56f28c7218f465f4ad5579a6b0fe0f41ea13fd5.zip
collision
Diffstat (limited to 'src/ray.c')
-rw-r--r--src/ray.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/ray.c b/src/ray.c
index 36e89b4..e3d2cb0 100644
--- a/src/ray.c
+++ b/src/ray.c
@@ -11,18 +11,17 @@ float v2_len(v2 a) {
return sqrt(a.x * a.x + a.y * a.y);
}
+float v2_dist(v2 a, v2 b) {
+ return sqrt(v2_square_dist(a, b));
+}
+
float v2_square_dist(v2 a, v2 b) {
return pow(a.x - b.x, 2) + pow(a.y - b.y, 2);
}
-#define PI 3.14159265358979323846
-#define PIH 1.57079632679489661923
-#define PI2 6.28318530718
-
uint32_t cast_ray(v2 pos, float theta, v2* hit_pos) {
const v2i move = {
- #define sign(a) ((a) < 0 ? -1 : 1)
sign(cos(theta)),
sign(sin(theta)),
};