aboutsummaryrefslogtreecommitdiff
path: root/src/vecmath.h
blob: c797b94c58e4652c7b2fab05ae34eeea70bcbca7 (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
28
29
30
31
32
33
34
35
#ifndef VECMATH_H_
#define VECMATH_H_

#include <stdint.h>

typedef struct {
    int x;
    int y;
} Vec2i;

typedef struct {
    float x;
    float y;
    float z;
} Vec3f;

typedef struct {
    float r;
    float g;
    float b;
} Color;


Vec3f vec3f_sub(Vec3f lhs, Vec3f rhs);
Vec3f vec3f_add(Vec3f lhs, Vec3f rhs);
float vec3f_dot(Vec3f lhs, Vec3f rhs);
Vec3f vec3f_neg(Vec3f v);
Vec3f vec3f_normalize(Vec3f vec);
Vec3f vec3f_mul(float a, Vec3f v);
void vec3f_show(const char *name, Vec3f v);

Color icolor(int32_t rgb);
Color pixel_avg4(Color pixels[4]);

#endif