/**
 * 位置坐标接口
 */
export interface Position {
    x: number;
    y: number;
}

/**
 * 创建位置对象
 */
export function createPosition(x: number, y: number): Position {
    return { x, y };
}

/**
 * 计算两点之间的距离
 */
export function getDistance(pos1: Position, pos2: Position): number {
    const dx = pos1.x - pos2.x;
    const dy = pos1.y - pos2.y;
    return Math.sqrt(dx * dx + dy * dy);
}

/**
 * 检查位置是否在范围内
 */
export function isInBounds(pos: Position, width: number, height: number): boolean {
    return pos.x >= 0 && pos.x < width && pos.y >= 0 && pos.y < height;
}

/**
 * 检查位置是否在圆形区域内
 */
export function isInCircle(pos: Position, center: Position, radius: number): boolean {
    return getDistance(pos, center) <= radius;
}
