# Path: pgzero/actor.py
# def transform_anchor(ax, ay, w, h, angle):
#     """Transform anchor based upon a rotation of a surface of size w x h."""
#     theta = -radians(angle)
# 
#     sintheta = sin(theta)
#     costheta = cos(theta)
# 
#     # Dims of the transformed rect
#     tw = abs(w * costheta) + abs(h * sintheta)
#     th = abs(w * sintheta) + abs(h * costheta)
# 
#     # Offset of the anchor from the center
#     cax = ax - w * 0.5
#     cay = ay - h * 0.5
# 
#     # Rotated offset of the anchor from the center
#     rax = cax * costheta - cay * sintheta
#     ray = cax * sintheta + cay * costheta
# 
#     return (
#         tw * 0.5 + rax,
#         th * 0.5 + ray
#     )


from math import sin, cos, radians
from unittest import TestCase
from pgzero.actor import transform_anchor

root2 = 2 ** 0.5


def assertVecEqual(a, b, decimal_places=7):
    for t in (a, b):
        if not isinstance(t, tuple):
            raise AssertionError('%r is not a tuple' % t)
        if len(t) != 2:
            raise AssertionError('Expected 2-tuple, not %r' % t)

    ax, ay = a
    bx, by = b
    epsilon = 10 ** -decimal_places
    if abs(ax - bx) > epsilon or abs(ay - by) > epsilon:
        raise AssertionError('%r != %r (to %d decimal places)' % (
            a, b, decimal_places
        ))


class TransformAnchorTest(TestCase):
    def test_identity(self):
        assertVecEqual(
            transform_anchor(5, 5, 10, 10, 0),
            (5, 5)
        )

    def test_45deg(self):
        assertVecEqual(

# Path: pgzero/actor.py
# def transform_anchor(ax, ay, w, h, angle):
#     """Transform anchor based upon a rotation of a surface of size w x h."""
#     theta = -radians(angle)
# 
#     sintheta = sin(theta)
#     costheta = cos(theta)
# 
#     # Dims of the transformed rect
#     tw = abs(w * costheta) + abs(h * sintheta)
#     th = abs(w * sintheta) + abs(h * costheta)
# 
#     # Offset of the anchor from the center
#     cax = ax - w * 0.5
#     cay = ay - h * 0.5
# 
#     # Rotated offset of the anchor from the center
#     rax = cax * costheta - cay * sintheta
#     ray = cax * sintheta + cay * costheta
# 
#     return (
#         tw * 0.5 + rax,
#         th * 0.5 + ray
#     )


# Path: test/test_transform_anchor.py
from math import sin, cos, radians
from unittest import TestCase
from pgzero.actor import transform_anchor


root2 = 2 ** 0.5


def assertVecEqual(a, b, decimal_places=7):
    for t in (a, b):
        if not isinstance(t, tuple):
            raise AssertionError('%r is not a tuple' % t)
        if len(t) != 2:
            raise AssertionError('Expected 2-tuple, not %r' % t)

    ax, ay = a
    bx, by = b
    epsilon = 10 ** -decimal_places
    if abs(ax - bx) > epsilon or abs(ay - by) > epsilon:
        raise AssertionError('%r != %r (to %d decimal places)' % (
            a, b, decimal_places
        ))


class TransformAnchorTest(TestCase):
    def test_identity(self):
        assertVecEqual(
            transform_anchor(5, 5, 10, 10, 0),
            (5, 5)
        )

    def test_45deg(self):
        assertVecEqual(

            transform_anchor(5, 5, 10, 10, 45),