Compare commits

..

No commits in common. "034897f92ddeb08dd17f411727d3c77bee331f23" and "2f2602f3ff34c07ae9b40482204dd9194d1f4446" have entirely different histories.

4 changed files with 8 additions and 29 deletions

View File

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

View File

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

View File

@ -298,16 +298,6 @@ DEF_VECTOR_OPS(3)
sum += a.data[i] * b.data[i]; \
py_newint(py_retval(), sum); \
return true; \
} \
static bool vec##D##i##__floordiv__(int argc, py_Ref argv) { \
PY_CHECK_ARGC(2); \
PY_CHECK_ARG_TYPE(1, tp_int); \
c11_vec##D##i a = py_tovec##D##i(&argv[0]); \
py_i64 b = py_toint(&argv[1]); \
for(int i = 0; i < D; i++) \
a.data[i] /= b; \
py_newvec##D##i(py_retval(), a); \
return true; \
}
DEF_VECTOR_INT_OPS(2)
@ -921,7 +911,6 @@ void pk__add_module_linalg() {
py_bindmagic(vec2i, __add__, vec2i__add__);
py_bindmagic(vec2i, __sub__, vec2i__sub__);
py_bindmagic(vec2i, __mul__, vec2i__mul__);
py_bindmagic(vec2i, __floordiv__, vec2i__floordiv__);
py_bindmagic(vec2i, __eq__, vec2i__eq__);
py_bindmagic(vec2i, __ne__, vec2i__ne__);
py_bindmagic(vec2i, __hash__, vec2i__hash__);
@ -946,7 +935,6 @@ void pk__add_module_linalg() {
py_bindmagic(vec3i, __add__, vec3i__add__);
py_bindmagic(vec3i, __sub__, vec3i__sub__);
py_bindmagic(vec3i, __mul__, vec3i__mul__);
py_bindmagic(vec3i, __floordiv__, vec3i__floordiv__);
py_bindmagic(vec3i, __eq__, vec3i__eq__);
py_bindmagic(vec3i, __ne__, vec3i__ne__);
py_bindmagic(vec3i, __hash__, vec3i__hash__);

View File

@ -388,9 +388,6 @@ assert vec3i(1, 2, 3) * vec3i(4, 5, 6) == vec3i(4, 10, 18)
assert vec3i(1, 2, 3) * 2 == vec3i(2, 4, 6)
assert vec3i(1, 2, 3).dot(vec3i(4, 5, 6)) == 32
assert vec2i(3, 5) // 2 == vec2i(1, 2)
assert vec3i(3, 5, 8) // 2 == vec3i(1, 2, 4)
a = {}
a[vec2i(1, 2)] = 1
assert a[vec2i(1, 2)] == 1