linalg.pyi 4.5 KB

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