linalg.pyi 4.1 KB

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