amulet-core 2.0a3__cp312-cp312-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of amulet-core might be problematic. Click here for more details.

Files changed (210) hide show
  1. amulet/__init__.cp312-win_amd64.pyd +0 -0
  2. amulet/__init__.pyi +30 -0
  3. amulet/__pyinstaller/__init__.py +2 -0
  4. amulet/__pyinstaller/hook-amulet.py +4 -0
  5. amulet/_init.py +28 -0
  6. amulet/_version.py +21 -0
  7. amulet/biome.cpp +36 -0
  8. amulet/biome.hpp +43 -0
  9. amulet/biome.pyi +77 -0
  10. amulet/block.cpp +435 -0
  11. amulet/block.hpp +119 -0
  12. amulet/block.pyi +273 -0
  13. amulet/block_entity.cpp +12 -0
  14. amulet/block_entity.hpp +56 -0
  15. amulet/block_entity.pyi +80 -0
  16. amulet/chunk.cpp +16 -0
  17. amulet/chunk.hpp +99 -0
  18. amulet/chunk.pyi +30 -0
  19. amulet/chunk_/components/biome.py +155 -0
  20. amulet/chunk_/components/block_entity.py +117 -0
  21. amulet/chunk_/components/entity.py +64 -0
  22. amulet/chunk_/components/height_2d.py +16 -0
  23. amulet/chunk_components.pyi +95 -0
  24. amulet/collections.pyi +37 -0
  25. amulet/data_types.py +29 -0
  26. amulet/entity.py +180 -0
  27. amulet/errors.py +63 -0
  28. amulet/game/__init__.py +7 -0
  29. amulet/game/_game.py +152 -0
  30. amulet/game/_universal/__init__.py +1 -0
  31. amulet/game/_universal/_biome.py +17 -0
  32. amulet/game/_universal/_block.py +47 -0
  33. amulet/game/_universal/_version.py +68 -0
  34. amulet/game/abc/__init__.py +22 -0
  35. amulet/game/abc/_block_specification.py +150 -0
  36. amulet/game/abc/biome.py +213 -0
  37. amulet/game/abc/block.py +331 -0
  38. amulet/game/abc/game_version_container.py +25 -0
  39. amulet/game/abc/json_interface.py +27 -0
  40. amulet/game/abc/version.py +44 -0
  41. amulet/game/bedrock/__init__.py +1 -0
  42. amulet/game/bedrock/_biome.py +35 -0
  43. amulet/game/bedrock/_block.py +42 -0
  44. amulet/game/bedrock/_version.py +165 -0
  45. amulet/game/java/__init__.py +2 -0
  46. amulet/game/java/_biome.py +35 -0
  47. amulet/game/java/_block.py +60 -0
  48. amulet/game/java/_version.py +176 -0
  49. amulet/game/translate/__init__.py +12 -0
  50. amulet/game/translate/_functions/__init__.py +15 -0
  51. amulet/game/translate/_functions/_code_functions/__init__.py +0 -0
  52. amulet/game/translate/_functions/_code_functions/_text.py +553 -0
  53. amulet/game/translate/_functions/_code_functions/banner_pattern.py +67 -0
  54. amulet/game/translate/_functions/_code_functions/bedrock_chest_connection.py +152 -0
  55. amulet/game/translate/_functions/_code_functions/bedrock_moving_block_pos.py +88 -0
  56. amulet/game/translate/_functions/_code_functions/bedrock_sign.py +152 -0
  57. amulet/game/translate/_functions/_code_functions/bedrock_skull_rotation.py +16 -0
  58. amulet/game/translate/_functions/_code_functions/custom_name.py +146 -0
  59. amulet/game/translate/_functions/_frozen.py +66 -0
  60. amulet/game/translate/_functions/_state.py +54 -0
  61. amulet/game/translate/_functions/_typing.py +98 -0
  62. amulet/game/translate/_functions/abc.py +116 -0
  63. amulet/game/translate/_functions/carry_nbt.py +160 -0
  64. amulet/game/translate/_functions/carry_properties.py +80 -0
  65. amulet/game/translate/_functions/code.py +143 -0
  66. amulet/game/translate/_functions/map_block_name.py +66 -0
  67. amulet/game/translate/_functions/map_nbt.py +111 -0
  68. amulet/game/translate/_functions/map_properties.py +93 -0
  69. amulet/game/translate/_functions/multiblock.py +112 -0
  70. amulet/game/translate/_functions/new_block.py +42 -0
  71. amulet/game/translate/_functions/new_entity.py +43 -0
  72. amulet/game/translate/_functions/new_nbt.py +206 -0
  73. amulet/game/translate/_functions/new_properties.py +64 -0
  74. amulet/game/translate/_functions/sequence.py +51 -0
  75. amulet/game/translate/_functions/walk_input_nbt.py +331 -0
  76. amulet/game/translate/_translator.py +433 -0
  77. amulet/item.py +75 -0
  78. amulet/level/__init__.pyi +27 -0
  79. amulet/level/_load.py +100 -0
  80. amulet/level/abc/__init__.py +12 -0
  81. amulet/level/abc/_chunk_handle.py +335 -0
  82. amulet/level/abc/_dimension.py +86 -0
  83. amulet/level/abc/_history/__init__.py +1 -0
  84. amulet/level/abc/_history/_cache.py +224 -0
  85. amulet/level/abc/_history/_history_manager.py +291 -0
  86. amulet/level/abc/_level/__init__.py +5 -0
  87. amulet/level/abc/_level/_compactable_level.py +10 -0
  88. amulet/level/abc/_level/_creatable_level.py +29 -0
  89. amulet/level/abc/_level/_disk_level.py +17 -0
  90. amulet/level/abc/_level/_level.py +453 -0
  91. amulet/level/abc/_level/_loadable_level.py +42 -0
  92. amulet/level/abc/_player_storage.py +7 -0
  93. amulet/level/abc/_raw_level.py +187 -0
  94. amulet/level/abc/_registry.py +40 -0
  95. amulet/level/bedrock/__init__.py +2 -0
  96. amulet/level/bedrock/_chunk_handle.py +19 -0
  97. amulet/level/bedrock/_dimension.py +22 -0
  98. amulet/level/bedrock/_level.py +187 -0
  99. amulet/level/bedrock/_raw/__init__.py +5 -0
  100. amulet/level/bedrock/_raw/_actor_counter.py +53 -0
  101. amulet/level/bedrock/_raw/_chunk.py +54 -0
  102. amulet/level/bedrock/_raw/_chunk_decode.py +668 -0
  103. amulet/level/bedrock/_raw/_chunk_encode.py +602 -0
  104. amulet/level/bedrock/_raw/_constant.py +9 -0
  105. amulet/level/bedrock/_raw/_dimension.py +343 -0
  106. amulet/level/bedrock/_raw/_level.py +463 -0
  107. amulet/level/bedrock/_raw/_level_dat.py +90 -0
  108. amulet/level/bedrock/_raw/_typing.py +6 -0
  109. amulet/level/bedrock/_raw/leveldb_chunk_versions.py +83 -0
  110. amulet/level/bedrock/chunk/__init__.py +1 -0
  111. amulet/level/bedrock/chunk/_chunk.py +126 -0
  112. amulet/level/bedrock/chunk/components/__init__.py +0 -0
  113. amulet/level/bedrock/chunk/components/chunk_version.py +12 -0
  114. amulet/level/bedrock/chunk/components/finalised_state.py +13 -0
  115. amulet/level/bedrock/chunk/components/raw_chunk.py +15 -0
  116. amulet/level/construction/__init__.py +0 -0
  117. amulet/level/java/__init__.pyi +21 -0
  118. amulet/level/java/_chunk_handle.py +17 -0
  119. amulet/level/java/_chunk_handle.pyi +15 -0
  120. amulet/level/java/_dimension.py +20 -0
  121. amulet/level/java/_dimension.pyi +13 -0
  122. amulet/level/java/_level.py +184 -0
  123. amulet/level/java/_level.pyi +120 -0
  124. amulet/level/java/_raw/__init__.pyi +19 -0
  125. amulet/level/java/_raw/_chunk.pyi +23 -0
  126. amulet/level/java/_raw/_chunk_decode.py +561 -0
  127. amulet/level/java/_raw/_chunk_encode.py +463 -0
  128. amulet/level/java/_raw/_constant.py +9 -0
  129. amulet/level/java/_raw/_constant.pyi +20 -0
  130. amulet/level/java/_raw/_data_pack/__init__.py +2 -0
  131. amulet/level/java/_raw/_data_pack/__init__.pyi +8 -0
  132. amulet/level/java/_raw/_data_pack/data_pack.py +241 -0
  133. amulet/level/java/_raw/_data_pack/data_pack.pyi +197 -0
  134. amulet/level/java/_raw/_data_pack/data_pack_manager.py +77 -0
  135. amulet/level/java/_raw/_data_pack/data_pack_manager.pyi +75 -0
  136. amulet/level/java/_raw/_dimension.py +86 -0
  137. amulet/level/java/_raw/_dimension.pyi +72 -0
  138. amulet/level/java/_raw/_level.py +507 -0
  139. amulet/level/java/_raw/_level.pyi +238 -0
  140. amulet/level/java/_raw/_typing.py +3 -0
  141. amulet/level/java/_raw/_typing.pyi +5 -0
  142. amulet/level/java/anvil/__init__.py +2 -0
  143. amulet/level/java/anvil/__init__.pyi +11 -0
  144. amulet/level/java/anvil/_dimension.py +170 -0
  145. amulet/level/java/anvil/_dimension.pyi +109 -0
  146. amulet/level/java/anvil/_region.py +421 -0
  147. amulet/level/java/anvil/_region.pyi +197 -0
  148. amulet/level/java/anvil/_sector_manager.py +223 -0
  149. amulet/level/java/anvil/_sector_manager.pyi +142 -0
  150. amulet/level/java/chunk.pyi +81 -0
  151. amulet/level/java/chunk_/_chunk.py +260 -0
  152. amulet/level/java/chunk_/components/inhabited_time.py +12 -0
  153. amulet/level/java/chunk_/components/last_update.py +12 -0
  154. amulet/level/java/chunk_/components/legacy_version.py +12 -0
  155. amulet/level/java/chunk_/components/light_populated.py +12 -0
  156. amulet/level/java/chunk_/components/named_height_2d.py +37 -0
  157. amulet/level/java/chunk_/components/status.py +11 -0
  158. amulet/level/java/chunk_/components/terrain_populated.py +12 -0
  159. amulet/level/java/chunk_components.pyi +22 -0
  160. amulet/level/java/long_array.pyi +38 -0
  161. amulet/level/java_forge/__init__.py +0 -0
  162. amulet/level/mcstructure/__init__.py +0 -0
  163. amulet/level/nbt/__init__.py +0 -0
  164. amulet/level/schematic/__init__.py +0 -0
  165. amulet/level/sponge_schematic/__init__.py +0 -0
  166. amulet/level/temporary_level/__init__.py +1 -0
  167. amulet/level/temporary_level/_level.py +16 -0
  168. amulet/palette/__init__.pyi +8 -0
  169. amulet/palette/biome_palette.pyi +45 -0
  170. amulet/palette/block_palette.pyi +45 -0
  171. amulet/player.py +64 -0
  172. amulet/py.typed +0 -0
  173. amulet/selection/__init__.py +2 -0
  174. amulet/selection/abstract_selection.py +342 -0
  175. amulet/selection/box.py +852 -0
  176. amulet/selection/group.py +481 -0
  177. amulet/utils/__init__.pyi +28 -0
  178. amulet/utils/call_spec/__init__.py +24 -0
  179. amulet/utils/call_spec/__init__.pyi +53 -0
  180. amulet/utils/call_spec/_call_spec.py +262 -0
  181. amulet/utils/call_spec/_call_spec.pyi +272 -0
  182. amulet/utils/format_utils.py +41 -0
  183. amulet/utils/generator.py +18 -0
  184. amulet/utils/matrix.py +243 -0
  185. amulet/utils/matrix.pyi +177 -0
  186. amulet/utils/numpy.pyi +11 -0
  187. amulet/utils/numpy_helpers.py +19 -0
  188. amulet/utils/shareable_lock.py +335 -0
  189. amulet/utils/shareable_lock.pyi +190 -0
  190. amulet/utils/signal/__init__.py +10 -0
  191. amulet/utils/signal/__init__.pyi +25 -0
  192. amulet/utils/signal/_signal.py +228 -0
  193. amulet/utils/signal/_signal.pyi +84 -0
  194. amulet/utils/task_manager.py +235 -0
  195. amulet/utils/task_manager.pyi +168 -0
  196. amulet/utils/typed_property.py +111 -0
  197. amulet/utils/typing.py +4 -0
  198. amulet/utils/typing.pyi +6 -0
  199. amulet/utils/weakref.py +70 -0
  200. amulet/utils/weakref.pyi +50 -0
  201. amulet/utils/world_utils.py +102 -0
  202. amulet/utils/world_utils.pyi +109 -0
  203. amulet/version.cpp +136 -0
  204. amulet/version.hpp +142 -0
  205. amulet/version.pyi +94 -0
  206. amulet_core-2.0a3.dist-info/METADATA +103 -0
  207. amulet_core-2.0a3.dist-info/RECORD +210 -0
  208. amulet_core-2.0a3.dist-info/WHEEL +5 -0
  209. amulet_core-2.0a3.dist-info/entry_points.txt +2 -0
  210. amulet_core-2.0a3.dist-info/top_level.txt +1 -0
amulet/utils/matrix.py ADDED
@@ -0,0 +1,243 @@
1
+ from typing import Tuple, Literal
2
+ import math
3
+ import numpy
4
+ from amulet.data_types import FloatTriplet, PointCoordinates
5
+
6
+
7
+ def scale_matrix(sx: float, sy: float, sz: float) -> numpy.ndarray:
8
+ """
9
+ Create a scale matrix from the inputs specified
10
+
11
+ :param sx: The scale in the x axis
12
+ :param sy: The scale in the y axis
13
+ :param sz: The scale in the z axis
14
+ :return: The 4x4 scale matrix
15
+ """
16
+ return numpy.array(
17
+ [[sx, 0, 0, 0], [0, sy, 0, 0], [0, 0, sz, 0], [0, 0, 0, 1]], dtype=numpy.float64
18
+ )
19
+
20
+
21
+ def displacement_matrix(x: float, y: float, z: float) -> numpy.ndarray:
22
+ """
23
+ Create a displacement matrix from the inputs specified
24
+
25
+ :param x: The displacement in the x axis
26
+ :param y: The displacement in the y axis
27
+ :param z: The displacement in the z axis
28
+ :return: The 4x4 displacement matrix
29
+ """
30
+ return numpy.array(
31
+ [[1, 0, 0, x], [0, 1, 0, y], [0, 0, 1, z], [0, 0, 0, 1]], dtype=numpy.float64
32
+ )
33
+
34
+
35
+ def _rotation_matrix(*angles: float, order: str) -> numpy.ndarray:
36
+ """
37
+ Create a rotation matrix from the inputs specified
38
+
39
+ :param angles: The angles in radians
40
+ :param order: The order the angles are specified. Transforms will be applied in this order.
41
+ :return: The 4x4 rotation matrix
42
+ """
43
+ assert isinstance(order, str) and len(order) == len(
44
+ angles
45
+ ), "Order must be a string of the same length as angles."
46
+ mat = numpy.identity(4, dtype=numpy.float64)
47
+
48
+ for angle, axis in zip(angles, order):
49
+ if angle:
50
+ c = math.cos(angle)
51
+ s = math.sin(angle)
52
+ if axis == "x":
53
+ mat = numpy.matmul(
54
+ numpy.array(
55
+ [[1, 0, 0, 0], [0, c, -s, 0], [0, s, c, 0], [0, 0, 0, 1]],
56
+ dtype=numpy.float64,
57
+ ),
58
+ mat,
59
+ )
60
+ elif axis == "y":
61
+ mat = numpy.matmul(
62
+ numpy.array(
63
+ [[c, 0, s, 0], [0, 1, 0, 0], [-s, 0, c, 0], [0, 0, 0, 1]],
64
+ dtype=numpy.float64,
65
+ ),
66
+ mat,
67
+ )
68
+ elif axis == "z":
69
+ mat = numpy.matmul(
70
+ numpy.array(
71
+ [[c, -s, 0, 0], [s, c, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],
72
+ dtype=numpy.float64,
73
+ ),
74
+ mat,
75
+ )
76
+
77
+ return mat
78
+
79
+
80
+ def rotation_matrix_x(rx: float) -> numpy.ndarray:
81
+ """
82
+ Create a rotation matrix in the x axis
83
+
84
+ :param rx: The angle in radians
85
+ :return: The 4x4 rotation matrix
86
+ """
87
+ return _rotation_matrix(rx, order="x")
88
+
89
+
90
+ def rotation_matrix_y(ry: float) -> numpy.ndarray:
91
+ """
92
+ Create a rotation matrix in the x axis
93
+
94
+ :param ry: The angle in radians
95
+ :return: The 4x4 rotation matrix
96
+ """
97
+ return _rotation_matrix(ry, order="y")
98
+
99
+
100
+ def rotation_matrix_z(rz: float) -> numpy.ndarray:
101
+ """
102
+ Create a rotation matrix in the x axis
103
+
104
+ :param rz: The angle in radians
105
+ :return: The 4x4 rotation matrix
106
+ """
107
+ return _rotation_matrix(rz, order="z")
108
+
109
+
110
+ def rotation_matrix_xy(rx: float, ry: float) -> numpy.ndarray:
111
+ """
112
+ Create a rotation matrix from the inputs specified
113
+
114
+ :param rx: The rotation in radians in the x axis
115
+ :param ry: The rotation in radians in the y axis
116
+ :return: The 4x4 rotation matrix
117
+ """
118
+ return _rotation_matrix(rx, ry, order="xy")
119
+
120
+
121
+ def rotation_matrix_yx(ry: float, rx: float) -> numpy.ndarray:
122
+ """
123
+ Create a rotation matrix from the inputs specified
124
+
125
+ :param rx: The rotation in radians in the x axis
126
+ :param ry: The rotation in radians in the y axis
127
+ :return: The 4x4 rotation matrix
128
+ """
129
+ return _rotation_matrix(ry, rx, order="yx")
130
+
131
+
132
+ def rotation_matrix_xyz(x: float, y: float, z: float) -> numpy.ndarray:
133
+ """
134
+ Create a rotation matrix from the inputs specified
135
+
136
+ :param x: The rotation in radians in the x axis
137
+ :param y: The rotation in radians in the y axis
138
+ :param z: The rotation in radians in the z axis
139
+ :return: The 4x4 rotation matrix
140
+ """
141
+ return _rotation_matrix(x, y, z, order="xyz")
142
+
143
+
144
+ def transform_matrix(
145
+ scale: FloatTriplet,
146
+ rotation: FloatTriplet,
147
+ displacement: PointCoordinates,
148
+ order: Literal["xyz", "xzy", "yxz", "yzx", "zxy", "zyx"] = "xyz",
149
+ ) -> numpy.ndarray:
150
+ """Create a 4x4 transformation matrix from the scale, rotation and displacement specified.
151
+
152
+ :param scale: The scale in the x, y and z axis
153
+ :param rotation: The rotation in the x, y and z axis in radians. (axis can be changed using `order`)
154
+ :param displacement: The displacement in the x, y and z axis
155
+ :param order: The order to apply the rotations in.
156
+ :return: The 4x4 transformation matrix of combined scale, rotation and displacement
157
+ """
158
+ scale_transform = scale_matrix(*scale)
159
+ rotation_transform = _rotation_matrix(*rotation, order=order)
160
+ displacement_transform = displacement_matrix(*displacement)
161
+ return numpy.matmul( # type: ignore
162
+ displacement_transform,
163
+ numpy.matmul(rotation_transform, scale_transform),
164
+ )
165
+
166
+
167
+ def inverse_transform_matrix(
168
+ scale: FloatTriplet,
169
+ rotation: FloatTriplet,
170
+ displacement: PointCoordinates,
171
+ order: Literal["xyz", "xzy", "yxz", "yzx", "zxy", "zyx"] = "xyz",
172
+ ) -> numpy.ndarray:
173
+ """Create the inverse of the 4x4 transformation matrix from the scale, rotation and displacement specified.
174
+ This should be the inverse of transform_matrix
175
+
176
+ :param scale: The scale in the x, y and z axis
177
+ :param rotation: The rotation in the x, y and z axis (axis can be changed using `order`)
178
+ :param displacement: The displacement in the x, y and z axis
179
+ :param order: The order to apply the rotations in.
180
+ :return: The 4x4 transformation matrix of combined scale, rotation and displacement
181
+ """
182
+ scale_transform = scale_matrix(*1 / numpy.asarray(scale))
183
+ ra, rb, rc = -numpy.asarray(rotation)
184
+ rotation_transform = _rotation_matrix(
185
+ rc, rb, ra, order="".join(list(reversed(order)))
186
+ )
187
+ displacement_transform = displacement_matrix(*-numpy.asarray(displacement))
188
+ return numpy.matmul( # type: ignore
189
+ scale_transform,
190
+ numpy.matmul(rotation_transform, displacement_transform),
191
+ )
192
+
193
+
194
+ def decompose_transformation_matrix(
195
+ matrix: numpy.ndarray,
196
+ ) -> Tuple[
197
+ Tuple[float, float, float], Tuple[float, float, float], Tuple[float, float, float]
198
+ ]:
199
+ """
200
+ Decompose a 4x4 transformation matrix into scale, rotation and displacement tuples.
201
+
202
+ :param matrix: The matrix to decompose.
203
+ :return: The scale, rotation and displacement.
204
+ """
205
+ assert isinstance(matrix, numpy.ndarray), "Matrix must be an ndarray"
206
+ assert matrix.shape == (4, 4), "Expected a 4x4 numpy array"
207
+ # https://gist.github.com/Aerilius/0cbc46271c163746717902b36bea8fd4
208
+ # 0 4 8 12
209
+ # 1 5 9 13
210
+ # 2 6 10 14
211
+ # 3 7 11 15
212
+ matrix = matrix.copy() # just in case
213
+ displacement = tuple(matrix[:3, 3].tolist())
214
+ matrix[:3, 3] = 0
215
+ scale_np = numpy.linalg.norm(matrix[:3, :3], axis=0) * matrix[3, 3]
216
+ scale = tuple(scale_np.tolist())
217
+ matrix[:3, :3] = matrix[:3, :3] / scale_np
218
+
219
+ matrix[3, 3] = 1
220
+
221
+ if (
222
+ numpy.dot(
223
+ numpy.cross(
224
+ matrix[:3, 0],
225
+ matrix[:3, 1],
226
+ ),
227
+ matrix[:3, 2],
228
+ )
229
+ < 0
230
+ ):
231
+ scale = (-scale[0], scale[1], scale[2])
232
+ matrix[:3, 0] *= -1
233
+
234
+ rotation = (
235
+ math.atan2(matrix[2, 1], matrix[2, 2]),
236
+ math.atan2(
237
+ -matrix[2, 0],
238
+ (matrix[2, 1] ** 2 + matrix[2, 2] ** 2) ** 0.5,
239
+ ),
240
+ math.atan2(matrix[1, 0], matrix[0, 0]),
241
+ )
242
+
243
+ return scale, rotation, displacement
@@ -0,0 +1,177 @@
1
+ from __future__ import annotations
2
+
3
+ import math as math
4
+ import types
5
+
6
+ import numpy as numpy
7
+
8
+ __all__ = [
9
+ "FloatTriplet",
10
+ "PointCoordinates",
11
+ "decompose_transformation_matrix",
12
+ "displacement_matrix",
13
+ "inverse_transform_matrix",
14
+ "math",
15
+ "numpy",
16
+ "rotation_matrix_x",
17
+ "rotation_matrix_xy",
18
+ "rotation_matrix_xyz",
19
+ "rotation_matrix_y",
20
+ "rotation_matrix_yx",
21
+ "rotation_matrix_z",
22
+ "scale_matrix",
23
+ "transform_matrix",
24
+ ]
25
+
26
+ def _rotation_matrix(*angles: float, order: str) -> numpy.ndarray:
27
+ """
28
+
29
+ Create a rotation matrix from the inputs specified
30
+
31
+ :param angles: The angles in radians
32
+ :param order: The order the angles are specified. Transforms will be applied in this order.
33
+ :return: The 4x4 rotation matrix
34
+
35
+ """
36
+
37
+ def decompose_transformation_matrix(
38
+ matrix: numpy.ndarray,
39
+ ) -> typing.Tuple[
40
+ typing.Tuple[float, float, float],
41
+ typing.Tuple[float, float, float],
42
+ typing.Tuple[float, float, float],
43
+ ]:
44
+ """
45
+
46
+ Decompose a 4x4 transformation matrix into scale, rotation and displacement tuples.
47
+
48
+ :param matrix: The matrix to decompose.
49
+ :return: The scale, rotation and displacement.
50
+
51
+ """
52
+
53
+ def displacement_matrix(x: float, y: float, z: float) -> numpy.ndarray:
54
+ """
55
+
56
+ Create a displacement matrix from the inputs specified
57
+
58
+ :param x: The displacement in the x axis
59
+ :param y: The displacement in the y axis
60
+ :param z: The displacement in the z axis
61
+ :return: The 4x4 displacement matrix
62
+
63
+ """
64
+
65
+ def inverse_transform_matrix(
66
+ scale: tuple[float, float, float],
67
+ rotation: tuple[float, float, float],
68
+ displacement: tuple[float, float, float],
69
+ order: typing.Literal["xyz", "xzy", "yxz", "yzx", "zxy", "zyx"] = "xyz",
70
+ ) -> numpy.ndarray:
71
+ """
72
+ Create the inverse of the 4x4 transformation matrix from the scale, rotation and displacement specified.
73
+ This should be the inverse of transform_matrix
74
+
75
+ :param scale: The scale in the x, y and z axis
76
+ :param rotation: The rotation in the x, y and z axis (axis can be changed using `order`)
77
+ :param displacement: The displacement in the x, y and z axis
78
+ :param order: The order to apply the rotations in.
79
+ :return: The 4x4 transformation matrix of combined scale, rotation and displacement
80
+
81
+ """
82
+
83
+ def rotation_matrix_x(rx: float) -> numpy.ndarray:
84
+ """
85
+
86
+ Create a rotation matrix in the x axis
87
+
88
+ :param rx: The angle in radians
89
+ :return: The 4x4 rotation matrix
90
+
91
+ """
92
+
93
+ def rotation_matrix_xy(rx: float, ry: float) -> numpy.ndarray:
94
+ """
95
+
96
+ Create a rotation matrix from the inputs specified
97
+
98
+ :param rx: The rotation in radians in the x axis
99
+ :param ry: The rotation in radians in the y axis
100
+ :return: The 4x4 rotation matrix
101
+
102
+ """
103
+
104
+ def rotation_matrix_xyz(x: float, y: float, z: float) -> numpy.ndarray:
105
+ """
106
+
107
+ Create a rotation matrix from the inputs specified
108
+
109
+ :param x: The rotation in radians in the x axis
110
+ :param y: The rotation in radians in the y axis
111
+ :param z: The rotation in radians in the z axis
112
+ :return: The 4x4 rotation matrix
113
+
114
+ """
115
+
116
+ def rotation_matrix_y(ry: float) -> numpy.ndarray:
117
+ """
118
+
119
+ Create a rotation matrix in the x axis
120
+
121
+ :param ry: The angle in radians
122
+ :return: The 4x4 rotation matrix
123
+
124
+ """
125
+
126
+ def rotation_matrix_yx(ry: float, rx: float) -> numpy.ndarray:
127
+ """
128
+
129
+ Create a rotation matrix from the inputs specified
130
+
131
+ :param rx: The rotation in radians in the x axis
132
+ :param ry: The rotation in radians in the y axis
133
+ :return: The 4x4 rotation matrix
134
+
135
+ """
136
+
137
+ def rotation_matrix_z(rz: float) -> numpy.ndarray:
138
+ """
139
+
140
+ Create a rotation matrix in the x axis
141
+
142
+ :param rz: The angle in radians
143
+ :return: The 4x4 rotation matrix
144
+
145
+ """
146
+
147
+ def scale_matrix(sx: float, sy: float, sz: float) -> numpy.ndarray:
148
+ """
149
+
150
+ Create a scale matrix from the inputs specified
151
+
152
+ :param sx: The scale in the x axis
153
+ :param sy: The scale in the y axis
154
+ :param sz: The scale in the z axis
155
+ :return: The 4x4 scale matrix
156
+
157
+ """
158
+
159
+ def transform_matrix(
160
+ scale: tuple[float, float, float],
161
+ rotation: tuple[float, float, float],
162
+ displacement: tuple[float, float, float],
163
+ order: typing.Literal["xyz", "xzy", "yxz", "yzx", "zxy", "zyx"] = "xyz",
164
+ ) -> numpy.ndarray:
165
+ """
166
+ Create a 4x4 transformation matrix from the scale, rotation and displacement specified.
167
+
168
+ :param scale: The scale in the x, y and z axis
169
+ :param rotation: The rotation in the x, y and z axis in radians. (axis can be changed using `order`)
170
+ :param displacement: The displacement in the x, y and z axis
171
+ :param order: The order to apply the rotations in.
172
+ :return: The 4x4 transformation matrix of combined scale, rotation and displacement
173
+
174
+ """
175
+
176
+ FloatTriplet: types.GenericAlias # value = tuple[float, float, float]
177
+ PointCoordinates: types.GenericAlias # value = tuple[float, float, float]
amulet/utils/numpy.pyi ADDED
@@ -0,0 +1,11 @@
1
+ from __future__ import annotations
2
+
3
+ import numpy
4
+ import numpy.typing
5
+ import typing_extensions
6
+
7
+ __all__ = ["unique_inverse"]
8
+
9
+ def unique_inverse(
10
+ array: typing_extensions.Buffer,
11
+ ) -> tuple[numpy.typing.NDArray[numpy.uint32], numpy.typing.NDArray[numpy.uint32]]: ...
@@ -0,0 +1,19 @@
1
+ from typing import Tuple, TypeVar
2
+ from collections.abc import Collection
3
+ import numpy
4
+
5
+ T = TypeVar("T")
6
+
7
+
8
+ def brute_sort_objects_no_hash(data: Collection[T]) -> Tuple[list[T], numpy.ndarray]:
9
+ unique: list[T] = []
10
+ inverse = numpy.zeros(dtype=numpy.uint32, shape=len(data))
11
+ for i, d in enumerate(data):
12
+ try:
13
+ index = unique.index(d)
14
+ except ValueError:
15
+ index = len(unique)
16
+ unique.append(d)
17
+ inverse[i] = index
18
+
19
+ return unique, numpy.array(inverse)