# Commits

committed 34182c0

utils.geometry: new 'Direction' class

• Participants
• Parent commits 449b02d
• Branches dev-utils

# File ars/utils/geometry.py

` import numpy as np`
` `
` import ars.utils.mathematical as mut`
`+#import ars.utils.matrix as mxut`
` `
` import generic as gut`
` `
` 		raise NotImplementedError()`
` `
` `
`+class Direction:`
`+	"""A vector can be used to represent a direction. Its length is not`
`+	relevant; only where it points to. If normalized, each component is a`
`+	'direction cosine', thus being constrained by the equation`
`+	x^2 + y^2 + z^2 = 1. That shows, so there are only 2 degrees of freedom,`
`+	hence the difference with Orientation.`
`+`
`+	"""`
`+`
`+	def __init__(self, vector, normalize=False):`
`+		if normalize:`
`+			vector = mut.norm3(vector)`
`+		self.x = vector[0]`
`+		self.y = vector[1]`
`+		self.z = vector[2]`
`+`
`+	def get_vector(self):`
`+		return (self.x, self.y, self.z)`
`+`
`+	def get_angles(self):`
`+		"""Returns (alpha, beta, gamma) such that`
`+		x = cos(alpha)`
`+		y = cos(beta)`
`+		z = cos(gamma)`
`+		"""`
`+		return (mut.acos(self.x), mut.acos(self.y), mut.acos(self.z))`
`+`
`+`
`+#class RotationMatrix(mxut.Matrix3):`
`+#`
`+#	def __init__(self, elements=None, rows=None, axis=None, angle=None):`
`+#		pass`
`+`
`+`
` def rot_matrix_to_hom_transform(rot_matrix):`
` 	"""From transform.r2t in Corke's Robotic Toolbox (python) rot_matrix 3x3`
` 	matrix.	It may be a tuple, tuple of tuples or the result of numpy.mat()"""`