linalg.pyi 3.9 KB

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