diff --git a/SimPEG/Utils/coordutils.py b/SimPEG/Utils/coordutils.py index e26a751e..0329495a 100644 --- a/SimPEG/Utils/coordutils.py +++ b/SimPEG/Utils/coordutils.py @@ -1,26 +1,5 @@ import numpy as np -def crossProd(v0,v1): - """ - Cross product of 2 vectors - - :param numpy.array v0: vector of length 3 - :param numpy.array v1: vector of length 3 - :rtype: numpy.array - :return: cross product of v0,v1 - """ - # ensure both n0, n1 are vectors of length 1 - assert len(v0) == 3, "Length of v0 should be 3" - assert len(v1) == 3, "Length of v1 should be 3" - - v2 = np.zeros(3,dtype=float) - - v2[0] = v0[1]*v1[2] - v1[1]*v0[2] - v2[1] = v1[0]*v0[2] - v0[0]*v1[2] - v2[2] = v0[0]*v1[1] - v1[0]*v0[1] - - return v2 - def rotationMatrixFromNormals(v0,v1,tol=1e-20): """ Performs the minimum number of rotations to define a rotation from the direction indicated by the vector n0 to the direction indicated by n1. @@ -46,7 +25,7 @@ def rotationMatrixFromNormals(v0,v1,tol=1e-20): n0dotn1 = n0.dot(n1) # define the rotation axis, which is the cross product of the two vectors - rotAx = crossProd(n0,n1) + rotAx = np.cross(n0,n1) if np.linalg.norm(rotAx) < tol: return np.eye(3,dtype=float) diff --git a/tests/utils/test_coordutils.py b/tests/utils/test_coordutils.py index 7770671d..dc036529 100644 --- a/tests/utils/test_coordutils.py +++ b/tests/utils/test_coordutils.py @@ -6,11 +6,6 @@ tol = 1e-15 class coorUtilsTest(unittest.TestCase): - def test_crossProd(self): - self.assertTrue(np.linalg.norm(Utils.coordutils.crossProd(np.r_[1.,0.,0.],np.r_[0.,1.,0.]) - np.r_[0.,0.,1.]) < tol) - self.assertTrue(np.linalg.norm(Utils.coordutils.crossProd(np.r_[0.,1.,0.],np.r_[0.,0.,1.]) - np.r_[1.,0.,0.]) < tol) - self.assertTrue(np.linalg.norm(Utils.coordutils.crossProd(np.r_[0.,0.,1.],np.r_[1.,0.,0.]) - np.r_[0.,1.,0.]) < tol) - def test_rotationMatrixFromNormals(self): v0 = np.random.rand(3) v0 *= 1./np.linalg.norm(v0)