linalg.pyi 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 rotate_(self, radians: float) -> None: ...
  19. @staticmethod
  20. def angle(__from: vec2, __to: vec2) -> float:
  21. """Returns the angle in radians between vectors `from` and `to`.
  22. The result range is `[-pi, pi]`.
  23. + if y axis is top to bottom, positive value means clockwise
  24. + if y axis is bottom to top, positive value means counter-clockwise
  25. """
  26. class vec3(_StructLike['vec3']):
  27. x: float
  28. y: float
  29. z: float
  30. def __init__(self, x: float, y: float, z: float) -> None: ...
  31. def __add__(self, other: vec3) -> vec3: ...
  32. def __sub__(self, other: vec3) -> vec3: ...
  33. def __mul__(self, other: float) -> vec3: ...
  34. def __rmul__(self, other: float) -> vec3: ...
  35. def __truediv__(self, other: float) -> vec3: ...
  36. def dot(self, other: vec3) -> float: ...
  37. def cross(self, other: vec3) -> float: ...
  38. def length(self) -> float: ...
  39. def length_squared(self) -> float: ...
  40. def normalize(self) -> vec3: ...
  41. class vec4(_StructLike['vec4']):
  42. x: float
  43. y: float
  44. z: float
  45. w: float
  46. def __init__(self, x: float, y: float, z: float, w: float) -> None: ...
  47. def __add__(self, other: vec4) -> vec4: ...
  48. def __sub__(self, other: vec4) -> vec4: ...
  49. def __mul__(self, other: float) -> vec4: ...
  50. def __rmul__(self, other: float) -> vec4: ...
  51. def __truediv__(self, other: float) -> vec4: ...
  52. def dot(self, other: vec4) -> float: ...
  53. def length(self) -> float: ...
  54. def length_squared(self) -> float: ...
  55. def normalize(self) -> vec4: ...
  56. class mat3x3(_StructLike['mat3x3']):
  57. _11: float
  58. _12: float
  59. _13: float
  60. _21: float
  61. _22: float
  62. _23: float
  63. _31: float
  64. _32: float
  65. _33: float
  66. @overload
  67. def __init__(self) -> None: ...
  68. @overload
  69. def __init__(self, _11, _12, _13, _21, _22, _23, _31, _32, _33) -> None: ...
  70. @overload
  71. def __init__(self, a: list[list]): ...
  72. def set_zeros(self) -> None: ...
  73. def set_ones(self) -> None: ...
  74. def set_identity(self) -> None: ...
  75. def determinant(self) -> float: ...
  76. def transpose(self) -> mat3x3: ...
  77. def __getitem__(self, index: tuple[int, int]) -> float: ...
  78. def __setitem__(self, index: tuple[int, int], value: float) -> None: ...
  79. def __add__(self, other: mat3x3) -> mat3x3: ...
  80. def __sub__(self, other: mat3x3) -> mat3x3: ...
  81. def __mul__(self, other: float) -> mat3x3: ...
  82. def __rmul__(self, other: float) -> mat3x3: ...
  83. def __truediv__(self, other: float) -> mat3x3: ...
  84. def __invert__(self) -> mat3x3: ...
  85. @overload
  86. def __matmul__(self, other: mat3x3) -> mat3x3: ...
  87. @overload
  88. def __matmul__(self, other: vec3) -> vec3: ...
  89. @staticmethod
  90. def zeros() -> mat3x3: ...
  91. @staticmethod
  92. def ones() -> mat3x3: ...
  93. @staticmethod
  94. def identity() -> mat3x3: ...
  95. # affine transformations
  96. @staticmethod
  97. def trs(t: vec2, r: float, s: vec2) -> mat3x3: ...
  98. def is_affine(self) -> bool: ...
  99. def _t(self) -> vec2: ...
  100. def _r(self) -> float: ...
  101. def _s(self) -> vec2: ...
  102. def transform_point(self, p: vec2) -> vec2: ...
  103. def transform_vector(self, v: vec2) -> vec2: ...
  104. vec2_p = float_p
  105. vec3_p = float_p
  106. vec4_p = float_p
  107. mat3x3_p = float_p