linalg.pyi 4.2 KB

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