def test_inplace(self, u): u_orig = u u += (1, 1) assert u == Vec2d(4, 5) assert u is u_orig u -= (1, 1) assert u == Vec2d(3, 4) assert u is u_orig u *= 2 assert u == Vec2d(6, 8) assert u is u_orig u /= 2 assert u == Vec2d(3, 4) assert u is u_orig
def read_vec(msg) -> Vec2d: """ Pede uma entrada vetorial. """ x, _, y = input(msg).lstrip("[( ").rstrip(")] ").partition(",") return Vec2d(float(x), float(y))
def test_algebraic_operations(self, u, v): assert u + v == Vec2d(u.x + v.x, u.y + v.y) assert u - v == Vec2d(u.x - v.x, u.y - v.y) assert u * 2 == Vec2d(2 * u.x, 2 * u.y) assert 2 * u == Vec2d(2 * u.x, 2 * u.y) assert u / 2 == Vec2d(u.x / 2, u.y / 2)
def jj(): return Vec2d(0, 1)
def ii(): return Vec2d(1, 0)
def v(): return Vec2d(1, 1)
def u(): return Vec2d(3, 4)