PowerBlocks SDK
 
Loading...
Searching...
No Matches
vec3.h
Go to the documentation of this file.
1
11
12#pragma once
13
14#include <math.h>
15
16typedef struct {
17 float x;
18 float y;
19 float z;
20} vec3;
21
22#define vec3_new(x, y, z) ((vec3){x, y, z})
23#define vec3_add(a, b) ((vec3){(a).x+(b).x, (a).y+(b).y, (a).z+(b).z})
24#define vec3_sub(a, b) ((vec3){(a).x-(b).x, (a).y-(b).y, (a).z-(b).z})
25#define vec3_dot(a, b) ((a).x * (b).x + (a).y * (b).y + (a.z) * (b).z)
26#define vec3_magnitude_sq(a) vec3_dot(a, a)
27#define vec3_magnitude(a) (sqrtf(vec3_magnitude_sq(a)))
28#define vec3_muls(a, s) ((vec3){(a).x*(s), (a).y*(s), (a).z*(s)})
29#define vec3_divs(a, s) ((vec3){(a).x/(s), (a).y/(s), (a).z/(s)})
30
31extern void vec3_normalize(vec3* v);
32
33// Generates a unit vector pointing from A -> B
34extern vec3 vec3_to(vec3 a, vec3 b);
Definition vec3.h:16