linalg.pyi 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. from typing import overload
  2. from c import _StructLike, float_p
  3. class vec2:
  4. x: float
  5. y: float
  6. ZERO: 'vec2' = ...
  7. ONE: 'vec2' = ...
  8. def __init__(self, x: float, y: float) -> None: ...
  9. def __add__(self, other: vec2) -> vec2: ...
  10. def __sub__(self, other: vec2) -> vec2: ...
  11. def __getitem__(self, index: int) -> float: ...
  12. @overload
  13. def __mul__(self, other: float) -> vec2: ...
  14. @overload
  15. def __mul__(self, other: vec2) -> vec2: ...
  16. def __rmul__(self, other: float) -> vec2: ...
  17. def __truediv__(self, other: float) -> vec2: ...
  18. def dot(self, other: vec2) -> float: ...
  19. def cross(self, other: vec2) -> float: ...
  20. def length(self) -> float: ...
  21. def length_squared(self) -> float: ...
  22. def normalize(self) -> vec2: ...
  23. def rotate(self, radians: float) -> vec2: ...
  24. @staticmethod
  25. def angle(__from: vec2, __to: vec2) -> float:
  26. """Returns the angle in radians between vectors `from` and `to`.
  27. The result range is `[-pi, pi]`.
  28. + if y axis is top to bottom, positive value means clockwise
  29. + if y axis is bottom to top, positive value means counter-clockwise
  30. """
  31. @staticmethod
  32. def smooth_damp(current: vec2, target: vec2, current_velocity: vec2, smooth_time: float, max_speed: float, delta_time: float) -> tuple[vec2, vec2]:
  33. """Smoothly changes a vector towards a desired goal over time.
  34. Returns a new value that is closer to the target and current velocity.
  35. """
  36. class vec3:
  37. x: float
  38. y: float
  39. z: float
  40. ZERO: 'vec3' = ...
  41. ONE: 'vec3' = ...
  42. def __init__(self, x: float, y: float, z: float) -> None: ...
  43. def __add__(self, other: vec3) -> vec3: ...
  44. def __sub__(self, other: vec3) -> vec3: ...
  45. def __getitem__(self, index: int) -> float: ...
  46. @overload
  47. def __mul__(self, other: float) -> vec3: ...
  48. @overload
  49. def __mul__(self, other: vec3) -> vec3: ...
  50. def __rmul__(self, other: float) -> vec3: ...
  51. def __truediv__(self, other: float) -> vec3: ...
  52. def dot(self, other: vec3) -> float: ...
  53. def cross(self, other: vec3) -> float: ...
  54. def length(self) -> float: ...
  55. def length_squared(self) -> float: ...
  56. def normalize(self) -> vec3: ...
  57. class vec4(_StructLike['vec4']):
  58. x: float
  59. y: float
  60. z: float
  61. w: float
  62. ZERO: 'vec4' = ...
  63. ONE: 'vec4' = ...
  64. def __init__(self, x: float, y: float, z: float, w: float) -> None: ...
  65. def __add__(self, other: vec4) -> vec4: ...
  66. def __sub__(self, other: vec4) -> vec4: ...
  67. def __getitem__(self, index: int) -> float: ...
  68. @overload
  69. def __mul__(self, other: float) -> vec4: ...
  70. @overload
  71. def __mul__(self, other: vec4) -> vec4: ...
  72. def __rmul__(self, other: float) -> vec4: ...
  73. def __truediv__(self, other: float) -> vec4: ...
  74. def dot(self, other: vec4) -> float: ...
  75. def length(self) -> float: ...
  76. def length_squared(self) -> float: ...
  77. def normalize(self) -> vec4: ...
  78. def copy_(self, other: vec4) -> None: ...
  79. def normalize_(self) -> None: ...
  80. class mat3x3(_StructLike['mat3x3']):
  81. _11: float
  82. _12: float
  83. _13: float
  84. _21: float
  85. _22: float
  86. _23: float
  87. _31: float
  88. _32: float
  89. _33: float
  90. @overload
  91. def __init__(self) -> None: ...
  92. @overload
  93. def __init__(self, _11, _12, _13, _21, _22, _23, _31, _32, _33) -> None: ...
  94. @overload
  95. def __init__(self, a: list[float]): ...
  96. def determinant(self) -> float: ...
  97. def inverse(self) -> mat3x3: ...
  98. def transpose(self) -> mat3x3: ...
  99. def __getitem__(self, index: tuple[int, int]) -> float: ...
  100. def __setitem__(self, index: tuple[int, int], value: float) -> None: ...
  101. def __add__(self, other: mat3x3) -> mat3x3: ...
  102. def __sub__(self, other: mat3x3) -> mat3x3: ...
  103. def __mul__(self, other: float) -> mat3x3: ...
  104. def __rmul__(self, other: float) -> mat3x3: ...
  105. def __truediv__(self, other: float) -> mat3x3: ...
  106. def __invert__(self) -> mat3x3: ...
  107. @overload
  108. def __matmul__(self, other: mat3x3) -> mat3x3: ...
  109. @overload
  110. def __matmul__(self, other: vec3) -> vec3: ...
  111. def matmul(self, other: mat3x3, out: mat3x3 = None) -> mat3x3 | None: ...
  112. def copy_(self, other: mat3x3) -> None: ...
  113. def inverse_(self) -> None: ...
  114. def transpose_(self) -> None: ...
  115. @staticmethod
  116. def zeros() -> mat3x3: ...
  117. @staticmethod
  118. def ones() -> mat3x3: ...
  119. @staticmethod
  120. def identity() -> mat3x3: ...
  121. # affine transformations
  122. @staticmethod
  123. def trs(t: vec2, r: float, s: vec2) -> mat3x3: ...
  124. def copy_trs_(self, t: vec2, r: float, s: vec2) -> None: ...
  125. def copy_t_(self, t: vec2) -> None: ...
  126. def copy_r_(self, r: float) -> None: ...
  127. def copy_s_(self, s: vec2) -> None: ...
  128. def _t(self) -> vec2: ...
  129. def _r(self) -> float: ...
  130. def _s(self) -> vec2: ...
  131. def is_affine(self) -> bool: ...
  132. def transform_point(self, p: vec2) -> vec2: ...
  133. def transform_vector(self, v: vec2) -> vec2: ...
  134. def inverse_transform_point(self, p: vec2) -> vec2: ...
  135. def inverse_transform_vector(self, v: vec2) -> vec2: ...
  136. vec4_p = float_p
  137. mat3x3_p = float_p