Example #1
0
def test_point_radius_property():
    p = Point(1, 1)
    r = math.hypot(1, 1)
    assert p.radius == r

    p.radius *= 3
    # XXX epsilons are biting me here.
    assert round(p.radius, 13) == round(3 * r, 13)

    p.radius = 0
    assert p.radius == 0 and p.is_origin
Example #2
0
def test_point_from_polar_not_origin_all_quadrants(x, y):

    radius = math.hypot(x, y)
    radians = math.atan2(y, x)
    degrees = math.degrees(radians)

    p = Point.from_polar(radius, radians)
    q = Point.from_polar(radius, degrees, is_radians=False)

    i = Point()
    i.radius = radius
    i.radians = radians

    j = Point()
    j.radius = radius
    j.degrees = degrees

    assert p.x == x and p.y == y
    assert q.x == x and q.y == y
    assert i.x == x and i.y == y
    assert j.x == x and j.y == y
    assert p == q == i == j