Blender V4.3
math_vector.c
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "BLI_math_vector.h"
10
11#include "BLI_math_base_safe.h"
12#include "BLI_math_geom.h"
13#include "BLI_math_rotation.h"
14
15#include "BLI_strict_flags.h" /* Keep last. */
16
17/* -------------------------------------------------------------------- */
21void interp_v2_v2v2(float r[2], const float a[2], const float b[2], const float t)
22{
23 const float s = 1.0f - t;
24
25 r[0] = s * a[0] + t * b[0];
26 r[1] = s * a[1] + t * b[1];
27}
28
30 float r[2], const float a[2], const float b[2], const float c[2], const float t[3])
31{
32 r[0] = a[0] * t[0] + b[0] * t[1] + c[0] * t[2];
33 r[1] = a[1] * t[0] + b[1] * t[1] + c[1] * t[2];
34}
35
36void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t)
37{
38 const float s = 1.0f - t;
39
40 r[0] = s * a[0] + t * b[0];
41 r[1] = s * a[1] + t * b[1];
42 r[2] = s * a[2] + t * b[2];
43}
44
45void interp_v4_v4v4(float r[4], const float a[4], const float b[4], const float t)
46{
47 const float s = 1.0f - t;
48
49 r[0] = s * a[0] + t * b[0];
50 r[1] = s * a[1] + t * b[1];
51 r[2] = s * a[2] + t * b[2];
52 r[3] = s * a[3] + t * b[3];
53}
54
55bool interp_v3_v3v3_slerp(float target[3], const float a[3], const float b[3], const float t)
56{
57 float cosom, w[2];
58
61
62 cosom = dot_v3v3(a, b);
63
64 /* direct opposites */
65 if (UNLIKELY(cosom < (-1.0f + FLT_EPSILON))) {
66 return false;
67 }
68
69 interp_dot_slerp(t, cosom, w);
70
71 target[0] = w[0] * a[0] + w[1] * b[0];
72 target[1] = w[0] * a[1] + w[1] * b[1];
73 target[2] = w[0] * a[2] + w[1] * b[2];
74
75 return true;
76}
77bool interp_v2_v2v2_slerp(float target[2], const float a[2], const float b[2], const float t)
78{
79 float cosom, w[2];
80
83
84 cosom = dot_v2v2(a, b);
85
86 /* direct opposites */
87 if (UNLIKELY(cosom < (1.0f + FLT_EPSILON))) {
88 return false;
89 }
90
91 interp_dot_slerp(t, cosom, w);
92
93 target[0] = w[0] * a[0] + w[1] * b[0];
94 target[1] = w[0] * a[1] + w[1] * b[1];
95
96 return true;
97}
98
99void interp_v3_v3v3_slerp_safe(float target[3], const float a[3], const float b[3], const float t)
100{
101 if (UNLIKELY(!interp_v3_v3v3_slerp(target, a, b, t))) {
102 /* Axis are aligned so any orthogonal vector is acceptable. */
103 float ab_ortho[3];
104 ortho_v3_v3(ab_ortho, a);
105 normalize_v3(ab_ortho);
106 if (t < 0.5f) {
107 if (UNLIKELY(!interp_v3_v3v3_slerp(target, a, ab_ortho, t * 2.0f))) {
108 BLI_assert(0);
109 copy_v3_v3(target, a);
110 }
111 }
112 else {
113 if (UNLIKELY(!interp_v3_v3v3_slerp(target, ab_ortho, b, (t - 0.5f) * 2.0f))) {
114 BLI_assert(0);
115 copy_v3_v3(target, b);
116 }
117 }
118 }
119}
120void interp_v2_v2v2_slerp_safe(float target[2], const float a[2], const float b[2], const float t)
121{
122 if (UNLIKELY(!interp_v2_v2v2_slerp(target, a, b, t))) {
123 /* Axis are aligned so any orthogonal vector is acceptable. */
124 float ab_ortho[2];
125 ortho_v2_v2(ab_ortho, a);
126 // normalize_v2(ab_ortho);
127 if (t < 0.5f) {
128 if (UNLIKELY(!interp_v2_v2v2_slerp(target, a, ab_ortho, t * 2.0f))) {
129 BLI_assert(0);
130 copy_v2_v2(target, a);
131 }
132 }
133 else {
134 if (UNLIKELY(!interp_v2_v2v2_slerp(target, ab_ortho, b, (t - 0.5f) * 2.0f))) {
135 BLI_assert(0);
136 copy_v2_v2(target, b);
137 }
138 }
139 }
140}
141
143 const float v1[2],
144 const float v2[2],
145 const float v3[2],
146 const float v4[2],
147 const float u)
148{
149 float q0[2], q1[2], q2[2], r0[2], r1[2];
150
151 interp_v2_v2v2(q0, v1, v2, u);
152 interp_v2_v2v2(q1, v2, v3, u);
153 interp_v2_v2v2(q2, v3, v4, u);
154
155 interp_v2_v2v2(r0, q0, q1, u);
156 interp_v2_v2v2(r1, q1, q2, u);
157
158 interp_v2_v2v2(p, r0, r1, u);
159}
160
162 float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3])
163{
164 p[0] = v1[0] * w[0] + v2[0] * w[1] + v3[0] * w[2];
165 p[1] = v1[1] * w[0] + v2[1] * w[1] + v3[1] * w[2];
166 p[2] = v1[2] * w[0] + v2[2] * w[1] + v3[2] * w[2];
167}
168
169void interp_v3_v3v3v3v3(float p[3],
170 const float v1[3],
171 const float v2[3],
172 const float v3[3],
173 const float v4[3],
174 const float w[4])
175{
176 p[0] = v1[0] * w[0] + v2[0] * w[1] + v3[0] * w[2] + v4[0] * w[3];
177 p[1] = v1[1] * w[0] + v2[1] * w[1] + v3[1] * w[2] + v4[1] * w[3];
178 p[2] = v1[2] * w[0] + v2[2] * w[1] + v3[2] * w[2] + v4[2] * w[3];
179}
180
182 float p[4], const float v1[4], const float v2[4], const float v3[4], const float w[3])
183{
184 p[0] = v1[0] * w[0] + v2[0] * w[1] + v3[0] * w[2];
185 p[1] = v1[1] * w[0] + v2[1] * w[1] + v3[1] * w[2];
186 p[2] = v1[2] * w[0] + v2[2] * w[1] + v3[2] * w[2];
187 p[3] = v1[3] * w[0] + v2[3] * w[1] + v3[3] * w[2];
188}
189
190void interp_v4_v4v4v4v4(float p[4],
191 const float v1[4],
192 const float v2[4],
193 const float v3[4],
194 const float v4[4],
195 const float w[4])
196{
197 p[0] = v1[0] * w[0] + v2[0] * w[1] + v3[0] * w[2] + v4[0] * w[3];
198 p[1] = v1[1] * w[0] + v2[1] * w[1] + v3[1] * w[2] + v4[1] * w[3];
199 p[2] = v1[2] * w[0] + v2[2] * w[1] + v3[2] * w[2] + v4[2] * w[3];
200 p[3] = v1[3] * w[0] + v2[3] * w[1] + v3[3] * w[2] + v4[3] * w[3];
201}
202
204 float p[3], const float v1[3], const float v2[3], const float v3[3], const float uv[2])
205{
206 p[0] = v1[0] + ((v2[0] - v1[0]) * uv[0]) + ((v3[0] - v1[0]) * uv[1]);
207 p[1] = v1[1] + ((v2[1] - v1[1]) * uv[0]) + ((v3[1] - v1[1]) * uv[1]);
208 p[2] = v1[2] + ((v2[2] - v1[2]) * uv[0]) + ((v3[2] - v1[2]) * uv[1]);
209}
210
211void interp_v3_v3v3_uchar(uchar target[3], const uchar a[3], const uchar b[3], const float t)
212{
213 const float s = 1.0f - t;
214
215 target[0] = (char)floorf(s * a[0] + t * b[0]);
216 target[1] = (char)floorf(s * a[1] + t * b[1]);
217 target[2] = (char)floorf(s * a[2] + t * b[2]);
218}
219void interp_v3_v3v3_char(char target[3], const char a[3], const char b[3], const float t)
220{
221 interp_v3_v3v3_uchar((uchar *)target, (const uchar *)a, (const uchar *)b, t);
222}
223
224void interp_v4_v4v4_uchar(uchar target[4], const uchar a[4], const uchar b[4], const float t)
225{
226 const float s = 1.0f - t;
227
228 target[0] = (char)floorf(s * a[0] + t * b[0]);
229 target[1] = (char)floorf(s * a[1] + t * b[1]);
230 target[2] = (char)floorf(s * a[2] + t * b[2]);
231 target[3] = (char)floorf(s * a[3] + t * b[3]);
232}
233void interp_v4_v4v4_char(char target[4], const char a[4], const char b[4], const float t)
234{
235 interp_v4_v4v4_uchar((uchar *)target, (const uchar *)a, (const uchar *)b, t);
236}
237
238void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
239{
240 r[0] = 0.5f * (a[0] + b[0]);
241 r[1] = 0.5f * (a[1] + b[1]);
242 r[2] = 0.5f * (a[2] + b[2]);
243}
244
245void mid_v2_v2v2(float r[2], const float a[2], const float b[2])
246{
247 r[0] = 0.5f * (a[0] + b[0]);
248 r[1] = 0.5f * (a[1] + b[1]);
249}
250
251void mid_v2_v2v2v2(float v[2], const float v1[2], const float v2[2], const float v3[2])
252{
253 v[0] = (v1[0] + v2[0] + v3[0]) / 3.0f;
254 v[1] = (v1[1] + v2[1] + v3[1]) / 3.0f;
255}
256
257void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3])
258{
259 v[0] = (v1[0] + v2[0] + v3[0]) / 3.0f;
260 v[1] = (v1[1] + v2[1] + v3[1]) / 3.0f;
261 v[2] = (v1[2] + v2[2] + v3[2]) / 3.0f;
262}
263
265 float v[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
266{
267 v[0] = (v1[0] + v2[0] + v3[0] + v4[0]) / 4.0f;
268 v[1] = (v1[1] + v2[1] + v3[1] + v4[1]) / 4.0f;
269 v[2] = (v1[2] + v2[2] + v3[2] + v4[2]) / 4.0f;
270}
271
272void mid_v3_v3_array(float r[3], const float (*vec_arr)[3], const uint vec_arr_num)
273{
274 const float factor = 1.0f / (float)vec_arr_num;
275 zero_v3(r);
276
277 for (uint i = 0; i < vec_arr_num; i++) {
278 madd_v3_v3fl(r, vec_arr[i], factor);
279 }
280}
281
282void mid_v3_v3v3_angle_weighted(float r[3], const float a[3], const float b[3])
283{
284 /* trick, we want the middle of 2 normals as well as the angle between them
285 * avoid multiple calculations by */
286 float angle;
287
288 /* double check they are normalized */
291
292 add_v3_v3v3(r, a, b);
293 angle = ((float)M_2_PI *
294 /* normally we would only multiply by 2,
295 * but instead of an angle make this 0-1 factor */
296 2.0f) *
297 acosf(normalize_v3(r) / 2.0f);
298 mul_v3_fl(r, angle);
299}
300void mid_v3_angle_weighted(float r[3])
301{
302 /* trick, we want the middle of 2 normals as well as the angle between them
303 * avoid multiple calculations by */
304 float angle;
305
306 /* double check they are normalized */
307 BLI_assert(len_squared_v3(r) <= 1.0f + FLT_EPSILON);
308
309 angle = ((float)M_2_PI *
310 /* normally we would only multiply by 2,
311 * but instead of an angle make this 0-1 factor */
312 2.0f) *
314 mul_v3_fl(r, angle);
315}
316
322void flip_v4_v4v4(float v[4], const float v1[4], const float v2[4])
323{
324 v[0] = v1[0] + (v1[0] - v2[0]);
325 v[1] = v1[1] + (v1[1] - v2[1]);
326 v[2] = v1[2] + (v1[2] - v2[2]);
327 v[3] = v1[3] + (v1[3] - v2[3]);
328}
329
330void flip_v3_v3v3(float v[3], const float v1[3], const float v2[3])
331{
332 v[0] = v1[0] + (v1[0] - v2[0]);
333 v[1] = v1[1] + (v1[1] - v2[1]);
334 v[2] = v1[2] + (v1[2] - v2[2]);
335}
336
337void flip_v2_v2v2(float v[2], const float v1[2], const float v2[2])
338{
339 v[0] = v1[0] + (v1[0] - v2[0]);
340 v[1] = v1[1] + (v1[1] - v2[1]);
341}
342
345/* -------------------------------------------------------------------- */
349bool is_finite_v2(const float v[2])
350{
351 return (isfinite(v[0]) && isfinite(v[1]));
352}
353
354bool is_finite_v3(const float v[3])
355{
356 return (isfinite(v[0]) && isfinite(v[1]) && isfinite(v[2]));
357}
358
359bool is_finite_v4(const float v[4])
360{
361 return (isfinite(v[0]) && isfinite(v[1]) && isfinite(v[2]) && isfinite(v[3]));
362}
363
366/* -------------------------------------------------------------------- */
370float angle_v3v3v3(const float a[3], const float b[3], const float c[3])
371{
372 float vec1[3], vec2[3];
373
374 sub_v3_v3v3(vec1, b, a);
375 sub_v3_v3v3(vec2, b, c);
376 normalize_v3(vec1);
377 normalize_v3(vec2);
378
379 return angle_normalized_v3v3(vec1, vec2);
380}
381
382float cos_v3v3v3(const float p1[3], const float p2[3], const float p3[3])
383{
384 float vec1[3], vec2[3];
385
386 sub_v3_v3v3(vec1, p2, p1);
387 sub_v3_v3v3(vec2, p2, p3);
388 normalize_v3(vec1);
389 normalize_v3(vec2);
390
391 return dot_v3v3(vec1, vec2);
392}
393
394float angle_v3v3(const float a[3], const float b[3])
395{
396 float vec1[3], vec2[3];
397
398 normalize_v3_v3(vec1, a);
399 normalize_v3_v3(vec2, b);
400
401 return angle_normalized_v3v3(vec1, vec2);
402}
403
404float angle_v2v2v2(const float a[2], const float b[2], const float c[2])
405{
406 float vec1[2], vec2[2];
407
408 vec1[0] = b[0] - a[0];
409 vec1[1] = b[1] - a[1];
410
411 vec2[0] = b[0] - c[0];
412 vec2[1] = b[1] - c[1];
413
414 normalize_v2(vec1);
415 normalize_v2(vec2);
416
417 return angle_normalized_v2v2(vec1, vec2);
418}
419
420float cos_v2v2v2(const float p1[2], const float p2[2], const float p3[2])
421{
422 float vec1[2], vec2[2];
423
424 sub_v2_v2v2(vec1, p2, p1);
425 sub_v2_v2v2(vec2, p2, p3);
426 normalize_v2(vec1);
427 normalize_v2(vec2);
428
429 return dot_v2v2(vec1, vec2);
430}
431
432float angle_v2v2(const float a[2], const float b[2])
433{
434 float vec1[2], vec2[2];
435
436 vec1[0] = a[0];
437 vec1[1] = a[1];
438
439 vec2[0] = b[0];
440 vec2[1] = b[1];
441
442 normalize_v2(vec1);
443 normalize_v2(vec2);
444
445 return angle_normalized_v2v2(vec1, vec2);
446}
447
448float angle_signed_v2v2(const float v1[2], const float v2[2])
449{
450 const float perp_dot = (v1[1] * v2[0]) - (v1[0] * v2[1]);
451 return atan2f(perp_dot, dot_v2v2(v1, v2));
452}
453
454float angle_normalized_v3v3(const float v1[3], const float v2[3])
455{
456 /* double check they are normalized */
459
460 /* this is the same as acos(dot_v3v3(v1, v2)), but more accurate */
461 if (dot_v3v3(v1, v2) >= 0.0f) {
462 return 2.0f * safe_asinf(len_v3v3(v1, v2) / 2.0f);
463 }
464
465 float v2_n[3];
466 negate_v3_v3(v2_n, v2);
467 return (float)M_PI - 2.0f * safe_asinf(len_v3v3(v1, v2_n) / 2.0f);
468}
469
470float angle_normalized_v2v2(const float a[2], const float b[2])
471{
472 /* double check they are normalized */
475
476 /* this is the same as acos(dot_v3v3(v1, v2)), but more accurate */
477 if (dot_v2v2(a, b) >= 0.0f) {
478 return 2.0f * safe_asinf(len_v2v2(a, b) / 2.0f);
479 }
480
481 float v2_n[2];
482 negate_v2_v2(v2_n, b);
483 return (float)M_PI - 2.0f * safe_asinf(len_v2v2(a, v2_n) / 2.0f);
484}
485
486float angle_on_axis_v3v3_v3(const float v1[3], const float v2[3], const float axis[3])
487{
488 float v1_proj[3], v2_proj[3];
489
490 /* project the vectors onto the axis */
491 project_plane_normalized_v3_v3v3(v1_proj, v1, axis);
492 project_plane_normalized_v3_v3v3(v2_proj, v2, axis);
493
494 return angle_v3v3(v1_proj, v2_proj);
495}
496
497float angle_signed_on_axis_v3v3_v3(const float v1[3], const float v2[3], const float axis[3])
498{
499 float v1_proj[3], v2_proj[3], tproj[3];
500 float angle;
501
502 /* project the vectors onto the axis */
503 project_plane_normalized_v3_v3v3(v1_proj, v1, axis);
504 project_plane_normalized_v3_v3v3(v2_proj, v2, axis);
505
506 angle = angle_v3v3(v1_proj, v2_proj);
507
508 /* calculate the sign (reuse 'tproj') */
509 cross_v3_v3v3(tproj, v2_proj, v1_proj);
510 if (dot_v3v3(tproj, axis) < 0.0f) {
511 angle = (float)(M_PI * 2.0) - angle;
512 }
513
514 return angle;
515}
516
517float angle_on_axis_v3v3v3_v3(const float v1[3],
518 const float v2[3],
519 const float v3[3],
520 const float axis[3])
521{
522 float vec1[3], vec2[3];
523
524 sub_v3_v3v3(vec1, v1, v2);
525 sub_v3_v3v3(vec2, v3, v2);
526
527 return angle_on_axis_v3v3_v3(vec1, vec2, axis);
528}
529
530float angle_signed_on_axis_v3v3v3_v3(const float v1[3],
531 const float v2[3],
532 const float v3[3],
533 const float axis[3])
534{
535 float vec1[3], vec2[3];
536
537 sub_v3_v3v3(vec1, v1, v2);
538 sub_v3_v3v3(vec2, v3, v2);
539
540 return angle_signed_on_axis_v3v3_v3(vec1, vec2, axis);
541}
542
543void angle_tri_v3(float angles[3], const float v1[3], const float v2[3], const float v3[3])
544{
545 float ed1[3], ed2[3], ed3[3];
546
547 sub_v3_v3v3(ed1, v3, v1);
548 sub_v3_v3v3(ed2, v1, v2);
549 sub_v3_v3v3(ed3, v2, v3);
550
551 normalize_v3(ed1);
552 normalize_v3(ed2);
553 normalize_v3(ed3);
554
555 angles[0] = (float)M_PI - angle_normalized_v3v3(ed1, ed2);
556 angles[1] = (float)M_PI - angle_normalized_v3v3(ed2, ed3);
557 // face_angles[2] = M_PI - angle_normalized_v3v3(ed3, ed1);
558 angles[2] = (float)M_PI - (angles[0] + angles[1]);
559}
560
562 float angles[4], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
563{
564 float ed1[3], ed2[3], ed3[3], ed4[3];
565
566 sub_v3_v3v3(ed1, v4, v1);
567 sub_v3_v3v3(ed2, v1, v2);
568 sub_v3_v3v3(ed3, v2, v3);
569 sub_v3_v3v3(ed4, v3, v4);
570
571 normalize_v3(ed1);
572 normalize_v3(ed2);
573 normalize_v3(ed3);
574 normalize_v3(ed4);
575
576 angles[0] = (float)M_PI - angle_normalized_v3v3(ed1, ed2);
577 angles[1] = (float)M_PI - angle_normalized_v3v3(ed2, ed3);
578 angles[2] = (float)M_PI - angle_normalized_v3v3(ed3, ed4);
579 angles[3] = (float)M_PI - angle_normalized_v3v3(ed4, ed1);
580}
581
582void angle_poly_v3(float *angles, const float *verts[3], int len)
583{
584 int i;
585 float vec[3][3];
586
587 sub_v3_v3v3(vec[2], verts[len - 1], verts[0]);
588 normalize_v3(vec[2]);
589 for (i = 0; i < len; i++) {
590 sub_v3_v3v3(vec[i % 3], verts[i % len], verts[(i + 1) % len]);
591 normalize_v3(vec[i % 3]);
592 angles[i] = (float)M_PI - angle_normalized_v3v3(vec[(i + 2) % 3], vec[i % 3]);
593 }
594}
595
598/* -------------------------------------------------------------------- */
602void project_v2_v2v2(float out[2], const float p[2], const float v_proj[2])
603{
604 if (UNLIKELY(is_zero_v2(v_proj))) {
605 zero_v2(out);
606 return;
607 }
608
609 const float mul = dot_v2v2(p, v_proj) / dot_v2v2(v_proj, v_proj);
610 mul_v2_v2fl(out, v_proj, mul);
611}
612
613void project_v3_v3v3(float out[3], const float p[3], const float v_proj[3])
614{
615 if (UNLIKELY(is_zero_v3(v_proj))) {
616 zero_v3(out);
617 return;
618 }
619
620 const float mul = dot_v3v3(p, v_proj) / dot_v3v3(v_proj, v_proj);
621 mul_v3_v3fl(out, v_proj, mul);
622}
623
624void project_v3_v3v3_db(double out[3], const double p[3], const double v_proj[3])
625{
626 if (UNLIKELY(is_zero_v3_db(v_proj))) {
627 zero_v3_db(out);
628 return;
629 }
630
631 const double mul = dot_v3v3_db(p, v_proj) / dot_v3v3_db(v_proj, v_proj);
632 mul_v3_v3db_db(out, v_proj, mul);
633}
634
635void project_v2_v2v2_normalized(float out[2], const float p[2], const float v_proj[2])
636{
637 BLI_ASSERT_UNIT_V2(v_proj);
638
639 const float mul = dot_v2v2(p, v_proj);
640 mul_v2_v2fl(out, v_proj, mul);
641}
642
643void project_v3_v3v3_normalized(float out[3], const float p[3], const float v_proj[3])
644{
645 BLI_ASSERT_UNIT_V3(v_proj);
646
647 const float mul = dot_v3v3(p, v_proj);
648 mul_v3_v3fl(out, v_proj, mul);
649}
650
651void project_plane_v3_v3v3(float out[3], const float p[3], const float v_plane[3])
652{
653 const float mul = dot_v3v3(p, v_plane) / dot_v3v3(v_plane, v_plane);
654 /* out[x] = p[x] - (mul * v_plane[x]) */
655 madd_v3_v3v3fl(out, p, v_plane, -mul);
656}
657
658void project_plane_v2_v2v2(float out[2], const float p[2], const float v_plane[2])
659{
660 const float mul = dot_v2v2(p, v_plane) / dot_v2v2(v_plane, v_plane);
661 /* out[x] = p[x] - (mul * v_plane[x]) */
662 madd_v2_v2v2fl(out, p, v_plane, -mul);
663}
664
665void project_plane_normalized_v3_v3v3(float out[3], const float p[3], const float v_plane[3])
666{
667 BLI_ASSERT_UNIT_V3(v_plane);
668 const float mul = dot_v3v3(p, v_plane);
669 /* out[x] = p[x] - (mul * v_plane[x]) */
670 madd_v3_v3v3fl(out, p, v_plane, -mul);
671}
672
673void project_plane_normalized_v2_v2v2(float out[2], const float p[2], const float v_plane[2])
674{
675 BLI_ASSERT_UNIT_V2(v_plane);
676 const float mul = dot_v2v2(p, v_plane);
677 /* out[x] = p[x] - (mul * v_plane[x]) */
678 madd_v2_v2v2fl(out, p, v_plane, -mul);
679}
680
681void project_v3_plane(float out[3], const float plane_no[3], const float plane_co[3])
682{
683 float vector[3];
684 float mul;
685
686 sub_v3_v3v3(vector, out, plane_co);
687 mul = dot_v3v3(vector, plane_no) / len_squared_v3(plane_no);
688
689 /* out[x] = out[x] - (mul * plane_no[x]) */
690 madd_v3_v3fl(out, plane_no, -mul);
691}
692
693void bisect_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3])
694{
695 float d_12[3], d_23[3];
696 sub_v3_v3v3(d_12, b, a);
697 sub_v3_v3v3(d_23, c, b);
698 normalize_v3(d_12);
699 normalize_v3(d_23);
700 add_v3_v3v3(r, d_12, d_23);
701 normalize_v3(r);
702}
703
704void reflect_v3_v3v3(float out[3], const float v[3], const float normal[3])
705{
706 BLI_ASSERT_UNIT_V3(normal);
707 const float dot2 = 2.0f * dot_v3v3(v, normal);
708 /* out[x] = v[x] - (dot2 * normal[x]) */
709 madd_v3_v3v3fl(out, v, normal, -dot2);
710}
711
712void reflect_v3_v3v3_db(double out[3], const double v[3], const double normal[3])
713{
714 BLI_ASSERT_UNIT_V3_DB(normal);
715 const double dot2 = 2.0 * dot_v3v3_db(v, normal);
716 /* out[x] = v[x] - (dot2 * normal[x]) */
717 madd_v3_v3v3db_db(out, v, normal, -dot2);
718}
719
720void ortho_basis_v3v3_v3(float r_n1[3], float r_n2[3], const float n[3])
721{
722 const float eps = FLT_EPSILON;
723 const float f = len_squared_v2(n);
724
725 if (f > eps) {
726 const float d = 1.0f / sqrtf(f);
727
728 BLI_assert(isfinite(d));
729
730 r_n1[0] = n[1] * d;
731 r_n1[1] = -n[0] * d;
732 r_n1[2] = 0.0f;
733 r_n2[0] = -n[2] * r_n1[1];
734 r_n2[1] = n[2] * r_n1[0];
735 r_n2[2] = n[0] * r_n1[1] - n[1] * r_n1[0];
736 }
737 else {
738 /* degenerate case */
739 r_n1[0] = (n[2] < 0.0f) ? -1.0f : 1.0f;
740 r_n1[1] = r_n1[2] = r_n2[0] = r_n2[2] = 0.0f;
741 r_n2[1] = 1.0f;
742 }
743}
744
745void ortho_v3_v3(float out[3], const float v[3])
746{
747 const int axis = axis_dominant_v3_single(v);
748
749 BLI_assert(out != v);
750
751 switch (axis) {
752 case 0:
753 out[0] = -v[1] - v[2];
754 out[1] = v[0];
755 out[2] = v[0];
756 break;
757 case 1:
758 out[0] = v[1];
759 out[1] = -v[0] - v[2];
760 out[2] = v[1];
761 break;
762 case 2:
763 out[0] = v[2];
764 out[1] = v[2];
765 out[2] = -v[0] - v[1];
766 break;
767 }
768}
769
770void ortho_v2_v2(float out[2], const float v[2])
771{
772 BLI_assert(out != v);
773
774 out[0] = -v[1];
775 out[1] = v[0];
776}
777
778void rotate_v2_v2fl(float r[2], const float p[2], const float angle)
779{
780 const float co = cosf(angle);
781 const float si = sinf(angle);
782
783 BLI_assert(r != p);
784
785 r[0] = co * p[0] - si * p[1];
786 r[1] = si * p[0] + co * p[1];
787}
788
790 const float p[3],
791 const float axis[3],
792 const float angle)
793{
794 const float costheta = cosf(angle);
795 const float sintheta = sinf(angle);
796
797 /* double check they are normalized */
798 BLI_ASSERT_UNIT_V3(axis);
799
800 out[0] = ((costheta + (1 - costheta) * axis[0] * axis[0]) * p[0]) +
801 (((1 - costheta) * axis[0] * axis[1] - axis[2] * sintheta) * p[1]) +
802 (((1 - costheta) * axis[0] * axis[2] + axis[1] * sintheta) * p[2]);
803
804 out[1] = (((1 - costheta) * axis[0] * axis[1] + axis[2] * sintheta) * p[0]) +
805 ((costheta + (1 - costheta) * axis[1] * axis[1]) * p[1]) +
806 (((1 - costheta) * axis[1] * axis[2] - axis[0] * sintheta) * p[2]);
807
808 out[2] = (((1 - costheta) * axis[0] * axis[2] - axis[1] * sintheta) * p[0]) +
809 (((1 - costheta) * axis[1] * axis[2] + axis[0] * sintheta) * p[1]) +
810 ((costheta + (1 - costheta) * axis[2] * axis[2]) * p[2]);
811}
812
813void rotate_v3_v3v3fl(float r[3], const float p[3], const float axis[3], const float angle)
814{
815 BLI_assert(r != p);
816
817 float axis_n[3];
818
819 normalize_v3_v3(axis_n, axis);
820
821 rotate_normalized_v3_v3v3fl(r, p, axis_n, angle);
822}
823
826/* -------------------------------------------------------------------- */
830void print_v2(const char *str, const float v[2])
831{
832 printf("%s: %.8f %.8f\n", str, v[0], v[1]);
833}
834
835void print_v3(const char *str, const float v[3])
836{
837 printf("%s: %.8f %.8f %.8f\n", str, v[0], v[1], v[2]);
838}
839
840void print_v4(const char *str, const float v[4])
841{
842 printf("%s: %.8f %.8f %.8f %.8f\n", str, v[0], v[1], v[2], v[3]);
843}
844
845void print_vn(const char *str, const float v[], const int n)
846{
847 int i = 0;
848 printf("%s[%d]:", str, n);
849 while (i < n) {
850 printf(" %.8f", v[i++]);
851 }
852 printf("\n");
853}
854
855void minmax_v4v4_v4(float min[4], float max[4], const float vec[4])
856{
857 if (min[0] > vec[0]) {
858 min[0] = vec[0];
859 }
860 if (min[1] > vec[1]) {
861 min[1] = vec[1];
862 }
863 if (min[2] > vec[2]) {
864 min[2] = vec[2];
865 }
866 if (min[3] > vec[3]) {
867 min[3] = vec[3];
868 }
869
870 if (max[0] < vec[0]) {
871 max[0] = vec[0];
872 }
873 if (max[1] < vec[1]) {
874 max[1] = vec[1];
875 }
876 if (max[2] < vec[2]) {
877 max[2] = vec[2];
878 }
879 if (max[3] < vec[3]) {
880 max[3] = vec[3];
881 }
882}
883
884void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
885{
886 if (min[0] > vec[0]) {
887 min[0] = vec[0];
888 }
889 if (min[1] > vec[1]) {
890 min[1] = vec[1];
891 }
892 if (min[2] > vec[2]) {
893 min[2] = vec[2];
894 }
895
896 if (max[0] < vec[0]) {
897 max[0] = vec[0];
898 }
899 if (max[1] < vec[1]) {
900 max[1] = vec[1];
901 }
902 if (max[2] < vec[2]) {
903 max[2] = vec[2];
904 }
905}
906
907void minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
908{
909 if (min[0] > vec[0]) {
910 min[0] = vec[0];
911 }
912 if (min[1] > vec[1]) {
913 min[1] = vec[1];
914 }
915
916 if (max[0] < vec[0]) {
917 max[0] = vec[0];
918 }
919 if (max[1] < vec[1]) {
920 max[1] = vec[1];
921 }
922}
923
924void dist_ensure_v3_v3fl(float v1[3], const float v2[3], const float dist)
925{
926 if (!equals_v3v3(v2, v1)) {
927 float nor[3];
928
929 sub_v3_v3v3(nor, v1, v2);
931 madd_v3_v3v3fl(v1, v2, nor, dist);
932 }
933}
934
935void dist_ensure_v2_v2fl(float v1[2], const float v2[2], const float dist)
936{
937 if (!equals_v2v2(v2, v1)) {
938 float nor[2];
939
940 sub_v2_v2v2(nor, v1, v2);
942 madd_v2_v2v2fl(v1, v2, nor, dist);
943 }
944}
945
946void axis_sort_v3(const float axis_values[3], int r_axis_order[3])
947{
948 float v[3];
949 copy_v3_v3(v, axis_values);
950
951#define SWAP_AXIS(a, b) \
952 { \
953 SWAP(float, v[a], v[b]); \
954 SWAP(int, r_axis_order[a], r_axis_order[b]); \
955 } \
956 (void)0
957
958 if (v[0] < v[1]) {
959 if (v[2] < v[0]) {
960 SWAP_AXIS(0, 2);
961 }
962 }
963 else {
964 if (v[1] < v[2]) {
965 SWAP_AXIS(0, 1);
966 }
967 else {
968 SWAP_AXIS(0, 2);
969 }
970 }
971 if (v[2] < v[1]) {
972 SWAP_AXIS(1, 2);
973 }
974
975#undef SWAP_AXIS
976}
977
980/* -------------------------------------------------------------------- */
984MINLINE double sqr_db(double f)
985{
986 return f * f;
987}
988
989double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int size)
990{
991 double d = 0.0f;
992 const float *array_pt_a = array_src_a + (size - 1);
993 const float *array_pt_b = array_src_b + (size - 1);
994 int i = size;
995 while (i--) {
996 d += (double)(*(array_pt_a--) * *(array_pt_b--));
997 }
998 return d;
999}
1000
1001double len_squared_vn(const float *array, const int size)
1002{
1003 double d = 0.0f;
1004 const float *array_pt = array + (size - 1);
1005 int i = size;
1006 while (i--) {
1007 d += sqr_db((double)*(array_pt--));
1008 }
1009 return d;
1010}
1011
1012float normalize_vn_vn(float *array_tar, const float *array_src, const int size)
1013{
1014 const double d = len_squared_vn(array_src, size);
1015 float d_sqrt;
1016 if (d > 1.0e-35) {
1017 d_sqrt = (float)sqrt(d);
1018 mul_vn_vn_fl(array_tar, array_src, size, 1.0f / d_sqrt);
1019 }
1020 else {
1021 copy_vn_fl(array_tar, size, 0.0f);
1022 d_sqrt = 0.0f;
1023 }
1024 return d_sqrt;
1025}
1026
1027float normalize_vn(float *array_tar, const int size)
1028{
1029 return normalize_vn_vn(array_tar, array_tar, size);
1030}
1031
1032void range_vn_i(int *array_tar, const int size, const int start)
1033{
1034 int *array_pt = array_tar + (size - 1);
1035 int j = start + (size - 1);
1036 int i = size;
1037 while (i--) {
1038 *(array_pt--) = j--;
1039 }
1040}
1041
1042void range_vn_u(uint *array_tar, const int size, const uint start)
1043{
1044 uint *array_pt = array_tar + (size - 1);
1045 uint j = start + (uint)(size - 1);
1046 int i = size;
1047 while (i--) {
1048 *(array_pt--) = j--;
1049 }
1050}
1051
1052void range_vn_fl(float *array_tar, const int size, const float start, const float step)
1053{
1054 float *array_pt = array_tar + (size - 1);
1055 int i = size;
1056 while (i--) {
1057 *(array_pt--) = start + step * (float)(i);
1058 }
1059}
1060
1061void negate_vn(float *array_tar, const int size)
1062{
1063 float *array_pt = array_tar + (size - 1);
1064 int i = size;
1065 while (i--) {
1066 *(array_pt--) *= -1.0f;
1067 }
1068}
1069
1070void negate_vn_vn(float *array_tar, const float *array_src, const int size)
1071{
1072 float *tar = array_tar + (size - 1);
1073 const float *src = array_src + (size - 1);
1074 int i = size;
1075 while (i--) {
1076 *(tar--) = -*(src--);
1077 }
1078}
1079
1080void mul_vn_vn(float *array_tar, const float *array_src, const int size)
1081{
1082 float *tar = array_tar + (size - 1);
1083 const float *src = array_src + (size - 1);
1084 int i = size;
1085 while (i--) {
1086 *(tar--) *= *(src--);
1087 }
1088}
1089
1090void mul_vn_vnvn(float *array_tar,
1091 const float *array_src_a,
1092 const float *array_src_b,
1093 const int size)
1094{
1095 float *tar = array_tar + (size - 1);
1096 const float *src_a = array_src_a + (size - 1);
1097 const float *src_b = array_src_b + (size - 1);
1098 int i = size;
1099 while (i--) {
1100 *(tar--) = *(src_a--) * *(src_b--);
1101 }
1102}
1103
1104void mul_vn_fl(float *array_tar, const int size, const float f)
1105{
1106 float *array_pt = array_tar + (size - 1);
1107 int i = size;
1108 while (i--) {
1109 *(array_pt--) *= f;
1110 }
1111}
1112
1113void mul_vn_vn_fl(float *array_tar, const float *array_src, const int size, const float f)
1114{
1115 float *tar = array_tar + (size - 1);
1116 const float *src = array_src + (size - 1);
1117 int i = size;
1118 while (i--) {
1119 *(tar--) = *(src--) * f;
1120 }
1121}
1122
1123void add_vn_vn(float *array_tar, const float *array_src, const int size)
1124{
1125 float *tar = array_tar + (size - 1);
1126 const float *src = array_src + (size - 1);
1127 int i = size;
1128 while (i--) {
1129 *(tar--) += *(src--);
1130 }
1131}
1132
1133void add_vn_vnvn(float *array_tar,
1134 const float *array_src_a,
1135 const float *array_src_b,
1136 const int size)
1137{
1138 float *tar = array_tar + (size - 1);
1139 const float *src_a = array_src_a + (size - 1);
1140 const float *src_b = array_src_b + (size - 1);
1141 int i = size;
1142 while (i--) {
1143 *(tar--) = *(src_a--) + *(src_b--);
1144 }
1145}
1146
1147void madd_vn_vn(float *array_tar, const float *array_src, const float f, const int size)
1148{
1149 float *tar = array_tar + (size - 1);
1150 const float *src = array_src + (size - 1);
1151 int i = size;
1152 while (i--) {
1153 *(tar--) += *(src--) * f;
1154 }
1155}
1156
1157void madd_vn_vnvn(float *array_tar,
1158 const float *array_src_a,
1159 const float *array_src_b,
1160 const float f,
1161 const int size)
1162{
1163 float *tar = array_tar + (size - 1);
1164 const float *src_a = array_src_a + (size - 1);
1165 const float *src_b = array_src_b + (size - 1);
1166 int i = size;
1167 while (i--) {
1168 *(tar--) = *(src_a--) + (*(src_b--) * f);
1169 }
1170}
1171
1172void sub_vn_vn(float *array_tar, const float *array_src, const int size)
1173{
1174 float *tar = array_tar + (size - 1);
1175 const float *src = array_src + (size - 1);
1176 int i = size;
1177 while (i--) {
1178 *(tar--) -= *(src--);
1179 }
1180}
1181
1182void sub_vn_vnvn(float *array_tar,
1183 const float *array_src_a,
1184 const float *array_src_b,
1185 const int size)
1186{
1187 float *tar = array_tar + (size - 1);
1188 const float *src_a = array_src_a + (size - 1);
1189 const float *src_b = array_src_b + (size - 1);
1190 int i = size;
1191 while (i--) {
1192 *(tar--) = *(src_a--) - *(src_b--);
1193 }
1194}
1195
1196void msub_vn_vn(float *array_tar, const float *array_src, const float f, const int size)
1197{
1198 float *tar = array_tar + (size - 1);
1199 const float *src = array_src + (size - 1);
1200 int i = size;
1201 while (i--) {
1202 *(tar--) -= *(src--) * f;
1203 }
1204}
1205
1206void msub_vn_vnvn(float *array_tar,
1207 const float *array_src_a,
1208 const float *array_src_b,
1209 const float f,
1210 const int size)
1211{
1212 float *tar = array_tar + (size - 1);
1213 const float *src_a = array_src_a + (size - 1);
1214 const float *src_b = array_src_b + (size - 1);
1215 int i = size;
1216 while (i--) {
1217 *(tar--) = *(src_a--) - (*(src_b--) * f);
1218 }
1219}
1220
1221void interp_vn_vn(float *array_tar, const float *array_src, const float t, const int size)
1222{
1223 const float s = 1.0f - t;
1224 float *tar = array_tar + (size - 1);
1225 const float *src = array_src + (size - 1);
1226 int i = size;
1227 while (i--) {
1228 *(tar) = (s * *(tar)) + (t * *(src));
1229 tar--;
1230 src--;
1231 }
1232}
1233
1234void copy_vn_i(int *array_tar, const int size, const int val)
1235{
1236 int *tar = array_tar + (size - 1);
1237 int i = size;
1238 while (i--) {
1239 *(tar--) = val;
1240 }
1241}
1242
1243void copy_vn_short(short *array_tar, const int size, const short val)
1244{
1245 short *tar = array_tar + (size - 1);
1246 int i = size;
1247 while (i--) {
1248 *(tar--) = val;
1249 }
1250}
1251
1252void copy_vn_ushort(ushort *array_tar, const int size, const ushort val)
1253{
1254 ushort *tar = array_tar + (size - 1);
1255 int i = size;
1256 while (i--) {
1257 *(tar--) = val;
1258 }
1259}
1260
1261void copy_vn_uchar(uchar *array_tar, const int size, const uchar val)
1262{
1263 uchar *tar = array_tar + (size - 1);
1264 int i = size;
1265 while (i--) {
1266 *(tar--) = val;
1267 }
1268}
1269
1270void copy_vn_fl(float *array_tar, const int size, const float val)
1271{
1272 float *tar = array_tar + (size - 1);
1273 int i = size;
1274 while (i--) {
1275 *(tar--) = val;
1276 }
1277}
1278
1281/* -------------------------------------------------------------------- */
1285void add_vn_vn_d(double *array_tar, const double *array_src, const int size)
1286{
1287 double *tar = array_tar + (size - 1);
1288 const double *src = array_src + (size - 1);
1289 int i = size;
1290 while (i--) {
1291 *(tar--) += *(src--);
1292 }
1293}
1294
1295void add_vn_vnvn_d(double *array_tar,
1296 const double *array_src_a,
1297 const double *array_src_b,
1298 const int size)
1299{
1300 double *tar = array_tar + (size - 1);
1301 const double *src_a = array_src_a + (size - 1);
1302 const double *src_b = array_src_b + (size - 1);
1303 int i = size;
1304 while (i--) {
1305 *(tar--) = *(src_a--) + *(src_b--);
1306 }
1307}
1308
1309void mul_vn_db(double *array_tar, const int size, const double f)
1310{
1311 double *array_pt = array_tar + (size - 1);
1312 int i = size;
1313 while (i--) {
1314 *(array_pt--) *= f;
1315 }
1316}
1317
1318void interp_v3_v3v3_db(double target[3], const double a[3], const double b[3], const double t)
1319{
1320 const double s = 1.0f - t;
1321
1322 target[0] = s * a[0] + t * b[0];
1323 target[1] = s * a[1] + t * b[1];
1324 target[2] = s * a[2] + t * b[2];
1325}
1326
1327void interp_v2_v2v2_db(double target[2], const double a[2], const double b[2], const double t)
1328{
1329 const double s = 1.0f - t;
1330
1331 target[0] = s * a[0] + t * b[0];
1332 target[1] = s * a[1] + t * b[1];
1333}
1334
#define BLI_assert(a)
Definition BLI_assert.h:50
sqrt(x)+1/max(0
#define BLI_ASSERT_UNIT_V3_DB(v)
#define BLI_ASSERT_UNIT_V2(v)
#define BLI_ASSERT_UNIT_V3(v)
#define M_PI
MINLINE float safe_asinf(float a)
MINLINE int axis_dominant_v3_single(const float vec[3])
#define MINLINE
void interp_dot_slerp(float t, float cosom, float r_w[2])
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_squared_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE bool is_zero_v3_db(const double v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void madd_v2_v2v2fl(float r[2], const float a[2], const float b[2], float f)
MINLINE void madd_v3_v3v3db_db(double r[3], const double a[3], const double b[3], double f)
MINLINE bool equals_v3v3(const float v1[3], const float v2[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE float len_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void mul_v3_v3db_db(double r[3], const double a[3], double f)
MINLINE bool is_zero_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void negate_v3_v3(float r[3], const float a[3])
MINLINE double dot_v3v3_db(const double a[3], const double b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void negate_v2_v2(float r[2], const float a[2])
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE bool equals_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float normalize_v3_v3(float r[3], const float a[3])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void zero_v2(float r[2])
MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float normalize_v2(float n[2])
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
MINLINE void zero_v3(float r[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f)
MINLINE void zero_v3_db(double r[3])
MINLINE float normalize_v3(float n[3])
unsigned char uchar
unsigned short ushort
unsigned int uint
#define UNLIKELY(x)
typedef double(DMatrix)[4][4]
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
Definition IK_Math.h:125
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
static void mul(btAlignedObjectArray< T > &items, const Q &value)
local_group_size(16, 16) .push_constant(Type b
#define printf
#define sinf(x)
#define cosf(x)
#define atan2f(x, y)
#define floorf(x)
#define acosf(x)
#define sqrtf(x)
int len
draw_view in_light_buf[] float
#define str(s)
static float verts[][3]
void mid_v3_v3v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
void copy_vn_fl(float *array_tar, const int size, const float val)
void project_v2_v2v2_normalized(float out[2], const float p[2], const float v_proj[2])
void madd_vn_vn(float *array_tar, const float *array_src, const float f, const int size)
void add_vn_vn_d(double *array_tar, const double *array_src, const int size)
void negate_vn(float *array_tar, const int size)
void interp_v2_v2v2(float r[2], const float a[2], const float b[2], const float t)
Definition math_vector.c:21
void reflect_v3_v3v3_db(double out[3], const double v[3], const double normal[3])
void angle_quad_v3(float angles[4], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
void axis_sort_v3(const float axis_values[3], int r_axis_order[3])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t)
Definition math_vector.c:36
void sub_vn_vn(float *array_tar, const float *array_src, const int size)
void mul_vn_db(double *array_tar, const int size, const double f)
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
void rotate_v2_v2fl(float r[2], const float p[2], const float angle)
void mul_vn_vn_fl(float *array_tar, const float *array_src, const int size, const float f)
void copy_vn_i(int *array_tar, const int size, const int val)
void print_v3(const char *str, const float v[3])
void madd_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const float f, const int size)
bool is_finite_v2(const float v[2])
void project_plane_normalized_v2_v2v2(float out[2], const float p[2], const float v_plane[2])
void interp_v4_v4v4_char(char target[4], const char a[4], const char b[4], const float t)
float angle_on_axis_v3v3_v3(const float v1[3], const float v2[3], const float axis[3])
float normalize_vn(float *array_tar, const int size)
float angle_v3v3v3(const float a[3], const float b[3], const float c[3])
void reflect_v3_v3v3(float out[3], const float v[3], const float normal[3])
bool is_finite_v4(const float v[4])
void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3])
float angle_normalized_v3v3(const float v1[3], const float v2[3])
void interp_v4_v4v4v4v4(float p[4], const float v1[4], const float v2[4], const float v3[4], const float v4[4], const float w[4])
#define SWAP_AXIS(a, b)
void sub_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size)
void interp_v3_v3v3_db(double target[3], const double a[3], const double b[3], const double t)
double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int size)
void angle_tri_v3(float angles[3], const float v1[3], const float v2[3], const float v3[3])
void add_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size)
void interp_v3_v3v3_char(char target[3], const char a[3], const char b[3], const float t)
void mid_v3_angle_weighted(float r[3])
float angle_v3v3(const float a[3], const float b[3])
void interp_v4_v4v4(float r[4], const float a[4], const float b[4], const float t)
Definition math_vector.c:45
void mid_v2_v2v2v2(float v[2], const float v1[2], const float v2[2], const float v3[2])
void project_v3_plane(float out[3], const float plane_no[3], const float plane_co[3])
float cos_v3v3v3(const float p1[3], const float p2[3], const float p3[3])
void add_vn_vn(float *array_tar, const float *array_src, const int size)
void project_v3_v3v3_normalized(float out[3], const float p[3], const float v_proj[3])
void interp_v2_v2v2v2(float r[2], const float a[2], const float b[2], const float c[2], const float t[3])
Definition math_vector.c:29
void print_v4(const char *str, const float v[4])
bool interp_v3_v3v3_slerp(float target[3], const float a[3], const float b[3], const float t)
Definition math_vector.c:55
float normalize_vn_vn(float *array_tar, const float *array_src, const int size)
bool is_finite_v3(const float v[3])
void negate_vn_vn(float *array_tar, const float *array_src, const int size)
void project_v3_v3v3(float out[3], const float p[3], const float v_proj[3])
void minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
void project_plane_v3_v3v3(float out[3], const float p[3], const float v_plane[3])
void interp_v3_v3v3_slerp_safe(float target[3], const float a[3], const float b[3], const float t)
Definition math_vector.c:99
void copy_vn_short(short *array_tar, const int size, const short val)
void project_plane_normalized_v3_v3v3(float out[3], const float p[3], const float v_plane[3])
void msub_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const float f, const int size)
void interp_v3_v3v3_uchar(uchar target[3], const uchar a[3], const uchar b[3], const float t)
void print_v2(const char *str, const float v[2])
void mid_v3_v3v3_angle_weighted(float r[3], const float a[3], const float b[3])
void rotate_v3_v3v3fl(float r[3], const float p[3], const float axis[3], const float angle)
void ortho_v3_v3(float out[3], const float v[3])
float angle_v2v2(const float a[2], const float b[2])
void interp_v2_v2v2_db(double target[2], const double a[2], const double b[2], const double t)
void interp_v4_v4v4v4(float p[4], const float v1[4], const float v2[4], const float v3[4], const float w[3])
void flip_v2_v2v2(float v[2], const float v1[2], const float v2[2])
float cos_v2v2v2(const float p1[2], const float p2[2], const float p3[2])
void print_vn(const char *str, const float v[], const int n)
void interp_v3_v3v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3], const float w[4])
void minmax_v4v4_v4(float min[4], float max[4], const float vec[4])
void dist_ensure_v2_v2fl(float v1[2], const float v2[2], const float dist)
void mid_v2_v2v2(float r[2], const float a[2], const float b[2])
void range_vn_u(uint *array_tar, const int size, const uint start)
void interp_v4_v4v4_uchar(uchar target[4], const uchar a[4], const uchar b[4], const float t)
void ortho_v2_v2(float out[2], const float v[2])
void mul_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size)
void interp_v2_v2v2_slerp_safe(float target[2], const float a[2], const float b[2], const float t)
void angle_poly_v3(float *angles, const float *verts[3], int len)
void range_vn_fl(float *array_tar, const int size, const float start, const float step)
void interp_vn_vn(float *array_tar, const float *array_src, const float t, const int size)
double len_squared_vn(const float *array, const int size)
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
void ortho_basis_v3v3_v3(float r_n1[3], float r_n2[3], const float n[3])
void mul_vn_vn(float *array_tar, const float *array_src, const int size)
void msub_vn_vn(float *array_tar, const float *array_src, const float f, const int size)
void add_vn_vnvn_d(double *array_tar, const double *array_src_a, const double *array_src_b, const int size)
void mid_v3_v3_array(float r[3], const float(*vec_arr)[3], const uint vec_arr_num)
void range_vn_i(int *array_tar, const int size, const int start)
void flip_v4_v4v4(float v[4], const float v1[4], const float v2[4])
void flip_v3_v3v3(float v[3], const float v1[3], const float v2[3])
void project_plane_v2_v2v2(float out[2], const float p[2], const float v_plane[2])
float angle_v2v2v2(const float a[2], const float b[2], const float c[2])
float angle_normalized_v2v2(const float a[2], const float b[2])
bool interp_v2_v2v2_slerp(float target[2], const float a[2], const float b[2], const float t)
Definition math_vector.c:77
void dist_ensure_v3_v3fl(float v1[3], const float v2[3], const float dist)
void project_v3_v3v3_db(double out[3], const double p[3], const double v_proj[3])
float angle_on_axis_v3v3v3_v3(const float v1[3], const float v2[3], const float v3[3], const float axis[3])
void mul_vn_fl(float *array_tar, const int size, const float f)
void copy_vn_uchar(uchar *array_tar, const int size, const uchar val)
void interp_v3_v3v3v3_uv(float p[3], const float v1[3], const float v2[3], const float v3[3], const float uv[2])
float angle_signed_on_axis_v3v3v3_v3(const float v1[3], const float v2[3], const float v3[3], const float axis[3])
void rotate_normalized_v3_v3v3fl(float out[3], const float p[3], const float axis[3], const float angle)
MINLINE double sqr_db(double f)
float angle_signed_on_axis_v3v3_v3(const float v1[3], const float v2[3], const float axis[3])
void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3])
void interp_v2_v2v2v2v2_cubic(float p[2], const float v1[2], const float v2[2], const float v3[2], const float v4[2], const float u)
void project_v2_v2v2(float out[2], const float p[2], const float v_proj[2])
void bisect_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3])
void copy_vn_ushort(ushort *array_tar, const int size, const ushort val)
float angle_signed_v2v2(const float v1[2], const float v2[2])
Frequency::GEOMETRY nor[]
const btScalar eps
Definition poly34.cpp:11
#define min(a, b)
Definition sort.c:32