Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-11-10 01:42:41 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-11-10 01:42:41 +0300
commit60ea7456137a019c2ddad75f14b3b6a0892f7b56 (patch)
tree7bcd9059496194f5af8d1c671998996a15e38f15 /source/blender/blenlib/BLI_math_vector.h
parent5935ef004935b27fc5795349aed32f87cf637049 (diff)
Math Lib Reorganization
* New header and source files. * Still need a few tweaks before switching code to use them.
Diffstat (limited to 'source/blender/blenlib/BLI_math_vector.h')
-rw-r--r--source/blender/blenlib/BLI_math_vector.h140
1 files changed, 140 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
new file mode 100644
index 00000000000..1cb1912208e
--- /dev/null
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -0,0 +1,140 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: some of this file.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ * */
+
+#ifndef BLI_MATH_VECTOR
+#define BLI_MATH_VECTOR
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MINLINE
+
+//#define static inline
+//#include "intern/math_vector_inline.h"
+
+/************************************* Init ***********************************/
+
+void zero_v2(float r[2]);
+void zero_v3(float r[3]);
+
+void copy_v2_v2(float r[2], float a[2]);
+void copy_v3_v3(float r[3], float a[3]);
+
+/********************************* Arithmetic ********************************/
+
+void add_v2_v2(float r[2], float a[2]);
+void add_v2_v2v2(float r[2], float a[2], float b[2]);
+void add_v3_v3(float r[3], float a[3]);
+void add_v3_v3v3(float r[3], float a[3], float b[3]);
+
+void sub_v2_v2(float r[2], float a[2]);
+void sub_v2_v2v2(float r[2], float a[2], float b[2]);
+void sub_v3_v3(float r[3], float a[3]);
+void sub_v3_v3v3(float r[3], float a[3], float b[3]);
+
+void mul_v2_fl(float r[2], float f);
+void mul_v3_fl(float r[3], float f);
+void mul_v3_v3fl(float r[3], float a[3], float f);
+void mul_v3_v3(float r[3], float a[3]);
+void mul_v3_v3v3(float r[3], float a[3], float b[3]);
+
+void negate_v3(float r[3]);
+void negate_v3_v3(float r[3], float a[3]);
+
+float dot_v2v2(float a[2], float b[2]);
+float dot_v3v3(float a[3], float b[3]);
+
+float cross_v2v2(float a[2], float b[2]);
+void cross_v3_v3v3(float r[3], float a[3], float b[3]);
+
+void star_m3_v3(float R[3][3],float a[3]);
+
+/*********************************** Length **********************************/
+
+float len_v2(float a[2]);
+float len_v2v2(float a[2], float b[2]);
+float len_v3(float a[3]);
+float len_v3v3(float a[3], float b[3]);
+
+float normalize_v2(float r[2]);
+float normalize_v3(float r[3]);
+
+/******************************* Interpolation *******************************/
+
+void interp_v2_v2v2(float r[2], const float a[2], const float b[2], const float t); // TODO const
+void interp_v2_v2v2v2(float r[2], const float a[2], const float b[2], const float c[3], const float t[3]); // TODO const
+void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t); // TODO const
+void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3]); // TODO const
+
+void mid_v3_v3v3(float r[3], float a[3], float b[3]);
+
+/********************************* Comparison ********************************/
+
+int is_zero_v3(float a[3]);
+int equals_v3v3(float a[3], float b[3]);
+int compare_v3v3(float a[3], float b[3], float limit);
+int compare_len_v3v3(float a[3], float b[3], float limit);
+
+int compare_v4v4(float a[4], float b[4], float limit);
+
+/********************************** Angles ***********************************/
+/* - angle with 2 arguments is angle between vector */
+/* - angle with 3 arguments is angle between 3 points at the middle point */
+/* - angle_normalized_* is faster equivalent if vectors are normalized */
+
+float angle_v2v2(float a[2], float b[2]);
+float angle_v2v2v2(float a[2], float b[2], float c[2]);
+float angle_normalized_v2v2(float a[2], float b[2]);
+float angle_v3v3(float a[2], float b[2]);
+float angle_v3v3v3(float a[2], float b[2], float c[2]);
+float angle_normalized_v3v3(float a[3], float b[3]);
+
+/********************************* Geometry **********************************/
+
+void project_v3_v3v3(float r[3], float p[3], float n[3]);
+void reflect_v3_v3v3(float r[3], float v[3], float n[3]);
+void ortho_basis_v3v3_v3(float r1[3], float r2[3], float a[3]);
+void bisect_v3_v3v3v3(float r[3], float a[3], float b[3], float c[3]);
+
+/*********************************** Other ***********************************/
+
+void print_v2(char *str, float a[2]);
+void print_v3(char *str, float a[3]);
+void print_v4(char *str, float a[4]);
+
+void normal_short_to_float_v3(float r[3], short n[3]);
+void normal_float_to_short_v3(short r[3], float n[3]);
+
+void minmax_v3_v3v3(float r[3], float min[3], float max[3]);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BLI_MATH_VECTOR */
+