Skip to content

Commit d46b897

Browse files
authored
fixing Julia code and embedding latest video (#702)
1 parent c134159 commit d46b897

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

contents/IFS/IFS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,17 @@ Which brings us to another topic entirely: restricted chaos games.
173173
Discussing restricted chaos games in more detail is a chapter in its own right, so I will forego the discussion here.
174174
If you are interested, please let me know and I will be more than willing to add the chapter in the future!
175175

176+
## Video Explanation
177+
178+
Here is a video describing iterated function systems:
179+
180+
181+
<div style="text-align:center">
182+
<iframe width="560" height="315" src="https://www.youtube.com/embed/nIIp-vo8rHg"
183+
frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; pic
184+
ture-in-picture" allowfullscreen></iframe>
185+
</div>
186+
176187
## Example Code
177188

178189
For the code in this chapter, we have decided to write it specifically for the Chaos game, not the hutchinson animations shown at the start of the chapter.

contents/IFS/code/julia/IFS.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
using DelimitedFiles
22

33
# This is a function to simulate a "chaos game"
4-
function chaos_game(n::Int, shape_points; output_file="out.dat")
4+
function chaos_game(n::Int, shape_points)
55

66
# Initializing the output array and the initial point
7-
out = zeros(n,2)
7+
output_points = zeros(n,2)
88
point = [rand(), rand()]
99

1010
for i = 1:n
11-
out[i,:] .= point
11+
output_points[i,:] .= point
1212
point = 0.5*(rand(shape_points) .+ point)
1313
end
1414

15-
writedlm(output_file, out)
16-
15+
return output_points
16+
1717
end
1818

1919
# This will generate a Sierpinski triangle with a chaos game of n points for an
@@ -25,4 +25,5 @@ end
2525
shape_points = [[0.0, 0.0],
2626
[0.5, sqrt(0.75)],
2727
[1.0, 0.0]]
28-
chaos_game(10000, shape_points)
28+
output_points = chaos_game(10000, shape_points)
29+
writedlm("out.dat", output_points)

0 commit comments

Comments
 (0)