cglm 0.1.0 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/Gemfile.lock +18 -16
- data/README.md +2 -0
- data/cglm.gemspec +3 -3
- data/ext/cglm/cglm-0.6.2/include/cglm/affine-mat.h +168 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/affine.h +490 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/applesimd.h +95 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/bezier.h +154 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/box.h +279 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/affine.h +117 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/bezier.h +31 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/box.h +79 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/cam.h +143 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/curve.h +23 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/ease.h +143 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/euler.h +55 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/frustum.h +41 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/io.h +44 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/mat3.h +86 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/mat4.h +127 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/plane.h +23 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/project.h +33 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/quat.h +159 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/sphere.h +39 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/vec3.h +312 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call/vec4.h +290 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/call.h +36 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/cam.h +585 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/cglm.h +32 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/color.h +26 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/common.h +37 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/curve.h +40 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/ease.h +317 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/euler.h +453 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/frustum.h +255 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/io.h +203 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/mat3.h +422 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/mat4.h +726 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/plane.h +36 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/project.h +118 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/quat.h +828 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/arm.h +83 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/avx/affine.h +66 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/avx/mat4.h +66 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/intrin.h +90 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/neon/mat4.h +57 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/sse2/affine.h +111 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/sse2/mat3.h +59 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/sse2/mat4.h +405 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/sse2/quat.h +46 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/simd/x86.h +192 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/sphere.h +99 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/affine.h +337 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/box.h +256 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/cam.h +451 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/color.h +27 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/curve.h +40 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/euler.h +152 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/frustum.h +155 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/io.h +82 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/mat3.h +285 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/mat4.h +459 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/plane.h +40 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/project.h +104 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/quat.h +532 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/sphere.h +93 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/vec3-ext.h +257 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/vec3.h +970 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/vec4-ext.h +257 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct/vec4.h +814 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/struct.h +36 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/types-struct.h +129 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/types.h +76 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/util.h +328 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/vec3-ext.h +272 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/vec3.h +1078 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/vec4-ext.h +315 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/vec4.h +1078 -0
- data/ext/cglm/cglm-0.6.2/include/cglm/version.h +15 -0
- data/ext/cglm/extconf.rb +2 -3
- data/ext/cglm/rb_cglm.h +5 -3
- data/ext/cglm/rb_cglm_mat3.c +3 -3
- data/ext/cglm/rb_cglm_mat4.c +3 -3
- data/ext/cglm/rb_cglm_quat.c +2 -2
- data/ext/cglm/rb_cglm_vec3.c +63 -61
- data/ext/cglm/rb_cglm_vec4.c +2 -0
- data/ext/cglm/ruby_pre27.h +35 -0
- data/lib/cglm/vec3.rb +2 -2
- data/lib/cglm/vec4.rb +2 -2
- data/lib/cglm/vector_type.rb +15 -0
- data/lib/cglm/version.rb +1 -1
- metadata +89 -13
@@ -0,0 +1,814 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c), Recep Aslantas.
|
3
|
+
*
|
4
|
+
* MIT License (MIT), http://opensource.org/licenses/MIT
|
5
|
+
* Full license can be found in the LICENSE file
|
6
|
+
*/
|
7
|
+
|
8
|
+
/*
|
9
|
+
Macros:
|
10
|
+
GLMS_VEC4_ONE_INIT
|
11
|
+
GLMS_VEC4_BLACK_INIT
|
12
|
+
GLMS_VEC4_ZERO_INIT
|
13
|
+
GLMS_VEC4_ONE
|
14
|
+
GLMS_VEC4_BLACK
|
15
|
+
GLMS_VEC4_ZERO
|
16
|
+
|
17
|
+
Functions:
|
18
|
+
CGLM_INLINE vec4s glms_vec4(vec3s v3, float last);
|
19
|
+
CGLM_INLINE vec3s glms_vec4_copy3(vec4s v);
|
20
|
+
CGLM_INLINE vec4s glms_vec4_copy(vec4s v);
|
21
|
+
CGLM_INLINE vec4s glms_vec4_ucopy(vec4s v);
|
22
|
+
CGLM_INLINE void glms_vec4_pack(vec4s dst[], vec4 src[], size_t len);
|
23
|
+
CGLM_INLINE void glms_vec4_unpack(vec4 dst[], vec4s src[], size_t len);
|
24
|
+
CGLM_INLINE float glms_vec4_dot(vec4s a, vec4s b);
|
25
|
+
CGLM_INLINE float glms_vec4_norm2(vec4s v);
|
26
|
+
CGLM_INLINE float glms_vec4_norm(vec4s v);
|
27
|
+
CGLM_INLINE float glms_vec4_norm_one(vec4s v);
|
28
|
+
CGLM_INLINE float glms_vec4_norm_inf(vec4s v);
|
29
|
+
CGLM_INLINE vec4s glms_vec4_add(vec4s a, vec4s b);
|
30
|
+
CGLM_INLINE vec4s glms_vec4_adds(vec4s v, float s);
|
31
|
+
CGLM_INLINE vec4s glms_vec4_sub(vec4s a, vec4s b);
|
32
|
+
CGLM_INLINE vec4s glms_vec4_subs(vec4s v, float s);
|
33
|
+
CGLM_INLINE vec4s glms_vec4_mul(vec4s a, vec4s b);
|
34
|
+
CGLM_INLINE vec4s glms_vec4_scale(vec4s v, float s);
|
35
|
+
CGLM_INLINE vec4s glms_vec4_scale_as(vec4s v, float s);
|
36
|
+
CGLM_INLINE vec4s glms_vec4_div(vec4s a, vec4s b);
|
37
|
+
CGLM_INLINE vec4s glms_vec4_divs(vec4s v, float s);
|
38
|
+
CGLM_INLINE vec4s glms_vec4_addadd(vec4s a, vec4s b, vec4s dest);
|
39
|
+
CGLM_INLINE vec4s glms_vec4_subadd(vec4s a, vec4s b, vec4s dest);
|
40
|
+
CGLM_INLINE vec4s glms_vec4_muladd(vec4s a, vec4s b, vec4s dest);
|
41
|
+
CGLM_INLINE vec4s glms_vec4_muladds(vec4s a, float s, vec4s dest);
|
42
|
+
CGLM_INLINE vec4s glms_vec4_maxadd(vec4s a, vec4s b, vec4s dest);
|
43
|
+
CGLM_INLINE vec4s glms_vec4_minadd(vec4s a, vec4s b, vec4s dest);
|
44
|
+
CGLM_INLINE vec4s glms_vec4_negate(vec4s v);
|
45
|
+
CGLM_INLINE vec4s glms_vec4_inv(vec4s v);
|
46
|
+
CGLM_INLINE vec4s glms_vec4_normalize(vec4s v);
|
47
|
+
CGLM_INLINE float glms_vec4_distance(vec4s a, vec4s b);
|
48
|
+
CGLM_INLINE float glms_vec4_distance2(vec4s a, vec4s b);
|
49
|
+
CGLM_INLINE vec4s glms_vec4_maxv(vec4s a, vec4s b);
|
50
|
+
CGLM_INLINE vec4s glms_vec4_minv(vec4s a, vec4s b);
|
51
|
+
CGLM_INLINE vec4s glms_vec4_clamp(vec4s v, float minVal, float maxVal);
|
52
|
+
CGLM_INLINE vec4s glms_vec4_lerp(vec4s from, vec4s to, float t);
|
53
|
+
CGLM_INLINE vec4s glms_vec4_lerpc(vec4s from, vec4s to, float t);
|
54
|
+
CGLM_INLINE vec4s glms_vec4_mix(vec4s from, vec4s to, float t);
|
55
|
+
CGLM_INLINE vec4s glms_vec4_mixc(vec4s from, vec4s to, float t);
|
56
|
+
CGLM_INLINE vec4s glms_vec4_step_uni(float edge, vec4s x);
|
57
|
+
CGLM_INLINE vec4s glms_vec4_step(vec4s edge, vec4s x);
|
58
|
+
CGLM_INLINE vec4s glms_vec4_smoothstep_uni(float edge0, float edge1, vec4s x);
|
59
|
+
CGLM_INLINE vec4s glms_vec4_smoothstep(vec4s edge0, vec4s edge1, vec4s x);
|
60
|
+
CGLM_INLINE vec4s glms_vec4_smoothinterp(vec4s from, vec4s to, float t);
|
61
|
+
CGLM_INLINE vec4s glms_vec4_smoothinterpc(vec4s from, vec4s to, float t);
|
62
|
+
CGLM_INLINE vec4s glms_vec4_cubic(float s);
|
63
|
+
CGLM_INLINE vec4s glms_vec4_swizzle(vec4s v, int mask);
|
64
|
+
*/
|
65
|
+
|
66
|
+
#ifndef cglms_vec4s_h
|
67
|
+
#define cglms_vec4s_h
|
68
|
+
|
69
|
+
#include "../common.h"
|
70
|
+
#include "../types-struct.h"
|
71
|
+
#include "../util.h"
|
72
|
+
#include "../vec4.h"
|
73
|
+
#include "vec4-ext.h"
|
74
|
+
|
75
|
+
#define GLMS_VEC4_ONE_INIT {GLM_VEC4_ONE_INIT}
|
76
|
+
#define GLMS_VEC4_BLACK_INIT {GLM_VEC4_BLACK_INIT}
|
77
|
+
#define GLMS_VEC4_ZERO_INIT {GLM_VEC4_ZERO_INIT}
|
78
|
+
|
79
|
+
#define GLMS_VEC4_ONE ((vec4s)GLM_VEC4_ONE_INIT)
|
80
|
+
#define GLMS_VEC4_BLACK ((vec4s)GLM_VEC4_BLACK_INIT)
|
81
|
+
#define GLMS_VEC4_ZERO ((vec4s)GLM_VEC4_ZERO_INIT)
|
82
|
+
|
83
|
+
/*!
|
84
|
+
* @brief init vec4 using vec3
|
85
|
+
*
|
86
|
+
* @param[in] v3 vector3
|
87
|
+
* @param[in] last last item
|
88
|
+
* @returns destination
|
89
|
+
*/
|
90
|
+
CGLM_INLINE
|
91
|
+
vec4s
|
92
|
+
glms_vec4(vec3s v3, float last) {
|
93
|
+
vec4s r;
|
94
|
+
glm_vec4(v3.raw, last, r.raw);
|
95
|
+
return r;
|
96
|
+
}
|
97
|
+
|
98
|
+
/*!
|
99
|
+
* @brief copy first 3 members of [a] to [dest]
|
100
|
+
*
|
101
|
+
* @param[in] v source
|
102
|
+
* @returns vec3
|
103
|
+
*/
|
104
|
+
CGLM_INLINE
|
105
|
+
vec3s
|
106
|
+
glms_vec4_copy3(vec4s v) {
|
107
|
+
vec3s r;
|
108
|
+
glm_vec4_copy3(v.raw, r.raw);
|
109
|
+
return r;
|
110
|
+
}
|
111
|
+
|
112
|
+
/*!
|
113
|
+
* @brief copy all members of [a] to [dest]
|
114
|
+
*
|
115
|
+
* @param[in] v source
|
116
|
+
* @returns destination
|
117
|
+
*/
|
118
|
+
CGLM_INLINE
|
119
|
+
vec4s
|
120
|
+
glms_vec4_copy(vec4s v) {
|
121
|
+
vec4s r;
|
122
|
+
glm_vec4_copy(v.raw, r.raw);
|
123
|
+
return r;
|
124
|
+
}
|
125
|
+
|
126
|
+
/*!
|
127
|
+
* @brief copy all members of [a] to [dest]
|
128
|
+
*
|
129
|
+
* alignment is not required
|
130
|
+
*
|
131
|
+
* @param[in] v source
|
132
|
+
* @returns destination
|
133
|
+
*/
|
134
|
+
CGLM_INLINE
|
135
|
+
vec4s
|
136
|
+
glms_vec4_ucopy(vec4s v) {
|
137
|
+
vec4s r;
|
138
|
+
glm_vec4_ucopy(v.raw, r.raw);
|
139
|
+
return r;
|
140
|
+
}
|
141
|
+
|
142
|
+
/*!
|
143
|
+
* @brief pack an array of vec4 into an array of vec4s
|
144
|
+
*
|
145
|
+
* @param[out] dst array of vec4
|
146
|
+
* @param[in] src array of vec4s
|
147
|
+
* @param[in] len number of elements
|
148
|
+
*/
|
149
|
+
CGLM_INLINE
|
150
|
+
void
|
151
|
+
glms_vec4_pack(vec4s dst[], vec4 src[], size_t len) {
|
152
|
+
size_t i;
|
153
|
+
|
154
|
+
for (i = 0; i < len; i++) {
|
155
|
+
glm_vec4_copy(src[i], dst[i].raw);
|
156
|
+
}
|
157
|
+
}
|
158
|
+
|
159
|
+
/*!
|
160
|
+
* @brief unpack an array of vec4s into an array of vec4
|
161
|
+
*
|
162
|
+
* @param[out] dst array of vec4s
|
163
|
+
* @param[in] src array of vec4
|
164
|
+
* @param[in] len number of elements
|
165
|
+
*/
|
166
|
+
CGLM_INLINE
|
167
|
+
void
|
168
|
+
glms_vec4_unpack(vec4 dst[], vec4s src[], size_t len) {
|
169
|
+
size_t i;
|
170
|
+
|
171
|
+
for (i = 0; i < len; i++) {
|
172
|
+
glm_vec4_copy(src[i].raw, dst[i]);
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
176
|
+
/*!
|
177
|
+
* @brief make vector zero
|
178
|
+
*
|
179
|
+
* @returns zero vector
|
180
|
+
*/
|
181
|
+
CGLM_INLINE
|
182
|
+
vec4s
|
183
|
+
glms_vec4_zero(void) {
|
184
|
+
vec4s r;
|
185
|
+
glm_vec4_zero(r.raw);
|
186
|
+
return r;
|
187
|
+
}
|
188
|
+
|
189
|
+
/*!
|
190
|
+
* @brief make vector one
|
191
|
+
*
|
192
|
+
* @returns one vector
|
193
|
+
*/
|
194
|
+
CGLM_INLINE
|
195
|
+
vec4s
|
196
|
+
glms_vec4_one(void) {
|
197
|
+
vec4s r;
|
198
|
+
glm_vec4_one(r.raw);
|
199
|
+
return r;
|
200
|
+
}
|
201
|
+
|
202
|
+
/*!
|
203
|
+
* @brief vec4 dot product
|
204
|
+
*
|
205
|
+
* @param[in] a vector1
|
206
|
+
* @param[in] b vector2
|
207
|
+
*
|
208
|
+
* @return dot product
|
209
|
+
*/
|
210
|
+
CGLM_INLINE
|
211
|
+
float
|
212
|
+
glms_vec4_dot(vec4s a, vec4s b) {
|
213
|
+
return glm_vec4_dot(a.raw, b.raw);
|
214
|
+
}
|
215
|
+
|
216
|
+
/*!
|
217
|
+
* @brief norm * norm (magnitude) of vec
|
218
|
+
*
|
219
|
+
* we can use this func instead of calling norm * norm, because it would call
|
220
|
+
* sqrtf fuction twice but with this func we can avoid func call, maybe this is
|
221
|
+
* not good name for this func
|
222
|
+
*
|
223
|
+
* @param[in] v vec4
|
224
|
+
*
|
225
|
+
* @return norm * norm
|
226
|
+
*/
|
227
|
+
CGLM_INLINE
|
228
|
+
float
|
229
|
+
glms_vec4_norm2(vec4s v) {
|
230
|
+
return glm_vec4_norm2(v.raw);
|
231
|
+
}
|
232
|
+
|
233
|
+
/*!
|
234
|
+
* @brief norm (magnitude) of vec4
|
235
|
+
*
|
236
|
+
* @param[in] v vector
|
237
|
+
*
|
238
|
+
* @return norm
|
239
|
+
*/
|
240
|
+
CGLM_INLINE
|
241
|
+
float
|
242
|
+
glms_vec4_norm(vec4s v) {
|
243
|
+
return glm_vec4_norm(v.raw);
|
244
|
+
}
|
245
|
+
|
246
|
+
/*!
|
247
|
+
* @brief L1 norm of vec4
|
248
|
+
* Also known as Manhattan Distance or Taxicab norm.
|
249
|
+
* L1 Norm is the sum of the magnitudes of the vectors in a space.
|
250
|
+
* It is calculated as the sum of the absolute values of the vector components.
|
251
|
+
* In this norm, all the components of the vector are weighted equally.
|
252
|
+
*
|
253
|
+
* This computes:
|
254
|
+
* R = |v[0]| + |v[1]| + |v[2]| + |v[3]|
|
255
|
+
*
|
256
|
+
* @param[in] v vector
|
257
|
+
*
|
258
|
+
* @return L1 norm
|
259
|
+
*/
|
260
|
+
CGLM_INLINE
|
261
|
+
float
|
262
|
+
glms_vec4_norm_one(vec4s v) {
|
263
|
+
return glm_vec4_norm_one(v.raw);
|
264
|
+
}
|
265
|
+
|
266
|
+
/*!
|
267
|
+
* @brief Infinity norm of vec4
|
268
|
+
* Also known as Maximum norm.
|
269
|
+
* Infinity Norm is the largest magnitude among each element of a vector.
|
270
|
+
* It is calculated as the maximum of the absolute values of the vector components.
|
271
|
+
*
|
272
|
+
* This computes:
|
273
|
+
* inf norm = max(|v[0]|, |v[1]|, |v[2]|, |v[3]|)
|
274
|
+
*
|
275
|
+
* @param[in] v vector
|
276
|
+
*
|
277
|
+
* @return Infinity norm
|
278
|
+
*/
|
279
|
+
CGLM_INLINE
|
280
|
+
float
|
281
|
+
glms_vec4_norm_inf(vec4s v) {
|
282
|
+
return glm_vec4_norm_inf(v.raw);
|
283
|
+
}
|
284
|
+
|
285
|
+
/*!
|
286
|
+
* @brief add b vector to a vector store result in dest
|
287
|
+
*
|
288
|
+
* @param[in] a vector1
|
289
|
+
* @param[in] b vector2
|
290
|
+
* @returns destination vector
|
291
|
+
*/
|
292
|
+
CGLM_INLINE
|
293
|
+
vec4s
|
294
|
+
glms_vec4_add(vec4s a, vec4s b) {
|
295
|
+
vec4s r;
|
296
|
+
glm_vec4_add(a.raw, b.raw, r.raw);
|
297
|
+
return r;
|
298
|
+
}
|
299
|
+
|
300
|
+
/*!
|
301
|
+
* @brief add scalar to v vector store result in dest (d = v + vec(s))
|
302
|
+
*
|
303
|
+
* @param[in] v vector
|
304
|
+
* @param[in] s scalar
|
305
|
+
* @returns destination vector
|
306
|
+
*/
|
307
|
+
CGLM_INLINE
|
308
|
+
vec4s
|
309
|
+
glms_vec4_adds(vec4s v, float s) {
|
310
|
+
vec4s r;
|
311
|
+
glm_vec4_adds(v.raw, s, r.raw);
|
312
|
+
return r;
|
313
|
+
}
|
314
|
+
|
315
|
+
/*!
|
316
|
+
* @brief subtract b vector from a vector store result in dest (d = a - b)
|
317
|
+
*
|
318
|
+
* @param[in] a vector1
|
319
|
+
* @param[in] b vector2
|
320
|
+
* @returns destination vector
|
321
|
+
*/
|
322
|
+
CGLM_INLINE
|
323
|
+
vec4s
|
324
|
+
glms_vec4_sub(vec4s a, vec4s b) {
|
325
|
+
vec4s r;
|
326
|
+
glm_vec4_sub(a.raw, b.raw, r.raw);
|
327
|
+
return r;
|
328
|
+
}
|
329
|
+
|
330
|
+
/*!
|
331
|
+
* @brief subtract scalar from v vector store result in dest (d = v - vec(s))
|
332
|
+
*
|
333
|
+
* @param[in] v vector
|
334
|
+
* @param[in] s scalar
|
335
|
+
* @returns destination vector
|
336
|
+
*/
|
337
|
+
CGLM_INLINE
|
338
|
+
vec4s
|
339
|
+
glms_vec4_subs(vec4s v, float s) {
|
340
|
+
vec4s r;
|
341
|
+
glm_vec4_subs(v.raw, s, r.raw);
|
342
|
+
return r;
|
343
|
+
}
|
344
|
+
|
345
|
+
/*!
|
346
|
+
* @brief multiply two vector (component-wise multiplication)
|
347
|
+
*
|
348
|
+
* @param a vector1
|
349
|
+
* @param b vector2
|
350
|
+
* @returns dest = (a[0] * b[0], a[1] * b[1], a[2] * b[2], a[3] * b[3])
|
351
|
+
*/
|
352
|
+
CGLM_INLINE
|
353
|
+
vec4s
|
354
|
+
glms_vec4_mul(vec4s a, vec4s b) {
|
355
|
+
vec4s r;
|
356
|
+
glm_vec4_mul(a.raw, b.raw, r.raw);
|
357
|
+
return r;
|
358
|
+
}
|
359
|
+
|
360
|
+
/*!
|
361
|
+
* @brief multiply/scale vec4 vector with scalar: result = v * s
|
362
|
+
*
|
363
|
+
* @param[in] v vector
|
364
|
+
* @param[in] s scalar
|
365
|
+
* @returns destination vector
|
366
|
+
*/
|
367
|
+
CGLM_INLINE
|
368
|
+
vec4s
|
369
|
+
glms_vec4_scale(vec4s v, float s) {
|
370
|
+
vec4s r;
|
371
|
+
glm_vec4_scale(v.raw, s, r.raw);
|
372
|
+
return r;
|
373
|
+
}
|
374
|
+
|
375
|
+
/*!
|
376
|
+
* @brief make vec4 vector scale as specified: result = unit(v) * s
|
377
|
+
*
|
378
|
+
* @param[in] v vector
|
379
|
+
* @param[in] s scalar
|
380
|
+
* @returns destination vector
|
381
|
+
*/
|
382
|
+
CGLM_INLINE
|
383
|
+
vec4s
|
384
|
+
glms_vec4_scale_as(vec4s v, float s) {
|
385
|
+
vec4s r;
|
386
|
+
glm_vec4_scale_as(v.raw, s, r.raw);
|
387
|
+
return r;
|
388
|
+
}
|
389
|
+
|
390
|
+
/*!
|
391
|
+
* @brief div vector with another component-wise division: d = a / b
|
392
|
+
*
|
393
|
+
* @param[in] a vector 1
|
394
|
+
* @param[in] b vector 2
|
395
|
+
* @returns result = (a[0]/b[0], a[1]/b[1], a[2]/b[2], a[3]/b[3])
|
396
|
+
*/
|
397
|
+
CGLM_INLINE
|
398
|
+
vec4s
|
399
|
+
glms_vec4_div(vec4s a, vec4s b) {
|
400
|
+
vec4s r;
|
401
|
+
glm_vec4_div(a.raw, b.raw, r.raw);
|
402
|
+
return r;
|
403
|
+
}
|
404
|
+
|
405
|
+
/*!
|
406
|
+
* @brief div vec4 vector with scalar: d = v / s
|
407
|
+
*
|
408
|
+
* @param[in] v vector
|
409
|
+
* @param[in] s scalar
|
410
|
+
* @returns destination vector
|
411
|
+
*/
|
412
|
+
CGLM_INLINE
|
413
|
+
vec4s
|
414
|
+
glms_vec4_divs(vec4s v, float s) {
|
415
|
+
vec4s r;
|
416
|
+
glm_vec4_divs(v.raw, s, r.raw);
|
417
|
+
return r;
|
418
|
+
}
|
419
|
+
|
420
|
+
/*!
|
421
|
+
* @brief add two vectors and add result to sum
|
422
|
+
*
|
423
|
+
* it applies += operator so dest must be initialized
|
424
|
+
*
|
425
|
+
* @param[in] a vector 1
|
426
|
+
* @param[in] b vector 2
|
427
|
+
* @returns dest += (a + b)
|
428
|
+
*/
|
429
|
+
CGLM_INLINE
|
430
|
+
vec4s
|
431
|
+
glms_vec4_addadd(vec4s a, vec4s b, vec4s dest) {
|
432
|
+
glm_vec4_addadd(a.raw, b.raw, dest.raw);
|
433
|
+
return dest;
|
434
|
+
}
|
435
|
+
|
436
|
+
/*!
|
437
|
+
* @brief sub two vectors and add result to dest
|
438
|
+
*
|
439
|
+
* it applies += operator so dest must be initialized
|
440
|
+
*
|
441
|
+
* @param[in] a vector 1
|
442
|
+
* @param[in] b vector 2
|
443
|
+
* @returns dest += (a - b)
|
444
|
+
*/
|
445
|
+
CGLM_INLINE
|
446
|
+
vec4s
|
447
|
+
glms_vec4_subadd(vec4s a, vec4s b, vec4s dest) {
|
448
|
+
glm_vec4_subadd(a.raw, b.raw, dest.raw);
|
449
|
+
return dest;
|
450
|
+
}
|
451
|
+
|
452
|
+
/*!
|
453
|
+
* @brief mul two vectors and add result to dest
|
454
|
+
*
|
455
|
+
* it applies += operator so dest must be initialized
|
456
|
+
*
|
457
|
+
* @param[in] a vector 1
|
458
|
+
* @param[in] b vector 2
|
459
|
+
* @returns dest += (a * b)
|
460
|
+
*/
|
461
|
+
CGLM_INLINE
|
462
|
+
vec4s
|
463
|
+
glms_vec4_muladd(vec4s a, vec4s b, vec4s dest) {
|
464
|
+
glm_vec4_muladd(a.raw, b.raw, dest.raw);
|
465
|
+
return dest;
|
466
|
+
}
|
467
|
+
|
468
|
+
/*!
|
469
|
+
* @brief mul vector with scalar and add result to sum
|
470
|
+
*
|
471
|
+
* it applies += operator so dest must be initialized
|
472
|
+
*
|
473
|
+
* @param[in] a vector
|
474
|
+
* @param[in] s scalar
|
475
|
+
* @returns dest += (a * b)
|
476
|
+
*/
|
477
|
+
CGLM_INLINE
|
478
|
+
vec4s
|
479
|
+
glms_vec4_muladds(vec4s a, float s, vec4s dest) {
|
480
|
+
glm_vec4_muladds(a.raw, s, dest.raw);
|
481
|
+
return dest;
|
482
|
+
}
|
483
|
+
|
484
|
+
/*!
|
485
|
+
* @brief add max of two vector to result/dest
|
486
|
+
*
|
487
|
+
* it applies += operator so dest must be initialized
|
488
|
+
*
|
489
|
+
* @param[in] a vector 1
|
490
|
+
* @param[in] b vector 2
|
491
|
+
* @returns dest += max(a, b)
|
492
|
+
*/
|
493
|
+
CGLM_INLINE
|
494
|
+
vec4s
|
495
|
+
glms_vec4_maxadd(vec4s a, vec4s b, vec4s dest) {
|
496
|
+
glm_vec4_maxadd(a.raw, b.raw, dest.raw);
|
497
|
+
return dest;
|
498
|
+
}
|
499
|
+
|
500
|
+
/*!
|
501
|
+
* @brief add min of two vector to result/dest
|
502
|
+
*
|
503
|
+
* it applies += operator so dest must be initialized
|
504
|
+
*
|
505
|
+
* @param[in] a vector 1
|
506
|
+
* @param[in] b vector 2
|
507
|
+
* @returns dest += min(a, b)
|
508
|
+
*/
|
509
|
+
CGLM_INLINE
|
510
|
+
vec4s
|
511
|
+
glms_vec4_minadd(vec4s a, vec4s b, vec4s dest) {
|
512
|
+
glm_vec4_minadd(a.raw, b.raw, dest.raw);
|
513
|
+
return dest;
|
514
|
+
}
|
515
|
+
|
516
|
+
/*!
|
517
|
+
* @brief negate vector components and store result in dest
|
518
|
+
*
|
519
|
+
* @param[in] v vector
|
520
|
+
* @returns result vector
|
521
|
+
*/
|
522
|
+
CGLM_INLINE
|
523
|
+
vec4s
|
524
|
+
glms_vec4_negate(vec4s v) {
|
525
|
+
glm_vec4_negate(v.raw);
|
526
|
+
return v;
|
527
|
+
}
|
528
|
+
|
529
|
+
/*!
|
530
|
+
* @brief normalize vec4 and store result in same vec
|
531
|
+
*
|
532
|
+
* @param[in] v vector
|
533
|
+
* @returns normalized vector
|
534
|
+
*/
|
535
|
+
CGLM_INLINE
|
536
|
+
vec4s
|
537
|
+
glms_vec4_normalize(vec4s v) {
|
538
|
+
glm_vec4_normalize(v.raw);
|
539
|
+
return v;
|
540
|
+
}
|
541
|
+
|
542
|
+
/**
|
543
|
+
* @brief distance between two vectors
|
544
|
+
*
|
545
|
+
* @param[in] a vector1
|
546
|
+
* @param[in] b vector2
|
547
|
+
* @return returns distance
|
548
|
+
*/
|
549
|
+
CGLM_INLINE
|
550
|
+
float
|
551
|
+
glms_vec4_distance(vec4s a, vec4s b) {
|
552
|
+
return glm_vec4_distance(a.raw, b.raw);
|
553
|
+
}
|
554
|
+
|
555
|
+
/**
|
556
|
+
* @brief squared distance between two vectors
|
557
|
+
*
|
558
|
+
* @param[in] a vector1
|
559
|
+
* @param[in] b vector2
|
560
|
+
* @return returns squared distance
|
561
|
+
*/
|
562
|
+
CGLM_INLINE
|
563
|
+
float
|
564
|
+
glms_vec4_distance2(vec4s a, vec4s b) {
|
565
|
+
return glm_vec4_distance2(a.raw, b.raw);
|
566
|
+
}
|
567
|
+
|
568
|
+
/*!
|
569
|
+
* @brief max values of vectors
|
570
|
+
*
|
571
|
+
* @param[in] a vector1
|
572
|
+
* @param[in] b vector2
|
573
|
+
* @returns destination
|
574
|
+
*/
|
575
|
+
CGLM_INLINE
|
576
|
+
vec4s
|
577
|
+
glms_vec4_maxv(vec4s a, vec4s b) {
|
578
|
+
vec4s r;
|
579
|
+
glm_vec4_maxv(a.raw, b.raw, r.raw);
|
580
|
+
return r;
|
581
|
+
}
|
582
|
+
|
583
|
+
/*!
|
584
|
+
* @brief min values of vectors
|
585
|
+
*
|
586
|
+
* @param[in] a vector1
|
587
|
+
* @param[in] b vector2
|
588
|
+
* @returns destination
|
589
|
+
*/
|
590
|
+
CGLM_INLINE
|
591
|
+
vec4s
|
592
|
+
glms_vec4_minv(vec4s a, vec4s b) {
|
593
|
+
vec4s r;
|
594
|
+
glm_vec4_minv(a.raw, b.raw, r.raw);
|
595
|
+
return r;
|
596
|
+
}
|
597
|
+
|
598
|
+
/*!
|
599
|
+
* @brief clamp vector's individual members between min and max values
|
600
|
+
*
|
601
|
+
* @param[in] v vector
|
602
|
+
* @param[in] minVal minimum value
|
603
|
+
* @param[in] maxVal maximum value
|
604
|
+
* @returns clamped vector
|
605
|
+
*/
|
606
|
+
CGLM_INLINE
|
607
|
+
vec4s
|
608
|
+
glms_vec4_clamp(vec4s v, float minVal, float maxVal) {
|
609
|
+
glm_vec4_clamp(v.raw, minVal, maxVal);
|
610
|
+
return v;
|
611
|
+
}
|
612
|
+
|
613
|
+
/*!
|
614
|
+
* @brief linear interpolation between two vectors
|
615
|
+
*
|
616
|
+
* formula: from + s * (to - from)
|
617
|
+
*
|
618
|
+
* @param[in] from from value
|
619
|
+
* @param[in] to to value
|
620
|
+
* @param[in] t interpolant (amount)
|
621
|
+
* @returns destination
|
622
|
+
*/
|
623
|
+
CGLM_INLINE
|
624
|
+
vec4s
|
625
|
+
glms_vec4_lerp(vec4s from, vec4s to, float t) {
|
626
|
+
vec4s r;
|
627
|
+
glm_vec4_lerp(from.raw, to.raw, t, r.raw);
|
628
|
+
return r;
|
629
|
+
}
|
630
|
+
|
631
|
+
/*!
|
632
|
+
* @brief linear interpolation between two vectors (clamped)
|
633
|
+
*
|
634
|
+
* formula: from + s * (to - from)
|
635
|
+
*
|
636
|
+
* @param[in] from from value
|
637
|
+
* @param[in] to to value
|
638
|
+
* @param[in] t interpolant (amount) clamped between 0 and 1
|
639
|
+
* @returns destination
|
640
|
+
*/
|
641
|
+
CGLM_INLINE
|
642
|
+
vec4s
|
643
|
+
glms_vec4_lerpc(vec4s from, vec4s to, float t) {
|
644
|
+
vec4s r;
|
645
|
+
glm_vec4_lerpc(from.raw, to.raw, t, r.raw);
|
646
|
+
return r;
|
647
|
+
}
|
648
|
+
|
649
|
+
/*!
|
650
|
+
* @brief linear interpolation between two vectors
|
651
|
+
*
|
652
|
+
* formula: from + s * (to - from)
|
653
|
+
*
|
654
|
+
* @param[in] from from value
|
655
|
+
* @param[in] to to value
|
656
|
+
* @param[in] t interpolant (amount)
|
657
|
+
* @returns destination
|
658
|
+
*/
|
659
|
+
CGLM_INLINE
|
660
|
+
vec4s
|
661
|
+
glms_vec4_mix(vec4s from, vec4s to, float t) {
|
662
|
+
vec4s r;
|
663
|
+
glm_vec4_mix(from.raw, to.raw, t, r.raw);
|
664
|
+
return r;
|
665
|
+
}
|
666
|
+
|
667
|
+
/*!
|
668
|
+
* @brief linear interpolation between two vectors (clamped)
|
669
|
+
*
|
670
|
+
* formula: from + s * (to - from)
|
671
|
+
*
|
672
|
+
* @param[in] from from value
|
673
|
+
* @param[in] to to value
|
674
|
+
* @param[in] t interpolant (amount) clamped between 0 and 1
|
675
|
+
* @returns destination
|
676
|
+
*/
|
677
|
+
CGLM_INLINE
|
678
|
+
vec4s
|
679
|
+
glms_vec4_mixc(vec4s from, vec4s to, float t) {
|
680
|
+
vec4s r;
|
681
|
+
glm_vec4_mixc(from.raw, to.raw, t, r.raw);
|
682
|
+
return r;
|
683
|
+
}
|
684
|
+
|
685
|
+
/*!
|
686
|
+
* @brief threshold function (unidimensional)
|
687
|
+
*
|
688
|
+
* @param[in] edge threshold
|
689
|
+
* @param[in] x value to test against threshold
|
690
|
+
* @returns 0.0 if x < edge, else 1.0
|
691
|
+
*/
|
692
|
+
CGLM_INLINE
|
693
|
+
vec4s
|
694
|
+
glms_vec4_step_uni(float edge, vec4s x) {
|
695
|
+
vec4s r;
|
696
|
+
glm_vec4_step_uni(edge, x.raw, r.raw);
|
697
|
+
return r;
|
698
|
+
}
|
699
|
+
|
700
|
+
/*!
|
701
|
+
* @brief threshold function
|
702
|
+
*
|
703
|
+
* @param[in] edge threshold
|
704
|
+
* @param[in] x value to test against threshold
|
705
|
+
* @returns 0.0 if x < edge, else 1.0
|
706
|
+
*/
|
707
|
+
CGLM_INLINE
|
708
|
+
vec4s
|
709
|
+
glms_vec4_step(vec4s edge, vec4s x) {
|
710
|
+
vec4s r;
|
711
|
+
glm_vec4_step(edge.raw, x.raw, r.raw);
|
712
|
+
return r;
|
713
|
+
}
|
714
|
+
|
715
|
+
/*!
|
716
|
+
* @brief threshold function with a smooth transition (unidimensional)
|
717
|
+
*
|
718
|
+
* @param[in] edge0 low threshold
|
719
|
+
* @param[in] edge1 high threshold
|
720
|
+
* @param[in] x value to test against threshold
|
721
|
+
* @returns destination
|
722
|
+
*/
|
723
|
+
CGLM_INLINE
|
724
|
+
vec4s
|
725
|
+
glms_vec4_smoothstep_uni(float edge0, float edge1, vec4s x) {
|
726
|
+
vec4s r;
|
727
|
+
glm_vec4_smoothstep_uni(edge0, edge1, x.raw, r.raw);
|
728
|
+
return r;
|
729
|
+
}
|
730
|
+
|
731
|
+
/*!
|
732
|
+
* @brief threshold function with a smooth transition
|
733
|
+
*
|
734
|
+
* @param[in] edge0 low threshold
|
735
|
+
* @param[in] edge1 high threshold
|
736
|
+
* @param[in] x value to test against threshold
|
737
|
+
* @returns destination
|
738
|
+
*/
|
739
|
+
CGLM_INLINE
|
740
|
+
vec4s
|
741
|
+
glms_vec4_smoothstep(vec4s edge0, vec4s edge1, vec4s x) {
|
742
|
+
vec4s r;
|
743
|
+
glm_vec4_smoothstep(edge0.raw, edge1.raw, x.raw, r.raw);
|
744
|
+
return r;
|
745
|
+
}
|
746
|
+
|
747
|
+
/*!
|
748
|
+
* @brief smooth Hermite interpolation between two vectors
|
749
|
+
*
|
750
|
+
* formula: from + s * (to - from)
|
751
|
+
*
|
752
|
+
* @param[in] from from value
|
753
|
+
* @param[in] to to value
|
754
|
+
* @param[in] t interpolant (amount)
|
755
|
+
* @returns destination
|
756
|
+
*/
|
757
|
+
CGLM_INLINE
|
758
|
+
vec4s
|
759
|
+
glms_vec4_smoothinterp(vec4s from, vec4s to, float t) {
|
760
|
+
vec4s r;
|
761
|
+
glm_vec4_smoothinterp(from.raw, to.raw, t, r.raw);
|
762
|
+
return r;
|
763
|
+
}
|
764
|
+
|
765
|
+
/*!
|
766
|
+
* @brief smooth Hermite interpolation between two vectors (clamped)
|
767
|
+
*
|
768
|
+
* formula: from + s * (to - from)
|
769
|
+
*
|
770
|
+
* @param[in] from from value
|
771
|
+
* @param[in] to to value
|
772
|
+
* @param[in] t interpolant (amount) clamped between 0 and 1
|
773
|
+
* @returns destination
|
774
|
+
*/
|
775
|
+
CGLM_INLINE
|
776
|
+
vec4s
|
777
|
+
glms_vec4_smoothinterpc(vec4s from, vec4s to, float t) {
|
778
|
+
vec4s r;
|
779
|
+
glm_vec4_smoothinterpc(from.raw, to.raw, t, r.raw);
|
780
|
+
return r;
|
781
|
+
}
|
782
|
+
|
783
|
+
/*!
|
784
|
+
* @brief helper to fill vec4 as [S^3, S^2, S, 1]
|
785
|
+
*
|
786
|
+
* @param[in] s parameter
|
787
|
+
* @returns destination
|
788
|
+
*/
|
789
|
+
CGLM_INLINE
|
790
|
+
vec4s
|
791
|
+
glms_vec4_cubic(float s) {
|
792
|
+
vec4s r;
|
793
|
+
glm_vec4_cubic(s, r.raw);
|
794
|
+
return r;
|
795
|
+
}
|
796
|
+
|
797
|
+
/*!
|
798
|
+
* @brief swizzle vector components
|
799
|
+
*
|
800
|
+
* you can use existin masks e.g. GLM_XXXX, GLM_WZYX
|
801
|
+
*
|
802
|
+
* @param[in] v source
|
803
|
+
* @param[in] mask mask
|
804
|
+
* @returns swizzled vector
|
805
|
+
*/
|
806
|
+
CGLM_INLINE
|
807
|
+
vec4s
|
808
|
+
glms_vec4_swizzle(vec4s v, int mask) {
|
809
|
+
vec4s dest;
|
810
|
+
glm_vec4_swizzle(v.raw, mask, dest.raw);
|
811
|
+
return dest;
|
812
|
+
}
|
813
|
+
|
814
|
+
#endif /* cglms_vec4s_h */
|