-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvec.h
54 lines (46 loc) · 1.42 KB
/
vec.h
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* Filename : vec.h
* Last Modified: 19 June 2020
* Owner : Group 20
*
* Description:
* This file contains the definitions of the functions whose declarations are
* specified in vec.h.
*
* Other:
* This file is formatted with a tab indent size of 4 and a character
* restriction of 80/line.
*/
#ifndef VEC_H
#define VEC_H
/*------------------------------Standard Headers------------------------------*/
#include <stdio.h>
#include <math.h>
#include <stdint.h>
/*-----------------------------User-defined Types-----------------------------*/
typedef struct {
float x;
float y;
float z;
} vec;
/*---------------------------Function Declarations----------------------------*/
/*================================Constructors================================*/
void vec_set_zero(vec *v);
void vec_set(vec *v, const float x, const float y, const float z);
/*==============================Unary Operations==============================*/
vec id(vec v);
vec neg(vec v);
float len(vec v);
float sq_len(vec v);
vec unit(vec v);
/*=============================Binary Operations==============================*/
vec add(vec v1, vec v2);
vec sub(vec v1, vec v2);
vec mul_v(vec v1, vec v2);
vec mul_c(vec v, const float s);
vec div_v(vec v1, vec v2);
vec div_c(vec v, const float s);
/*=========================Special Binary Operations==========================*/
float dot(vec v1, vec v2);
vec cross(vec v1, vec v2);
#endif