1
0

linalg.pyi 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. from typing import overload, Iterator
  2. class _vecF[T]:
  3. ONE: T
  4. ZERO: T
  5. def __add__(self, other: T) -> T: ...
  6. def __sub__(self, other: T) -> T: ...
  7. @overload
  8. def __mul__(self, other: float) -> T: ...
  9. @overload
  10. def __mul__(self, other: T) -> T: ...
  11. def __truediv__(self, other: float) -> T: ...
  12. def dot(self, other: T) -> float: ...
  13. def length(self) -> float: ...
  14. def length_squared(self) -> float: ...
  15. def normalize(self) -> T: ...
  16. # dummy iter for unpacking
  17. def __iter__(self) -> Iterator[float]: ...
  18. class _vecI[T]:
  19. ONE: T
  20. ZERO: T
  21. def __add__(self, other: T) -> T: ...
  22. def __sub__(self, other: T) -> T: ...
  23. @overload
  24. def __mul__(self, other: int) -> T: ...
  25. @overload
  26. def __mul__(self, other: T) -> T: ...
  27. def __floordiv__(self, other: int) -> T: ...
  28. def __hash__(self) -> int: ...
  29. def dot(self, other: T) -> int: ...
  30. # dummy iter for unpacking
  31. def __iter__(self) -> Iterator[int]: ...
  32. class vec2(_vecF['vec2']):
  33. LEFT: vec2
  34. RIGHT: vec2
  35. UP: vec2
  36. DOWN: vec2
  37. @property
  38. def x(self) -> float: ...
  39. @property
  40. def y(self) -> float: ...
  41. def with_x(self, x: float) -> vec2: ...
  42. def with_y(self, y: float) -> vec2: ...
  43. def with_z(self, z: float) -> vec3: ...
  44. @overload
  45. def __init__(self, x: float, y: float) -> None: ...
  46. @overload
  47. def __init__(self, xy: vec2i) -> None: ...
  48. def rotate(self, radians: float) -> vec2:
  49. """Rotate the vector by `radians`.
  50. + If y axis is top to bottom, positive value means clockwise (default)
  51. + If y axis is bottom to top, positive value means counter-clockwise
  52. """
  53. @staticmethod
  54. def angle(__from: vec2, __to: vec2) -> float:
  55. """Return the angle in radians between vectors `from` and `to`.
  56. The result range is `[-pi, pi]`.
  57. + If y axis is top to bottom, positive value means clockwise (default)
  58. + If y axis is bottom to top, positive value means counter-clockwise
  59. """
  60. @staticmethod
  61. def smooth_damp(current: vec2, target: vec2, current_velocity: vec2, smooth_time: float, max_speed: float, delta_time: float) -> tuple[vec2, vec2]:
  62. """Smoothly change a vector towards a desired goal over time.
  63. Returns a new value that is closer to the target and current velocity.
  64. """
  65. class mat3x3:
  66. def __init__(self, _11, _12, _13, _21, _22, _23, _31, _32, _33) -> None: ...
  67. def __getitem__(self, index: tuple[int, int]) -> float: ...
  68. def __setitem__(self, index: tuple[int, int], value: float) -> None: ...
  69. @overload
  70. def __matmul__(self, other: mat3x3) -> mat3x3: ...
  71. @overload
  72. def __matmul__(self, other: vec3) -> vec3: ...
  73. def __invert__(self) -> mat3x3: ...
  74. def matmul(self, other: mat3x3, out: mat3x3) -> mat3x3 | None: ...
  75. def determinant(self) -> float: ...
  76. def copy(self) -> mat3x3: ...
  77. def inverse(self) -> mat3x3: ...
  78. def copy_(self, other: mat3x3) -> None: ...
  79. def inverse_(self) -> None: ...
  80. @staticmethod
  81. def zeros() -> mat3x3: ...
  82. @staticmethod
  83. def identity() -> mat3x3: ...
  84. # affine transformations
  85. @staticmethod
  86. def trs(t: vec2, r: float, s: vec2) -> mat3x3: ...
  87. def copy_trs_(self, t: vec2, r: float, s: vec2) -> None: ...
  88. def t(self) -> vec2: ...
  89. def r(self) -> float: ...
  90. def s(self) -> vec2: ...
  91. def transform_point(self, p: vec2) -> vec2: ...
  92. def transform_vector(self, v: vec2) -> vec2: ...
  93. class vec2i(_vecI['vec2i']):
  94. LEFT: vec2i
  95. RIGHT: vec2i
  96. UP: vec2i
  97. DOWN: vec2i
  98. @property
  99. def x(self) -> int: ...
  100. @property
  101. def y(self) -> int: ...
  102. def with_x(self, x: int) -> vec2i: ...
  103. def with_y(self, y: int) -> vec2i: ...
  104. def __init__(self, x: int, y: int) -> None: ...
  105. class vec3i(_vecI['vec3i']):
  106. @property
  107. def x(self) -> int: ...
  108. @property
  109. def y(self) -> int: ...
  110. @property
  111. def z(self) -> int: ...
  112. def with_x(self, x: int) -> vec3i: ...
  113. def with_y(self, y: int) -> vec3i: ...
  114. def with_z(self, z: int) -> vec3i: ...
  115. def __init__(self, x: int, y: int, z: int) -> None: ...
  116. class vec3(_vecF['vec3']):
  117. @property
  118. def x(self) -> float: ...
  119. @property
  120. def y(self) -> float: ...
  121. @property
  122. def z(self) -> float: ...
  123. @property
  124. def xy(self) -> vec2: ...
  125. def with_x(self, x: float) -> vec3: ...
  126. def with_y(self, y: float) -> vec3: ...
  127. def with_z(self, z: float) -> vec3: ...
  128. def with_xy(self, xy: vec2) -> vec3: ...
  129. @overload
  130. def __init__(self, x: float, y: float, z: float) -> None: ...
  131. @overload
  132. def __init__(self, xyz: vec3i) -> None: ...