def testLineIntersection2(self): normal = np.array([2, 2, 2]) offset = np.array([0, 0, 2]) plane = SourcePlane(normal, offset) lin_off = np.array([0, 0, -2]) grad = np.array([-1, -1, -2]) intersection = plane.line_intersection(grad, lin_off) self.assertListEqual(list(intersection), [1, 1, 0])
def testLineIntersection3(self): normal = np.array([0, 1, 0]) offset = np.array([0, 5, 0]) plane = SourcePlane(normal, offset) mic_loc = np.array([0, 0, 0]) direction = np.array([-1, 1, 1]) loc = plane.line_intersection(direction, mic_loc) self.assertListEqual(list(loc), [-5, 5, 5])
def setUp(self): normal = np.array([0, 1, 0]) offset = np.array([0, 5, 0]) normal2 = np.array([0, 0, 1]) offset2 = np.array([0, 0, 6]) normal3 = np.array([1, 0, 0]) offset3 = np.array([-1, 0, 0]) self.plane1 = SourcePlane(normal, offset) self.plane2 = SourcePlane(normal2, offset2) self.plane3 = SourcePlane(normal3, offset3) self.planes = [self.plane1, self.plane2, self.plane3] pass
def testInvalidPlanes(self): normal = np.array([0, 1, 0]) offset = np.array([0, 5, 0]) planes = SourcePlane(offset, normal) mic_loc = np.array([0, 0, 0]) cam_loc = np.array([1, 1, 1]) self.assertRaises(ValueError, SearchSpace, mic_loc, cam_loc, planes)
def testInit(self): normal = np.array([0, 1, 0]) offset = np.array([0, 5, 0]) planes = [SourcePlane(offset, normal)] mic_loc = np.array([0, 0, 0]) cam_loc = np.array([1, 1, 1]) space = SearchSpace(mic_loc, cam_loc, planes)
def testGetSourceLoc2PlaneBehind(self): normal2 = np.array([0, 0, 1]) offset2 = np.array([0, 0, -1]) planes = [self.plane1, SourcePlane(normal2, offset2)] mic_loc = np.array([0, 0, 0]) cam_loc = np.array([1, 1, 1]) space = SearchSpace(mic_loc, cam_loc, planes) direction = np.array([-1, 1, 1]) loc = space.get_source_loc(direction) self.assertListEqual(list(loc), [-5, 5, 5])
def testValidSetup(self): normal = np.array([1, 2, 3]) offset = np.array([3, 1, 1]) plane = SourcePlane(normal, offset)