Commits

German Larrain  committed 649bca8

Transform: renamed methods; implemented 'matrix', 'get_translation' and 'get_rotation'.

  • Participants
  • Parent commits 1752576

Comments (0)

Files changed (2)

File ars/utils/geometry.py

 	def __str__(self):
 		return str(self._matrix)
 
+	@property
+	def matrix(self):
+		r"""Return matrix that contains the transform values.
+
+		:return: 4x4 matrix
+		:rtype: :class:`numpy.ndarray`
+
+		"""
+		return self._matrix
+
 	def get_long_tuple(self):
 		return tuple(self._matrix.flatten())
 
-	def get_position(self):
-		raise NotImplementedError()
+	def get_translation(self, as_numpy=False):
+		"""Return the translation vector component.
 
-	def get_rotation_matrix(self):
-		raise NotImplementedError()
+		:param as_numpy: whether to return a numpy object or a tuple
+		:return: length-3 sequence
+		:rtype: tuple or :class:`numpy.ndarray`
+
+		"""
+		rot = self._matrix[0:3,3]
+		if as_numpy:
+			return rot
+		return tuple(rot)
+
+	def get_rotation(self, as_numpy=False):
+		"""Return the rotation matrix component.
+
+		:param as_numpy: whether to return a numpy object or a tuple
+		:return: 3x3 matrix
+		:rtype: tuple of tuples or :class:`numpy.ndarray`
+
+		"""
+		rot = self._matrix[0:3,0:3]
+		if as_numpy:
+			return rot
+		return mut.np_matrix_to_tuple(rot)
 
 
 def rot_matrix_to_hom_transform(rot_matrix):

File tests/utils_geometry.py

 	print(rot)
 	print(t)
 	print(t.get_long_tuple())
+	print(t.matrix)
+	print(t.get_rotation())
+	print(t.get_rotation(True))
+	print(t.get_translation())
+	print(t.get_translation(True))
 
 def _test_rot_matrix_to_hom_transform():