Skip to content

fixing Julia code and embedding latest video #702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions contents/IFS/IFS.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,17 @@ Which brings us to another topic entirely: restricted chaos games.
Discussing restricted chaos games in more detail is a chapter in its own right, so I will forego the discussion here.
If you are interested, please let me know and I will be more than willing to add the chapter in the future!

## Video Explanation

Here is a video describing iterated function systems:


<div style="text-align:center">
<iframe width="560" height="315" src="https://www.youtube.com/embed/nIIp-vo8rHg"
frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; pic
ture-in-picture" allowfullscreen></iframe>
</div>

## Example Code

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.
Expand Down
13 changes: 7 additions & 6 deletions contents/IFS/code/julia/IFS.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
using DelimitedFiles

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

# Initializing the output array and the initial point
out = zeros(n,2)
output_points = zeros(n,2)
point = [rand(), rand()]

for i = 1:n
out[i,:] .= point
output_points[i,:] .= point
point = 0.5*(rand(shape_points) .+ point)
end

writedlm(output_file, out)
return output_points

end

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