Fixed Point Arithmetic  0
Fixed-point math library.
vector.h
Go to the documentation of this file.
1 
38 #ifndef FXP_VECTOR_H
39 #define FXP_VECTOR_H
40 
41 #include "common.h"
42 #include "vector_types.h"
43 
63 #define MAKE_VEC_VEC_F3(name, typeR, typeA, typeB, f) \
64 FXP_DECLARATION(_FXP_INLINE_KW typeR name(typeA a, typeB b)) \
65 { \
66  typeR r; \
67  r.x = f(a.x, b.x); \
68  r.y = f(a.y, b.y); \
69  r.z = f(a.z, b.z); \
70  return r; \
71 }
72 
80 #define MAKE_VEC_VEC_F(name, type, f) MAKE_VEC_VEC_F3(name, type, type, type, f)
81 
91 #define MAKE_VEC_SCALAR_F2(name, typeR, typeA, typeB, f) \
92 FXP_DECLARATION(_FXP_INLINE_KW typeR name(typeA a, typeB b)) \
93 { \
94  typeR r; \
95  r.x = f(a.x, b); \
96  r.y = f(a.y, b); \
97  r.z = f(a.z, b); \
98  return r; \
99 }
100 
109 #define MAKE_VEC_SCALAR_F(name, typeA, typeB, f) \
110  MAKE_VEC_SCALAR_F2(name, typeA, typeA, typeB, f)
111 
121 #define MAKE_VEC_ELEM_F(name, typeR, typeA, f) \
122 FXP_DECLARATION(_FXP_INLINE_KW typeR name(typeA a)) \
123 { \
124  typeR r; \
125  r.x = f(a.x); \
126  r.y = f(a.y); \
127  r.z = f(a.z); \
128  return r; \
129 }
130 
135 #ifdef FXP_C99_INLINE
136 
137 #ifndef _FXP_INLINE_KW
138 #define _FXP_INLINE_KW inline
139 #define _FXP_INLINE_PROTO_KW extern inline
140 #endif
141 
142 #ifndef FXP_DECLARATION
143 #define FXP_DECLARATION FXP_DECLARATION_C99_HEADER
144 #endif
145 
146 #include "inline/vector.h"
147 
148 #endif /* FXP_C99_INLINE */
149 
150 #endif /* FXP_VECTOR_H */