def test_angle_between(): v1 = Vector(0, 1) v2 = Vector(1, 1) angle = v1.angle_between(v2) assert is_close(angle, math.pi / 4) # reverse order, same result angle = v2.angle_between(v1) assert is_close(angle, math.pi / 4)
def test_spatial_angle(): v = Vector(3, 3, 0) assert is_close(v.spatial_angle_deg, 45) assert is_close(v.spatial_angle_rad, math.radians(45))
def test_get_angle(): v = Vector(3, 3) assert is_close(v.angle_deg, 45) assert is_close(v.angle_rad, math.radians(45))
def test_angle_deg(): assert is_close(Vector(0, 1).angle_deg, 90) assert is_close(Vector(0, -1).angle_deg, -90) assert is_close(Vector(1, 1).angle_deg, 45) assert is_close(Vector(-1, 1).angle_deg, 135)
def test_dot_product(): v1 = Vector(2, 7, 1) v2 = Vector(3, 9, 8) assert is_close(v1.dot(v2), 77)
def test_magnitude_square(): v = Vector(3, 4, 5) assert is_close(v.magnitude_square, 50)
def test_magnitude(): v = Vector(3, 4, 5) assert is_close(abs(v), 7.0710678118654755) assert is_close(v.magnitude, 7.0710678118654755)