linalg.pyi 3.6 KB

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