An open API service indexing awesome lists of open source software.

https://github.com/wendtpiotr/procedural-lorenz-attractor

An interactive Lorenz attractor simulator in Unity, designed to explore chaos, the butterfly effect, and velocity dynamics in a visually intuitive way.
https://github.com/wendtpiotr/procedural-lorenz-attractor

chaos-theory lorenz-attractor physics-simulation rk4-algorithm unity3d

Last synced: 12 days ago
JSON representation

An interactive Lorenz attractor simulator in Unity, designed to explore chaos, the butterfly effect, and velocity dynamics in a visually intuitive way.

Awesome Lists containing this project

README

          

# ๐ŸŒ€ Lorenz Attractor Visualizer
image

An interactive **Lorenz attractor simulator** in Unity ๐ŸŽฎ, designed to explore chaos, the butterfly effect, and velocity dynamics in a visually intuitive way.

https://github.com/user-attachments/assets/76d7efe5-4e04-4267-96d2-44bbb219e8cf

https://github.com/user-attachments/assets/95d4b545-8f63-478f-89a7-17e371ebb23c

---

## ๐Ÿ”ฌ Features

- **Numerical Integration:** Uses **RK4** (Runge-Kutta 4th order) for accurate time evolution of the Lorenz system.
- **Dynamic Mesh Rendering:** The attractor trail is drawn with a **Mesh** rather than a LineRenderer for performance (even with 25k+ points).
- **Per-Point Velocity Coloring:**
Visualize instantaneous **velocity magnitude** along the trail using a customizable **Gradient** ๐ŸŽจ.
- **Butterfly Effect Mode ๐Ÿฆ‹:**
Slight rounding of initial conditions demonstrates **sensitive dependence on initial conditions** โ€” chaos in action!
- **Compare Two Attractors:**
Spawn multiple attractors (normal vs. butterfly-effect) to observe **divergence over time**.
- **Orbit Camera:**
Smooth, mouse-controlled orbit camera that automatically centers on the active attractor points.

---

## โš™๏ธ Usage

1. **Setup Attractor:**
- Create a **ScriptableObject** (`LorenzAttractorSettings`) for each attractor.
- Configure:
- `timeStep`
- `initialPosition`
- `maxPoints`
- `velocityGradient`
- `enableButterflyEffect` โœ… to apply rounding to initial conditions.

2. **Add Attractor to Scene:**
- Attach `LorenzAttractor.cs` to a GameObject.
- Assign the corresponding `LorenzAttractorSettings`.

3. **Camera Setup:**
- Attach `OrbitCamera.cs` to your main camera.
- Set `target` to one of the Lorenz attractor GameObjects.
- Enable `Use Dynamic Center` to follow the attractor trail.

4. **Visual Exploration:**
- Drag the mouse to rotate the camera.
- Scroll to zoom in/out.
- Watch attractors diverge in real time, colored by velocity magnitude.

---

## ๐Ÿ“Š Scientific Notes

- The Lorenz system is defined by:

\[
\begin{cases}
\frac{dx}{dt} = \sigma (y - x) \\
\frac{dy}{dt} = x (\rho - z) - y \\
\frac{dz}{dt} = xy - \beta z
\end{cases}
\]

with typical parameters:
`ฯƒ = 10`, `ฯ = 28`, `ฮฒ = 8/3`.

- **Butterfly Effect:** Small differences in initial conditions (here via rounding) grow exponentially, illustrating chaotic dynamics.
- **Velocity Visualization:**
Each vertex is colored according to the **magnitude of its instantaneous derivative**, showing where the system moves faster or slower in 3D space.

---

## ๐Ÿงฉ Scripts

- `LorenzAttractor.cs` โ€” Generates and updates the attractor mesh in real-time.
- `LorenzAttractorEquationsSolver.cs` โ€” Implements RK4 integration and derivative calculation.
- `LorenzAttractorSettings.cs` โ€” ScriptableObject storing parameters, including butterfly effect option.
- `OrbitCamera.cs` โ€” Smooth orbit camera centered on the attractorโ€™s active points.

---

## ๐Ÿš€ Demo Ideas

- Spawn two attractors:
- One normal
- One with butterfly effect enabled
- Observe divergence over time ๐Ÿฆ‹.
- Experiment with gradient coloring to highlight **high-velocity regions**.
- Increase `maxPoints` for high-resolution trails.

---

## ๐Ÿ’ป Requirements

- Unity 2023+ (or compatible version)
- Standard 3D pipeline
- Optional: HDRP/URP for improved visuals