[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60024] trunk/blender/source/blender: add angle_to_mat2 utility function.

Campbell Barton ideasman42 at gmail.com
Tue Sep 10 22:45:47 CEST 2013


Revision: 60024
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60024
Author:   campbellbarton
Date:     2013-09-10 20:45:47 +0000 (Tue, 10 Sep 2013)
Log Message:
-----------
add angle_to_mat2 utility function.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_math_rotation.h
    trunk/blender/source/blender/blenlib/intern/math_rotation.c
    trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c

Modified: trunk/blender/source/blender/blenlib/BLI_math_rotation.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_rotation.h	2013-09-10 20:26:34 UTC (rev 60023)
+++ trunk/blender/source/blender/blenlib/BLI_math_rotation.h	2013-09-10 20:45:47 UTC (rev 60024)
@@ -104,7 +104,8 @@
 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 *********************************/
 

Modified: trunk/blender/source/blender/blenlib/intern/math_rotation.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_rotation.c	2013-09-10 20:26:34 UTC (rev 60023)
+++ trunk/blender/source/blender/blenlib/intern/math_rotation.c	2013-09-10 20:45:47 UTC (rev 60024)
@@ -817,7 +817,8 @@
 	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 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 */

Modified: trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c	2013-09-10 20:26:34 UTC (rev 60023)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c	2013-09-10 20:45:47 UTC (rev 60024)
@@ -522,18 +522,12 @@
 		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) {




More information about the Bf-blender-cvs mailing list