"""
Line collision detection extension for Animation library.

This module provides a thick line segment class `Line` with comprehensive 
collision detection capabilities, designed for interactive animations and 
game development.

Features:
    - Collision detection with points (with tolerance)
    - Thick line-to-line collision detection
    - Rectangle and circle collision detection
    - Bounding box calculation
    - Pygame drawing support (optional)

Note:
    This is an extension module and not required for core animation functionality.
    Use it when you need interactive elements or game physics in your animations.

Example:
    from Animation.method import Line
    wall = Line(0, 0, 100, 100, thickness=10)
    if wall.collisions_with_point(mouse_x, mouse_y):
        print("Hit!")

        

动画库线段碰撞检测扩展程序

该模块提供具备完备碰撞检测功能的粗线段类`Line`，适用于交互式动画与游戏开发场景。

功能特性：
    - 带容错值的点碰撞检测
    - 粗线段之间的碰撞检测
    - 矩形与圆形碰撞检测
    - 边界包围盒计算
    - 可选支持Pygame绘图功能

备注：
本模块属于扩展组件，动画核心运行无需依赖该模块。
仅在动画中需要交互元素或游戏物理效果时调用即可。

示例：
    from Animation.method import Line
    wall = Line(0, 0, 100, 100, thickness=10)
    if wall.collisions_with_point(mouse_x, mouse_y):
        print("Hit!") 

"""

import math

class Line:
    """
    Thick line segment type, supporting various collision detection


    带厚度的线段类，支持各种碰撞检测
    """

    def __init__(self, x1, y1, x2, y2, thickness=5):
        """
        Initialize line segment

        Parameters:
            x1, y1: Starting point of the line segment
            x2, y2: End point of the line segment
            thickness: Line thickness (pixels)


        初始化线段
        
        参数:
            x1, y1: 线段起点
            x2, y2: 线段终点
            thickness: 线条厚度（像素）
        """
        ...

    def update(self, x1=None, y1=None, x2=None, y2=None):
        """
        Update line position


        更新线段位置
        """
        ...

    def set_thickness(self, thickness):
        """
        Set line thickness
        

        设置线条厚度
        """
        ...

    def get_start_point(self):
        """
        Get start point
        

        获取起点
        """
        ...

    def get_end_point(self):
        """
        Get end point


        获取终点
        """
        ...

    def get_center_point(self):
        """
        get line center point


        获取线段中点
        """
        ...

    def get_length(self):
        """
        Get line length


        获取线段长度
        """
        ...

    def get_direction(self):
        """
        Get unit direction vector


        获取单位方向向量
        """
        ...

    def get_normal(self):
        """
        Get normal vector (perpendicular to line segment)


        获取法向量（垂直于线段）
        """
        ...

    def collisions_with_point(self, px, py, extra_tolerance=0):
        """
        Detect whether a point collides with a line segment

        Parameters:
            px, py: Coordinates of the point
            extra_tolerance: Additional tolerance (pixel)

        Return:
            bool: Collision status


        检测点是否与线段碰撞
        
        参数:
            px, py: 点的坐标
            extra_tolerance: 额外容差（像素）
        
        返回:
            bool: 是否碰撞
        """
        ...

    def collisions_with_line(self, other_line):
        """
        Detect collision between two line segments (considering thickness)

        Parameters:
            other_line: Another Line object

        Return:
            bool: Whether collision occurs

        
        检测两条线段是否碰撞（考虑厚度）
        
        参数:
            other_line: 另一个Line对象
        
        返回:
            bool: 是否碰撞
        """
        ...

    def collisions_with_rect(self, rect_x, rect_y, rect_w, rect_h):
        """
        Detect whether a line segment collides with a rectangle (considering thickness)

        Parameters:
            rect_x, rect_y: Coordinates of the top-left corner of the rectangle
            rect_w, rect_h: Width and height of the rectangle

        Return:
            bool: Collision status


        检测线段是否与矩形碰撞（考虑厚度）
        
        参数:
            rect_x, rect_y: 矩形左上角坐标
            rect_w, rect_h: 矩形宽度和高度
        
        返回:
            bool: 是否碰撞
        """
        ...

    def collisions_with_circle(self, circle_x, circle_y, radius):
        """
        Detect collision between line segment and circle (considering thickness)

        Parameters:
            circle_x, circle_y: Coordinates of circle center
            radius: Radius of the circle

        Return:
            bool: Whether collision occurs


        检测线段是否与圆碰撞（考虑厚度）
        
        参数:
            circle_x, circle_y: 圆心坐标
            radius: 圆半径
        
        返回:
            bool: 是否碰撞
        """
        ...

    def get_bounding_rect(self):
        """
        Obtain the bounding rectangle of the line segment (considering thickness)

        Return:
            (x, y, width, height): bounding rectangle


        获取线段的包围矩形（考虑厚度）
        
        返回:
            (x, y, width, height): 包围矩形
        """
        ...

    def draw(self, screen, color, width=None):
        """
        Draw line on the pygame screen

        Parameters:
            screen: pygame.Surface object
            color: color (RGB tuple)
            width: line width (self.thickness will be used if not specified)


        在pygame屏幕上绘制线段
        
        参数:
            screen: pygame.Surface对象
            color: 颜色（RGB元组）
            width: 线条宽度（如果不指定则使用self.thickness）
        """
        ...

    def draw_control_points(self, screen, color, radius=8):
        """
        Draw control points (two endpoints)

        
        绘制控制点（两端点）
        """
        ...