German Larrain avatar German Larrain committed 8232638

utils.mathematical: addded and changed some imports

Comments (0)

Files changed (1)

ars/utils/mathematical.py

 deal with homogeneous transforms; convert angles and other structures.
 """
 
-import math
-from math import sqrt, pi, cos, sin, acos
+#import itertools
+from math import sqrt, pi, cos, sin, acos, atan, atan2, degrees, radians
+#import operator
+
+import numpy as np
 
 import generic as gut
 
 #===============================================================================
 
 def radians_to_degrees(radians_):
-	return math.degrees(radians_)
+	return degrees(radians_)
 
 # TODO: mix with the corresponding scalar-argument function
 def vec3_radians_to_degrees(vector_):
 	return tuple(result)
 
 def degrees_to_radians(degrees_):
-	return math.radians(degrees_)
+	return radians(degrees_)
 
 # TODO: mix with the corresponding scalar-argument function
 def vec3_degrees_to_radians(vector_):
 	"""returns the matrix multiplication of matrix1 and matrix2"""
 	#TODO: check objects are valid, or use exceptions to catch errors raised by numpy
 
-	import numpy as np
-
 	a1 = np.array(matrix1)
 	a2 = np.array(matrix2)
 	result = np.dot(a1, a2)
 #===============================================================================
 
 def _test_angular_conversions(angle_):
-	#x = 2.0/3*math.pi
+	#x = 2.0/3*pi
 	y = radians_to_degrees(angle_)
 	z = degrees_to_radians(y)
 	dif = angle_ - z
 
 if __name__ == '__main__':
 
-	_test_angular_conversions(2.0/3*math.pi)
-	_test_angular_conversions(4.68*math.pi)
+	_test_angular_conversions(2.0 / 3 * pi)
+	_test_angular_conversions(4.68 * pi)
 
-	radians_ = (2.0/3*math.pi, 2.0*math.pi, 1.0/4*math.pi)
+	radians_ = (2.0 / 3 * pi, 2.0 * pi, 1.0 / 4 * pi)
 	degrees_ = (120, 360, 45)
 	print(vec3_radians_to_degrees(radians_))
 	print(vec3_degrees_to_radians(degrees_))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.