@woosh/meep-engine 2.109.0 → 2.109.2

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.
Files changed (311) hide show
  1. package/build/meep.cjs +150 -199
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +150 -199
  4. package/package.json +1 -1
  5. package/src/core/binary/BitSet.d.ts +6 -0
  6. package/src/core/binary/BitSet.d.ts.map +1 -1
  7. package/src/core/binary/BitSet.js +14 -42
  8. package/src/core/binary/align_32.d.ts +7 -0
  9. package/src/core/binary/align_32.d.ts.map +1 -0
  10. package/src/core/binary/align_32.js +8 -0
  11. package/src/core/binary/align_32.spec.d.ts +2 -0
  12. package/src/core/binary/align_32.spec.d.ts.map +1 -0
  13. package/src/core/binary/align_32.spec.js +11 -0
  14. package/src/core/binary/align_4.js +2 -1
  15. package/src/core/binary/ctz32.d.ts.map +1 -1
  16. package/src/core/binary/ctz32.js +12 -11
  17. package/src/core/binary/lsb_32.d.ts +9 -0
  18. package/src/core/binary/lsb_32.d.ts.map +1 -0
  19. package/src/core/binary/lsb_32.js +12 -0
  20. package/src/core/binary/msb_32.d.ts +2 -0
  21. package/src/core/binary/msb_32.d.ts.map +1 -0
  22. package/src/core/binary/msb_32.js +20 -0
  23. package/src/core/binary/msb_lut_de_bruijn.d.ts +7 -0
  24. package/src/core/binary/msb_lut_de_bruijn.d.ts.map +1 -0
  25. package/src/core/binary/msb_lut_de_bruijn.js +9 -0
  26. package/src/core/binary/reinterpret_int32_as_float32.d.ts +7 -0
  27. package/src/core/binary/reinterpret_int32_as_float32.d.ts.map +1 -0
  28. package/src/core/binary/reinterpret_int32_as_float32.js +14 -0
  29. package/src/core/binary/reverse_bits_uint32.d.ts +8 -0
  30. package/src/core/binary/reverse_bits_uint32.d.ts.map +1 -0
  31. package/src/core/binary/reverse_bits_uint32.js +17 -0
  32. package/src/core/binary/reverse_bits_uint32.spec.d.ts +2 -0
  33. package/src/core/binary/reverse_bits_uint32.spec.d.ts.map +1 -0
  34. package/src/core/binary/reverse_bits_uint32.spec.js +18 -0
  35. package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
  36. package/src/core/bvh2/bvh3/BVH.js +13 -18
  37. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_incremental.d.ts.map +1 -1
  38. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_incremental.js +3 -1
  39. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
  40. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +6 -7
  41. package/src/core/bvh2/bvh3/ebvh_build_hierarchy.d.ts.map +1 -1
  42. package/src/core/bvh2/bvh3/ebvh_build_hierarchy.js +4 -0
  43. package/src/core/bvh2/bvh3/query/backtracking/bvh_backtracking_query_leaves_ray.d.ts +16 -0
  44. package/src/core/bvh2/bvh3/query/backtracking/bvh_backtracking_query_leaves_ray.d.ts.map +1 -0
  45. package/src/core/bvh2/bvh3/query/backtracking/bvh_backtracking_query_leaves_ray.js +130 -0
  46. package/src/core/bvh2/bvh3/query/cache/BVH_QUERY_CACHE_SIZE.d.ts +2 -0
  47. package/src/core/bvh2/bvh3/query/cache/BVH_QUERY_CACHE_SIZE.d.ts.map +1 -0
  48. package/src/core/bvh2/bvh3/query/cache/BVH_QUERY_CACHE_SIZE.js +1 -0
  49. package/src/core/bvh2/bvh3/query/cache/bvh_query_cache_hash_v3.d.ts +9 -0
  50. package/src/core/bvh2/bvh3/query/cache/bvh_query_cache_hash_v3.d.ts.map +1 -0
  51. package/src/core/bvh2/bvh3/query/cache/bvh_query_cache_hash_v3.js +31 -0
  52. package/src/core/collection/array/array_quick_sort_by_lookup_map.d.ts +9 -0
  53. package/src/core/collection/array/array_quick_sort_by_lookup_map.d.ts.map +1 -0
  54. package/src/core/collection/array/array_quick_sort_by_lookup_map.js +79 -0
  55. package/src/core/collection/array/array_quick_sort_by_lookup_uint.d.ts +8 -0
  56. package/src/core/collection/array/array_quick_sort_by_lookup_uint.d.ts.map +1 -0
  57. package/src/core/collection/array/{array_quick_sort_by_lookup.js → array_quick_sort_by_lookup_uint.js} +1 -1
  58. package/src/core/collection/array/array_shuffle.js +1 -1
  59. package/src/core/collection/array/array_swap_one.d.ts.map +1 -1
  60. package/src/core/collection/array/array_swap_one.js +6 -0
  61. package/src/core/events/signal/Signal.d.ts.map +1 -1
  62. package/src/core/events/signal/Signal.js +10 -10
  63. package/src/core/geom/2d/compute_triangle_area_2d.d.ts.map +1 -1
  64. package/src/core/geom/2d/compute_triangle_area_2d.js +5 -3
  65. package/src/core/geom/3d/Ray3.d.ts +6 -0
  66. package/src/core/geom/3d/Ray3.d.ts.map +1 -1
  67. package/src/core/geom/3d/Ray3.js +24 -0
  68. package/src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_min.d.ts +16 -0
  69. package/src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_min.d.ts.map +1 -0
  70. package/src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_min.js +29 -0
  71. package/src/core/geom/3d/aabb/aabb3_from_v3_array_transformed.d.ts +2 -2
  72. package/src/core/geom/3d/aabb/aabb3_from_v3_array_transformed.d.ts.map +1 -1
  73. package/src/core/geom/3d/aabb/aabb3_from_v3_array_transformed.js +6 -6
  74. package/src/core/geom/3d/aabb/aabb3_overlaps_ray_segment.d.ts +11 -0
  75. package/src/core/geom/3d/aabb/aabb3_overlaps_ray_segment.d.ts.map +1 -0
  76. package/src/core/geom/3d/aabb/aabb3_overlaps_ray_segment.js +61 -0
  77. package/src/core/geom/3d/eulerAnglesFromMatrix.d.ts +2 -2
  78. package/src/core/geom/3d/eulerAnglesFromMatrix.d.ts.map +1 -1
  79. package/src/core/geom/3d/eulerAnglesFromMatrix.js +28 -25
  80. package/src/core/geom/3d/morton/v3_morton_encode_bounded.d.ts +2 -2
  81. package/src/core/geom/3d/morton/v3_morton_encode_bounded.d.ts.map +1 -1
  82. package/src/core/geom/3d/morton/v3_morton_encode_bounded.js +1 -1
  83. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts +2 -2
  84. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts.map +1 -1
  85. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js +1 -1
  86. package/src/core/geom/3d/ray/ray3_shift_origin_along_direction.js +2 -2
  87. package/src/core/geom/3d/sphere/harmonics/sh3_convolve_with_cosine_kernel.js +2 -1
  88. package/src/core/geom/3d/sphere/harmonics/sh3_vector_accumulate.d.ts +12 -0
  89. package/src/core/geom/3d/sphere/harmonics/sh3_vector_accumulate.d.ts.map +1 -0
  90. package/src/core/geom/3d/sphere/harmonics/sh3_vector_accumulate.js +40 -0
  91. package/src/core/geom/3d/sphere/harmonics/sh3_vector_accumulate.spec.d.ts +2 -0
  92. package/src/core/geom/3d/sphere/harmonics/sh3_vector_accumulate.spec.d.ts.map +1 -0
  93. package/src/core/geom/3d/sphere/harmonics/sh3_vector_accumulate.spec.js +27 -0
  94. package/src/core/geom/3d/sphere/sphere_intersects_ray.js +1 -1
  95. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.d.ts.map +1 -1
  96. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.js +24 -188
  97. package/src/core/geom/3d/tetrahedra/triangle/prototype.js +1 -1
  98. package/src/core/geom/3d/tetrahedra/visualize_tetrahedral_mesh.d.ts +11 -0
  99. package/src/core/geom/3d/tetrahedra/visualize_tetrahedral_mesh.d.ts.map +1 -0
  100. package/src/core/geom/3d/tetrahedra/visualize_tetrahedral_mesh.js +42 -0
  101. package/src/core/geom/3d/topology/samples/sampleFloodFill.js +2 -2
  102. package/src/core/geom/3d/topology/tm_face_area.js +2 -2
  103. package/src/core/geom/3d/triangle/{computeTriangleSurfaceArea.d.ts → compute_triangle_area_3d.d.ts} +2 -2
  104. package/src/core/geom/3d/triangle/compute_triangle_area_3d.d.ts.map +1 -0
  105. package/src/core/geom/3d/triangle/{computeTriangleSurfaceArea.js → compute_triangle_area_3d.js} +2 -4
  106. package/src/core/geom/Quaternion.d.ts.map +1 -1
  107. package/src/core/geom/Quaternion.js +13 -102
  108. package/src/core/geom/Quaternion.spec.js +2 -2
  109. package/src/core/geom/Vector1.d.ts.map +1 -1
  110. package/src/core/geom/Vector1.js +14 -6
  111. package/src/core/geom/vec/vector_copy.d.ts +10 -0
  112. package/src/core/geom/vec/vector_copy.d.ts.map +1 -0
  113. package/src/core/geom/vec/vector_copy.js +13 -0
  114. package/src/core/{math/vector_nd_dot.d.ts → geom/vec/vector_dot.d.ts} +2 -2
  115. package/src/core/geom/vec/vector_dot.d.ts.map +1 -0
  116. package/src/core/{math/vector_nd_dot.js → geom/vec/vector_dot.js} +1 -1
  117. package/src/core/{math/vector_nd_normalize.d.ts → geom/vec/vector_normalize.d.ts} +2 -2
  118. package/src/core/geom/vec/vector_normalize.d.ts.map +1 -0
  119. package/src/core/{math/vector_nd_normalize.js → geom/vec/vector_normalize.js} +1 -1
  120. package/src/core/geom/vec/vector_normalize.spec.d.ts +2 -0
  121. package/src/core/geom/vec/vector_normalize.spec.d.ts.map +1 -0
  122. package/src/core/{math/vector_nd_normalize.spec.js → geom/vec/vector_normalize.spec.js} +3 -3
  123. package/src/core/geom/vec/vector_scale_array.d.ts +11 -0
  124. package/src/core/geom/vec/vector_scale_array.d.ts.map +1 -0
  125. package/src/core/geom/vec/vector_scale_array.js +31 -0
  126. package/src/core/geom/vec3/v3_array_displace_in_direction.d.ts +14 -0
  127. package/src/core/geom/vec3/v3_array_displace_in_direction.d.ts.map +1 -0
  128. package/src/core/geom/vec3/{v3_shift_along_direction.js → v3_array_displace_in_direction.js} +1 -1
  129. package/src/core/geom/vec3/v3_displace_in_direction.d.ts +7 -7
  130. package/src/core/geom/vec3/v3_displace_in_direction.d.ts.map +1 -1
  131. package/src/core/geom/vec3/v3_displace_in_direction.js +20 -17
  132. package/src/core/geom/vec3/v3_displace_in_direction.spec.d.ts +2 -0
  133. package/src/core/geom/vec3/v3_displace_in_direction.spec.d.ts.map +1 -0
  134. package/src/core/geom/vec3/v3_displace_in_direction.spec.js +80 -0
  135. package/src/core/geom/vec3/v3_dot_array_array.js +2 -0
  136. package/src/core/geom/vec4/v4_length.d.ts +10 -0
  137. package/src/core/geom/vec4/v4_length.d.ts.map +1 -0
  138. package/src/core/geom/vec4/v4_length.js +13 -0
  139. package/src/core/geom/vec4/v4_length_sqr.js +2 -1
  140. package/src/core/graph/eigen/matrix_eigenvalues_in_place.spec.js +31 -1
  141. package/src/core/math/FLT_EPSILON_64.d.ts +6 -0
  142. package/src/core/math/FLT_EPSILON_64.d.ts.map +1 -0
  143. package/src/core/math/FLT_EPSILON_64.js +5 -0
  144. package/src/core/math/gaussian.d.ts +2 -2
  145. package/src/core/math/gaussian.js +2 -2
  146. package/src/core/math/linalg/README.md +1 -0
  147. package/src/core/math/linalg/lu_factor_linear_system.d.ts +13 -0
  148. package/src/core/math/linalg/lu_factor_linear_system.d.ts.map +1 -0
  149. package/src/core/math/linalg/lu_factor_linear_system.js +112 -0
  150. package/src/core/math/linalg/lu_solve_linear_system.d.ts +14 -0
  151. package/src/core/math/linalg/lu_solve_linear_system.d.ts.map +1 -0
  152. package/src/core/math/linalg/lu_solve_linear_system.js +51 -0
  153. package/src/core/math/linalg/solve_linear_system.d.ts +14 -0
  154. package/src/core/math/linalg/solve_linear_system.d.ts.map +1 -0
  155. package/src/core/math/linalg/solve_linear_system.js +52 -0
  156. package/src/core/math/linalg/solve_linear_system.spec.d.ts +2 -0
  157. package/src/core/math/linalg/solve_linear_system.spec.d.ts.map +1 -0
  158. package/src/core/math/linalg/solve_linear_system.spec.js +70 -0
  159. package/src/core/math/linalg/solve_linear_system_GEPP_2x2.d.ts +10 -0
  160. package/src/core/math/linalg/solve_linear_system_GEPP_2x2.d.ts.map +1 -0
  161. package/src/core/math/linalg/solve_linear_system_GEPP_2x2.js +91 -0
  162. package/src/core/math/solveQuadratic.d.ts.map +1 -1
  163. package/src/core/math/solveQuadratic.js +2 -0
  164. package/src/core/math/statistics/gaussian_amplitude.d.ts +8 -0
  165. package/src/core/math/statistics/gaussian_amplitude.d.ts.map +1 -0
  166. package/src/core/math/statistics/gaussian_amplitude.js +13 -0
  167. package/src/core/math/statistics/halton_sequence.js +3 -3
  168. package/src/core/math/statistics/halton_sequence.spec.js +18 -0
  169. package/src/core/math/statistics/hammersley_sequence.d.ts +9 -0
  170. package/src/core/math/statistics/hammersley_sequence.d.ts.map +1 -0
  171. package/src/core/math/statistics/hammersley_sequence.js +25 -0
  172. package/src/core/math/statistics/hammersley_sequence_2d.d.ts +9 -0
  173. package/src/core/math/statistics/hammersley_sequence_2d.d.ts.map +1 -0
  174. package/src/core/math/statistics/hammersley_sequence_2d.js +17 -0
  175. package/src/core/math/statistics/radical_inverse_VdC_base_2.d.ts +8 -0
  176. package/src/core/math/statistics/radical_inverse_VdC_base_2.d.ts.map +1 -0
  177. package/src/core/math/statistics/radical_inverse_VdC_base_2.js +15 -0
  178. package/src/core/math/statistics/radical_inverse_VdC_base_2.spec.d.ts +2 -0
  179. package/src/core/math/statistics/radical_inverse_VdC_base_2.spec.d.ts.map +1 -0
  180. package/src/core/math/statistics/radical_inverse_VdC_base_2.spec.js +9 -0
  181. package/src/core/model/node-graph/node/NodeInstance.d.ts.map +1 -1
  182. package/src/core/model/node-graph/node/NodeInstance.js +44 -12
  183. package/src/core/model/node-graph/node/NodeInstance.spec.d.ts +2 -0
  184. package/src/core/model/node-graph/node/NodeInstance.spec.d.ts.map +1 -0
  185. package/src/core/model/node-graph/node/NodeInstance.spec.js +82 -0
  186. package/src/core/model/node-graph/node/NodeInstancePortReference.d.ts.map +1 -1
  187. package/src/core/model/node-graph/node/NodeInstancePortReference.js +9 -0
  188. package/src/core/model/node-graph/node/NodeInstancePortReference.spec.js +20 -0
  189. package/src/core/model/node-graph/node/Port.d.ts.map +1 -1
  190. package/src/core/model/node-graph/node/Port.js +5 -12
  191. package/src/core/model/node-graph/node/PortDirection.d.ts.map +1 -1
  192. package/src/core/model/node-graph/node/PortDirection.js +7 -1
  193. package/src/engine/asset/CORS/CrossOriginConfig.d.ts.map +1 -1
  194. package/src/engine/asset/CORS/CrossOriginConfig.js +6 -4
  195. package/src/engine/graphics/geometry/computeMeshSurfaceArea.js +2 -2
  196. package/src/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.d.ts.map +1 -1
  197. package/src/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.js +33 -3
  198. package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +9 -7
  199. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_INFERNO.d.ts +6 -0
  200. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_INFERNO.d.ts.map +1 -0
  201. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_INFERNO.js +18 -0
  202. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_TURBO.d.ts +6 -0
  203. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_TURBO.d.ts.map +1 -0
  204. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_TURBO.js +266 -0
  205. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_VIRIDIS.d.ts +7 -0
  206. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_VIRIDIS.d.ts.map +1 -0
  207. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_VIRIDIS.js +19 -0
  208. package/src/engine/graphics/sh3/SH3VisualisationMaterial.js +9 -9
  209. package/src/engine/graphics/sh3/fromCubeRenderTarget.d.ts.map +1 -1
  210. package/src/engine/graphics/sh3/fromCubeRenderTarget.js +14 -17
  211. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -1
  212. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +0 -2
  213. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +7 -29
  214. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
  215. package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +52 -164
  216. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts +13 -0
  217. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts.map +1 -0
  218. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +63 -0
  219. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts +1 -0
  220. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
  221. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +33 -16
  222. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -1
  223. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +4 -29
  224. package/src/engine/graphics/sh3/lpv/{LightProbeVolumeSerializationAdapter.d.ts → serialization/LightProbeVolumeSerializationAdapter.d.ts} +2 -2
  225. package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.d.ts.map +1 -0
  226. package/src/engine/graphics/sh3/lpv/{LightProbeVolumeSerializationAdapter.js → serialization/LightProbeVolumeSerializationAdapter.js} +2 -2
  227. package/src/engine/graphics/sh3/lpv/sh3_bake_depth.d.ts +13 -0
  228. package/src/engine/graphics/sh3/lpv/sh3_bake_depth.d.ts.map +1 -0
  229. package/src/engine/graphics/sh3/lpv/sh3_bake_depth.js +71 -0
  230. package/src/engine/graphics/sh3/lpv/worker/lpv_build_worker.d.ts +2 -0
  231. package/src/engine/graphics/sh3/lpv/worker/lpv_build_worker.d.ts.map +1 -0
  232. package/src/engine/graphics/sh3/lpv/worker/lpv_build_worker.js +38 -0
  233. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts +1 -7
  234. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts.map +1 -1
  235. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js +58 -147
  236. package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.d.ts +13 -9
  237. package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.d.ts.map +1 -1
  238. package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.js +74 -54
  239. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts +23 -5
  240. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -1
  241. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +211 -59
  242. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +1 -1
  243. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.d.ts +15 -0
  244. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.d.ts.map +1 -0
  245. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.js +46 -0
  246. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.d.ts +14 -0
  247. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.d.ts.map +1 -0
  248. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.js +43 -0
  249. package/src/engine/graphics/sh3/path_tracer/geometry/compute_triangle_group_aabb3.d.ts.map +1 -0
  250. package/src/engine/graphics/sh3/path_tracer/{compute_triangle_group_aabb3.js → geometry/compute_triangle_group_aabb3.js} +2 -2
  251. package/src/engine/graphics/sh3/path_tracer/geometry/construct_ray_hit_from_geometry.d.ts +12 -0
  252. package/src/engine/graphics/sh3/path_tracer/geometry/construct_ray_hit_from_geometry.d.ts.map +1 -0
  253. package/src/engine/graphics/sh3/path_tracer/geometry/construct_ray_hit_from_geometry.js +72 -0
  254. package/src/engine/graphics/sh3/path_tracer/geometry/sample_triangle_attribute.d.ts.map +1 -0
  255. package/src/engine/graphics/sh3/path_tracer/geometry/sort_triangles_by_distance_to_point.d.ts +13 -0
  256. package/src/engine/graphics/sh3/path_tracer/geometry/sort_triangles_by_distance_to_point.d.ts.map +1 -0
  257. package/src/engine/graphics/sh3/path_tracer/geometry/sort_triangles_by_distance_to_point.js +48 -0
  258. package/src/engine/graphics/sh3/path_tracer/material/StandardMaterial.d.ts +1 -0
  259. package/src/engine/graphics/sh3/path_tracer/material/StandardMaterial.d.ts.map +1 -1
  260. package/src/engine/graphics/sh3/path_tracer/material/StandardMaterial.js +4 -0
  261. package/src/engine/graphics/sh3/path_tracer/material/StandardTexture.d.ts +1 -0
  262. package/src/engine/graphics/sh3/path_tracer/material/StandardTexture.d.ts.map +1 -1
  263. package/src/engine/graphics/sh3/path_tracer/material/StandardTexture.js +8 -5
  264. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +24 -18
  265. package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.d.ts +2 -2
  266. package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.d.ts.map +1 -1
  267. package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.js +1 -1
  268. package/src/engine/graphics/sh3/path_tracer/sampling/getBiasedNormalSample.d.ts.map +1 -0
  269. package/src/engine/graphics/sh3/path_tracer/{getBiasedNormalSample.js → sampling/getBiasedNormalSample.js} +1 -1
  270. package/src/engine/graphics/sh3/path_tracer/sampling/random_in_hemisphere.d.ts.map +1 -0
  271. package/src/engine/graphics/sh3/path_tracer/{random_in_hemisphere.js → sampling/random_in_hemisphere.js} +1 -1
  272. package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.d.ts +12 -0
  273. package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.d.ts.map +1 -0
  274. package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.js +46 -0
  275. package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +2 -2
  276. package/src/engine/graphics/sh3/path_tracer/three_object_to_path_traced_scene.d.ts +7 -0
  277. package/src/engine/graphics/sh3/path_tracer/three_object_to_path_traced_scene.d.ts.map +1 -0
  278. package/src/engine/graphics/sh3/path_tracer/three_object_to_path_traced_scene.js +69 -0
  279. package/src/engine/graphics/sh3/prototypeSH3Probe.js +45 -7
  280. package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.d.ts +11 -1
  281. package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.d.ts.map +1 -1
  282. package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.js +33 -16
  283. package/src/engine/graphics/texture/formatToChannelCount.d.ts.map +1 -1
  284. package/src/engine/graphics/texture/formatToChannelCount.js +14 -1
  285. package/src/engine/graphics/three/three_object_replace_materials.d.ts +7 -0
  286. package/src/engine/graphics/three/three_object_replace_materials.d.ts.map +1 -0
  287. package/src/engine/graphics/three/three_object_replace_materials.js +13 -0
  288. package/src/engine/sound/material/detector/terrain/TerrainSoundMaterialSurfaceDetector.d.ts.map +1 -1
  289. package/src/engine/sound/material/detector/terrain/TerrainSoundMaterialSurfaceDetector.js +6 -6
  290. package/src/core/collection/array/array_quick_sort_by_lookup.d.ts +0 -8
  291. package/src/core/collection/array/array_quick_sort_by_lookup.d.ts.map +0 -1
  292. package/src/core/geom/3d/triangle/computeTriangleSurfaceArea.d.ts.map +0 -1
  293. package/src/core/geom/vec3/v3_shift_along_direction.d.ts +0 -14
  294. package/src/core/geom/vec3/v3_shift_along_direction.d.ts.map +0 -1
  295. package/src/core/math/vector_nd_dot.d.ts.map +0 -1
  296. package/src/core/math/vector_nd_normalize.d.ts.map +0 -1
  297. package/src/core/math/vector_nd_normalize.spec.d.ts +0 -2
  298. package/src/core/math/vector_nd_normalize.spec.d.ts.map +0 -1
  299. package/src/engine/graphics/filter/FlipArrayViaCanvas.d.ts +0 -2
  300. package/src/engine/graphics/filter/FlipArrayViaCanvas.d.ts.map +0 -1
  301. package/src/engine/graphics/filter/FlipArrayViaCanvas.js +0 -13
  302. package/src/engine/graphics/sh3/lpv/LightProbeVolumeSerializationAdapter.d.ts.map +0 -1
  303. package/src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.d.ts.map +0 -1
  304. package/src/engine/graphics/sh3/path_tracer/getBiasedNormalSample.d.ts.map +0 -1
  305. package/src/engine/graphics/sh3/path_tracer/random_in_hemisphere.d.ts.map +0 -1
  306. package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.d.ts.map +0 -1
  307. /package/src/engine/graphics/sh3/path_tracer/{compute_triangle_group_aabb3.d.ts → geometry/compute_triangle_group_aabb3.d.ts} +0 -0
  308. /package/src/engine/graphics/sh3/path_tracer/{sample_triangle_attribute.d.ts → geometry/sample_triangle_attribute.d.ts} +0 -0
  309. /package/src/engine/graphics/sh3/path_tracer/{sample_triangle_attribute.js → geometry/sample_triangle_attribute.js} +0 -0
  310. /package/src/engine/graphics/sh3/path_tracer/{getBiasedNormalSample.d.ts → sampling/getBiasedNormalSample.d.ts} +0 -0
  311. /package/src/engine/graphics/sh3/path_tracer/{random_in_hemisphere.d.ts → sampling/random_in_hemisphere.d.ts} +0 -0
@@ -0,0 +1,80 @@
1
+ import Vector3 from "../Vector3.js";
2
+ import { v3_displace_in_direction } from "./v3_displace_in_direction.js";
3
+
4
+ test("zero distance", () => {
5
+
6
+ const r = new Vector3();
7
+
8
+ expect(v3_displace_in_direction(
9
+ r, 0,
10
+ 0, 0, 0,
11
+ 0, 0, 1
12
+ )).toBe(true);
13
+
14
+ });
15
+
16
+ test("direction magnitude is 0", () => {
17
+
18
+ const r = new Vector3();
19
+
20
+ expect(v3_displace_in_direction(
21
+ r, 1,
22
+ 0, 0, 0,
23
+ 0, 0, 0
24
+ )).toBe(false);
25
+
26
+ });
27
+
28
+ test("cardinal directions", () => {
29
+
30
+ const r = new Vector3();
31
+
32
+ expect(v3_displace_in_direction(
33
+ r, -3,
34
+ 1, 2, 3,
35
+ 0, 0, 1
36
+ )).toBe(true);
37
+
38
+ expect(r.asArray()).toEqual([1, 2, 0]);
39
+
40
+ expect(v3_displace_in_direction(
41
+ r, -3,
42
+ 1, 2, 3,
43
+ 0, 0, -1
44
+ )).toBe(true);
45
+
46
+ expect(r.asArray()).toEqual([1, 2, 6]);
47
+
48
+ expect(v3_displace_in_direction(
49
+ r, -3,
50
+ 1, 2, 3,
51
+ 0, 1, 0
52
+ )).toBe(true);
53
+
54
+ expect(r.asArray()).toEqual([1, -1, 3]);
55
+
56
+ expect(v3_displace_in_direction(
57
+ r, -3,
58
+ 1, 2, 3,
59
+ 0, -1, 0
60
+ )).toBe(true);
61
+
62
+ expect(r.asArray()).toEqual([1, 5, 3]);
63
+
64
+ expect(v3_displace_in_direction(
65
+ r, -3,
66
+ 1, 2, 3,
67
+ 1, 0, 0
68
+ )).toBe(true);
69
+
70
+ expect(r.asArray()).toEqual([-2, 2, 3]);
71
+
72
+ expect(v3_displace_in_direction(
73
+ r, -3,
74
+ 1, 2, 3,
75
+ -1, 0, 0
76
+ )).toBe(true);
77
+
78
+ expect(r.asArray()).toEqual([4, 2, 3]);
79
+
80
+ });
@@ -18,3 +18,5 @@ export function v3_dot_array_array(a, a_offset, b, b_offset) {
18
18
 
19
19
  return a_x * b_x + a_y * b_y + a_z * b_z;
20
20
  }
21
+
22
+
@@ -0,0 +1,10 @@
1
+ /**
2
+ *
3
+ * @param {number} x
4
+ * @param {number} y
5
+ * @param {number} z
6
+ * @param {number} w
7
+ * @returns {number}
8
+ */
9
+ export function v4_length(x: number, y: number, z: number, w: number): number;
10
+ //# sourceMappingURL=v4_length.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v4_length.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec4/v4_length.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,6BANW,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CAIlB"}
@@ -0,0 +1,13 @@
1
+ import { v4_length_sqr } from "./v4_length_sqr.js";
2
+
3
+ /**
4
+ *
5
+ * @param {number} x
6
+ * @param {number} y
7
+ * @param {number} z
8
+ * @param {number} w
9
+ * @returns {number}
10
+ */
11
+ export function v4_length(x, y, z, w) {
12
+ return Math.sqrt(v4_length_sqr(x, y, z, w));
13
+ }
@@ -8,4 +8,5 @@
8
8
  */
9
9
  export function v4_length_sqr(x, y, z, w) {
10
10
  return x * x + y * y + z * z + w * w;
11
- }
11
+ }
12
+
@@ -10,7 +10,22 @@ function roughly_equal_array_vectors(actual, expected) {
10
10
  }
11
11
  }
12
12
 
13
- test("sample", () => {
13
+ test("2x2 sample A", () => {
14
+
15
+
16
+ const t = new SquareMatrix(2, BinaryDataType.Float32);
17
+ t.fromArray([
18
+ 1,-2,
19
+ 5,-7
20
+ ]);
21
+
22
+ const eigen = matrix_eigenvalues_in_place(t);
23
+
24
+
25
+ roughly_equal_array_vectors(eigen, [-5.44949, -0.55051]);
26
+ });
27
+
28
+ test("3x3 sample A", () => {
14
29
 
15
30
 
16
31
  const t = new SquareMatrix(3, BinaryDataType.Float32);
@@ -25,3 +40,18 @@ test("sample", () => {
25
40
 
26
41
  roughly_equal_array_vectors(eigen, [9.62192181, -9.12030391, 3.4983821]);
27
42
  });
43
+ test("3x3 sample B", () => {
44
+
45
+
46
+ const t = new SquareMatrix(3, BinaryDataType.Float32);
47
+ t.fromArray([
48
+ 1, 2, 3,
49
+ 4, 5, 6,
50
+ 7, 8, 9
51
+ ]);
52
+
53
+ const eigen = matrix_eigenvalues_in_place(t);
54
+
55
+
56
+ roughly_equal_array_vectors(eigen, [16.1168, -1.11684, 0]);
57
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Machine epsilon, 2^(-53)
3
+ * @type {number}
4
+ */
5
+ export const FLT_EPSILON_64: number;
6
+ //# sourceMappingURL=FLT_EPSILON_64.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FLT_EPSILON_64.d.ts","sourceRoot":"","sources":["../../../../src/core/math/FLT_EPSILON_64.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,6BAFU,MAAM,CAEqC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Machine epsilon, 2^(-53)
3
+ * @type {number}
4
+ */
5
+ export const FLT_EPSILON_64 = 1.1102230246251565e-16;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  *
3
- * @param {number} sigma
4
- * @param {number} v
3
+ * @param {number} sigma distance from mean
4
+ * @param {number} v Variance
5
5
  * @returns {number}
6
6
  */
7
7
  export function gaussian(sigma: number, v: number): number;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  *
3
- * @param {number} sigma
4
- * @param {number} v
3
+ * @param {number} sigma distance from mean
4
+ * @param {number} v Variance
5
5
  * @returns {number}
6
6
  */
7
7
  export function gaussian(sigma, v) {
@@ -0,0 +1 @@
1
+ Linear Argebra package
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Factor linear equations Ax = b using LU decomposition A = LU where L is
3
+ * lower triangular matrix and U is upper triangular matrix. Input is
4
+ * square matrix A, integer array of pivot indices index[0->n-1], and size
5
+ * of square matrix n. Output factorization LU is in matrix A. If error is
6
+ * found, method returns 0.
7
+ * @param {number[]} A Square matrix, will be modified
8
+ * @param {number[]|Uint32Array} index will be written to
9
+ * @param {number} size Size of the matrix ( 4x4 matrix has size 4 )
10
+ * @returns {boolean}
11
+ */
12
+ export function lu_factor_linear_system(A: number[], index: number[] | Uint32Array, size: number): boolean;
13
+ //# sourceMappingURL=lu_factor_linear_system.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lu_factor_linear_system.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/linalg/lu_factor_linear_system.js"],"names":[],"mappings":"AAOA;;;;;;;;;;GAUG;AACH,2CALW,MAAM,EAAE,SACR,MAAM,EAAE,GAAC,WAAW,QACpB,MAAM,GACJ,OAAO,CA+FnB"}
@@ -0,0 +1,112 @@
1
+ import { assert } from "../../assert.js";
2
+
3
+ const SMALL_NUMBER = 1e-12;
4
+
5
+ const SCRATCH_SIZE = 16;
6
+ const scratch = new Float64Array(SCRATCH_SIZE);
7
+
8
+ /**
9
+ * Factor linear equations Ax = b using LU decomposition A = LU where L is
10
+ * lower triangular matrix and U is upper triangular matrix. Input is
11
+ * square matrix A, integer array of pivot indices index[0->n-1], and size
12
+ * of square matrix n. Output factorization LU is in matrix A. If error is
13
+ * found, method returns 0.
14
+ * @param {number[]} A Square matrix, will be modified
15
+ * @param {number[]|Uint32Array} index will be written to
16
+ * @param {number} size Size of the matrix ( 4x4 matrix has size 4 )
17
+ * @returns {boolean}
18
+ */
19
+ export function lu_factor_linear_system(A, index, size) {
20
+ assert.isNonNegativeInteger(size,'size');
21
+
22
+ // double scratch[10];
23
+ // double* scale = (size < 10 ? scratch : new double[size]);
24
+ //
25
+ // int i, j, k;
26
+ // int maxI = 0;
27
+ // double largest, temp1, temp2, sum;
28
+ //
29
+ // // Manage number of output warnings
30
+ // static int numWarns = 0;
31
+ //
32
+ // //
33
+
34
+ let i, j, k;
35
+ let maxI = 0;
36
+ let largest, temp1, temp2, sum;
37
+
38
+ const scale = size <= SCRATCH_SIZE ? scratch : new Float64Array(size);
39
+
40
+ // Loop over rows to get implicit scaling information
41
+ //
42
+ for (i = 0; i < size; ++i) {
43
+ for (largest = 0.0, j = 0; j < size; ++j) {
44
+ if ((temp2 = Math.abs(A[i * size + j])) > largest) {
45
+ largest = temp2;
46
+ }
47
+ }
48
+
49
+ if (largest === 0.0) {
50
+ // Unable to factor linear system
51
+
52
+ return false;
53
+ }
54
+ scale[i] = 1.0 / largest;
55
+ }
56
+ //
57
+ // Loop over all columns using Crout's method
58
+ //
59
+ for (j = 0; j < size; ++j) {
60
+ for (i = 0; i < j; ++i) {
61
+ sum = A[i * size + j];
62
+ for (k = 0; k < i; ++k) {
63
+ sum -= A[i * size + k] * A[k * size + j];
64
+ }
65
+ A[i * size + j] = sum;
66
+ }
67
+ //
68
+ // Begin search for largest pivot element
69
+ //
70
+ for (largest = 0.0, i = j; i < size; ++i) {
71
+ sum = A[i * size + j];
72
+ for (k = 0; k < j; ++k) {
73
+ sum -= A[i * size + k] * A[k * size + j];
74
+ }
75
+ A[i * size + j] = sum;
76
+
77
+ if ((temp1 = scale[i] * Math.abs(sum)) >= largest) {
78
+ largest = temp1;
79
+ maxI = i;
80
+ }
81
+ }
82
+ //
83
+ // Check for row interchange
84
+ //
85
+ if (j !== maxI) {
86
+ for (k = 0; k < size; ++k) {
87
+ temp1 = A[maxI * size + k];
88
+ A[maxI * size + k] = A[j * size + k];
89
+ A[j * size + k] = temp1;
90
+ }
91
+ scale[maxI] = scale[j];
92
+ }
93
+ //
94
+ // Divide by pivot element and perform elimination
95
+ //
96
+ index[j] = maxI;
97
+
98
+ if (Math.abs(A[j * size + j]) <= SMALL_NUMBER) {
99
+ // Unable to factor linear system
100
+ return false;
101
+ }
102
+
103
+ if (j !== (size - 1)) {
104
+ temp1 = 1.0 / A[j * size + j];
105
+ for (i = j + 1; i < size; ++i) {
106
+ A[i * size + j] *= temp1;
107
+ }
108
+ }
109
+ }
110
+
111
+ return true;
112
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Solve linear equations Ax = b using LU decomposition A = LU where L is
3
+ * lower triangular matrix and U is upper triangular matrix. Input is
4
+ * factored matrix A=LU, integer array of pivot indices index[0->n-1],
5
+ * load vector x[0->n-1], and size of square matrix n. Note that A=LU and
6
+ * index[] are generated from method LUFactorLinearSystem). Also, solution
7
+ * vector is written directly over input load vector.
8
+ * @param {number[]} A Square matrix
9
+ * @param {number[]|Uint32Array} index
10
+ * @param {number[]} x
11
+ * @param {number} size matrix size ( 4x4 matrix has size 4)
12
+ */
13
+ export function lu_solve_linear_system(A: number[], index: number[] | Uint32Array, x: number[], size: number): void;
14
+ //# sourceMappingURL=lu_solve_linear_system.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lu_solve_linear_system.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/linalg/lu_solve_linear_system.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,0CALW,MAAM,EAAE,SACR,MAAM,EAAE,GAAC,WAAW,KACpB,MAAM,EAAE,QACR,MAAM,QAsChB"}
@@ -0,0 +1,51 @@
1
+ import { assert } from "../../assert.js";
2
+
3
+ /**
4
+ * Solve linear equations Ax = b using LU decomposition A = LU where L is
5
+ * lower triangular matrix and U is upper triangular matrix. Input is
6
+ * factored matrix A=LU, integer array of pivot indices index[0->n-1],
7
+ * load vector x[0->n-1], and size of square matrix n. Note that A=LU and
8
+ * index[] are generated from method LUFactorLinearSystem). Also, solution
9
+ * vector is written directly over input load vector.
10
+ * @param {number[]} A Square matrix
11
+ * @param {number[]|Uint32Array} index
12
+ * @param {number[]} x
13
+ * @param {number} size matrix size ( 4x4 matrix has size 4)
14
+ */
15
+ export function lu_solve_linear_system(A, index, x, size) {
16
+ assert.isNonNegativeInteger(size, 'size');
17
+
18
+ let i = 0, j, ii = -1;
19
+
20
+ let sum;
21
+
22
+ // Proceed with forward and back-substitution for L and U matrices. First, forward substitution.
23
+ for (; i < size; ++i) {
24
+ const idx = index[i];
25
+ sum = x[idx];
26
+ x[idx] = x[i];
27
+
28
+ if (ii >= 0) {
29
+
30
+ for (j = ii; j <= i - 1; ++j) {
31
+ sum -= A[i * size + j] * x[j];
32
+ }
33
+
34
+ } else if (sum !== 0.0) {
35
+ ii = i;
36
+ }
37
+
38
+ x[i] = sum;
39
+ }
40
+
41
+ // Now, back substitution
42
+ for (i = size - 1; i >= 0; i--) {
43
+ sum = x[i];
44
+
45
+ for (j = i + 1; j < size; ++j) {
46
+ sum -= A[i * size + j] * x[j];
47
+ }
48
+
49
+ x[i] = sum / A[i * size + i];
50
+ }
51
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Solve linear equations Ax = b using Crout's method. Input is square matrix A and load vector b.
3
+ * Solution x is written over load vector.
4
+ * The dimension of the matrix is specified in size. If error is found, method returns a 0.
5
+ *
6
+ * @see https://github.com/Kitware/VTK/blob/af928016f4041ad8a6a193d032355b909721fc95/Common/Core/vtkMath.cxx
7
+ *
8
+ * @param {number[]|Float32Array|Float64Array} A
9
+ * @param {number[]|Float32Array|Float64Array} x
10
+ * @param {number} size
11
+ * @returns {boolean} true if solution found, false if factorization fails
12
+ */
13
+ export function solve_linear_system(A: number[] | Float32Array | Float64Array, x: number[] | Float32Array | Float64Array, size: number): boolean;
14
+ //# sourceMappingURL=solve_linear_system.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solve_linear_system.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/linalg/solve_linear_system.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;GAWG;AACH,uCALW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,KAClC,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,QAClC,MAAM,GACJ,OAAO,CAgCnB"}
@@ -0,0 +1,52 @@
1
+ import { assert } from "../../assert.js";
2
+ import { lu_factor_linear_system } from "./lu_factor_linear_system.js";
3
+ import { lu_solve_linear_system } from "./lu_solve_linear_system.js";
4
+ import { solve_linear_system_GEPP_2x2 } from "./solve_linear_system_GEPP_2x2.js";
5
+
6
+ const SCRATCH_SIZE = 16;
7
+ const scratch = new Uint32Array(SCRATCH_SIZE);
8
+
9
+ /**
10
+ * Solve linear equations Ax = b using Crout's method. Input is square matrix A and load vector b.
11
+ * Solution x is written over load vector.
12
+ * The dimension of the matrix is specified in size. If error is found, method returns a 0.
13
+ *
14
+ * @see https://github.com/Kitware/VTK/blob/af928016f4041ad8a6a193d032355b909721fc95/Common/Core/vtkMath.cxx
15
+ *
16
+ * @param {number[]|Float32Array|Float64Array} A
17
+ * @param {number[]|Float32Array|Float64Array} x
18
+ * @param {number} size
19
+ * @returns {boolean} true if solution found, false if factorization fails
20
+ */
21
+ export function solve_linear_system(A, x, size) {
22
+ assert.isNonNegativeInteger(size, 'size');
23
+ assert.defined(A, 'A');
24
+ assert.defined(x, 'x');
25
+
26
+ if (size === 1) {
27
+ if (A[0] === 0) {
28
+ // Unable to solve linear system
29
+ return false;
30
+ }
31
+
32
+ x[0] /= A[0];
33
+
34
+ return true;
35
+
36
+ } else if (size === 2) {
37
+
38
+ return solve_linear_system_GEPP_2x2(A, x, x);
39
+
40
+ }
41
+
42
+ const index = size <= SCRATCH_SIZE ? scratch : new Uint32Array(size);
43
+
44
+ if (lu_factor_linear_system(A, index, size) === false) {
45
+ return false;
46
+ }
47
+
48
+ lu_solve_linear_system(A, index, x, size);
49
+
50
+ return true;
51
+ }
52
+
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=solve_linear_system.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solve_linear_system.spec.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/linalg/solve_linear_system.spec.js"],"names":[],"mappings":""}
@@ -0,0 +1,70 @@
1
+ import { solve_linear_system } from "./solve_linear_system.js";
2
+
3
+ test("3 variables", () => {
4
+
5
+ /*
6
+
7
+ x + y + z = 6
8
+ 2x - y - x = -3
9
+ 3y - 2z = 0
10
+
11
+ */
12
+ const x = [6, -3, 0];
13
+
14
+ expect(solve_linear_system(
15
+ [
16
+ 1, 1, 1,
17
+ 2, -1, -1,
18
+ 0, 3, -2
19
+ ],
20
+ x,
21
+ 3
22
+ )).toBe(true);
23
+
24
+ expect(x).toEqual([1, 2, 3])
25
+
26
+ });
27
+
28
+ test("2 variables", () => {
29
+
30
+ /*
31
+
32
+ 2x + 7y = 34
33
+ 5x - 4y = -1
34
+
35
+ */
36
+ const x = [34, -1];
37
+
38
+ expect(solve_linear_system(
39
+ [
40
+ 2,7,
41
+ 5,-4
42
+ ],
43
+ x,
44
+ 2
45
+ )).toBe(true);
46
+
47
+ expect(x).toEqual([3,4])
48
+
49
+ });
50
+
51
+ test("1 variable", () => {
52
+
53
+ /*
54
+
55
+ 2x = -42
56
+
57
+ */
58
+ const x = [-42];
59
+
60
+ expect(solve_linear_system(
61
+ [
62
+ 2
63
+ ],
64
+ x,
65
+ 1
66
+ )).toBe(true);
67
+
68
+ expect(x).toEqual([-21])
69
+
70
+ });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Solve linear equation Ax = b using Gaussian Elimination with Partial Pivoting for a 2x2 system.
3
+ * If the matrix is found to be singular within a small numerical tolerance close to machine precision then 0 is returned.
4
+ * @param {number[]} A
5
+ * @param {number[]} x
6
+ * @param {number[]} b
7
+ * @returns {boolean}
8
+ */
9
+ export function solve_linear_system_GEPP_2x2(A: number[], x: number[], b: number[]): boolean;
10
+ //# sourceMappingURL=solve_linear_system_GEPP_2x2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solve_linear_system_GEPP_2x2.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/linalg/solve_linear_system_GEPP_2x2.js"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,gDALW,MAAM,EAAE,KACR,MAAM,EAAE,KACR,MAAM,EAAE,GACN,OAAO,CA6EnB"}
@@ -0,0 +1,91 @@
1
+ import { array_swap_one } from "../../collection/array/array_swap_one.js";
2
+ import { fabsf } from "../fabsf.js";
3
+ import { FLT_EPSILON_64 } from "../FLT_EPSILON_64.js";
4
+
5
+ // Note the choice of eps is reasonable but somewhat arbitrary.
6
+ const epsilon = 256 * FLT_EPSILON_64;
7
+
8
+ /**
9
+ * Solve linear equation Ax = b using Gaussian Elimination with Partial Pivoting for a 2x2 system.
10
+ * If the matrix is found to be singular within a small numerical tolerance close to machine precision then 0 is returned.
11
+ * @param {number[]} A
12
+ * @param {number[]} x
13
+ * @param {number[]} b
14
+ * @returns {boolean}
15
+ */
16
+ export function solve_linear_system_GEPP_2x2(A, x, b) {
17
+
18
+ // Check if any of the matrix coefficients is zero.
19
+ // If so then swap rows/columns to form an upper triangular matrix without having to use GEPP.
20
+ let cols_swapped = false;
21
+ if (A[0] === 0 || A[1] === 0 || A[2] === 0 || A[3] === 0) {
22
+
23
+ // zero in either row of the 2nd column?
24
+ if (A[1] === 0 || A[3] === 0) {
25
+ // swap columns
26
+ array_swap_one(A, 0, 1);
27
+ array_swap_one(A, 2, 3);
28
+
29
+ cols_swapped = true;
30
+ }
31
+
32
+ // zero in a00?
33
+ if (A[0] === 0) {
34
+ // swap rows
35
+ array_swap_one(A, 0, 2);
36
+ array_swap_one(A, 1, 3);
37
+ array_swap_one(b, 0, 1);
38
+ }
39
+
40
+ } else {
41
+
42
+ // None of the matrix coefficients are exactly zero.
43
+ // Use GEPP to form upper triangular matrix, i.e. so that a10 == 0.
44
+ // Select pivot by looking at largest absolute value in a00, a10
45
+ if (fabsf(A[0]) < fabsf(A[2])) {
46
+ // swap rows so the largest coefficient in first column is in the first row
47
+ array_swap_one(A, 0, 2);
48
+ array_swap_one(A, 1, 3);
49
+ array_swap_one(b, 0, 1);
50
+ }
51
+
52
+ const f = -A[2] / A[0];
53
+
54
+ A[3] += A[1] * f;
55
+ b[1] += b[0] * f;
56
+
57
+ }
58
+
59
+ // Have now an exact zero in a10.
60
+ // Need to check for singularity by looking at a11.
61
+
62
+ if (fabsf(A[3]) < epsilon) {
63
+ // matrix is singular within small numerical tolerance
64
+ return false;
65
+ }
66
+
67
+ // Solve the triangular system
68
+ if (A[3] !== 0) {
69
+ x[1] = b[1] / A[3];
70
+ } else {
71
+ return false;
72
+ }
73
+
74
+ if (A[0] !== 0) {
75
+ x[0] = (b[0] - A[1] * x[1]) / A[0];
76
+ } else {
77
+ return false;
78
+ }
79
+
80
+ // other failures in solution?
81
+ if (!Number.isFinite(x[0]) || !Number.isFinite(x[1])) {
82
+ return false;
83
+ }
84
+
85
+ // If necessary swap solution vector rows.
86
+ if (cols_swapped) {
87
+ array_swap_one(x, 0, 1);
88
+ }
89
+
90
+ return true;
91
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"solveQuadratic.d.ts","sourceRoot":"","sources":["../../../../src/core/math/solveQuadratic.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,uCAJW,MAAM,EAAE,iBACR,MAAM,KAJN,MAAM,KACN,MAAM,KACN,MAAM,GAGJ,MAAM,CAqClB"}
1
+ {"version":3,"file":"solveQuadratic.d.ts","sourceRoot":"","sources":["../../../../src/core/math/solveQuadratic.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,uCAJW,MAAM,EAAE,iBACR,MAAM,KAJN,MAAM,KACN,MAAM,KACN,MAAM,GAGJ,MAAM,CAuClB"}