Commits

German Larrain committed 73fa726

utils.geometry: fixed docstrings and formatted some code

Comments (0)

Files changed (1)

ars/utils/geometry.py

 	\cos \theta + u_z^2\left(1-\cos \theta\right)
 	\end{bmatrix}
 	</math>
+
+	The returned matrix format is length-9 tuple.
+
 	"""
 
 	cos_theta = mut.cos(angle)
 	sin_theta = mut.sin(angle)
 	t = 1.0 - cos_theta
-	return (
-	t * axis[0]**2 + cos_theta,
-	t * axis[0] * axis[1] - sin_theta * axis[2],
-	t * axis[0] * axis[2] + sin_theta * axis[1],
-	t * axis[0] * axis[1] + sin_theta * axis[2],
-	t * axis[1]**2 + cos_theta,
-	t * axis[1] * axis[2] - sin_theta * axis[0],
-	t * axis[0] * axis[2] - sin_theta * axis[1],
-	t * axis[1] * axis[2] + sin_theta * axis[0],
-	t * axis[2]**2 + cos_theta)
+	return (t * axis[0]**2 + cos_theta,
+		t * axis[0] * axis[1] - sin_theta * axis[2],
+		t * axis[0] * axis[2] + sin_theta * axis[1],
+		t * axis[0] * axis[1] + sin_theta * axis[2],
+		t * axis[1]**2 + cos_theta,
+		t * axis[1] * axis[2] - sin_theta * axis[0],
+		t * axis[0] * axis[2] - sin_theta * axis[1],
+		t * axis[1] * axis[2] + sin_theta * axis[0],
+		t * axis[2]**2 + cos_theta)
 
 
 def make_OpenGL_matrix(rotation, position):
 	"""Returns an OpenGL compatible (column-major, 4x4 homogeneous)
 	transformation matrix from ODE compatible (row-major, 3x3) rotation matrix
-	rotation and position vector position"""
-	return (
-	rotation[0], rotation[3], rotation[6], 0.0,
-	rotation[1], rotation[4], rotation[7], 0.0,
-	rotation[2], rotation[5], rotation[8], 0.0,
-	position[0], position[1], position[2], 1.0)
+	rotation and position vector position.
+
+	The returned matrix format is length-9 tuple.
+
+	"""
+	return (rotation[0], rotation[3], rotation[6], 0.0,
+		rotation[1], rotation[4], rotation[7], 0.0,
+		rotation[2], rotation[5], rotation[8], 0.0,
+		position[0], position[1], position[2], 1.0)
 
 
 def get_body_relative_vector(body, vector):
 
 
 def rot_matrix_to_euler_angles(rot_matrix):
-	"""Returns the 3-1-3 Euler angles 'phi', 'theta' and 'psi' (using the
+	"""Returns the 3-1-3 Euler angles `phi`, `theta` and `psi` (using the
 	x-convention) corresponding to the rotation matrix ``rot_matrix``, which
 	is a tuple of three 3-element tuples, where each one is a row (what is
 	called row-major order).
 
-	Using the x-convention, the 3-1-3 Euler angles 'phi', 'theta' and 'psi'
+	Using the x-convention, the 3-1-3 Euler angles `phi`, `theta` and `psi`
 	(around	the Z, X and again the Z-axis) can be obtained as follows
 		phi = arctan2(A_{31}, A_{32})
 		theta = arccos(A_{33})
 		psi = -arctan2(A_{13}, A_{23})
- 	http://en.wikipedia.org/wiki/Rotation_representation_(mathematics)#Rotation_matrix_.E2.86.94_Euler_angles
+
+ 	http://en.wikipedia.org/wiki/Rotation_representation_(mathematics)#
+ 		Rotation_matrix_.E2.86.94_Euler_angles
+
 	"""
 	A = rot_matrix
 	phi = mut.atan2(A[2][0], A[2][1])		# arctan2(A_{31}, A_{32})