This commit is contained in:
blueloveTH 2025-02-21 14:54:18 +08:00
parent dc8df160d6
commit 034897f92d
2 changed files with 13 additions and 8 deletions

View File

@ -25,7 +25,7 @@ class array2d_like[T]:
def get[R](self, col: int, row: int, default: R = None) -> T | R: def get[R](self, col: int, row: int, default: R = None) -> T | R:
"""Get the value at the given position. """Get the value at the given position.
If the position is out of bounds, return the default value. If the position is out of bounds, returns the default value.
""" """
def render(self) -> str: ... def render(self) -> str: ...
@ -100,7 +100,7 @@ class array2d_like[T]:
"""Convolve the array with the given kernel.""" """Convolve the array with the given kernel."""
def get_connected_components(self, value: T, neighborhood: Neighborhood) -> tuple[array2d[int], int]: def get_connected_components(self, value: T, neighborhood: Neighborhood) -> tuple[array2d[int], int]:
"""Get connected components of the grid. """Get connected components of the grid via BFS algorithm.
Returns the `visited` array and the number of connected components, Returns the `visited` array and the number of connected components,
where `0` means unvisited, and non-zero means the index of the connected component. where `0` means unvisited, and non-zero means the index of the connected component.
@ -144,7 +144,7 @@ class chunked_array2d[T, TContext]:
def clear(self) -> None: ... def clear(self) -> None: ...
def world_to_chunk(self, world_pos: vec2i) -> tuple[vec2i, vec2i]: def world_to_chunk(self, world_pos: vec2i) -> tuple[vec2i, vec2i]:
"""Convert world position to chunk position and local position.""" """Converts world position to chunk position and local position."""
def add_chunk(self, chunk_pos: vec2i) -> TContext: ... def add_chunk(self, chunk_pos: vec2i) -> TContext: ...
def remove_chunk(self, chunk_pos: vec2i) -> bool: ... def remove_chunk(self, chunk_pos: vec2i) -> bool: ...

View File

@ -60,21 +60,26 @@ class vec2(_vecF['vec2']):
@overload @overload
def __init__(self, xy: vec2i) -> None: ... def __init__(self, xy: vec2i) -> None: ...
def rotate(self, radians: float) -> vec2: ... def rotate(self, radians: float) -> vec2:
"""Rotate the vector by `radians`.
+ If y axis is top to bottom, positive value means clockwise (default)
+ If y axis is bottom to top, positive value means counter-clockwise
"""
@staticmethod @staticmethod
def angle(__from: vec2, __to: vec2) -> float: def angle(__from: vec2, __to: vec2) -> float:
"""Returns the angle in radians between vectors `from` and `to`. """Return the angle in radians between vectors `from` and `to`.
The result range is `[-pi, pi]`. The result range is `[-pi, pi]`.
+ if y axis is top to bottom, positive value means clockwise + If y axis is top to bottom, positive value means clockwise (default)
+ if y axis is bottom to top, positive value means counter-clockwise + If y axis is bottom to top, positive value means counter-clockwise
""" """
@staticmethod @staticmethod
def smooth_damp(current: vec2, target: vec2, current_velocity: vec2, smooth_time: float, max_speed: float, delta_time: float) -> tuple[vec2, vec2]: def smooth_damp(current: vec2, target: vec2, current_velocity: vec2, smooth_time: float, max_speed: float, delta_time: float) -> tuple[vec2, vec2]:
"""Smoothly changes a vector towards a desired goal over time. """Smoothly change a vector towards a desired goal over time.
Returns a new value that is closer to the target and current velocity. Returns a new value that is closer to the target and current velocity.
""" """