[Bf-blender-cvs] [47a5d7d] master: BLI_math: Add double versions of functions

Campbell Barton noreply at git.blender.org
Thu Jun 16 11:21:21 CEST 2016


Commit: 47a5d7d1bcad974dbeaf5e7f2945027e72835d34
Author: Campbell Barton
Date:   Tue Jun 14 16:43:14 2016 +1000
Branches: master
https://developer.blender.org/rB47a5d7d1bcad974dbeaf5e7f2945027e72835d34

BLI_math: Add double versions of functions

- mul_v3_m3v3_db
- mul_m3_v3_db
- negate_v3_db

===================================================================

M	source/blender/blenlib/BLI_math_matrix.h
M	source/blender/blenlib/BLI_math_vector.h
M	source/blender/blenlib/intern/math_matrix.c
M	source/blender/blenlib/intern/math_vector_inline.c

===================================================================

diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 6d6fbe4..9120d9f 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -138,10 +138,14 @@ bool invert_m3_m3(float R[3][3], float A[3][3]);
 bool invert_m4(float R[4][4]);
 bool invert_m4_m4(float R[4][4], float A[4][4]);
 
-/* double ariphmetics */
+/* double arithmetic (mixed float/double) */
 void mul_m4_v4d(float M[4][4], double r[4]);
 void mul_v4d_m4v4d(double r[4], float M[4][4], double v[4]);
 
+/* double matrix functions (no mixing types) */
+void mul_v3_m3v3_db(double r[3], double M[3][3], const double a[3]);
+void mul_m3_v3_db(double M[3][3], double r[3]);
+
 
 /****************************** Linear Algebra *******************************/
 
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 25f485a..8a36b04 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -148,6 +148,7 @@ MINLINE void negate_v4(float r[4]);
 MINLINE void negate_v4_v4(float r[4], const float a[3]);
 
 MINLINE void negate_v3_short(short r[3]);
+MINLINE void negate_v3_db(double r[3]);
 
 MINLINE void invert_v2(float r[2]);
 
@@ -231,6 +232,7 @@ 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 flip_v2_v2v2(float v[2], const float v1[2], const float v2[2]);
 
+
 /********************************* Comparison ********************************/
 
 MINLINE bool is_zero_v2(const float a[3])  ATTR_WARN_UNUSED_RESULT;
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 0e3f905..c9c61d5 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -587,6 +587,15 @@ void mul_v3_m3v3(float r[3], float M[3][3], const float a[3])
 	r[2] = M[0][2] * a[0] + M[1][2] * a[1] + M[2][2] * a[2];
 }
 
+void mul_v3_m3v3_db(double r[3], double M[3][3], const double a[3])
+{
+	BLI_assert(r != a);
+
+	r[0] = M[0][0] * a[0] + M[1][0] * a[1] + M[2][0] * a[2];
+	r[1] = M[0][1] * a[0] + M[1][1] * a[1] + M[2][1] * a[2];
+	r[2] = M[0][2] * a[0] + M[1][2] * a[1] + M[2][2] * a[2];
+}
+
 void mul_v2_m3v3(float r[2], float M[3][3], const float a[3])
 {
 	BLI_assert(r != a);
@@ -597,10 +606,12 @@ void mul_v2_m3v3(float r[2], float M[3][3], const float a[3])
 
 void mul_m3_v3(float M[3][3], float r[3])
 {
-	float tmp[3];
+	mul_v3_m3v3(r, M, (const float[3]){UNPACK3(r)});
+}
 
-	mul_v3_m3v3(tmp, M, r);
-	copy_v3_v3(r, tmp);
+void mul_m3_v3_db(double M[3][3], double r[3])
+{
+	mul_v3_m3v3_db(r, M, (const double[3]){UNPACK3(r)});
 }
 
 void mul_transposed_m3_v3(float mat[3][3], float vec[3])
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index b43fb6e..fd9f3d5 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -633,6 +633,13 @@ MINLINE void negate_v3_short(short r[3])
 	r[2] = (short)-r[2];
 }
 
+MINLINE void negate_v3_db(double r[3])
+{
+	r[0] = -r[0];
+	r[1] = -r[1];
+	r[2] = -r[2];
+}
+
 MINLINE void invert_v2(float r[2])
 {
 	BLI_assert(!ELEM(0.0f, r[0], r[1]));




More information about the Bf-blender-cvs mailing list