linalg.pyi 4.4 KB

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