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:
authorCampbell Barton <ideasman42@gmail.com>2014-04-03 14:47:03 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-04-03 14:47:03 +0400
commit5770d691bbed31d05ecf22383f56df2a4371acfa (patch)
tree54b0ee57d35e4ca3b66b4bc4a44bdf51c807aee3 /source/blender/blenlib/intern/math_vector_inline.c
parent51abc2becd602676eeebc24ba7dc64c804bb935a (diff)
Optimize BLI_convexhull_aabb_fit_hull_2d, avoid atan2, sin, cos
add utility functions for using a 2d unit vector as a rotation matrix mul_v2_v2_cw & mul_v2_v2_ccw
Diffstat (limited to 'source/blender/blenlib/intern/math_vector_inline.c')
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index 59d5f7e7627..aed604eddb4 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -432,6 +432,31 @@ MINLINE void mul_v4_v4fl(float r[4], const float a[4], float f)
r[3] = a[3] * f;
}
+/**
+ * Avoid doing:
+ *
+ * angle = atan2f(dvec[0], dvec[1]);
+ * angle_to_mat2(mat, angle);
+ *
+ * instead use a vector as a matrix.
+ */
+
+MINLINE void mul_v2_v2_cw(float r[2], const float mat[2], const float vec[2])
+{
+ BLI_assert(r != vec);
+
+ r[0] = mat[0] * vec[0] + (+mat[1]) * vec[1];
+ r[1] = mat[1] * vec[0] + (-mat[0]) * vec[1];
+}
+
+MINLINE void mul_v2_v2_ccw(float r[2], const float mat[2], const float vec[2])
+{
+ BLI_assert(r != vec);
+
+ r[0] = mat[0] * vec[0] + (-mat[1]) * vec[1];
+ r[1] = mat[1] * vec[0] + (+mat[0]) * vec[1];
+}
+
/* note: could add a matrix inline */
MINLINE float mul_project_m4_v3_zfac(float mat[4][4], const float co[3])
{