-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvector3.h
More file actions
32 lines (24 loc) · 1.01 KB
/
vector3.h
File metadata and controls
32 lines (24 loc) · 1.01 KB
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
#ifndef VECTOR3_H
#define VECTOR3_H
#include <stdio.h>
#include <math.h>
#include "matrix4.h"
struct Vector3 {
float x, y, z, w;
};
// We move Vector3 instances by value.
inline struct Vector3 Vector3_create_point(float x, float y, float z);
inline struct Vector3 Vector3_create_direction(float x, float y, float z);
// Operations.
inline struct Vector3 Vector3_add(struct Vector3 v1, struct Vector3 v2);
inline struct Vector3 Vector3_sub(struct Vector3 v1, struct Vector3 v2);
inline struct Vector3 Vector3_smul(struct Vector3 v, float s);
inline struct Vector3 Vector3_sdiv(struct Vector3 v, float s);
inline struct Vector3 Vector3_cross(struct Vector3 v1, struct Vector3 v2);
inline float Vector3_dot(struct Vector3 v1, struct Vector3 v2);
inline float Vector3_norm(struct Vector3 v);
inline float Vector3_norm_squared(struct Vector3 v);
inline struct Vector3 Vector3_normalize(struct Vector3 v);
// Utility.
inline void Vector3_print(const char *str, struct Vector3 v);
#endif