def test_scalar_projection_collinear(): v1 = np.array([1., 2., 0.]) v2 = np.array([4., 8., 0.]) res = mm.scalar_projection(v1, v2) assert np.allclose(res, 20. / np.linalg.norm(v2))
def test_scalar_projection_collinear(): v1 = np.array([1., 2., 0.]) v2 = np.array([4., 8., 0.]) res = mm.scalar_projection(v1, v2) nt.assert_true(np.allclose(res, 20./np.linalg.norm(v2)))
def test_scalar_projection_perpendicular(): v1 = np.array([3., 0., 0.]) v2 = np.array([0., 1.5, 0.]) res = mm.scalar_projection(v1, v2) assert np.allclose(res, 0.)
def test_scalar_projection(): v1 = np.array([4., 1., 0.]) v2 = np.array([2., 3., 0.]) res = mm.scalar_projection(v1, v2) assert np.isclose(res, 3.0508510792387602)
def test_scalar_projection_perpendicular(): v1 = np.array([3., 0., 0.]) v2 = np.array([0., 1.5, 0.]) res = mm.scalar_projection(v1, v2) nt.assert_true(np.allclose(res, 0.))
def test_scalar_projection(): v1 = np.array([4., 1., 0.]) v2 = np.array([2., 3., 0.]) res = mm.scalar_projection(v1, v2) nt.assert_true(np.isclose(res, 3.0508510792387602))