# Problem Description
This is a geometric transformation problem where we need to:
1. Calculate the new position of a circle's center after rotation
2. The rotation occurs around a fixed point (green point)
3. The rotation angle is given in degrees (can be positive or negative)
4. The circle maintains its size and shape during transformation
5. The blue area represents the region formed by the triangle created by the red point, the green point, and the new center coordinates of the circle.

# Visual Facts
1. The diagram shows two examples with different rotations:
   - Example 1: 90° (counterclockwise)
   - Example 2: -90° (clockwise)

2. Coordinate Points:
   - Green point coordinates: (3,5) in both examples
   - Red point coordinates: 
     - Example 1: starts at (3,3), ends at (5,5)
     - Example 2: starts at (5,5), ends at (3,3)

3. Grid Properties:
   - Both x and y axes range from 0 to 8
   - Grid lines are spaced at unit intervals

4. Visual Elements:
   - Red dot represents the circle's center
   - Green dot serves as the rotation pivot point
   - Circle maintains constant radius during rotation
   - Dotted lines show the rotation path

# Visual Patterns
1. Rotational Properties:
   - Positive angle (90°) results in counterclockwise rotation
   - Negative angle (-90°) results in clockwise rotation
   - The rotation preserves the distance between red and green points

2. Mathematical Patterns:
   - The radius of rotation equals the distance between red and green points
   - The rotation follows standard geometric rotation formulas around a pivot point
   - 90° rotation creates perpendicular lines between original and final positions

3. Transformation Rules:
   - The circle's shape and size remain unchanged during rotation
   - The transformation only affects the position of the circle's center
   - All points maintain their relative distances from the pivot point
   - The rotation arc length is proportional to the angle of rotation
   - The blue area represents the region formed by the triangle created by the red point, the green point, and the new center coordinates of the circle.

4. Geometric Constraints:
   - The rotation occurs in a 2D plane
   - The pivot point (green) remains stationary
   - The transformation preserves the circle's geometric properties

# Solution
from typing import Tuple
import math

def solution(red: Tuple[float, float], angle: int, green: Tuple[float, float]) -> float:
    """
    Calculate the area of the blue sector.

    Args:
        red: A tuple (x, y) representing the coordinates of the red point.
        angle: An integer representing the rotation angle in degrees.
        green: A tuple (x, y) representing the coordinates of the green point.

    Returns:
        A float representing the area of the blue sector.
    """
    # Extract coordinates
    rx, ry = red
    gx, gy = green

    # Calculate the vector from green to red
    dx = rx - gx
    dy = ry - gy

    # Convert angle to radians
    rad = math.radians(angle)

    # Rotate the vector
    rotated_x = dx * math.cos(rad) - dy * math.sin(rad)
    rotated_y = dx * math.sin(rad) + dy * math.cos(rad)

    # Calculate the new red point after rotation
    new_rx = rotated_x + gx
    new_ry = rotated_y + gy

    # Calculate the area of the triangle formed by red, new red, and green
    area = abs(
        (rx * (new_ry - gy) + new_rx * (gy - ry) + gx * (ry - new_ry)) / 2
    )

    return round(area, 2)


# Test Script
def test():
    def tuples_almost_equal(t1, t2,  tol: float = 1e-2) -> bool:
         return abs(t1 - t2) < tol

    test_cases = [
        {
            'red': (5.0, 5.0),
            'angle': 90,
            'green': (3.0, 5.0),
            'expected':2.0
        },
        {
            'red': (5.0, 5.0),
            'angle': 180,
            'green': (3.0, 3.0),
            'expected': 0
        },
        {
            'red': (5.0, 5.0),
            'angle': 270,
            'green': (2.5, 5.0),
            'expected': 3.12
        },
        {
            'red': (1.0, 5.0),
            'angle': 45,
            'green': (3, 5.0),
            'expected': 1.41
        },
        {
            'red': (1, 1),
            'angle': 90,
            'green': (4, 4),
            'expected': 9.0
        },
        {
            'red': (0, 0),
            'angle': 90,
            'green': (100, 100),
            'expected':  10000.0
        },
        {
            'red': (5.0, 5.0),
            'angle': -90,
            'green': (-5, -5),
            'expected':  100.0
        },
        {
            'red': (10.0, 5.0),
            'angle': -90,
            'green': (-5, -10),
            'expected': 225.0
        },
                {
            'red': (10.0, 5.0),
            'angle': 90,
            'green': (-5, -10),
            'expected': 225.0
        },
                {
            'red': (10.0, 5.0),
            'angle': 180,
            'green': (-5, -10),
            'expected': 0.0
        },
    ]

    for idx, test in enumerate(test_cases, start=1):
        try:
            output = solution(
                red=test['red'],
                angle=test['angle'],
                green=test['green']
            )
        except Exception as e:
            error_message = (
                f"An exception occurred while running the test case:\n"
                f"`red`: {test['red']}\n"
                f"`angle`: {test['angle']}\n" 
                f"`green`: {test['green']}\n\n"
                f"Exception: '{str(e)}'"
            )
            assert False, error_message
            
        if not tuples_almost_equal(output, test['expected']):
            error_message = (
                f"The following Test Case failed:\n"
                f"`red`: {test['red']}\n"
                f"`angle`: {test['angle']}\n"
                f"`green`: {test['green']}\n\n"
                f"Actual Output: {output}\n"
                f"Expected Output: {test['expected']}"
            )
            assert False, error_message

test()