Skip to content

Commit 839cc53

Browse files
authored
Update README.md
Minor edits for clarity. Grouped chaos theory and recursive math examples together. Removed note about `camera.type` needing to be updated after RayLib 3.7 after code review of all examples.
1 parent a04b81e commit 839cc53

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

README.md

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,36 @@
11
# RayLib-Examples
22
Some fun math or physics demos made easy with [RayLib](https://github.com/raysan5/raylib)
33

4-
Note that the examples with GUIs also require [RayGui](https://github.com/raysan5/raygui), an optional companion to RayLib that is super-easy to install. Older examples may need to be updated because of a breaking change in raylib 3.7. If you get `camera.type` error, simply change `camera.type` to `camera.projection`
4+
Note that the examples with GUIs also require [RayGui](https://github.com/raysan5/raygui), an optional companion to RayLib that is super-easy to install.
55

66
## Water Sim: Ripple Tank Physics
77
Simulates water in a ripple tank. Demonstrates basic wave mechanics: wave reflection, diffraction, and superimposition.
88

99
Press "P" to pause the simulation and "R" to reset it. Left-click to add a drop to the pool, or left-click and drag to run your finger through the water. Right-click to draw boundaries. Hold "E" while right-clicking to erase them. Hold X to draw a straight-line boundary across the x-axis. Hold Z for z-axis. Hold X and E to erase a whole line. Alter the code to add as many colored floating spheres as you'd like, or none.
10+
1011
![Water Ripple Tank Sim](images/water.gif)
1112

13+
14+
## Raindrop simulator
15+
Simulates raindrops coalescing and falling down a window pane, which I've always found beautiful.
16+
Raindrops 2.0 brings improved collision detection with much faster performance. Large, fast drops now leave streaks of droplets behind them on the glass. Drop shape now changes with velocity. The number below the frame rate is the number of drops in the simulation. You can alter the code to change drop size and frequency.
17+
![Raindrops](images/raindrops.gif)
18+
19+
20+
## Audio Oscilloscope and Frequency Analyzer
21+
Loads a wave file, plays it, and provides the following in real time:
22+
23+
In Red: Time-domain plot of audio amplitude (oscilloscope)
24+
25+
In Orange: Discrete Fast Fourier Transform of audio sample (Frequency domain plot) to Nyquist frequency, with peak dots
26+
27+
In Blue: The above, but gathered into logarithmically spaced bins which better indicate musical octaves, with peak bars
28+
29+
The code provides multiple windowing functions for the DFFT: Hann, Hamming, Blackman-Harris, Flat-top and Dolph-Chebyshev windows. The latter is enabled by default, since it gives narrowest frequency resolution with flat sidelobe response.
30+
Still a work-in-progress!
31+
![Audio Analyzer](images/Audio2.png)
32+
33+
1234
## Strange Attractor:
1335
Plots the Clifford Pickover attractor, a point cloud in 3D space.
1436

@@ -18,11 +40,13 @@ Check boxes allow you to cycle through two parameters gradually to see the chang
1840

1941
![Clifford Strange Attractor](images/StrangeAttractor1.png)
2042

43+
2144
## Lorenz Attractor:
2245
Plots the Lorenz attractor using lines in 3D space. Use X, Y, Z controls to specify the initial point, which shows that the system is indeed an attractor. One of the earliest "strange attractors" in chaos theory.
2346

2447
![Lorenz Attractor](images/Lorenz.png)
2548

49+
2650
## Prime Viewer:
2751
Four ways to visualize the distribution of all primes less than 1,000,000. Press 1, 2, 3 or 4 to change view modes.
2852
* Mode 1: Plots primes as semi-transparent white cubes on a 100x100x100 grid. Rotate and pan the view to see rows of numbers eliminated.
@@ -32,13 +56,15 @@ Four ways to visualize the distribution of all primes less than 1,000,000. Pres
3256

3357
![View Mode 2](images/PrimeViewer2.png)
3458

59+
3560
## 3D Sierpinsky Triangles IFS
3661
Uses an Iterated Function System to generate a 3D Sierpinski triangle. (Technically, a pyramid, I suppose...)
3762
IFS = a recursive system of affine transformations applied to random starting points, which converge to the final shape.
3863
The shape is fractal, although visualization is limited by resolution.
3964

4065
![Sierpinski Triangles](images/Sierpinski-Triangles1.png)
4166

67+
4268
## 3D Bifurcation Diagram of the Logistic Map
4369
Plots the values of the logistic map recursive equation: x=kx*(1-x), x={0,1.0} against various values of K.
4470
This simple equation is historically important in the history of chaos theory because it was believed to be well-behaved, since for many values of k, the recursion converges to a single value of x after a few iterations. Only later was discovered values of K for which the system alternates between two or more values. As can be seen from the diagram, some values of K produce wild results.
@@ -49,28 +75,17 @@ The data is two dimensional only, but I used a 3D view because it provided an ea
4975

5076
![Bifurcation Normal Display](images/Bifurc1small.png) ![Bifurcation Alt View](images/Bifurc2small.png)
5177

52-
## Raindrop simulator
53-
Simulates raindrops coalescing and falling down a window pane, which I've always found beautiful.
54-
The code isn't pretty; I was experimenting with C++ classes. Raindrops 2.0 brings improved collision detection with much faster performance. Large, fast drops now leave streaks of droplets behind them on the glass. Drop shape now changes with velocity. Number below the frame rate is the number of drops in the simulation. You can alter the code to change drop size and frequency.
55-
![Raindrops](images/raindrops.gif)
5678

5779
## Koch Curve
5880
Generates a Koch Curve a/k/a Koch "Snowflake" by starting with an equilateral triangle, then trisecting each line, and building a smaller equilateral triangle on the middle third of each line. The process is then repeated recursively. Beyond 8 levels of recursion, the results are no longer visible, but the shape is rather complex. Koch Curves have interesting properties as the number of recursions grows to infinity. The area converges to a finite area. The perimeter, however, grows unbounded, to infinity. As a result, in the limit case, one has a figure with infinite perimeter surrounding a finite area, and thus an area to perimeter ratio of zero! You can select the number of recursions using the slider. Clicking the "analysis" checkbox will display values for the perimeter, area and area/perimeter ratio for your selected level of recursion, together with the limit values, so you can compare. A simple circle inscribing the figure helps to emphasize that the area will always be finite at higher recursion levels: the figure never grows outside the circle, even though its border grows longer exponentially.
5981
![Koch Curve](images/KochCurve1.png)
6082

61-
## Audio Oscilloscope and Frequency Analyzer
62-
Loads a wave file, plays it, and provides the following in real time:
63-
In Red: Time-domain plot of audio amplitude (oscilloscope)
64-
In Orange: Discrete Fast Fourier Transform of audio sample (Frequency domain plot) to Nyquist frequency, with peak dots
65-
In Blue: The above, but gathered into logarithmically spaced bins which better indicate musical octaves, with peak bars
66-
The code provides multiple windowing functions for the DFFT: Hann, Hamming, Blackman-Harris, Flat-top and Dolph-Chebyshev windows. The latter is enabled by default, since it gives narrowest frequency resolution with flat sidelobe response.
67-
Still a work-in-progress!
68-
![Audio Analyzer](images/Audio2.png)
6983

7084
## Apollonian Gasket Generator
7185
Some simple code to generate an Apollonian Gasket: a fractal that recursively packs a space with tangential circles.
7286
![Apollonian Gasket](images/ApollonianGasket.png)
7387

88+
7489
## Linear Interpolation between Cartesian and Polar coordinates
75-
Lerp *all* the things! Quick and dirty l-interp between two sets of points: sine function plotted against a Cartesian grid to polar. There are certainly more elegant ways to do this, but I just made it because I wondered what a gradual tranformation to polar would look like. Much smoother in the program, but I had to keep the file size down.
90+
Lerp *all* the things! Quick and dirty linear interpolation between two sets of points. The first shows a sine function plotted in yellow upon a Cartesian grid. The second shows the same function plotted against polar coordinates. There are certainly more elegant ways to do this. I made it simply because I wondered what a gradual tranformation to polar would look like. It looks much smoother in the program, but I had to keep the image file size down.
7691
![Lerp Cartesian to Polar](images/polerp2.gif)

0 commit comments

Comments
 (0)