Blender  V2.93
math_vector.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  *
19  * The Original Code is: some of this file.
20  */
21 
26 #include "BLI_math.h"
27 
28 #include "BLI_strict_flags.h"
29 
30 //******************************* Interpolation *******************************/
31 
32 void interp_v2_v2v2(float r[2], const float a[2], const float b[2], const float t)
33 {
34  const float s = 1.0f - t;
35 
36  r[0] = s * a[0] + t * b[0];
37  r[1] = s * a[1] + t * b[1];
38 }
39 
40 /* weight 3 2D vectors,
41  * 'w' must be unit length but is not a vector, just 3 weights */
43  float r[2], const float a[2], const float b[2], const float c[2], const float t[3])
44 {
45  r[0] = a[0] * t[0] + b[0] * t[1] + c[0] * t[2];
46  r[1] = a[1] * t[0] + b[1] * t[1] + c[1] * t[2];
47 }
48 
49 void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t)
50 {
51  const float s = 1.0f - t;
52 
53  r[0] = s * a[0] + t * b[0];
54  r[1] = s * a[1] + t * b[1];
55  r[2] = s * a[2] + t * b[2];
56 }
57 
58 void interp_v4_v4v4(float r[4], const float a[4], const float b[4], const float t)
59 {
60  const float s = 1.0f - t;
61 
62  r[0] = s * a[0] + t * b[0];
63  r[1] = s * a[1] + t * b[1];
64  r[2] = s * a[2] + t * b[2];
65  r[3] = s * a[3] + t * b[3];
66 }
67 
74 bool interp_v3_v3v3_slerp(float target[3], const float a[3], const float b[3], const float t)
75 {
76  float cosom, w[2];
77 
80 
81  cosom = dot_v3v3(a, b);
82 
83  /* direct opposites */
84  if (UNLIKELY(cosom < (-1.0f + FLT_EPSILON))) {
85  return false;
86  }
87 
88  interp_dot_slerp(t, cosom, w);
89 
90  target[0] = w[0] * a[0] + w[1] * b[0];
91  target[1] = w[0] * a[1] + w[1] * b[1];
92  target[2] = w[0] * a[2] + w[1] * b[2];
93 
94  return true;
95 }
96 bool interp_v2_v2v2_slerp(float target[2], const float a[2], const float b[2], const float t)
97 {
98  float cosom, w[2];
99 
102 
103  cosom = dot_v2v2(a, b);
104 
105  /* direct opposites */
106  if (UNLIKELY(cosom < (1.0f + FLT_EPSILON))) {
107  return false;
108  }
109 
110  interp_dot_slerp(t, cosom, w);
111 
112  target[0] = w[0] * a[0] + w[1] * b[0];
113  target[1] = w[0] * a[1] + w[1] * b[1];
114 
115  return true;
116 }
117 
121 void interp_v3_v3v3_slerp_safe(float target[3], const float a[3], const float b[3], const float t)
122 {
123  if (UNLIKELY(!interp_v3_v3v3_slerp(target, a, b, t))) {
124  /* Axis are aligned so any orthogonal vector is acceptable. */
125  float ab_ortho[3];
126  ortho_v3_v3(ab_ortho, a);
127  normalize_v3(ab_ortho);
128  if (t < 0.5f) {
129  if (UNLIKELY(!interp_v3_v3v3_slerp(target, a, ab_ortho, t * 2.0f))) {
130  BLI_assert(0);
131  copy_v3_v3(target, a);
132  }
133  }
134  else {
135  if (UNLIKELY(!interp_v3_v3v3_slerp(target, ab_ortho, b, (t - 0.5f) * 2.0f))) {
136  BLI_assert(0);
137  copy_v3_v3(target, b);
138  }
139  }
140  }
141 }
142 void interp_v2_v2v2_slerp_safe(float target[2], const float a[2], const float b[2], const float t)
143 {
144  if (UNLIKELY(!interp_v2_v2v2_slerp(target, a, b, t))) {
145  /* Axis are aligned so any orthogonal vector is acceptable. */
146  float ab_ortho[2];
147  ortho_v2_v2(ab_ortho, a);
148  // normalize_v2(ab_ortho);
149  if (t < 0.5f) {
150  if (UNLIKELY(!interp_v2_v2v2_slerp(target, a, ab_ortho, t * 2.0f))) {
151  BLI_assert(0);
152  copy_v2_v2(target, a);
153  }
154  }
155  else {
156  if (UNLIKELY(!interp_v2_v2v2_slerp(target, ab_ortho, b, (t - 0.5f) * 2.0f))) {
157  BLI_assert(0);
158  copy_v2_v2(target, b);
159  }
160  }
161  }
162 }
163 
164 /* -------------------------------------------------------------------- */
168 void interp_v2_v2v2v2v2_cubic(float p[2],
169  const float v1[2],
170  const float v2[2],
171  const float v3[2],
172  const float v4[2],
173  const float u)
174 {
175  float q0[2], q1[2], q2[2], r0[2], r1[2];
176 
177  interp_v2_v2v2(q0, v1, v2, u);
178  interp_v2_v2v2(q1, v2, v3, u);
179  interp_v2_v2v2(q2, v3, v4, u);
180 
181  interp_v2_v2v2(r0, q0, q1, u);
182  interp_v2_v2v2(r1, q1, q2, u);
183 
184  interp_v2_v2v2(p, r0, r1, u);
185 }
186 
189 /* weight 3 vectors,
190  * 'w' must be unit length but is not a vector, just 3 weights */
192  float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3])
193 {
194  p[0] = v1[0] * w[0] + v2[0] * w[1] + v3[0] * w[2];
195  p[1] = v1[1] * w[0] + v2[1] * w[1] + v3[1] * w[2];
196  p[2] = v1[2] * w[0] + v2[2] * w[1] + v3[2] * w[2];
197 }
198 
199 /* weight 3 vectors,
200  * 'w' must be unit length but is not a vector, just 4 weights */
201 void interp_v3_v3v3v3v3(float p[3],
202  const float v1[3],
203  const float v2[3],
204  const float v3[3],
205  const float v4[3],
206  const float w[4])
207 {
208  p[0] = v1[0] * w[0] + v2[0] * w[1] + v3[0] * w[2] + v4[0] * w[3];
209  p[1] = v1[1] * w[0] + v2[1] * w[1] + v3[1] * w[2] + v4[1] * w[3];
210  p[2] = v1[2] * w[0] + v2[2] * w[1] + v3[2] * w[2] + v4[2] * w[3];
211 }
212 
214  float p[4], const float v1[4], const float v2[4], const float v3[4], const float w[3])
215 {
216  p[0] = v1[0] * w[0] + v2[0] * w[1] + v3[0] * w[2];
217  p[1] = v1[1] * w[0] + v2[1] * w[1] + v3[1] * w[2];
218  p[2] = v1[2] * w[0] + v2[2] * w[1] + v3[2] * w[2];
219  p[3] = v1[3] * w[0] + v2[3] * w[1] + v3[3] * w[2];
220 }
221 
222 void interp_v4_v4v4v4v4(float p[4],
223  const float v1[4],
224  const float v2[4],
225  const float v3[4],
226  const float v4[4],
227  const float w[4])
228 {
229  p[0] = v1[0] * w[0] + v2[0] * w[1] + v3[0] * w[2] + v4[0] * w[3];
230  p[1] = v1[1] * w[0] + v2[1] * w[1] + v3[1] * w[2] + v4[1] * w[3];
231  p[2] = v1[2] * w[0] + v2[2] * w[1] + v3[2] * w[2] + v4[2] * w[3];
232  p[3] = v1[3] * w[0] + v2[3] * w[1] + v3[3] * w[2] + v4[3] * w[3];
233 }
234 
236  float p[3], const float v1[3], const float v2[3], const float v3[3], const float uv[2])
237 {
238  p[0] = v1[0] + ((v2[0] - v1[0]) * uv[0]) + ((v3[0] - v1[0]) * uv[1]);
239  p[1] = v1[1] + ((v2[1] - v1[1]) * uv[0]) + ((v3[1] - v1[1]) * uv[1]);
240  p[2] = v1[2] + ((v2[2] - v1[2]) * uv[0]) + ((v3[2] - v1[2]) * uv[1]);
241 }
242 
243 void interp_v3_v3v3_uchar(uchar target[3], const uchar a[3], const uchar b[3], const float t)
244 {
245  const float s = 1.0f - t;
246 
247  target[0] = (char)floorf(s * a[0] + t * b[0]);
248  target[1] = (char)floorf(s * a[1] + t * b[1]);
249  target[2] = (char)floorf(s * a[2] + t * b[2]);
250 }
251 void interp_v3_v3v3_char(char target[3], const char a[3], const char b[3], const float t)
252 {
253  interp_v3_v3v3_uchar((uchar *)target, (const uchar *)a, (const uchar *)b, t);
254 }
255 
256 void interp_v4_v4v4_uchar(uchar target[4], const uchar a[4], const uchar b[4], const float t)
257 {
258  const float s = 1.0f - t;
259 
260  target[0] = (char)floorf(s * a[0] + t * b[0]);
261  target[1] = (char)floorf(s * a[1] + t * b[1]);
262  target[2] = (char)floorf(s * a[2] + t * b[2]);
263  target[3] = (char)floorf(s * a[3] + t * b[3]);
264 }
265 void interp_v4_v4v4_char(char target[4], const char a[4], const char b[4], const float t)
266 {
267  interp_v4_v4v4_uchar((uchar *)target, (const uchar *)a, (const uchar *)b, t);
268 }
269 
270 void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
271 {
272  r[0] = 0.5f * (a[0] + b[0]);
273  r[1] = 0.5f * (a[1] + b[1]);
274  r[2] = 0.5f * (a[2] + b[2]);
275 }
276 
277 void mid_v2_v2v2(float r[2], const float a[2], const float b[2])
278 {
279  r[0] = 0.5f * (a[0] + b[0]);
280  r[1] = 0.5f * (a[1] + b[1]);
281 }
282 
283 void mid_v2_v2v2v2(float v[2], const float v1[2], const float v2[2], const float v3[2])
284 {
285  v[0] = (v1[0] + v2[0] + v3[0]) / 3.0f;
286  v[1] = (v1[1] + v2[1] + v3[1]) / 3.0f;
287 }
288 
289 void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3])
290 {
291  v[0] = (v1[0] + v2[0] + v3[0]) / 3.0f;
292  v[1] = (v1[1] + v2[1] + v3[1]) / 3.0f;
293  v[2] = (v1[2] + v2[2] + v3[2]) / 3.0f;
294 }
295 
297  float v[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
298 {
299  v[0] = (v1[0] + v2[0] + v3[0] + v4[0]) / 4.0f;
300  v[1] = (v1[1] + v2[1] + v3[1] + v4[1]) / 4.0f;
301  v[2] = (v1[2] + v2[2] + v3[2] + v4[2]) / 4.0f;
302 }
303 
304 void mid_v3_v3_array(float r[3], const float (*vec_arr)[3], const uint nbr)
305 {
306  const float factor = 1.0f / (float)nbr;
307  zero_v3(r);
308 
309  for (uint i = 0; i < nbr; i++) {
310  madd_v3_v3fl(r, vec_arr[i], factor);
311  }
312 }
313 
326 void mid_v3_v3v3_angle_weighted(float r[3], const float a[3], const float b[3])
327 {
328  /* trick, we want the middle of 2 normals as well as the angle between them
329  * avoid multiple calculations by */
330  float angle;
331 
332  /* double check they are normalized */
335 
336  add_v3_v3v3(r, a, b);
337  angle = ((float)(1.0 / (M_PI / 2.0)) *
338  /* normally we would only multiply by 2,
339  * but instead of an angle make this 0-1 factor */
340  2.0f) *
341  acosf(normalize_v3(r) / 2.0f);
342  mul_v3_fl(r, angle);
343 }
348 void mid_v3_angle_weighted(float r[3])
349 {
350  /* trick, we want the middle of 2 normals as well as the angle between them
351  * avoid multiple calculations by */
352  float angle;
353 
354  /* double check they are normalized */
355  BLI_assert(len_squared_v3(r) <= 1.0f + FLT_EPSILON);
356 
357  angle = ((float)(1.0 / (M_PI / 2.0)) *
358  /* normally we would only multiply by 2,
359  * but instead of an angle make this 0-1 factor */
360  2.0f) *
361  acosf(normalize_v3(r));
362  mul_v3_fl(r, angle);
363 }
364 
370 void flip_v4_v4v4(float v[4], const float v1[4], const float v2[4])
371 {
372  v[0] = v1[0] + (v1[0] - v2[0]);
373  v[1] = v1[1] + (v1[1] - v2[1]);
374  v[2] = v1[2] + (v1[2] - v2[2]);
375  v[3] = v1[3] + (v1[3] - v2[3]);
376 }
377 
378 void flip_v3_v3v3(float v[3], const float v1[3], const float v2[3])
379 {
380  v[0] = v1[0] + (v1[0] - v2[0]);
381  v[1] = v1[1] + (v1[1] - v2[1]);
382  v[2] = v1[2] + (v1[2] - v2[2]);
383 }
384 
385 void flip_v2_v2v2(float v[2], const float v1[2], const float v2[2])
386 {
387  v[0] = v1[0] + (v1[0] - v2[0]);
388  v[1] = v1[1] + (v1[1] - v2[1]);
389 }
390 
391 /********************************* Comparison ********************************/
392 
393 bool is_finite_v2(const float v[2])
394 {
395  return (isfinite(v[0]) && isfinite(v[1]));
396 }
397 
398 bool is_finite_v3(const float v[3])
399 {
400  return (isfinite(v[0]) && isfinite(v[1]) && isfinite(v[2]));
401 }
402 
403 bool is_finite_v4(const float v[4])
404 {
405  return (isfinite(v[0]) && isfinite(v[1]) && isfinite(v[2]) && isfinite(v[3]));
406 }
407 
408 /********************************** Angles ***********************************/
409 
410 /* Return the angle in radians between vecs 1-2 and 2-3 in radians
411  * If v1 is a shoulder, v2 is the elbow and v3 is the hand,
412  * this would return the angle at the elbow.
413  *
414  * note that when v1/v2/v3 represent 3 points along a straight line
415  * that the angle returned will be pi (180deg), rather then 0.0
416  */
417 float angle_v3v3v3(const float a[3], const float b[3], const float c[3])
418 {
419  float vec1[3], vec2[3];
420 
421  sub_v3_v3v3(vec1, b, a);
422  sub_v3_v3v3(vec2, b, c);
423  normalize_v3(vec1);
424  normalize_v3(vec2);
425 
426  return angle_normalized_v3v3(vec1, vec2);
427 }
428 
429 /* Quicker than full angle computation */
430 float cos_v3v3v3(const float p1[3], const float p2[3], const float p3[3])
431 {
432  float vec1[3], vec2[3];
433 
434  sub_v3_v3v3(vec1, p2, p1);
435  sub_v3_v3v3(vec2, p2, p3);
436  normalize_v3(vec1);
437  normalize_v3(vec2);
438 
439  return dot_v3v3(vec1, vec2);
440 }
441 
442 /* Return the shortest angle in radians between the 2 vectors */
443 float angle_v3v3(const float a[3], const float b[3])
444 {
445  float vec1[3], vec2[3];
446 
447  normalize_v3_v3(vec1, a);
448  normalize_v3_v3(vec2, b);
449 
450  return angle_normalized_v3v3(vec1, vec2);
451 }
452 
453 float angle_v2v2v2(const float a[2], const float b[2], const float c[2])
454 {
455  float vec1[2], vec2[2];
456 
457  vec1[0] = b[0] - a[0];
458  vec1[1] = b[1] - a[1];
459 
460  vec2[0] = b[0] - c[0];
461  vec2[1] = b[1] - c[1];
462 
463  normalize_v2(vec1);
464  normalize_v2(vec2);
465 
466  return angle_normalized_v2v2(vec1, vec2);
467 }
468 
469 /* Quicker than full angle computation */
470 float cos_v2v2v2(const float p1[2], const float p2[2], const float p3[2])
471 {
472  float vec1[2], vec2[2];
473 
474  sub_v2_v2v2(vec1, p2, p1);
475  sub_v2_v2v2(vec2, p2, p3);
476  normalize_v2(vec1);
477  normalize_v2(vec2);
478 
479  return dot_v2v2(vec1, vec2);
480 }
481 
482 /* Return the shortest angle in radians between the 2 vectors */
483 float angle_v2v2(const float a[2], const float b[2])
484 {
485  float vec1[2], vec2[2];
486 
487  vec1[0] = a[0];
488  vec1[1] = a[1];
489 
490  vec2[0] = b[0];
491  vec2[1] = b[1];
492 
493  normalize_v2(vec1);
494  normalize_v2(vec2);
495 
496  return angle_normalized_v2v2(vec1, vec2);
497 }
498 
499 float angle_signed_v2v2(const float v1[2], const float v2[2])
500 {
501  const float perp_dot = (v1[1] * v2[0]) - (v1[0] * v2[1]);
502  return atan2f(perp_dot, dot_v2v2(v1, v2));
503 }
504 
505 float angle_normalized_v3v3(const float v1[3], const float v2[3])
506 {
507  /* double check they are normalized */
510 
511  /* this is the same as acos(dot_v3v3(v1, v2)), but more accurate */
512  if (dot_v3v3(v1, v2) >= 0.0f) {
513  return 2.0f * saasin(len_v3v3(v1, v2) / 2.0f);
514  }
515 
516  float v2_n[3];
517  negate_v3_v3(v2_n, v2);
518  return (float)M_PI - 2.0f * saasin(len_v3v3(v1, v2_n) / 2.0f);
519 }
520 
521 float angle_normalized_v2v2(const float a[2], const float b[2])
522 {
523  /* double check they are normalized */
526 
527  /* this is the same as acos(dot_v3v3(v1, v2)), but more accurate */
528  if (dot_v2v2(a, b) >= 0.0f) {
529  return 2.0f * saasin(len_v2v2(a, b) / 2.0f);
530  }
531 
532  float v2_n[2];
533  negate_v2_v2(v2_n, b);
534  return (float)M_PI - 2.0f * saasin(len_v2v2(a, v2_n) / 2.0f);
535 }
536 
540 float angle_on_axis_v3v3_v3(const float v1[3], const float v2[3], const float axis[3])
541 {
542  float v1_proj[3], v2_proj[3];
543 
544  /* project the vectors onto the axis */
545  project_plane_normalized_v3_v3v3(v1_proj, v1, axis);
546  project_plane_normalized_v3_v3v3(v2_proj, v2, axis);
547 
548  return angle_v3v3(v1_proj, v2_proj);
549 }
550 
551 float angle_signed_on_axis_v3v3_v3(const float v1[3], const float v2[3], const float axis[3])
552 {
553  float v1_proj[3], v2_proj[3], tproj[3];
554  float angle;
555 
556  /* project the vectors onto the axis */
557  project_plane_normalized_v3_v3v3(v1_proj, v1, axis);
558  project_plane_normalized_v3_v3v3(v2_proj, v2, axis);
559 
560  angle = angle_v3v3(v1_proj, v2_proj);
561 
562  /* calculate the sign (reuse 'tproj') */
563  cross_v3_v3v3(tproj, v2_proj, v1_proj);
564  if (dot_v3v3(tproj, axis) < 0.0f) {
565  angle = ((float)(M_PI * 2.0)) - angle;
566  }
567 
568  return angle;
569 }
570 
574 float angle_on_axis_v3v3v3_v3(const float v1[3],
575  const float v2[3],
576  const float v3[3],
577  const float axis[3])
578 {
579  float vec1[3], vec2[3];
580 
581  sub_v3_v3v3(vec1, v1, v2);
582  sub_v3_v3v3(vec2, v3, v2);
583 
584  return angle_on_axis_v3v3_v3(vec1, vec2, axis);
585 }
586 
587 float angle_signed_on_axis_v3v3v3_v3(const float v1[3],
588  const float v2[3],
589  const float v3[3],
590  const float axis[3])
591 {
592  float vec1[3], vec2[3];
593 
594  sub_v3_v3v3(vec1, v1, v2);
595  sub_v3_v3v3(vec2, v3, v2);
596 
597  return angle_signed_on_axis_v3v3_v3(vec1, vec2, axis);
598 }
599 
600 void angle_tri_v3(float angles[3], const float v1[3], const float v2[3], const float v3[3])
601 {
602  float ed1[3], ed2[3], ed3[3];
603 
604  sub_v3_v3v3(ed1, v3, v1);
605  sub_v3_v3v3(ed2, v1, v2);
606  sub_v3_v3v3(ed3, v2, v3);
607 
608  normalize_v3(ed1);
609  normalize_v3(ed2);
610  normalize_v3(ed3);
611 
612  angles[0] = (float)M_PI - angle_normalized_v3v3(ed1, ed2);
613  angles[1] = (float)M_PI - angle_normalized_v3v3(ed2, ed3);
614  // face_angles[2] = M_PI - angle_normalized_v3v3(ed3, ed1);
615  angles[2] = (float)M_PI - (angles[0] + angles[1]);
616 }
617 
619  float angles[4], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
620 {
621  float ed1[3], ed2[3], ed3[3], ed4[3];
622 
623  sub_v3_v3v3(ed1, v4, v1);
624  sub_v3_v3v3(ed2, v1, v2);
625  sub_v3_v3v3(ed3, v2, v3);
626  sub_v3_v3v3(ed4, v3, v4);
627 
628  normalize_v3(ed1);
629  normalize_v3(ed2);
630  normalize_v3(ed3);
631  normalize_v3(ed4);
632 
633  angles[0] = (float)M_PI - angle_normalized_v3v3(ed1, ed2);
634  angles[1] = (float)M_PI - angle_normalized_v3v3(ed2, ed3);
635  angles[2] = (float)M_PI - angle_normalized_v3v3(ed3, ed4);
636  angles[3] = (float)M_PI - angle_normalized_v3v3(ed4, ed1);
637 }
638 
639 void angle_poly_v3(float *angles, const float *verts[3], int len)
640 {
641  int i;
642  float vec[3][3];
643 
644  sub_v3_v3v3(vec[2], verts[len - 1], verts[0]);
645  normalize_v3(vec[2]);
646  for (i = 0; i < len; i++) {
647  sub_v3_v3v3(vec[i % 3], verts[i % len], verts[(i + 1) % len]);
648  normalize_v3(vec[i % 3]);
649  angles[i] = (float)M_PI - angle_normalized_v3v3(vec[(i + 2) % 3], vec[i % 3]);
650  }
651 }
652 
653 /********************************* Geometry **********************************/
654 
658 void project_v2_v2v2(float out[2], const float p[2], const float v_proj[2])
659 {
660  if (UNLIKELY(is_zero_v2(v_proj))) {
661  zero_v2(out);
662  return;
663  }
664 
665  const float mul = dot_v2v2(p, v_proj) / dot_v2v2(v_proj, v_proj);
666 
667  out[0] = mul * v_proj[0];
668  out[1] = mul * v_proj[1];
669 }
670 
674 void project_v3_v3v3(float out[3], const float p[3], const float v_proj[3])
675 {
676  if (UNLIKELY(is_zero_v3(v_proj))) {
677  zero_v3(out);
678  return;
679  }
680 
681  const float mul = dot_v3v3(p, v_proj) / dot_v3v3(v_proj, v_proj);
682 
683  out[0] = mul * v_proj[0];
684  out[1] = mul * v_proj[1];
685  out[2] = mul * v_proj[2];
686 }
687 
688 void project_v3_v3v3_db(double out[3], const double p[3], const double v_proj[3])
689 {
690  if (UNLIKELY(is_zero_v3_db(v_proj))) {
691  zero_v3_db(out);
692  return;
693  }
694 
695  const double mul = dot_v3v3_db(p, v_proj) / dot_v3v3_db(v_proj, v_proj);
696 
697  out[0] = mul * v_proj[0];
698  out[1] = mul * v_proj[1];
699  out[2] = mul * v_proj[2];
700 }
701 
705 void project_v2_v2v2_normalized(float out[2], const float p[2], const float v_proj[2])
706 {
707  BLI_ASSERT_UNIT_V2(v_proj);
708  const float mul = dot_v2v2(p, v_proj);
709 
710  out[0] = mul * v_proj[0];
711  out[1] = mul * v_proj[1];
712 }
713 
717 void project_v3_v3v3_normalized(float out[3], const float p[3], const float v_proj[3])
718 {
719  BLI_ASSERT_UNIT_V3(v_proj);
720  const float mul = dot_v3v3(p, v_proj);
721 
722  out[0] = mul * v_proj[0];
723  out[1] = mul * v_proj[1];
724  out[2] = mul * v_proj[2];
725 }
726 
740 void project_plane_v3_v3v3(float out[3], const float p[3], const float v_plane[3])
741 {
742  const float mul = dot_v3v3(p, v_plane) / dot_v3v3(v_plane, v_plane);
743 
744  out[0] = p[0] - (mul * v_plane[0]);
745  out[1] = p[1] - (mul * v_plane[1]);
746  out[2] = p[2] - (mul * v_plane[2]);
747 }
748 
749 void project_plane_v2_v2v2(float out[2], const float p[2], const float v_plane[2])
750 {
751  const float mul = dot_v2v2(p, v_plane) / dot_v2v2(v_plane, v_plane);
752 
753  out[0] = p[0] - (mul * v_plane[0]);
754  out[1] = p[1] - (mul * v_plane[1]);
755 }
756 
757 void project_plane_normalized_v3_v3v3(float out[3], const float p[3], const float v_plane[3])
758 {
759  BLI_ASSERT_UNIT_V3(v_plane);
760  const float mul = dot_v3v3(p, v_plane);
761 
762  out[0] = p[0] - (mul * v_plane[0]);
763  out[1] = p[1] - (mul * v_plane[1]);
764  out[2] = p[2] - (mul * v_plane[2]);
765 }
766 
767 void project_plane_normalized_v2_v2v2(float out[2], const float p[2], const float v_plane[2])
768 {
769  BLI_ASSERT_UNIT_V2(v_plane);
770  const float mul = dot_v2v2(p, v_plane);
771 
772  out[0] = p[0] - (mul * v_plane[0]);
773  out[1] = p[1] - (mul * v_plane[1]);
774 }
775 
776 /* project a vector on a plane defined by normal and a plane point p */
777 void project_v3_plane(float out[3], const float plane_no[3], const float plane_co[3])
778 {
779  float vector[3];
780  float mul;
781 
782  sub_v3_v3v3(vector, out, plane_co);
783  mul = dot_v3v3(vector, plane_no) / len_squared_v3(plane_no);
784 
785  mul_v3_v3fl(vector, plane_no, mul);
786 
787  sub_v3_v3(out, vector);
788 }
789 
790 /* Returns a vector bisecting the angle at b formed by a, b and c */
791 void bisect_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3])
792 {
793  float d_12[3], d_23[3];
794  sub_v3_v3v3(d_12, b, a);
795  sub_v3_v3v3(d_23, c, b);
796  normalize_v3(d_12);
797  normalize_v3(d_23);
798  add_v3_v3v3(r, d_12, d_23);
799  normalize_v3(r);
800 }
801 
818 void reflect_v3_v3v3(float out[3], const float v[3], const float normal[3])
819 {
820  const float dot2 = 2.0f * dot_v3v3(v, normal);
821 
823 
824  out[0] = v[0] - (dot2 * normal[0]);
825  out[1] = v[1] - (dot2 * normal[1]);
826  out[2] = v[2] - (dot2 * normal[2]);
827 }
828 
829 void reflect_v3_v3v3_db(double out[3], const double v[3], const double normal[3])
830 {
831  const double dot2 = 2.0 * dot_v3v3_db(v, normal);
832 
833  /* BLI_ASSERT_UNIT_V3_DB(normal); this assert is not known? */
834 
835  out[0] = v[0] - (dot2 * normal[0]);
836  out[1] = v[1] - (dot2 * normal[1]);
837  out[2] = v[2] - (dot2 * normal[2]);
838 }
839 
845 void ortho_basis_v3v3_v3(float r_n1[3], float r_n2[3], const float n[3])
846 {
847  const float eps = FLT_EPSILON;
848  const float f = len_squared_v2(n);
849 
850  if (f > eps) {
851  const float d = 1.0f / sqrtf(f);
852 
853  BLI_assert(isfinite(d));
854 
855  r_n1[0] = n[1] * d;
856  r_n1[1] = -n[0] * d;
857  r_n1[2] = 0.0f;
858  r_n2[0] = -n[2] * r_n1[1];
859  r_n2[1] = n[2] * r_n1[0];
860  r_n2[2] = n[0] * r_n1[1] - n[1] * r_n1[0];
861  }
862  else {
863  /* degenerate case */
864  r_n1[0] = (n[2] < 0.0f) ? -1.0f : 1.0f;
865  r_n1[1] = r_n1[2] = r_n2[0] = r_n2[2] = 0.0f;
866  r_n2[1] = 1.0f;
867  }
868 }
869 
875 void ortho_v3_v3(float out[3], const float v[3])
876 {
877  const int axis = axis_dominant_v3_single(v);
878 
879  BLI_assert(out != v);
880 
881  switch (axis) {
882  case 0:
883  out[0] = -v[1] - v[2];
884  out[1] = v[0];
885  out[2] = v[0];
886  break;
887  case 1:
888  out[0] = v[1];
889  out[1] = -v[0] - v[2];
890  out[2] = v[1];
891  break;
892  case 2:
893  out[0] = v[2];
894  out[1] = v[2];
895  out[2] = -v[0] - v[1];
896  break;
897  }
898 }
899 
903 void ortho_v2_v2(float out[2], const float v[2])
904 {
905  BLI_assert(out != v);
906 
907  out[0] = -v[1];
908  out[1] = v[0];
909 }
910 
914 void rotate_v2_v2fl(float r[2], const float p[2], const float angle)
915 {
916  const float co = cosf(angle);
917  const float si = sinf(angle);
918 
919  BLI_assert(r != p);
920 
921  r[0] = co * p[0] - si * p[1];
922  r[1] = si * p[0] + co * p[1];
923 }
924 
929 void rotate_normalized_v3_v3v3fl(float out[3],
930  const float p[3],
931  const float axis[3],
932  const float angle)
933 {
934  const float costheta = cosf(angle);
935  const float sintheta = sinf(angle);
936 
937  /* double check they are normalized */
938  BLI_ASSERT_UNIT_V3(axis);
939 
940  out[0] = ((costheta + (1 - costheta) * axis[0] * axis[0]) * p[0]) +
941  (((1 - costheta) * axis[0] * axis[1] - axis[2] * sintheta) * p[1]) +
942  (((1 - costheta) * axis[0] * axis[2] + axis[1] * sintheta) * p[2]);
943 
944  out[1] = (((1 - costheta) * axis[0] * axis[1] + axis[2] * sintheta) * p[0]) +
945  ((costheta + (1 - costheta) * axis[1] * axis[1]) * p[1]) +
946  (((1 - costheta) * axis[1] * axis[2] - axis[0] * sintheta) * p[2]);
947 
948  out[2] = (((1 - costheta) * axis[0] * axis[2] - axis[1] * sintheta) * p[0]) +
949  (((1 - costheta) * axis[1] * axis[2] + axis[0] * sintheta) * p[1]) +
950  ((costheta + (1 - costheta) * axis[2] * axis[2]) * p[2]);
951 }
952 
953 void rotate_v3_v3v3fl(float r[3], const float p[3], const float axis[3], const float angle)
954 {
955  BLI_assert(r != p);
956 
957  float axis_n[3];
958 
959  normalize_v3_v3(axis_n, axis);
960 
961  rotate_normalized_v3_v3v3fl(r, p, axis_n, angle);
962 }
963 
964 /*********************************** Other ***********************************/
965 
966 void print_v2(const char *str, const float v[2])
967 {
968  printf("%s: %.8f %.8f\n", str, v[0], v[1]);
969 }
970 
971 void print_v3(const char *str, const float v[3])
972 {
973  printf("%s: %.8f %.8f %.8f\n", str, v[0], v[1], v[2]);
974 }
975 
976 void print_v4(const char *str, const float v[4])
977 {
978  printf("%s: %.8f %.8f %.8f %.8f\n", str, v[0], v[1], v[2], v[3]);
979 }
980 
981 void print_vn(const char *str, const float v[], const int n)
982 {
983  int i = 0;
984  printf("%s[%d]:", str, n);
985  while (i < n) {
986  printf(" %.8f", v[i++]);
987  }
988  printf("\n");
989 }
990 
991 void minmax_v4v4_v4(float min[4], float max[4], const float vec[4])
992 {
993  if (min[0] > vec[0]) {
994  min[0] = vec[0];
995  }
996  if (min[1] > vec[1]) {
997  min[1] = vec[1];
998  }
999  if (min[2] > vec[2]) {
1000  min[2] = vec[2];
1001  }
1002  if (min[3] > vec[3]) {
1003  min[3] = vec[3];
1004  }
1005 
1006  if (max[0] < vec[0]) {
1007  max[0] = vec[0];
1008  }
1009  if (max[1] < vec[1]) {
1010  max[1] = vec[1];
1011  }
1012  if (max[2] < vec[2]) {
1013  max[2] = vec[2];
1014  }
1015  if (max[3] < vec[3]) {
1016  max[3] = vec[3];
1017  }
1018 }
1019 
1020 void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
1021 {
1022  if (min[0] > vec[0]) {
1023  min[0] = vec[0];
1024  }
1025  if (min[1] > vec[1]) {
1026  min[1] = vec[1];
1027  }
1028  if (min[2] > vec[2]) {
1029  min[2] = vec[2];
1030  }
1031 
1032  if (max[0] < vec[0]) {
1033  max[0] = vec[0];
1034  }
1035  if (max[1] < vec[1]) {
1036  max[1] = vec[1];
1037  }
1038  if (max[2] < vec[2]) {
1039  max[2] = vec[2];
1040  }
1041 }
1042 
1043 void minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
1044 {
1045  if (min[0] > vec[0]) {
1046  min[0] = vec[0];
1047  }
1048  if (min[1] > vec[1]) {
1049  min[1] = vec[1];
1050  }
1051 
1052  if (max[0] < vec[0]) {
1053  max[0] = vec[0];
1054  }
1055  if (max[1] < vec[1]) {
1056  max[1] = vec[1];
1057  }
1058 }
1059 
1060 void minmax_v3v3_v3_array(float r_min[3], float r_max[3], const float (*vec_arr)[3], int nbr)
1061 {
1062  while (nbr--) {
1063  minmax_v3v3_v3(r_min, r_max, *vec_arr++);
1064  }
1065 }
1066 
1068 void dist_ensure_v3_v3fl(float v1[3], const float v2[3], const float dist)
1069 {
1070  if (!equals_v3v3(v2, v1)) {
1071  float nor[3];
1072 
1073  sub_v3_v3v3(nor, v1, v2);
1074  normalize_v3(nor);
1075  madd_v3_v3v3fl(v1, v2, nor, dist);
1076  }
1077 }
1078 
1079 void dist_ensure_v2_v2fl(float v1[2], const float v2[2], const float dist)
1080 {
1081  if (!equals_v2v2(v2, v1)) {
1082  float nor[2];
1083 
1084  sub_v2_v2v2(nor, v1, v2);
1085  normalize_v2(nor);
1086  madd_v2_v2v2fl(v1, v2, nor, dist);
1087  }
1088 }
1089 
1090 void axis_sort_v3(const float axis_values[3], int r_axis_order[3])
1091 {
1092  float v[3];
1093  copy_v3_v3(v, axis_values);
1094 
1095 #define SWAP_AXIS(a, b) \
1096  { \
1097  SWAP(float, v[a], v[b]); \
1098  SWAP(int, r_axis_order[a], r_axis_order[b]); \
1099  } \
1100  (void)0
1101 
1102  if (v[0] < v[1]) {
1103  if (v[2] < v[0]) {
1104  SWAP_AXIS(0, 2);
1105  }
1106  }
1107  else {
1108  if (v[1] < v[2]) {
1109  SWAP_AXIS(0, 1);
1110  }
1111  else {
1112  SWAP_AXIS(0, 2);
1113  }
1114  }
1115  if (v[2] < v[1]) {
1116  SWAP_AXIS(1, 2);
1117  }
1118 
1119 #undef SWAP_AXIS
1120 }
1121 
1122 /***************************** Array Functions *******************************/
1123 
1124 MINLINE double sqr_db(double f)
1125 {
1126  return f * f;
1127 }
1128 
1129 double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int size)
1130 {
1131  double d = 0.0f;
1132  const float *array_pt_a = array_src_a + (size - 1);
1133  const float *array_pt_b = array_src_b + (size - 1);
1134  int i = size;
1135  while (i--) {
1136  d += (double)(*(array_pt_a--) * *(array_pt_b--));
1137  }
1138  return d;
1139 }
1140 
1141 double len_squared_vn(const float *array, const int size)
1142 {
1143  double d = 0.0f;
1144  const float *array_pt = array + (size - 1);
1145  int i = size;
1146  while (i--) {
1147  d += sqr_db((double)(*(array_pt--)));
1148  }
1149  return d;
1150 }
1151 
1152 float normalize_vn_vn(float *array_tar, const float *array_src, const int size)
1153 {
1154  const double d = len_squared_vn(array_src, size);
1155  float d_sqrt;
1156  if (d > 1.0e-35) {
1157  d_sqrt = (float)sqrt(d);
1158  mul_vn_vn_fl(array_tar, array_src, size, 1.0f / d_sqrt);
1159  }
1160  else {
1161  copy_vn_fl(array_tar, size, 0.0f);
1162  d_sqrt = 0.0f;
1163  }
1164  return d_sqrt;
1165 }
1166 
1167 float normalize_vn(float *array_tar, const int size)
1168 {
1169  return normalize_vn_vn(array_tar, array_tar, size);
1170 }
1171 
1172 void range_vn_i(int *array_tar, const int size, const int start)
1173 {
1174  int *array_pt = array_tar + (size - 1);
1175  int j = start + (size - 1);
1176  int i = size;
1177  while (i--) {
1178  *(array_pt--) = j--;
1179  }
1180 }
1181 
1182 void range_vn_u(uint *array_tar, const int size, const uint start)
1183 {
1184  uint *array_pt = array_tar + (size - 1);
1185  uint j = start + (uint)(size - 1);
1186  int i = size;
1187  while (i--) {
1188  *(array_pt--) = j--;
1189  }
1190 }
1191 
1192 void range_vn_fl(float *array_tar, const int size, const float start, const float step)
1193 {
1194  float *array_pt = array_tar + (size - 1);
1195  int i = size;
1196  while (i--) {
1197  *(array_pt--) = start + step * (float)(i);
1198  }
1199 }
1200 
1201 void negate_vn(float *array_tar, const int size)
1202 {
1203  float *array_pt = array_tar + (size - 1);
1204  int i = size;
1205  while (i--) {
1206  *(array_pt--) *= -1.0f;
1207  }
1208 }
1209 
1210 void negate_vn_vn(float *array_tar, const float *array_src, const int size)
1211 {
1212  float *tar = array_tar + (size - 1);
1213  const float *src = array_src + (size - 1);
1214  int i = size;
1215  while (i--) {
1216  *(tar--) = -*(src--);
1217  }
1218 }
1219 
1220 void mul_vn_vn(float *array_tar, const float *array_src, const int size)
1221 {
1222  float *tar = array_tar + (size - 1);
1223  const float *src = array_src + (size - 1);
1224  int i = size;
1225  while (i--) {
1226  *(tar--) *= *(src--);
1227  }
1228 }
1229 
1230 void mul_vn_vnvn(float *array_tar,
1231  const float *array_src_a,
1232  const float *array_src_b,
1233  const int size)
1234 {
1235  float *tar = array_tar + (size - 1);
1236  const float *src_a = array_src_a + (size - 1);
1237  const float *src_b = array_src_b + (size - 1);
1238  int i = size;
1239  while (i--) {
1240  *(tar--) = *(src_a--) * *(src_b--);
1241  }
1242 }
1243 
1244 void mul_vn_fl(float *array_tar, const int size, const float f)
1245 {
1246  float *array_pt = array_tar + (size - 1);
1247  int i = size;
1248  while (i--) {
1249  *(array_pt--) *= f;
1250  }
1251 }
1252 
1253 void mul_vn_vn_fl(float *array_tar, const float *array_src, const int size, const float f)
1254 {
1255  float *tar = array_tar + (size - 1);
1256  const float *src = array_src + (size - 1);
1257  int i = size;
1258  while (i--) {
1259  *(tar--) = *(src--) * f;
1260  }
1261 }
1262 
1263 void add_vn_vn(float *array_tar, const float *array_src, const int size)
1264 {
1265  float *tar = array_tar + (size - 1);
1266  const float *src = array_src + (size - 1);
1267  int i = size;
1268  while (i--) {
1269  *(tar--) += *(src--);
1270  }
1271 }
1272 
1273 void add_vn_vnvn(float *array_tar,
1274  const float *array_src_a,
1275  const float *array_src_b,
1276  const int size)
1277 {
1278  float *tar = array_tar + (size - 1);
1279  const float *src_a = array_src_a + (size - 1);
1280  const float *src_b = array_src_b + (size - 1);
1281  int i = size;
1282  while (i--) {
1283  *(tar--) = *(src_a--) + *(src_b--);
1284  }
1285 }
1286 
1287 void madd_vn_vn(float *array_tar, const float *array_src, const float f, const int size)
1288 {
1289  float *tar = array_tar + (size - 1);
1290  const float *src = array_src + (size - 1);
1291  int i = size;
1292  while (i--) {
1293  *(tar--) += *(src--) * f;
1294  }
1295 }
1296 
1297 void madd_vn_vnvn(float *array_tar,
1298  const float *array_src_a,
1299  const float *array_src_b,
1300  const float f,
1301  const int size)
1302 {
1303  float *tar = array_tar + (size - 1);
1304  const float *src_a = array_src_a + (size - 1);
1305  const float *src_b = array_src_b + (size - 1);
1306  int i = size;
1307  while (i--) {
1308  *(tar--) = *(src_a--) + (*(src_b--) * f);
1309  }
1310 }
1311 
1312 void sub_vn_vn(float *array_tar, const float *array_src, const int size)
1313 {
1314  float *tar = array_tar + (size - 1);
1315  const float *src = array_src + (size - 1);
1316  int i = size;
1317  while (i--) {
1318  *(tar--) -= *(src--);
1319  }
1320 }
1321 
1322 void sub_vn_vnvn(float *array_tar,
1323  const float *array_src_a,
1324  const float *array_src_b,
1325  const int size)
1326 {
1327  float *tar = array_tar + (size - 1);
1328  const float *src_a = array_src_a + (size - 1);
1329  const float *src_b = array_src_b + (size - 1);
1330  int i = size;
1331  while (i--) {
1332  *(tar--) = *(src_a--) - *(src_b--);
1333  }
1334 }
1335 
1336 void msub_vn_vn(float *array_tar, const float *array_src, const float f, const int size)
1337 {
1338  float *tar = array_tar + (size - 1);
1339  const float *src = array_src + (size - 1);
1340  int i = size;
1341  while (i--) {
1342  *(tar--) -= *(src--) * f;
1343  }
1344 }
1345 
1346 void msub_vn_vnvn(float *array_tar,
1347  const float *array_src_a,
1348  const float *array_src_b,
1349  const float f,
1350  const int size)
1351 {
1352  float *tar = array_tar + (size - 1);
1353  const float *src_a = array_src_a + (size - 1);
1354  const float *src_b = array_src_b + (size - 1);
1355  int i = size;
1356  while (i--) {
1357  *(tar--) = *(src_a--) - (*(src_b--) * f);
1358  }
1359 }
1360 
1361 void interp_vn_vn(float *array_tar, const float *array_src, const float t, const int size)
1362 {
1363  const float s = 1.0f - t;
1364  float *tar = array_tar + (size - 1);
1365  const float *src = array_src + (size - 1);
1366  int i = size;
1367  while (i--) {
1368  *(tar) = (s * *(tar)) + (t * *(src));
1369  tar--;
1370  src--;
1371  }
1372 }
1373 
1374 void copy_vn_i(int *array_tar, const int size, const int val)
1375 {
1376  int *tar = array_tar + (size - 1);
1377  int i = size;
1378  while (i--) {
1379  *(tar--) = val;
1380  }
1381 }
1382 
1383 void copy_vn_short(short *array_tar, const int size, const short val)
1384 {
1385  short *tar = array_tar + (size - 1);
1386  int i = size;
1387  while (i--) {
1388  *(tar--) = val;
1389  }
1390 }
1391 
1392 void copy_vn_ushort(ushort *array_tar, const int size, const ushort val)
1393 {
1394  ushort *tar = array_tar + (size - 1);
1395  int i = size;
1396  while (i--) {
1397  *(tar--) = val;
1398  }
1399 }
1400 
1401 void copy_vn_uchar(uchar *array_tar, const int size, const uchar val)
1402 {
1403  uchar *tar = array_tar + (size - 1);
1404  int i = size;
1405  while (i--) {
1406  *(tar--) = val;
1407  }
1408 }
1409 
1410 void copy_vn_fl(float *array_tar, const int size, const float val)
1411 {
1412  float *tar = array_tar + (size - 1);
1413  int i = size;
1414  while (i--) {
1415  *(tar--) = val;
1416  }
1417 }
1418 
1419 /* -------------------------------------------------------------------- */
1423 void add_vn_vn_d(double *array_tar, const double *array_src, const int size)
1424 {
1425  double *tar = array_tar + (size - 1);
1426  const double *src = array_src + (size - 1);
1427  int i = size;
1428  while (i--) {
1429  *(tar--) += *(src--);
1430  }
1431 }
1432 
1433 void add_vn_vnvn_d(double *array_tar,
1434  const double *array_src_a,
1435  const double *array_src_b,
1436  const int size)
1437 {
1438  double *tar = array_tar + (size - 1);
1439  const double *src_a = array_src_a + (size - 1);
1440  const double *src_b = array_src_b + (size - 1);
1441  int i = size;
1442  while (i--) {
1443  *(tar--) = *(src_a--) + *(src_b--);
1444  }
1445 }
1446 
1447 void mul_vn_db(double *array_tar, const int size, const double f)
1448 {
1449  double *array_pt = array_tar + (size - 1);
1450  int i = size;
1451  while (i--) {
1452  *(array_pt--) *= f;
1453  }
1454 }
1455 
1456 void interp_v3_v3v3_db(double target[3], const double a[3], const double b[3], const double t)
1457 {
1458  const double s = 1.0f - t;
1459 
1460  target[0] = s * a[0] + t * b[0];
1461  target[1] = s * a[1] + t * b[1];
1462  target[2] = s * a[2] + t * b[2];
1463 }
1464 
1465 void interp_v2_v2v2_db(double target[2], const double a[2], const double b[2], const double t)
1466 {
1467  const double s = 1.0f - t;
1468 
1469  target[0] = s * a[0] + t * b[0];
1470  target[1] = s * a[1] + t * b[1];
1471 }
1472 
typedef float(TangentPoint)[2]
#define BLI_assert(a)
Definition: BLI_assert.h:58
sqrt(x)+1/max(0
#define BLI_ASSERT_UNIT_V2(v)
MINLINE float saasin(float fac)
#define BLI_ASSERT_UNIT_V3(v)
#define M_PI
Definition: BLI_math_base.h:38
MINLINE int axis_dominant_v3_single(const float vec[3])
#define MINLINE
void interp_dot_slerp(const float t, const float cosom, float w[2])
MINLINE bool is_zero_v3_db(const double a[3]) ATTR_WARN_UNUSED_RESULT
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 void madd_v2_v2v2fl(float r[2], const float a[2], const float b[2], float f)
MINLINE float normalize_v3(float r[3])
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_fl(float r[3], float f)
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 bool is_zero_v3(const float a[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 void zero_v2(float r[2])
MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE bool equals_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
MINLINE bool is_zero_v2(const float a[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void zero_v3(float r[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE float normalize_v2(float r[2])
MINLINE void zero_v3_db(double r[3])
Strict compiler flags for areas of code we want to ensure don't do conversions without us knowing abo...
unsigned char uchar
Definition: BLI_sys_types.h:86
unsigned int uint
Definition: BLI_sys_types.h:83
unsigned short ushort
Definition: BLI_sys_types.h:84
#define UNLIKELY(x)
typedef double(DMatrix)[4][4]
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
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)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition: btVector3.h:356
#define str(s)
static float verts[][3]
uint nor
IconTextureDrawCall normal
#define sinf(x)
#define cosf(x)
#define atan2f(x, y)
#define floorf(x)
#define acosf(x)
#define sqrtf(x)
void mid_v3_v3v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
Definition: math_vector.c:296
void copy_vn_fl(float *array_tar, const int size, const float val)
Definition: math_vector.c:1410
void project_v2_v2v2_normalized(float out[2], const float p[2], const float v_proj[2])
Definition: math_vector.c:705
void madd_vn_vn(float *array_tar, const float *array_src, const float f, const int size)
Definition: math_vector.c:1287
void add_vn_vn_d(double *array_tar, const double *array_src, const int size)
Definition: math_vector.c:1423
void negate_vn(float *array_tar, const int size)
Definition: math_vector.c:1201
void interp_v2_v2v2(float r[2], const float a[2], const float b[2], const float t)
Definition: math_vector.c:32
void reflect_v3_v3v3_db(double out[3], const double v[3], const double normal[3])
Definition: math_vector.c:829
void angle_quad_v3(float angles[4], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
Definition: math_vector.c:618
void axis_sort_v3(const float axis_values[3], int r_axis_order[3])
Definition: math_vector.c:1090
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t)
Definition: math_vector.c:49
void sub_vn_vn(float *array_tar, const float *array_src, const int size)
Definition: math_vector.c:1312
void mul_vn_db(double *array_tar, const int size, const double f)
Definition: math_vector.c:1447
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
Definition: math_vector.c:1020
void rotate_v2_v2fl(float r[2], const float p[2], const float angle)
Definition: math_vector.c:914
void mul_vn_vn_fl(float *array_tar, const float *array_src, const int size, const float f)
Definition: math_vector.c:1253
void copy_vn_i(int *array_tar, const int size, const int val)
Definition: math_vector.c:1374
void print_v3(const char *str, const float v[3])
Definition: math_vector.c:971
void madd_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const float f, const int size)
Definition: math_vector.c:1297
bool is_finite_v2(const float v[2])
Definition: math_vector.c:393
void minmax_v3v3_v3_array(float r_min[3], float r_max[3], const float(*vec_arr)[3], int nbr)
Definition: math_vector.c:1060
void project_plane_normalized_v2_v2v2(float out[2], const float p[2], const float v_plane[2])
Definition: math_vector.c:767
void interp_v4_v4v4_char(char target[4], const char a[4], const char b[4], const float t)
Definition: math_vector.c:265
float angle_on_axis_v3v3_v3(const float v1[3], const float v2[3], const float axis[3])
Definition: math_vector.c:540
float normalize_vn(float *array_tar, const int size)
Definition: math_vector.c:1167
float angle_v3v3v3(const float a[3], const float b[3], const float c[3])
Definition: math_vector.c:417
void reflect_v3_v3v3(float out[3], const float v[3], const float normal[3])
Definition: math_vector.c:818
bool is_finite_v4(const float v[4])
Definition: math_vector.c:403
void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3])
Definition: math_vector.c:191
float angle_normalized_v3v3(const float v1[3], const float v2[3])
Definition: math_vector.c:505
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])
Definition: math_vector.c:222
#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)
Definition: math_vector.c:1322
void interp_v3_v3v3_db(double target[3], const double a[3], const double b[3], const double t)
Definition: math_vector.c:1456
double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int size)
Definition: math_vector.c:1129
void angle_tri_v3(float angles[3], const float v1[3], const float v2[3], const float v3[3])
Definition: math_vector.c:600
void add_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size)
Definition: math_vector.c:1273
void interp_v3_v3v3_char(char target[3], const char a[3], const char b[3], const float t)
Definition: math_vector.c:251
void mid_v3_angle_weighted(float r[3])
Definition: math_vector.c:348
float angle_v3v3(const float a[3], const float b[3])
Definition: math_vector.c:443
void interp_v4_v4v4(float r[4], const float a[4], const float b[4], const float t)
Definition: math_vector.c:58
void mid_v2_v2v2v2(float v[2], const float v1[2], const float v2[2], const float v3[2])
Definition: math_vector.c:283
void project_v3_plane(float out[3], const float plane_no[3], const float plane_co[3])
Definition: math_vector.c:777
float cos_v3v3v3(const float p1[3], const float p2[3], const float p3[3])
Definition: math_vector.c:430
void add_vn_vn(float *array_tar, const float *array_src, const int size)
Definition: math_vector.c:1263
void project_v3_v3v3_normalized(float out[3], const float p[3], const float v_proj[3])
Definition: math_vector.c:717
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:42
void print_v4(const char *str, const float v[4])
Definition: math_vector.c:976
bool interp_v3_v3v3_slerp(float target[3], const float a[3], const float b[3], const float t)
Definition: math_vector.c:74
float normalize_vn_vn(float *array_tar, const float *array_src, const int size)
Definition: math_vector.c:1152
bool is_finite_v3(const float v[3])
Definition: math_vector.c:398
void negate_vn_vn(float *array_tar, const float *array_src, const int size)
Definition: math_vector.c:1210
void project_v3_v3v3(float out[3], const float p[3], const float v_proj[3])
Definition: math_vector.c:674
void minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
Definition: math_vector.c:1043
void project_plane_v3_v3v3(float out[3], const float p[3], const float v_plane[3])
Definition: math_vector.c:740
void interp_v3_v3v3_slerp_safe(float target[3], const float a[3], const float b[3], const float t)
Definition: math_vector.c:121
void copy_vn_short(short *array_tar, const int size, const short val)
Definition: math_vector.c:1383
void project_plane_normalized_v3_v3v3(float out[3], const float p[3], const float v_plane[3])
Definition: math_vector.c:757
void msub_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const float f, const int size)
Definition: math_vector.c:1346
void interp_v3_v3v3_uchar(uchar target[3], const uchar a[3], const uchar b[3], const float t)
Definition: math_vector.c:243
void print_v2(const char *str, const float v[2])
Definition: math_vector.c:966
void mid_v3_v3v3_angle_weighted(float r[3], const float a[3], const float b[3])
Definition: math_vector.c:326
void rotate_v3_v3v3fl(float r[3], const float p[3], const float axis[3], const float angle)
Definition: math_vector.c:953
void ortho_v3_v3(float out[3], const float v[3])
Definition: math_vector.c:875
float angle_v2v2(const float a[2], const float b[2])
Definition: math_vector.c:483
void interp_v2_v2v2_db(double target[2], const double a[2], const double b[2], const double t)
Definition: math_vector.c:1465
void interp_v4_v4v4v4(float p[4], const float v1[4], const float v2[4], const float v3[4], const float w[3])
Definition: math_vector.c:213
void flip_v2_v2v2(float v[2], const float v1[2], const float v2[2])
Definition: math_vector.c:385
float cos_v2v2v2(const float p1[2], const float p2[2], const float p3[2])
Definition: math_vector.c:470
void print_vn(const char *str, const float v[], const int n)
Definition: math_vector.c:981
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])
Definition: math_vector.c:201
void minmax_v4v4_v4(float min[4], float max[4], const float vec[4])
Definition: math_vector.c:991
void dist_ensure_v2_v2fl(float v1[2], const float v2[2], const float dist)
Definition: math_vector.c:1079
void mid_v2_v2v2(float r[2], const float a[2], const float b[2])
Definition: math_vector.c:277
void range_vn_u(uint *array_tar, const int size, const uint start)
Definition: math_vector.c:1182
void interp_v4_v4v4_uchar(uchar target[4], const uchar a[4], const uchar b[4], const float t)
Definition: math_vector.c:256
void ortho_v2_v2(float out[2], const float v[2])
Definition: math_vector.c:903
void mul_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size)
Definition: math_vector.c:1230
void interp_v2_v2v2_slerp_safe(float target[2], const float a[2], const float b[2], const float t)
Definition: math_vector.c:142
void mid_v3_v3_array(float r[3], const float(*vec_arr)[3], const uint nbr)
Definition: math_vector.c:304
void angle_poly_v3(float *angles, const float *verts[3], int len)
Definition: math_vector.c:639
void range_vn_fl(float *array_tar, const int size, const float start, const float step)
Definition: math_vector.c:1192
void interp_vn_vn(float *array_tar, const float *array_src, const float t, const int size)
Definition: math_vector.c:1361
double len_squared_vn(const float *array, const int size)
Definition: math_vector.c:1141
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
Definition: math_vector.c:270
void ortho_basis_v3v3_v3(float r_n1[3], float r_n2[3], const float n[3])
Definition: math_vector.c:845
void mul_vn_vn(float *array_tar, const float *array_src, const int size)
Definition: math_vector.c:1220
void msub_vn_vn(float *array_tar, const float *array_src, const float f, const int size)
Definition: math_vector.c:1336
void add_vn_vnvn_d(double *array_tar, const double *array_src_a, const double *array_src_b, const int size)
Definition: math_vector.c:1433
void range_vn_i(int *array_tar, const int size, const int start)
Definition: math_vector.c:1172
void flip_v4_v4v4(float v[4], const float v1[4], const float v2[4])
Definition: math_vector.c:370
void flip_v3_v3v3(float v[3], const float v1[3], const float v2[3])
Definition: math_vector.c:378
void project_plane_v2_v2v2(float out[2], const float p[2], const float v_plane[2])
Definition: math_vector.c:749
float angle_v2v2v2(const float a[2], const float b[2], const float c[2])
Definition: math_vector.c:453
float angle_normalized_v2v2(const float a[2], const float b[2])
Definition: math_vector.c:521
bool interp_v2_v2v2_slerp(float target[2], const float a[2], const float b[2], const float t)
Definition: math_vector.c:96
void dist_ensure_v3_v3fl(float v1[3], const float v2[3], const float dist)
Definition: math_vector.c:1068
void project_v3_v3v3_db(double out[3], const double p[3], const double v_proj[3])
Definition: math_vector.c:688
float angle_on_axis_v3v3v3_v3(const float v1[3], const float v2[3], const float v3[3], const float axis[3])
Definition: math_vector.c:574
void mul_vn_fl(float *array_tar, const int size, const float f)
Definition: math_vector.c:1244
void copy_vn_uchar(uchar *array_tar, const int size, const uchar val)
Definition: math_vector.c:1401
void interp_v3_v3v3v3_uv(float p[3], const float v1[3], const float v2[3], const float v3[3], const float uv[2])
Definition: math_vector.c:235
float angle_signed_on_axis_v3v3v3_v3(const float v1[3], const float v2[3], const float v3[3], const float axis[3])
Definition: math_vector.c:587
void rotate_normalized_v3_v3v3fl(float out[3], const float p[3], const float axis[3], const float angle)
Definition: math_vector.c:929
MINLINE double sqr_db(double f)
Definition: math_vector.c:1124
float angle_signed_on_axis_v3v3_v3(const float v1[3], const float v2[3], const float axis[3])
Definition: math_vector.c:551
void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3])
Definition: math_vector.c:289
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)
Definition: math_vector.c:168
void project_v2_v2v2(float out[2], const float p[2], const float v_proj[2])
Definition: math_vector.c:658
void bisect_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3])
Definition: math_vector.c:791
void copy_vn_ushort(ushort *array_tar, const int size, const ushort val)
Definition: math_vector.c:1392
float angle_signed_v2v2(const float v1[2], const float v2[2])
Definition: math_vector.c:499
bool isfinite(uchar)
Definition: image.cpp:44
static unsigned c
Definition: RandGen.cpp:97
static unsigned a[3]
Definition: RandGen.cpp:92
const btScalar eps
Definition: poly34.cpp:11
#define min(a, b)
Definition: sort.c:51
float max
uint len