bzr branch
http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
1 |
#ifndef __H_VEC__
|
2 |
#define __H_VEC__
|
|
3 |
||
4 |
#include <stdlib.h> |
|
|
30
by Gustav Hartvigsson
* Made the code compile using CMake. |
5 |
#include <stdint.h> |
6 |
#include "defs.h" |
|
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
7 |
|
8 |
/** @file
|
|
9 |
* @defgroup Vectors Vectors
|
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
10 |
* @addtogroup Vectors
|
11 |
* @{
|
|
12 |
* Vectors are multi value structures that can be used when doing some types of
|
|
13 |
* maths.
|
|
14 |
*/
|
|
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
15 |
|
16 |
BEGIN_DECLS
|
|
17 |
||
18 |
/**
|
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
19 |
* A Vector of three standard int values.
|
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
20 |
*
|
21 |
* A Vec3 is considerer a primitive type and as such has no ref/unref memory
|
|
22 |
* management and no vec_free function. You will have to do that yourself.
|
|
23 |
*
|
|
24 |
* @sa vec3_new
|
|
25 |
* @sa Vec3_16
|
|
26 |
*/
|
|
27 |
typedef struct |
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
28 |
Vec3 { |
29 |
sint a; |
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
30 |
sint b; |
31 |
sint c; |
|
32 |
} Vec3; |
|
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
33 |
|
34 |
/**
|
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
35 |
* A Vector of three 16 bit int values.
|
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
36 |
*
|
37 |
* @sa vec3_16_new
|
|
38 |
* @sa Vec3
|
|
39 |
*/
|
|
40 |
typedef struct |
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
41 |
Vec3_16 { |
42 |
sshort a; |
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
43 |
sshort b; |
44 |
sshort c; |
|
45 |
} Vec3_16; |
|
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
46 |
|
47 |
/**
|
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
48 |
*
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
49 |
* A Vec3_f is a vector of three 32bit precision floating point values.
|
50 |
*/
|
|
51 |
typedef struct |
|
52 |
Vec3_f { |
|
53 |
sfloat a; |
|
54 |
sfloat b; |
|
55 |
sfloat c; |
|
56 |
} Vec3_f; |
|
57 |
||
58 |
#ifndef __MSC_VER
|
|
|
83
by Gustav Hartvigsson
* vec.h: |
59 |
/**
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
60 |
* Add Vectors together, resulting in a new vector.
|
61 |
*
|
|
62 |
* The type of vector that is returned depends on the types that were put in.
|
|
63 |
*
|
|
64 |
* Due to the reflective way of these operations, many may just be inverses of
|
|
65 |
* others. IE: `vec3_add (Vec3 *, Vec3_16 *)` is the same as
|
|
66 |
* `vec3_add (Vec3_16 *, Vec3 *)`.
|
|
67 |
*/
|
|
68 |
#define vec3_add(x, y) _Generic((x, y)\
|
|
|
84
by Gustav Hartvigsson
WOOPS! |
69 |
Vec3 *: _Generic((y)\
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
70 |
Vec3 *: vec3_add_vec3\
|
71 |
Vec3_16 *: vec3_add_vec3_16\
|
|
72 |
Vec3_f *: vec3_add_vec3_f\
|
|
73 |
)\
|
|
74 |
Vec3_16 *: _Generic((y)\
|
|
75 |
Vec3 *: vec3_16_add_vec3\
|
|
76 |
Vec3_16 *: vec3_16_add_vec3_16\
|
|
77 |
Vec3_f *: vec3_16_add_vec3_f\
|
|
78 |
)\
|
|
79 |
Vec3_f *: _Generic((y)\
|
|
80 |
Vec3 *: vec3_f_add_vec3\
|
|
81 |
Vec3_16 *: vec3_f_add_vec3_16\
|
|
82 |
Vec3_f *: vec3_f_add_vec3_f\
|
|
83 |
)\
|
|
84 |
)(x,y)
|
|
85 |
#endif /* __MSC_VER */ |
|
|
83
by Gustav Hartvigsson
* vec.h: |
86 |
|
87 |
||
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
88 |
#define vec_free(x) free (x)
|
89 |
||
90 |
||
91 |
||
92 |
/** @brief
|
|
93 |
* allocates and initialises a Vec3 pointer.
|
|
94 |
*
|
|
95 |
* @sa Vec3
|
|
96 |
*/
|
|
97 |
Vec3 * |
|
98 |
vec3_new (sint a, sint b, sint c); |
|
99 |
||
100 |
/**
|
|
101 |
* Add Vector a to Vector
|
|
102 |
*/
|
|
103 |
Vec3 * |
|
104 |
vec3_add_vec3 (Vec3 * a, Vec3 * b); |
|
105 |
||
106 |
Vec3 * |
|
107 |
vec3_add_vec3_16 (Vec3 * a, Vec3_16 * b); |
|
108 |
||
109 |
||
110 |
/**
|
|
111 |
* @brief
|
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
112 |
* allocates and initialises a Vec3_16 pointer.
|
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
113 |
*
|
114 |
* @sa Vec3_16
|
|
115 |
*/
|
|
116 |
Vec3_16 * |
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
117 |
vec3_16_new (sshort a, sshort b, sshort c); |
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
118 |
|
119 |
Vec3_16 * |
|
120 |
vec3_16_add_vec3_16 (Vec3_16 * a, Vec3_16 * b); |
|
121 |
||
122 |
||
123 |
||
124 |
||
125 |
/**
|
|
126 |
* Allocates and initialises a Vec3_f pointer.
|
|
127 |
*/
|
|
128 |
Vec3_f * |
|
129 |
vec3_f_new (sfloat a, sfloat b, sfloat c); |
|
130 |
||
131 |
Vec3_f * |
|
132 |
vec3_f_add_vec3_f (Vec3_f * a, Vec3_f * b); |
|
133 |
||
134 |
Vec3_f * |
|
135 |
vec3_f_add_vec3 (Vec3_f * a, Vec3 * b); |
|
136 |
||
137 |
Vec3_f * |
|
138 |
vec3_f_add_vec3_16 (Vec3_f * a, Vec3_16 * b); |
|
139 |
||
140 |
||
141 |
/* Aliases */
|
|
|
83
by Gustav Hartvigsson
* vec.h: |
142 |
inline Vec3_f * |
143 |
vec3_add_vec3_f(Vec3 * x, Vec3_f * y){return vec3_f_add_vec3(y, x);} |
|
144 |
||
145 |
inline Vec3 * |
|
146 |
vec3_16_add_vec3(Vec3_16 * x, Vec3 * y) {return vec3_add_vec3_16(y, x);} |
|
147 |
||
148 |
inline Vec3_f * |
|
149 |
vec3_16_add_vec3_f(Vec3_16 * x, Vec3_f * y) {return vec3_f_add_vec3_16(y, x);} |
|
150 |
||
151 |
/** @} */
|
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
152 |
|
153 |
||
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
154 |
END_DECLS
|
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
155 |
|
156 |
#endif /* __H_VEC__ */ |
|
157 |