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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-09-11 00:45:47 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-09-11 00:45:47 +0400
commitab8d88ac18f7310889d11d21f94fdca400b428e0 (patch)
tree4745687538eee2c08ab0c6327f52a4799afbe924 /source
parent734eaab54542644f6a031858b4ca280cd565dc6a (diff)
add angle_to_mat2 utility function.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenlib/BLI_math_rotation.h3
-rw-r--r--source/blender/blenlib/intern/math_rotation.c15
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c10
3 files changed, 18 insertions, 10 deletions
diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h
index 87c065f3016..42161279bfd 100644
--- a/source/blender/blenlib/BLI_math_rotation.h
+++ b/source/blender/blenlib/BLI_math_rotation.h
@@ -104,7 +104,8 @@ void quat_to_axis_angle(float axis[3], float *angle, const float q[4]);
void mat3_to_axis_angle(float axis[3], float *angle, float M[3][3]);
void mat4_to_axis_angle(float axis[3], float *angle, float M[4][4]);
-void single_axis_angle_to_mat3(float R[3][3], const char axis, const float angle);
+void axis_angle_to_mat3_single(float R[3][3], const char axis, const float angle);
+void angle_to_mat2(float R[2][2], const float angle);
/******************************** XYZ Eulers *********************************/
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index c9919e7be37..6bac102e1b1 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -817,7 +817,8 @@ void mat4_to_axis_angle(float axis[3], float *angle, float mat[4][4])
quat_to_axis_angle(axis, angle, q);
}
-void single_axis_angle_to_mat3(float mat[3][3], const char axis, const float angle)
+/* rotation matrix from a single axis */
+void axis_angle_to_mat3_single(float mat[3][3], const char axis, const float angle)
{
const float angle_cos = cosf(angle);
const float angle_sin = sinf(angle);
@@ -862,6 +863,18 @@ void single_axis_angle_to_mat3(float mat[3][3], const char axis, const float ang
}
}
+void angle_to_mat2(float mat[2][2], const float angle)
+{
+ const float angle_cos = cosf(angle);
+ const float angle_sin = sinf(angle);
+
+ /* 2D rotation matrix */
+ mat[0][0] = angle_cos;
+ mat[0][1] = angle_sin;
+ mat[1][0] = -angle_sin;
+ mat[1][1] = angle_cos;
+}
+
/******************************** XYZ Eulers *********************************/
/* XYZ order */
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index d471cd05a2b..3e5dcc28903 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -522,18 +522,12 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
axis_angle_to_mat3((float (*)[3])mat, tvec, angle);
}
else if (matSize == 2) {
- const float angle_cos = cosf(angle);
- const float angle_sin = sinf(angle);
+ angle_to_mat2((float (*)[2])mat, angle);
- /* 2D rotation matrix */
- mat[0] = angle_cos;
- mat[1] = angle_sin;
- mat[2] = -angle_sin;
- mat[3] = angle_cos;
}
else {
/* valid axis checked above */
- single_axis_angle_to_mat3((float (*)[3])mat, axis[0], angle);
+ axis_angle_to_mat3_single((float (*)[3])mat, axis[0], angle);
}
if (matSize == 4) {