-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathdq_vec3.h
131 lines (128 loc) · 2.93 KB
/
dq_vec3.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#ifndef _DQ_VEC3_H
# define _DQ_VEC3_H
/**
* @file dq_vec3.h
*
* @brief File containing functions related to 3d vectors.
*/
/**
* @defgroup vec3 Auxiliary 3d Vector Functions
* @brief Set of auxiliary functions to manipulate 3d vectors.
*/
/** @{ */
/**
* @brief Does the dot product of two 3d vectors.
*
* \f[
* o = u \cdot v
* \f]
*
* @param[in] u First 3d vector to operate on.
* @param[in] v Second 3d vector to operate on.
* @return The dot product of u.v.
*/
double vec3_dot( const double u[3], const double v[3] );
/**
* @brief Does the cross product of two 3d vectors.
*
* \f[
* o = u \times v
* \f]
*
* @param[out] o The cross product of u and v.
* @param[in] u First 3d vector to operate on.
* @param[in] v Second 3d vector to operate on.
*/
void vec3_cross( double o[3], const double u[3], const double v[3] );
/**
* @brief Adds two 3d vectors.
*
* \f[
* o = u + v
* \f]
*
* @param[out] o Result of the addition.
* @param[in] u First 3d vector to operate on.
* @param[in] v Second 3d vector to operate on.
*/
void vec3_add( double o[3], const double u[3], const double v[3] );
/**
* @brief Subtracts two 3d vectors.
*
* \f[
* o = u - v
* \f]
*
* @param[out] o Result of the subtraction.
* @param[in] u First 3d vector to operate on.
* @param[in] v Second 3d vector to operate on.
*/
void vec3_sub( double o[3], const double u[3], const double v[3] );
/**
* @brief Changes the sign of a vector.
*
* \f[
* o = -v
* \f]
*
* @param v Vector to change sign of.
*/
void vec3_sign( double v[3] );
/**
* @brief Gets the norm of a 3d vector.
*
* \f[
* o = \| v \|
* \f]
*
* @param[in] v Vector to get norm of.
* @return The norm of the 3d vector.
*/
double vec3_norm( const double v[3] );
/**
* @brief Normalizes a 3d vector.
*
* \f[
* v_{out} = \frac{v}{\| v \|}
* \f]
*
* @param v Vector to normalize.
*/
void vec3_normalize( double v[3] );
/**
* @brief Gets the distance between two vectors.
*
* \f[
* out = \| u - v \|
* \f]
*
* @param[in] u Base vector.
* @param[in] v Vector to get distance from u.
* @return The distance between the two vectors.
*/
double vec3_distance( const double u[3], const double v[3] );
/**
* @brief Compares two 3d vectors.
*
* @param[in] u First 3d vector to compare.
* @param[in] v Second 3d vector to compare.
* @return 0 if they are the same.
*/
int vec3_cmp( const double u[3], const double v[3] );
/**
* @brief Compares two 3d vectors with variable precision.
*
* @param[in] u First 3d vector to compare.
* @param[in] v Second 3d vector to compare.
* @param[in] precision Precision to use.
* @return 0 if they are the same.
*/
int vec3_cmpV( const double u[3], const double v[3], double precision );
/**
* @brief Prints a 3d vector on screen.
*
* @param[in] v Vector to print.
*/
void vec3_print( const double v[3] );
/** @} */
#endif /* _DQ_VEC3_H */