hyperstellar 0.1.61__tar.gz → 0.1.63__tar.gz

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 (22) hide show
  1. {hyperstellar-0.1.61 → hyperstellar-0.1.63}/LICENSE +1 -1
  2. hyperstellar-0.1.63/PKG-INFO +372 -0
  3. hyperstellar-0.1.63/README.md +330 -0
  4. {hyperstellar-0.1.61 → hyperstellar-0.1.63}/hyperstellar/src/hyperstellar/__init__.pyi +1 -88
  5. {hyperstellar-0.1.61 → hyperstellar-0.1.63}/hyperstellar/src/hyperstellar/_native/windows-x64/shaders/math.comp +2054 -1517
  6. {hyperstellar-0.1.61 → hyperstellar-0.1.63}/hyperstellar/src/hyperstellar/_native/windows-x64/shaders/quad.geom +156 -156
  7. {hyperstellar-0.1.61 → hyperstellar-0.1.63}/hyperstellar/src/hyperstellar/_native/windows-x64/shaders/quad.vert +38 -38
  8. hyperstellar-0.1.63/hyperstellar/src/hyperstellar/_native/windows-x64/stellar.pyd +0 -0
  9. hyperstellar-0.1.63/hyperstellar/src/hyperstellar.egg-info/PKG-INFO +372 -0
  10. {hyperstellar-0.1.61 → hyperstellar-0.1.63}/pyproject.toml +1 -9
  11. hyperstellar-0.1.61/PKG-INFO +0 -124
  12. hyperstellar-0.1.61/README.md +0 -82
  13. hyperstellar-0.1.61/hyperstellar/src/hyperstellar/_native/windows-x64/stellar.pyd +0 -0
  14. hyperstellar-0.1.61/hyperstellar/src/hyperstellar.egg-info/PKG-INFO +0 -124
  15. {hyperstellar-0.1.61 → hyperstellar-0.1.63}/hyperstellar/src/hyperstellar/__init__.py +0 -0
  16. {hyperstellar-0.1.61 → hyperstellar-0.1.63}/hyperstellar/src/hyperstellar/_native/windows-x64/shaders/quad.frag +0 -0
  17. {hyperstellar-0.1.61 → hyperstellar-0.1.63}/hyperstellar/src/hyperstellar/py.typed +0 -0
  18. {hyperstellar-0.1.61 → hyperstellar-0.1.63}/hyperstellar/src/hyperstellar.egg-info/SOURCES.txt +0 -0
  19. {hyperstellar-0.1.61 → hyperstellar-0.1.63}/hyperstellar/src/hyperstellar.egg-info/dependency_links.txt +0 -0
  20. {hyperstellar-0.1.61 → hyperstellar-0.1.63}/hyperstellar/src/hyperstellar.egg-info/top_level.txt +0 -0
  21. {hyperstellar-0.1.61 → hyperstellar-0.1.63}/setup.cfg +0 -0
  22. {hyperstellar-0.1.61 → hyperstellar-0.1.63}/tests/test.py +0 -0
@@ -1,4 +1,4 @@
1
- MIT License
1
+ MIT License
2
2
 
3
3
  Copyright (c) 2024 desktop-hnrtra0\user
4
4
  MIT License
@@ -0,0 +1,372 @@
1
+ Metadata-Version: 2.4
2
+ Name: hyperstellar
3
+ Version: 0.1.63
4
+ Summary: GPU-accelerated physics simulation engine
5
+ Author-email: Aiden Jabari <Jabariaiden15@email.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2024 desktop-hnrtra0\user
9
+ MIT License
10
+
11
+ Copyright (c) 2025 Void_unleashed
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+
31
+ Keywords: physics,simulation,gpu,opengl
32
+ Classifier: Development Status :: 3 - Alpha
33
+ Classifier: Intended Audience :: Science/Research
34
+ Classifier: License :: OSI Approved :: MIT License
35
+ Classifier: Operating System :: Microsoft :: Windows
36
+ Classifier: Programming Language :: Python :: 3.13
37
+ Classifier: Topic :: Scientific/Engineering :: Physics
38
+ Requires-Python: >=3.13
39
+ Description-Content-Type: text/markdown
40
+ License-File: LICENSE
41
+ Dynamic: license-file
42
+
43
+ # Hyperstellar
44
+ ### Write math Equations in python
45
+
46
+ Buckle up, because this isn't just another preset physics engine. Hyperstellar gives you the mathematical language to define *any* dynamical system, then GPU accelerates it to thousands of frames per second. From orbital mechanics to fluid dynamics, if you can write the equation, you can simulate it.
47
+
48
+ <p align="center">
49
+ <img src="media/orbit.gif" alt="Two-Body Orbital System">
50
+ </p>
51
+
52
+ ## Why Hyperstellar?
53
+ Most Python simulation tools make you choose between ease and performance. CPU-based libraries (NumPy, SciPy) are easy but slow. GPU tools (CUDA, Taichi, Warp) are fast but require learning new languages or shader programming.
54
+ Hyperstellar gives you both: write plain Python, get GPU performance.
55
+
56
+ | | Hyperstellar | NumPy (CPU) | Taichi | NVIDIA Warp |
57
+ |---|---|---|---|---|
58
+ | Write in Python | yes | yes | no (own lang) | yes (decorators) |
59
+ | No shader code | yes | yes | yes | yes |
60
+ | Real-time visualization | yes built-in | no | partial | no |
61
+ | Visual editor app | yes(in testing) | no | no | no |
62
+ | Collision system | yes | no | no | partial |
63
+ | pip install | yes | yes | yes | yes |
64
+
65
+ ## Performance
66
+
67
+ Tested on integrated graphics(thats iGPU, no dedicated GPU):
68
+
69
+ | Objects | FPS |
70
+ |---|---|
71
+ | 1,000 | ~60 fps |
72
+ | 5,000 | ~52 fps |
73
+
74
+ Each object is running a per-frame force equation on the GPU. This is not pre-baked animation; it's live physics computation.
75
+
76
+ ## Installation
77
+ ```bash
78
+ pip install hyperstellar
79
+ ```
80
+ Platform Note: The current release (0.1.x) supports Windows 10/11 (64-bit). Linux support is in development - Linux users can build from source using the project files.
81
+
82
+ ## Quick Start
83
+ ### planetary rotation
84
+ ```python
85
+ import hyperstellar as se
86
+ import math
87
+
88
+ sim = se.Simulation(headless=False, enable_grid=False)
89
+ while not sim.are_all_shaders_ready(): # A one time GPU initialization (required before simulation)
90
+ sim.update_shader_loading()
91
+ while sim.object_count() > 0: # Remove default object
92
+ sim.remove_object(0)
93
+
94
+ G, M_star, M_planet, sep = 1.0, 50.0, 1.0, 3.0
95
+ v_orbit = math.sqrt(G * (M_star + M_planet) / sep)
96
+
97
+ # Create star and planet
98
+ star = sim.add_object(x=0, y=0, vy=M_planet*v_orbit/(M_star+M_planet),
99
+ mass=M_star, skin=se.SkinType.CIRCLE, size=0.8)
100
+ planet = sim.add_object(x=sep, y=0, vy=-M_star*v_orbit/(M_star+M_planet),
101
+ mass=M_planet, skin=se.SkinType.CIRCLE, size=0.25)
102
+
103
+ # Gravitational force equations (ax, ay, angular, r, g, b, a)
104
+ sim.set_equation(star,
105
+ f"{G}*{M_planet}*(p[1].x-x)/((p[1].x-x)^2+(p[1].y-y)^2)^1.5," # Newtonian gravity equation using object reference p[index]
106
+ f"{G}*{M_planet}*(p[1].y-y)/((p[1].x-x)^2+(p[1].y-y)^2)^1.5,"
107
+ "0, 1.0, 0.9, 0.3, 1.0" # Yellow
108
+ )
109
+ sim.set_equation(planet,
110
+ f"{G}*{M_star}*(p[0].x-x)/((p[0].x-x)^2+(p[0].y-y)^2)^1.5,"
111
+ f"{G}*{M_star}*(p[0].y-y)/((p[0].x-x)^2+(p[0].y-y)^2)^1.5,"
112
+ "0, 0.3, 0.6, 1.0, 1.0" # Blue
113
+ )
114
+
115
+
116
+
117
+ while not sim.should_close():
118
+ sim.update(0.016)
119
+ sim.render()
120
+ sim.process_input()
121
+ ```
122
+
123
+ ### Bouncing Ball
124
+ ```python
125
+ import hyperstellar as se
126
+
127
+ sim = se.Simulation(headless=False, enable_grid=False, width=1400, height=1000, title="Collision Test")
128
+ while not sim.are_all_shaders_ready():
129
+ sim.update_shader_loading() # Wait for shaders to load before proceeding
130
+ while sim.object_count() > 0:
131
+ sim.remove_object(0) # Clear default objects
132
+
133
+ ball = sim.add_object(x=0, y=20, vy=0,
134
+ mass=0.1, skin=se.SkinType.CIRCLE, size=0.8)
135
+ platform = sim.add_object(x=0, y=-1, vy=0,
136
+ mass=1e12, skin=se.SkinType.RECTANGLE, height=3.0, width=10.0)
137
+
138
+ sim.set_collision_properties(ball, restitution=0.8, friction=0.5)
139
+ sim.set_collision_properties(platform, restitution=0.7, friction=0.5)
140
+ sim.set_collision_shape(platform, se.CollisionShape.AABB)
141
+ sim.set_collision_shape(ball, se.CollisionShape.CIRCLE)
142
+
143
+ sim.set_equation(ball, f"0, -9.8, 0, 1.0, 0.3, 0.3, 1.0")
144
+ sim.set_equation(platform, f"0, 0, 0, 0.3, 1.0, 1.0, 1.0")
145
+
146
+ while not sim.should_close():
147
+ sim.update(0.067)
148
+ sim.render()
149
+ sim.process_input() #use wsad to move the camera left and right
150
+
151
+ ```
152
+
153
+ ### 50,000 Ring of death (GPU benchmark)
154
+
155
+ ```python
156
+ import hyperstellar as se
157
+ import math
158
+
159
+ N = 50000
160
+ dt = 0.0006
161
+ sim = se.Simulation(headless=False)
162
+ while not sim.are_all_shaders_ready():
163
+ sim.update_shader_loading()
164
+ while sim.object_count() > 0:
165
+ sim.remove_object(0)
166
+
167
+ spacing = 0.4
168
+ R = (N * spacing) / (2 * math.pi)
169
+ K, V = 1.5, math.sqrt(1.5 * R)
170
+ offset_x = R
171
+
172
+ for i in range(N):
173
+ angle = (i / N) * 2 * math.pi
174
+ x = math.cos(angle) * R + offset_x
175
+ y = math.sin(angle) * R
176
+ vx = -math.sin(angle) * V
177
+ vy = math.cos(angle) * V
178
+ obj = sim.add_object(x=x, y=y, vx=vx, vy=vy, size=0.15)
179
+ sim.set_collision_enabled(obj, False)
180
+ sim.set_equation(obj, f"-(x-{offset_x})*{K/R}, -y*{K/R}, 0, 0.5, 0.2, 1.0, 1.0")
181
+
182
+ while not sim.should_close():
183
+ sim.update(dt)
184
+ sim.render()
185
+ sim.process_input()
186
+ ```
187
+
188
+
189
+
190
+ ## Core Concepts
191
+
192
+
193
+ ### Equation Format
194
+
195
+ Every object's behavior is defined by a comma-separated equation string with 7 components:
196
+
197
+ ```
198
+ "ax, ay, angular, r, g, b, a"
199
+ ```
200
+
201
+ Only `ax` and `ay` are required. All other components are optional and default to `0` (for angular) or `1.0` (for color channels).
202
+
203
+ ---
204
+
205
+ #### Available Variables
206
+
207
+ These variables represent the current object's state and can be used directly in any equation:
208
+
209
+ | Variable | Meaning |
210
+ |---|---|
211
+ | `x`, `y` | Position |
212
+ | `vx`, `vy` | Velocity |
213
+ | `ax`, `ay` | Acceleration |
214
+ | `theta` | Rotation angle |
215
+ | `omega` | Angular velocity |
216
+ | `alpha` | Angular acceleration |
217
+ | `mass` | Object mass |
218
+ | `charge` | Object charge |
219
+ | `r`, `g`, `b`, `a` | Current color (RGBA) |
220
+ | `h`, `s`, `v` | Color in HSV space |
221
+ | `t` | Simulation time |
222
+ | `i` | Imaginary unit (complex numbers supported) |
223
+ | `pi`, `e` | Mathematical constants |
224
+ | `k` | Spring/coupling constant |
225
+ | `damping` | Damping coefficient |
226
+ | `gravity` | Gravitational constant |
227
+ | `coupling` | Coupling strength |
228
+ | `freq`, `amp` | Frequency, amplitude |
229
+
230
+ ---
231
+
232
+ #### Object References
233
+
234
+ Reference other objects in the simulation using `p[index].property`:
235
+
236
+ ```python
237
+ # Gravity from object 0 pulling on the current object
238
+ sim.set_equation(planet,
239
+ f"{G}*(p[0].x - x) / ((p[0].x-x)^2 + (p[0].y-y)^2)^1.5,"
240
+ f"{G}*(p[0].y - y) / ((p[0].x-x)^2 + (p[0].y-y)^2)^1.5,"
241
+ "0, 0.3, 0.6, 1.0, 1.0"
242
+ )
243
+ ```
244
+
245
+ All readable properties on `p[index]`:
246
+
247
+ | Property | Meaning |
248
+ |---|---|
249
+ | `p[i].x`, `p[i].y` | Position |
250
+ | `p[i].vx`, `p[i].vy` | Velocity |
251
+ | `p[i].ax`, `p[i].ay` | Acceleration |
252
+ | `p[i].mass` | Mass |
253
+ | `p[i].charge` | Charge |
254
+ | `p[i].data.x` | Rotation |
255
+ | `p[i].data.y` | Angular velocity |
256
+ | `p[i].color.r`, `p[i].color.g`, `p[i].color.b`, `p[i].color.a` | Color state |
257
+
258
+ ---
259
+
260
+ #### Built-in Functions
261
+
262
+ All functions run natively on the GPU:
263
+
264
+ **Single-argument:**
265
+ `sin`, `cos`, `tan`, `sqrt`, `log`, `exp`, `abs`, `floor`, `ceil`, `frac`, `sign`, `step`
266
+
267
+ **Two-argument:**
268
+ `min(a, b)`, `max(a, b)`, `mod(a, b)`, `atan2(y, x)`
269
+
270
+ **Three-argument:**
271
+ `clamp(x, min, max)`
272
+
273
+ **Complex number:**
274
+ `real(z)`, `imag(z)`, `conj(z)`, `arg(z)`
275
+
276
+ **Operators:**
277
+ `+`, `-`, `*`, `/`, `^` (power, right-associative: `2^3^2` = `2^(3^2)`)
278
+
279
+ ---
280
+
281
+ #### Derivatives
282
+
283
+ Compute numerical derivatives of any expression on the GPU using `D(expr, variable, order)`:
284
+
285
+ ```python
286
+ # First derivative of x^2 with respect to x
287
+ sim.set_equation(obj, "D(x^2, x, 1), 0, 0, 1.0, 1.0, 1.0, 1.0")
288
+
289
+ # Second derivative (order defaults to 1 if omitted)
290
+ sim.set_equation(obj, "D(sin(x), x, 2), 0, 0, 1.0, 1.0, 1.0, 1.0")
291
+ ```
292
+
293
+ Valid differentiation variables: `x`, `y`, `theta`
294
+
295
+ Order must be between 1 and 4.
296
+
297
+ ---
298
+
299
+ #### Color as Simulation State
300
+
301
+ Color channels (`r, g, b, a`) are not just rendering — they are part of the live simulation state per object, updated every frame on the GPU. You can make color depend on velocity, position, or any other variable:
302
+
303
+ ```python
304
+ # Color shifts from blue to red based on speed
305
+ speed = "sqrt(vx^2 + vy^2)"
306
+ sim.set_equation(obj, f"0, -3, 0, {speed}/10, 0.3, 1.0-{speed}/10, 1.0")
307
+ ```
308
+
309
+ ### Headless Mode
310
+
311
+ Run without a window for data collection or batch processing:
312
+
313
+ ```python
314
+ sim = se.Simulation(headless=True)
315
+ # ... setup ...
316
+ while True:
317
+ sim.update(dt)
318
+ height = sim.get_object(ball).y # read state back to Python
319
+ ```
320
+
321
+ ### Collision System
322
+
323
+ ```python
324
+ sim.set_collision_parameters(enabled=True, iterations=20)
325
+ sim.set_collision_shape(obj, se.CollisionShape.CIRCLE) # or AABB
326
+ sim.set_collision_properties(obj, restitution=0.9, friction=0.5)
327
+ sim.set_collision_enabled(obj, True)
328
+ ```
329
+
330
+ ### Constraints
331
+ Lock relationships between objects.
332
+ - `sim.add_boundary_constraint(object_index, se.BoundaryConstraint(min_x, max_x, min_y, max_y))`
333
+ - `sim.add_distance_constraint(object_index, se.DistanceConstraint(target_object, rest_length))`
334
+
335
+ ### Shapes / Skins
336
+ - `se.SkinType.CIRCLE`
337
+ - `se.SkinType.RECTANGLE`
338
+ - `se.SkinType.POLYGON`
339
+
340
+ ### Collision Shapes
341
+ - `se.CollisionShape.POLYGON`
342
+ - `se.CollisionShape.CIRCLE`
343
+ - `se.CollisionShape.AABB`
344
+
345
+ ## The App
346
+
347
+ Hyperstellar ships with a **visual editor** built in ImGui. You can build and configure simulations visually, save your project, and load it back — similar to how Unity and Visual Studio relate to each other. The Python API and the app work on the same project format. Though it is publicly available through the building of project files.
348
+
349
+ ## Examples
350
+
351
+ | Example | Description |
352
+ |---|---|
353
+ | `examples/orbit.py` | Two-body Newtonian gravity |
354
+ | `examples/pendulum.py` | Spring-based harmonic motion |
355
+ | `examples/boids.py` | Emergent flocking with obstacle avoidance |
356
+ | `examples/mcmc.py` | Metropolis-Hastings sampling on GPU |
357
+
358
+ ## Roadmap
359
+
360
+ - [ ] Linux official release
361
+ - [ ] More collision shapes (OBB, convex polygon)
362
+ - [ ] Full constraints system
363
+ - [ ] API reference documentation
364
+ - [ ] More examples
365
+
366
+ ## Contributing
367
+
368
+ Contributions welcome — code, documentation, examples, and bug reports all help. See the source in `src/bindings.cpp` for the current full API surface while formal docs are in progress.
369
+
370
+ ## License
371
+
372
+ See [LICENSE](LICENSE).
@@ -0,0 +1,330 @@
1
+ # Hyperstellar
2
+ ### Write math Equations in python
3
+
4
+ Buckle up, because this isn't just another preset physics engine. Hyperstellar gives you the mathematical language to define *any* dynamical system, then GPU accelerates it to thousands of frames per second. From orbital mechanics to fluid dynamics, if you can write the equation, you can simulate it.
5
+
6
+ <p align="center">
7
+ <img src="media/orbit.gif" alt="Two-Body Orbital System">
8
+ </p>
9
+
10
+ ## Why Hyperstellar?
11
+ Most Python simulation tools make you choose between ease and performance. CPU-based libraries (NumPy, SciPy) are easy but slow. GPU tools (CUDA, Taichi, Warp) are fast but require learning new languages or shader programming.
12
+ Hyperstellar gives you both: write plain Python, get GPU performance.
13
+
14
+ | | Hyperstellar | NumPy (CPU) | Taichi | NVIDIA Warp |
15
+ |---|---|---|---|---|
16
+ | Write in Python | yes | yes | no (own lang) | yes (decorators) |
17
+ | No shader code | yes | yes | yes | yes |
18
+ | Real-time visualization | yes built-in | no | partial | no |
19
+ | Visual editor app | yes(in testing) | no | no | no |
20
+ | Collision system | yes | no | no | partial |
21
+ | pip install | yes | yes | yes | yes |
22
+
23
+ ## Performance
24
+
25
+ Tested on integrated graphics(thats iGPU, no dedicated GPU):
26
+
27
+ | Objects | FPS |
28
+ |---|---|
29
+ | 1,000 | ~60 fps |
30
+ | 5,000 | ~52 fps |
31
+
32
+ Each object is running a per-frame force equation on the GPU. This is not pre-baked animation; it's live physics computation.
33
+
34
+ ## Installation
35
+ ```bash
36
+ pip install hyperstellar
37
+ ```
38
+ Platform Note: The current release (0.1.x) supports Windows 10/11 (64-bit). Linux support is in development - Linux users can build from source using the project files.
39
+
40
+ ## Quick Start
41
+ ### planetary rotation
42
+ ```python
43
+ import hyperstellar as se
44
+ import math
45
+
46
+ sim = se.Simulation(headless=False, enable_grid=False)
47
+ while not sim.are_all_shaders_ready(): # A one time GPU initialization (required before simulation)
48
+ sim.update_shader_loading()
49
+ while sim.object_count() > 0: # Remove default object
50
+ sim.remove_object(0)
51
+
52
+ G, M_star, M_planet, sep = 1.0, 50.0, 1.0, 3.0
53
+ v_orbit = math.sqrt(G * (M_star + M_planet) / sep)
54
+
55
+ # Create star and planet
56
+ star = sim.add_object(x=0, y=0, vy=M_planet*v_orbit/(M_star+M_planet),
57
+ mass=M_star, skin=se.SkinType.CIRCLE, size=0.8)
58
+ planet = sim.add_object(x=sep, y=0, vy=-M_star*v_orbit/(M_star+M_planet),
59
+ mass=M_planet, skin=se.SkinType.CIRCLE, size=0.25)
60
+
61
+ # Gravitational force equations (ax, ay, angular, r, g, b, a)
62
+ sim.set_equation(star,
63
+ f"{G}*{M_planet}*(p[1].x-x)/((p[1].x-x)^2+(p[1].y-y)^2)^1.5," # Newtonian gravity equation using object reference p[index]
64
+ f"{G}*{M_planet}*(p[1].y-y)/((p[1].x-x)^2+(p[1].y-y)^2)^1.5,"
65
+ "0, 1.0, 0.9, 0.3, 1.0" # Yellow
66
+ )
67
+ sim.set_equation(planet,
68
+ f"{G}*{M_star}*(p[0].x-x)/((p[0].x-x)^2+(p[0].y-y)^2)^1.5,"
69
+ f"{G}*{M_star}*(p[0].y-y)/((p[0].x-x)^2+(p[0].y-y)^2)^1.5,"
70
+ "0, 0.3, 0.6, 1.0, 1.0" # Blue
71
+ )
72
+
73
+
74
+
75
+ while not sim.should_close():
76
+ sim.update(0.016)
77
+ sim.render()
78
+ sim.process_input()
79
+ ```
80
+
81
+ ### Bouncing Ball
82
+ ```python
83
+ import hyperstellar as se
84
+
85
+ sim = se.Simulation(headless=False, enable_grid=False, width=1400, height=1000, title="Collision Test")
86
+ while not sim.are_all_shaders_ready():
87
+ sim.update_shader_loading() # Wait for shaders to load before proceeding
88
+ while sim.object_count() > 0:
89
+ sim.remove_object(0) # Clear default objects
90
+
91
+ ball = sim.add_object(x=0, y=20, vy=0,
92
+ mass=0.1, skin=se.SkinType.CIRCLE, size=0.8)
93
+ platform = sim.add_object(x=0, y=-1, vy=0,
94
+ mass=1e12, skin=se.SkinType.RECTANGLE, height=3.0, width=10.0)
95
+
96
+ sim.set_collision_properties(ball, restitution=0.8, friction=0.5)
97
+ sim.set_collision_properties(platform, restitution=0.7, friction=0.5)
98
+ sim.set_collision_shape(platform, se.CollisionShape.AABB)
99
+ sim.set_collision_shape(ball, se.CollisionShape.CIRCLE)
100
+
101
+ sim.set_equation(ball, f"0, -9.8, 0, 1.0, 0.3, 0.3, 1.0")
102
+ sim.set_equation(platform, f"0, 0, 0, 0.3, 1.0, 1.0, 1.0")
103
+
104
+ while not sim.should_close():
105
+ sim.update(0.067)
106
+ sim.render()
107
+ sim.process_input() #use wsad to move the camera left and right
108
+
109
+ ```
110
+
111
+ ### 50,000 Ring of death (GPU benchmark)
112
+
113
+ ```python
114
+ import hyperstellar as se
115
+ import math
116
+
117
+ N = 50000
118
+ dt = 0.0006
119
+ sim = se.Simulation(headless=False)
120
+ while not sim.are_all_shaders_ready():
121
+ sim.update_shader_loading()
122
+ while sim.object_count() > 0:
123
+ sim.remove_object(0)
124
+
125
+ spacing = 0.4
126
+ R = (N * spacing) / (2 * math.pi)
127
+ K, V = 1.5, math.sqrt(1.5 * R)
128
+ offset_x = R
129
+
130
+ for i in range(N):
131
+ angle = (i / N) * 2 * math.pi
132
+ x = math.cos(angle) * R + offset_x
133
+ y = math.sin(angle) * R
134
+ vx = -math.sin(angle) * V
135
+ vy = math.cos(angle) * V
136
+ obj = sim.add_object(x=x, y=y, vx=vx, vy=vy, size=0.15)
137
+ sim.set_collision_enabled(obj, False)
138
+ sim.set_equation(obj, f"-(x-{offset_x})*{K/R}, -y*{K/R}, 0, 0.5, 0.2, 1.0, 1.0")
139
+
140
+ while not sim.should_close():
141
+ sim.update(dt)
142
+ sim.render()
143
+ sim.process_input()
144
+ ```
145
+
146
+
147
+
148
+ ## Core Concepts
149
+
150
+
151
+ ### Equation Format
152
+
153
+ Every object's behavior is defined by a comma-separated equation string with 7 components:
154
+
155
+ ```
156
+ "ax, ay, angular, r, g, b, a"
157
+ ```
158
+
159
+ Only `ax` and `ay` are required. All other components are optional and default to `0` (for angular) or `1.0` (for color channels).
160
+
161
+ ---
162
+
163
+ #### Available Variables
164
+
165
+ These variables represent the current object's state and can be used directly in any equation:
166
+
167
+ | Variable | Meaning |
168
+ |---|---|
169
+ | `x`, `y` | Position |
170
+ | `vx`, `vy` | Velocity |
171
+ | `ax`, `ay` | Acceleration |
172
+ | `theta` | Rotation angle |
173
+ | `omega` | Angular velocity |
174
+ | `alpha` | Angular acceleration |
175
+ | `mass` | Object mass |
176
+ | `charge` | Object charge |
177
+ | `r`, `g`, `b`, `a` | Current color (RGBA) |
178
+ | `h`, `s`, `v` | Color in HSV space |
179
+ | `t` | Simulation time |
180
+ | `i` | Imaginary unit (complex numbers supported) |
181
+ | `pi`, `e` | Mathematical constants |
182
+ | `k` | Spring/coupling constant |
183
+ | `damping` | Damping coefficient |
184
+ | `gravity` | Gravitational constant |
185
+ | `coupling` | Coupling strength |
186
+ | `freq`, `amp` | Frequency, amplitude |
187
+
188
+ ---
189
+
190
+ #### Object References
191
+
192
+ Reference other objects in the simulation using `p[index].property`:
193
+
194
+ ```python
195
+ # Gravity from object 0 pulling on the current object
196
+ sim.set_equation(planet,
197
+ f"{G}*(p[0].x - x) / ((p[0].x-x)^2 + (p[0].y-y)^2)^1.5,"
198
+ f"{G}*(p[0].y - y) / ((p[0].x-x)^2 + (p[0].y-y)^2)^1.5,"
199
+ "0, 0.3, 0.6, 1.0, 1.0"
200
+ )
201
+ ```
202
+
203
+ All readable properties on `p[index]`:
204
+
205
+ | Property | Meaning |
206
+ |---|---|
207
+ | `p[i].x`, `p[i].y` | Position |
208
+ | `p[i].vx`, `p[i].vy` | Velocity |
209
+ | `p[i].ax`, `p[i].ay` | Acceleration |
210
+ | `p[i].mass` | Mass |
211
+ | `p[i].charge` | Charge |
212
+ | `p[i].data.x` | Rotation |
213
+ | `p[i].data.y` | Angular velocity |
214
+ | `p[i].color.r`, `p[i].color.g`, `p[i].color.b`, `p[i].color.a` | Color state |
215
+
216
+ ---
217
+
218
+ #### Built-in Functions
219
+
220
+ All functions run natively on the GPU:
221
+
222
+ **Single-argument:**
223
+ `sin`, `cos`, `tan`, `sqrt`, `log`, `exp`, `abs`, `floor`, `ceil`, `frac`, `sign`, `step`
224
+
225
+ **Two-argument:**
226
+ `min(a, b)`, `max(a, b)`, `mod(a, b)`, `atan2(y, x)`
227
+
228
+ **Three-argument:**
229
+ `clamp(x, min, max)`
230
+
231
+ **Complex number:**
232
+ `real(z)`, `imag(z)`, `conj(z)`, `arg(z)`
233
+
234
+ **Operators:**
235
+ `+`, `-`, `*`, `/`, `^` (power, right-associative: `2^3^2` = `2^(3^2)`)
236
+
237
+ ---
238
+
239
+ #### Derivatives
240
+
241
+ Compute numerical derivatives of any expression on the GPU using `D(expr, variable, order)`:
242
+
243
+ ```python
244
+ # First derivative of x^2 with respect to x
245
+ sim.set_equation(obj, "D(x^2, x, 1), 0, 0, 1.0, 1.0, 1.0, 1.0")
246
+
247
+ # Second derivative (order defaults to 1 if omitted)
248
+ sim.set_equation(obj, "D(sin(x), x, 2), 0, 0, 1.0, 1.0, 1.0, 1.0")
249
+ ```
250
+
251
+ Valid differentiation variables: `x`, `y`, `theta`
252
+
253
+ Order must be between 1 and 4.
254
+
255
+ ---
256
+
257
+ #### Color as Simulation State
258
+
259
+ Color channels (`r, g, b, a`) are not just rendering — they are part of the live simulation state per object, updated every frame on the GPU. You can make color depend on velocity, position, or any other variable:
260
+
261
+ ```python
262
+ # Color shifts from blue to red based on speed
263
+ speed = "sqrt(vx^2 + vy^2)"
264
+ sim.set_equation(obj, f"0, -3, 0, {speed}/10, 0.3, 1.0-{speed}/10, 1.0")
265
+ ```
266
+
267
+ ### Headless Mode
268
+
269
+ Run without a window for data collection or batch processing:
270
+
271
+ ```python
272
+ sim = se.Simulation(headless=True)
273
+ # ... setup ...
274
+ while True:
275
+ sim.update(dt)
276
+ height = sim.get_object(ball).y # read state back to Python
277
+ ```
278
+
279
+ ### Collision System
280
+
281
+ ```python
282
+ sim.set_collision_parameters(enabled=True, iterations=20)
283
+ sim.set_collision_shape(obj, se.CollisionShape.CIRCLE) # or AABB
284
+ sim.set_collision_properties(obj, restitution=0.9, friction=0.5)
285
+ sim.set_collision_enabled(obj, True)
286
+ ```
287
+
288
+ ### Constraints
289
+ Lock relationships between objects.
290
+ - `sim.add_boundary_constraint(object_index, se.BoundaryConstraint(min_x, max_x, min_y, max_y))`
291
+ - `sim.add_distance_constraint(object_index, se.DistanceConstraint(target_object, rest_length))`
292
+
293
+ ### Shapes / Skins
294
+ - `se.SkinType.CIRCLE`
295
+ - `se.SkinType.RECTANGLE`
296
+ - `se.SkinType.POLYGON`
297
+
298
+ ### Collision Shapes
299
+ - `se.CollisionShape.POLYGON`
300
+ - `se.CollisionShape.CIRCLE`
301
+ - `se.CollisionShape.AABB`
302
+
303
+ ## The App
304
+
305
+ Hyperstellar ships with a **visual editor** built in ImGui. You can build and configure simulations visually, save your project, and load it back — similar to how Unity and Visual Studio relate to each other. The Python API and the app work on the same project format. Though it is publicly available through the building of project files.
306
+
307
+ ## Examples
308
+
309
+ | Example | Description |
310
+ |---|---|
311
+ | `examples/orbit.py` | Two-body Newtonian gravity |
312
+ | `examples/pendulum.py` | Spring-based harmonic motion |
313
+ | `examples/boids.py` | Emergent flocking with obstacle avoidance |
314
+ | `examples/mcmc.py` | Metropolis-Hastings sampling on GPU |
315
+
316
+ ## Roadmap
317
+
318
+ - [ ] Linux official release
319
+ - [ ] More collision shapes (OBB, convex polygon)
320
+ - [ ] Full constraints system
321
+ - [ ] API reference documentation
322
+ - [ ] More examples
323
+
324
+ ## Contributing
325
+
326
+ Contributions welcome — code, documentation, examples, and bug reports all help. See the source in `src/bindings.cpp` for the current full API surface while formal docs are in progress.
327
+
328
+ ## License
329
+
330
+ See [LICENSE](LICENSE).