Coding Challenge #129: Koch Fractal Snowflake

preview_player
Показать описание


References:

Videos:

Related Coding Challenges:

Timestamps:
0:00 Introducing today's topic
0:36 Koch curve algorithm
2:20 Create a Segment class
4:40 Add an array list of segments
5:10 Draw the segments
8:24 Divide segment by 3
0:00 Rotate to get the "hat"
12:50 Write a function to add the children to the segments
14:18 Use mousePressed() to get a new generation of segments
16:00 Why is the Koch curve called the "Monster Curve"?
19:11 Add a triangle
20:59 Conclusion and creative possibilities
21:47 Bonus addendum: use height of equilateral triangle to find 3rd point

Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound

#kochcurve #fractals #kochsnowflake #processing
Рекомендации по теме
Комментарии
Автор

20:02 Haha! That moment when you get your code right on the first compile. Feels so good!

lubaka
Автор

Hey!! I did an assignment on this exact Fractal in my Calc I Course for my first year of University! We found that the area of the whole shape is [2*sqrt(3)*s²]/5 (when starting with a triangle), and that it’s perimeter is the limit as n -> ∞ of 3s(4/3)^n, where s is the initial sidelength and n is the iteration through, starting at 0. I’m very excited to finally see a coding challenge about something I’m familiar with!! :D

mattshnoop
Автор

"I will refactor this later" AKA programmer's code for 'it'll be like that forever, because I've got better things to do than fix stuff that mostly works" XD

KuraIthys
Автор

Mathematicians and Programmers are the only people on the internet that welcome snowflakes

hammer_ttk
Автор

16:00 you could actually accomplish the same result with such function:
f(x)=sin(a*x)
where a->infinity
The sine wave will be more "squeezed", proportionally to the 'a' parameter, resulting in infinite length of the curve in a finite space (for example 2 PI).
Of course there are many more examples, but this is a little bit easier to explain, because most people know how a sine wave looks like.

adamsero
Автор

For the coding part and doing it "functional". You have an Input Line and a function that takes a Single input line and gives you 4 lines back. So function is like "Line -> Line list". You just run your function on every line and collect all result into a new list. You just repeat that step as how often you want your recursion to happen.

David_Raab
Автор

You are the BEST programmer I know...
I wish that i could be soo good at programming.

Kind regards from Austria

EDIT:
Thank you so much for the ❤

mariomatschgi
Автор

Every next step, you divide the curve by 3, and multiply the length by 4! Since you do that every step, they get multiplied together, so the length of one side is (4/3)^n
Since lim n->inf+ a^n goes to infinity for a > 1, the length of one side goes to infinity, and therefore the whole perimeter!

ganster
Автор

I would honestly buy that jumper / sweater in a heartbeat if I could. Great video, thanks!

jdawg
Автор

Never find someone in france that can make coding fun for everyone ! thank you to bring that part of my life at a funnier step for other people !

yonnitabeling
Автор

You are an inspiration. Most enthusiastic and entertaining programmer I've ever seen.

hathibelagalproductions
Автор

I didn't know the videos were distributed first through the "The Coding Train" website :o

Tatubanana
Автор

Great video! P.S. addAll takes only arraylists as a parameter so you need to make the array a list first by doing Arrays.asList(myArray)

gamingbutnotreally
Автор

Koch is a very difficult name for native English speakers :D Check it out in google translator with german or swiss as language and let google say it - i believe the "ch" gets pronounced in a way that most english speaking people dont know :)
Amazing Video! I had to program this Koch Snowflake in my first year of highschool with the python turtle :D brings back highschool memories ^^

CutyCupy
Автор

Congratulations on 700k keep up the great work!

lironmeler
Автор

If you start with the equilateral triangle, the infinite curve surrounds a finite area.

bokkenka
Автор

I dont know how to code at all and i am still completely hypnotized by your videos. Keep it up. Much love from sweden <3

putte
Автор

You don't need an infinite amount of ink. When i pour a single drop of ink on a sheet its probably fills out more than needed. Now think of it as removing ink to create the structure. You now can basically remove ink up to infinity, but it never will come to zero.

David_Raab
Автор

Nice coding video tutorials ...
You all videos are very very helpful
thanks for making these videos

princeshukla
Автор

Wouldn't this be a perfect example for recursive objects where the show function either draws a line (no children generated yet), or calls the show function of it's children

krazykowsr