[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53898] trunk/blender/source/blender/ blenlib: utility vector functions for flipping one vector about another:

Campbell Barton ideasman42 at gmail.com
Sat Jan 19 00:07:31 CET 2013


Revision: 53898
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53898
Author:   campbellbarton
Date:     2013-01-18 23:07:27 +0000 (Fri, 18 Jan 2013)
Log Message:
-----------
utility vector functions for flipping one vector about another:
  nicer then interp_v3_v3v3(v, v1, v2, -1.0f);

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_math_vector.h
    trunk/blender/source/blender/blenlib/intern/math_vector.c

Modified: trunk/blender/source/blender/blenlib/BLI_math_vector.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_vector.h	2013-01-18 22:10:20 UTC (rev 53897)
+++ trunk/blender/source/blender/blenlib/BLI_math_vector.h	2013-01-18 23:07:27 UTC (rev 53898)
@@ -171,6 +171,10 @@
 void mid_v2_v2v2(float r[2], const float a[2], const float b[2]);
 void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3]);
 
+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 int is_zero_v3(const float a[3]);

Modified: trunk/blender/source/blender/blenlib/intern/math_vector.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_vector.c	2013-01-18 22:10:20 UTC (rev 53897)
+++ trunk/blender/source/blender/blenlib/intern/math_vector.c	2013-01-18 23:07:27 UTC (rev 53898)
@@ -122,6 +122,32 @@
 	v[2] = (v1[2] + v2[2] + v3[2]) / 3.0f;
 }
 
+/**
+ * Equivalent to:
+ * interp_v3_v3v3(v, v1, v2, -1.0f);
+ */
+
+void flip_v4_v4v4(float v[4], const float v1[4], const float v2[4])
+{
+	v[0] = v1[0] + (v1[0] - v2[0]);
+	v[1] = v1[1] + (v1[1] - v2[1]);
+	v[2] = v1[2] + (v1[2] - v2[2]);
+	v[3] = v1[3] + (v1[3] - v2[3]);
+}
+
+void flip_v3_v3v3(float v[3], const float v1[3], const float v2[3])
+{
+	v[0] = v1[0] + (v1[0] - v2[0]);
+	v[1] = v1[1] + (v1[1] - v2[1]);
+	v[2] = v1[2] + (v1[2] - v2[2]);
+}
+
+void flip_v2_v2v2(float v[2], const float v1[2], const float v2[2])
+{
+	v[0] = v1[0] + (v1[0] - v2[0]);
+	v[1] = v1[1] + (v1[1] - v2[1]);
+}
+
 /********************************** Angles ***********************************/
 
 /* Return the angle in radians between vecs 1-2 and 2-3 in radians




More information about the Bf-blender-cvs mailing list