Skip to content

Commit

Permalink
Matrix class refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
alopezrivera committed Dec 17, 2021
1 parent e691e56 commit 27ad651
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def T(self):
"""
Rotation matrix Transpose
"""
return R(matrix=self.matrix.T, params=self.params)
return M(matrix=self.matrix.T, params=self.params)

def I(self):
"""
Expand All @@ -71,26 +71,26 @@ def I(self):
# Negative angles
for param in self.params:
inv_matrix.subs(param, -param)
return R(matrix=inv_matrix, params=self.params)
return M(matrix=inv_matrix, params=self.params)

def diff(self):
dm = sp.diff(self.matrix, self.params)
return R(matrix=dm, params=self.params | dm.free_symbols)
return M(matrix=dm, params=self.params | dm.free_symbols)

"""
Operators
"""
def _operate(self, other, f):

# Another rotation matrix
if isinstance(other, R):
return R(matrix=f(self.matrix, other.matrix), params=self.params | other.params)
if isinstance(other, M):
return M(matrix=f(self.matrix, other.matrix), params=self.params | other.params)
# A NumPy array
elif isinstance(other, np.ndarray):
return R(matrix=f(self.matrix, other), params=self.params)
return M(matrix=f(self.matrix, other), params=self.params)
# A SymPy array
elif 'sympy' in other.__module__:
return R(matrix=f(self.matrix, other), params=self.params | other.free_symbols)
return M(matrix=f(self.matrix, other), params=self.params | other.free_symbols)
else:
raise ValueError("Multiplication input invalid. It should be either a rotation, or a NumPy or SymPy array.")

Expand Down

0 comments on commit 27ad651

Please sign in to comment.