summaryrefslogtreecommitdiff
path: root/src/ray.h
blob: 6f2e6005e42c5d2a7ca91b3805f2605b544eb210 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#pragma once

#include <stdbool.h>
#include <stdint.h>

#define PI		3.14159265358979323846
#define PIH		1.57079632679489661923
#define PI2		6.28318530718

#define sign(a) ((a) < 0 ? -1 : 1)
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

typedef struct {
    float x, y;
} v2;

typedef struct {
    int x, y;
} v2i;

float v2_cross(v2 a, v2 b);
float v2_len(v2 a);
float v2_dist(v2 a, v2 b);
float v2_square_dist(v2 a, v2 b);

uint32_t cast_ray(v2 pos, float theta, v2* hit_pos);