Coding the Hilbert Curve

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 พ.ย. 2024

ความคิดเห็น • 263

  • @anthonycannet1305
    @anthonycannet1305 4 ปีที่แล้ว +173

    Catchphrase: “I’ll see you at the next stop”
    Like how trains stop at each station

    • @coolankush100
      @coolankush100 4 ปีที่แล้ว +6

      The thought is beautiful and wholesome. Hope Coding Train adopts it.

  • @silviugrada3561
    @silviugrada3561 4 ปีที่แล้ว +139

    please keep doing these. You are the reason I started to genuinely enjoy programming :))

    • @amund8767
      @amund8767 4 ปีที่แล้ว +16

      They way he get things wrong really help me to not feel so anxious by making mistakes on my own projects. He Just makes mistakes look "fun" that really motivates me to pickup old projects from earlier

    • @pixelpox11
      @pixelpox11 4 ปีที่แล้ว +5

      @@amund8767 I can relate. Truly the Bob Ross of programming.

  • @generic6ixty5ive
    @generic6ixty5ive 4 ปีที่แล้ว +76

    This may be the single best series out there

  • @CrashingThunder
    @CrashingThunder 4 ปีที่แล้ว +258

    "Nobody is watching this on a television"
    Yeah, about that...

    • @Diamonddrake
      @Diamonddrake 4 ปีที่แล้ว +4

      CrashingThunder me too

    • @TheLostSorcerer
      @TheLostSorcerer 4 ปีที่แล้ว +4

      Using my TV as a second monitor so yea...

    • @TheBytesCode
      @TheBytesCode 4 ปีที่แล้ว +2

      Came here to say this.

    • @KeithKritselis
      @KeithKritselis 4 ปีที่แล้ว +3

      Ditto, thanks Roku. 😁

    • @brmveen56
      @brmveen56 4 ปีที่แล้ว +2

      Here, here.

  • @arnavsirigere2877
    @arnavsirigere2877 4 ปีที่แล้ว +48

    I watched 3blue1brown's video on the Hilbert curve a while ago........ I can already tell this video is gonna be fun

  • @oshgnacknak72
    @oshgnacknak72 4 ปีที่แล้ว +54

    Catchphrase: Remind me to refactor this later, bye

  • @ruben_meerman
    @ruben_meerman 10 หลายเดือนก่อน +2

    I love your enthusiasm Mister Shiffman! This is wonderful

  • @SkyeMpuremagic
    @SkyeMpuremagic ปีที่แล้ว +3

    I'm not even a programmer and I enjoyed watching this from beginning to end! Even lifted my spirits a bit because the coder has such a bright and fun personality. Loved the finished result. Screenshot it so I could share it with others. Thank you for this!

    • @TheCodingTrain
      @TheCodingTrain  ปีที่แล้ว +1

      How did you find this video?

    • @SkyeMpuremagic
      @SkyeMpuremagic ปีที่แล้ว

      @@TheCodingTrain It was recommended to me. I'm into studying a bunch of things. Mathematics/physics... Weird mysticism stuff 😆
      I watched a numberphile video on The Hilbert Curve and I think that's why it was recommended by TH-cam for me 🤷
      I'm really interested in watching lectures on topology & geometric knots. 😅
      I get around LOL!

  • @szymoniak75
    @szymoniak75 4 ปีที่แล้ว +12

    I love the fact you are always happy and smiling it's so cheering

  • @MrSyNRG
    @MrSyNRG ปีที่แล้ว +4

    he cordially codes in the cold cabana, regardless of the condensation conundrum

  • @CSGOClips12
    @CSGOClips12 4 ปีที่แล้ว +4

    wow, i was watching 3b1b's video literally 30mins before this got uploaded, and wanted to draw it in processing and now u post this, that's amazing.

  • @catapillie
    @catapillie 4 ปีที่แล้ว +14

    This is so sweet!
    I'm also very excited for the new nature of code series!
    Keep up man :)

  • @johanrojassoderman5590
    @johanrojassoderman5590 4 ปีที่แล้ว +16

    17:00
    float len = order;
    v.x += order
    ...
    Yep, seems about right xD

  • @wilstaley9479
    @wilstaley9479 4 ปีที่แล้ว +4

    Love how the animation finishes right at the end of the video!

  • @amund8767
    @amund8767 4 ปีที่แล้ว +50

    "Nobody is watching this on a televison"
    I feel attacked

    • @TheCodingTrain
      @TheCodingTrain  4 ปีที่แล้ว +37

      As usual I’m terribly misguided in my understand of the world!

    • @GrinyaPLAY
      @GrinyaPLAY 4 ปีที่แล้ว +2

      I prefer TV to watch the coding train too! David, can I ask you to make video about different splines, but not Bézier curves?! Thanks!

    • @reyariass
      @reyariass 4 ปีที่แล้ว

      I’m watching this on tv too! Blast it on my speakers so the neighbors can be interested! (Just kidding on that last bit)

  • @lalit_096
    @lalit_096 2 ปีที่แล้ว +1

    love the way you code ...

  • @anasadeelallawala4156
    @anasadeelallawala4156 4 ปีที่แล้ว +2

    Who could possibly dislike such a wonderful video like this. Thumbs up to you Dan!

  • @live_destin-3408
    @live_destin-3408 4 ปีที่แล้ว +7

    "You guys are probably screeming at you're television, nobodys watching this on television..."
    well umm Im actully doing both... my dog thinks im crazy

  • @D00FY98
    @D00FY98 3 ปีที่แล้ว

    These videos are amazing. I used to hate coding but after watching and following along with a few of your vids I’m starting to love it. There’s so many Amazing possibilities!

  • @monsieuralexandergulbu3678
    @monsieuralexandergulbu3678 4 ปีที่แล้ว

    it’s so homely, it’s so nice to see and hear you, keep shooting the video, and keep your joy to yourself always!

  • @AntonPanchishin
    @AntonPanchishin 4 ปีที่แล้ว

    Great video, I love the very personal feel of the cabana!! It is fantastic that you show the whole process of coding, including planning, research, errors, and debugging.

  • @truthteller4689
    @truthteller4689 4 ปีที่แล้ว +91

    Your catchphrase should be: "Goodbye, and don't forget the this dot."

    • @gabrielmoreno4135
      @gabrielmoreno4135 4 ปีที่แล้ว +1

      And after that, a "Choo choo!". That would be the perfect catchphrase!

    • @qcdiamond8292
      @qcdiamond8292 4 ปีที่แล้ว +1

      Meh

    • @jaredbowen827
      @jaredbowen827 4 ปีที่แล้ว

      Drop "the" , then it would be better.

  • @redhen
    @redhen 4 ปีที่แล้ว +4

    Perhaps a random catch-phrase generator is in need :) Perhaps the excitement this would bring at the end of each episode would be too overwhelming, however.
    Thanks for the maths, Uncle Shiffles x

  • @olbluelips
    @olbluelips 4 ปีที่แล้ว

    I love your Coding in the Cabana series! It's really like how I program for fun -- just play around with math, noise, cellular automata, and procedural generation in a creative/artistic way. It's soo much fun and every once in a while you discover something really cool! :)

  • @sanderbos4243
    @sanderbos4243 4 ปีที่แล้ว +3

    Loved the editing on this episode!

  • @scottstensland
    @scottstensland 7 หลายเดือนก่อน

    funny how I instinctively guessed this was filmed in Brooklyn by seeing the opening snowing scene --- Brooklyn just has a unique architectural look --- justifiably nonplus yet pervasive block after block

  • @alikellaway3901
    @alikellaway3901 2 ปีที่แล้ว +1

    I know this video is fairly old now; I implemented this in java with java fx recently for a project (super helpful video, thank you!).
    I found you get a really cool fractal effect if you draw the order 8 curve in 1024x1024 window and only draw the line if the point you are drawing's index modulus 1.5 is 0. You get some really cool and wacky effects if you change the order or the 1.5 to other values. Take a look and let me know what you think!
    private void draw() {
    for (int i = 1; I < path.length; i++) { // Start at one so we can draw backwards.
    double hue = map(i, path.length);
    gc.setStroke(Color.hsb(hue, 1, 1));
    try { // Draw the line
    if (i % 1.5 != 0) {
    gc.strokeLine(path[i].getX(), path[i].getY(), path[i - 1].getX(), path[i - 1].getY());
    }
    } catch (IndexOutOfBoundsException ignored) {
    }

    }
    }
    private double map(float coordinateIndex, float maxIndex) {
    return (coordinateIndex/maxIndex) * 360; // Note that when using the hue value in the hsb method, it will loop round to red
    }
    Not sure where I can post an image of it so that's why I am dumping here. Let me know if you try it or where I could post the result!
    P.S. This is not my actual draw function, this is a simplified version since I had to optimise mine for an AnimationTimer class.

  • @rasenmaher7666
    @rasenmaher7666 4 ปีที่แล้ว

    Actuallly, the nice thing about the Hilbert Curve is that u can map every Point of an INFINITE plane to one single scalar. When just counting line by line, u already couldn't count the second line, because those values are infinite, cause the first row is infinite. Nice video :D

  • @timh.6872
    @timh.6872 4 ปีที่แล้ว +1

    I know it's not the Processing way, but I think this curve drawing is worth revisiting recursively. In particular, the 3b1b videos on the towers of hanoi and sierpinski's triangle have a really neat perspective on the recursion.
    In this case, we're counting in base 4, with a flourish of rotation and translation thrown in between the subtasks. I don't know if processing can cleanly express that idea, but I'd love to see the more pure, if less perfomant, solution.

  • @turzim_uai
    @turzim_uai 4 ปีที่แล้ว +1

    Hey, just saw all the Cabana videos today, and I loved them all! Maybe the next one could be a tutorial on how to plant all those beautiful flowers from the previous episodes! The timing couldn't be better, since you guys at the northern hemisphere are entering Spring haha. Cheers!

  • @Ouro17
    @Ouro17 4 ปีที่แล้ว

    Wonderfully explained! Thank you so much and please! Keep warm! I suffered watching you coding in that cold!

  • @deadmusik9969
    @deadmusik9969 4 ปีที่แล้ว

    telling me to hold on and wait a minute, like im just barely listening to you over my typing, just coding away, ha no im in amazement ha. love this

  • @mikenguyen9826
    @mikenguyen9826 4 ปีที่แล้ว

    love this series. very soothing and calming, especially in my moments of feebleness. thank you.

  • @stellanadais
    @stellanadais ปีที่แล้ว

    I watched on my TV, great coding, I had fun, thanks!

  • @ThePiGuy24
    @ThePiGuy24 4 ปีที่แล้ว +3

    I have a suggestion for the catch phrase: "I will see you in the next iteration!"

  • @deansundquist9601
    @deansundquist9601 4 ปีที่แล้ว

    Watching this during the summer in the middle of the corona virus, makes the cabana and snow look very enjoyable at this time.

  • @akhilkaushik7348
    @akhilkaushik7348 3 ปีที่แล้ว

    I tried Hilbert curve in Unity, transforming it to Hilbert maze, Really beautiful to dive into this amazing maze , I skip one wall each time randomly choosen So that even I, have no idea where the exit could be.
    Thanks Daniel for this beautiful video.

  • @Djzaamir
    @Djzaamir 4 ปีที่แล้ว

    Thank you for making programming so much fun. I have learned so many maths concepts from your coding videos. Thank you much :)

  • @RickeyBowers
    @RickeyBowers 4 ปีที่แล้ว

    L => +RF-LFL-FR+
    R => -LF+RFR+FL-
    Where * means to change the direction of rotation and (.) period means to rotate. L needs to be rotation & direction neutral, or fixups would be required after each L. Splitting the rotate operator allowed further optimization because the first four symbols repeat. Leading to:
    L => RRL.F*L.*
    R => *.LF

  • @RandomHamster
    @RandomHamster 4 ปีที่แล้ว +4

    Wow that looks really cold!

  • @BillyBob-tr5cv
    @BillyBob-tr5cv 4 ปีที่แล้ว +7

    I have never been this early. I just randomly watch coding videos and whelp here I am lol

  • @truthteller4689
    @truthteller4689 4 ปีที่แล้ว +4

    my fingers are cold just watching!!!

  • @1996Pinocchio
    @1996Pinocchio 4 ปีที่แล้ว

    The amazing thing about the Hilbert Curve is very clearly shown in the video at 25:15 where you color it and increase the order, the colors would still be mapped to the same location, whereas if you'd color it just line by line, and increase the order, the result would look completely different for each order, not stabilizing at any point, whereas when filled with the hilbert curve, the color at each point is the value of the hilbert curve color mapping for order to infinity. This color can't be defined for the line-by-line mapping.

  • @orugma
    @orugma ปีที่แล้ว

    Just came to say... I watched this on a television! (And thank you!)

  • @felipedelgado4328
    @felipedelgado4328 4 ปีที่แล้ว

    Love your work and your passion for programming. It is really inspiring, best wishes from Chile.

  • @kevnar
    @kevnar 4 ปีที่แล้ว

    I like how his breath eventually stops steaming as the electronic equipment warms the cabana.

  • @solsticeprojekt1937
    @solsticeprojekt1937 4 ปีที่แล้ว

    Dude, you're awesome! I'm sitting under my (diagonal) window a lot, even when it's winter outside. Got me some hot tea and as long as the wind's not chilling my hands I'm a happy little camper. :D

  • @BradleyDunlap
    @BradleyDunlap 4 ปีที่แล้ว

    Awesome video. Thanks for enduring the cold for us!

  • @neeharikaroyal9293
    @neeharikaroyal9293 4 ปีที่แล้ว

    Colour ful animation😍 I am excited when I am watching the coding👏👌🙂

  • @prototy
    @prototy 4 ปีที่แล้ว

    I watch all your videos on my tv lol my cats LOVE watching you code things

  • @zacharymcarthur9013
    @zacharymcarthur9013 4 ปีที่แล้ว

    I only ever watch you on my TV. Loved this, very interesting.

  • @iPrint3D
    @iPrint3D 4 ปีที่แล้ว

    I like this style of coding maybe more than your normal white board series!

  • @X22GJP
    @X22GJP 4 ปีที่แล้ว

    I watch the vast majority of TH-cam on my television 😉 Phones are for texts, phone calls and photos, tablets are for browsing and media consumption when on the go!

  • @arjuns.3752
    @arjuns.3752 4 ปีที่แล้ว

    I love what u do
    Never stop it

  • @Mihai-mb4ew
    @Mihai-mb4ew 4 ปีที่แล้ว

    Amazing video, much love from Romania!

  • @delanolourenco
    @delanolourenco 4 ปีที่แล้ว +4

    Hope you reach 1M subs soon.👍

  • @davutsauze8319
    @davutsauze8319 4 ปีที่แล้ว

    Nice, i was waiting for you to make it like a week before

  • @danielluna7648
    @danielluna7648 3 ปีที่แล้ว +1

    Absolutely fascinating. I need to learn more maths. But I think I can use this to smoothly transition an RGB LED through every color in the spectrum...time to hook up the Arduino and start tooling around.

    • @PMA_ReginaldBoscoG
      @PMA_ReginaldBoscoG ปีที่แล้ว

      Instead do it in python, create an explanatory video about it, and submit in manim discord channel for summer of math exposition 3. Wishing you good luck

  • @kenhaley4
    @kenhaley4 4 ปีที่แล้ว +1

    How about a recursive approach?
    Roughly speaking, to draw nth-order curve, draw 4 n-1 order curves rotating and positioning appropriately. When n is 1 just draw the simple U-shape and a line to connect to the next one.

  • @RicoGalassi
    @RicoGalassi 4 ปีที่แล้ว

    Some say Dan's cup is still steaming to this day..
    Awesome work as usual Dan! I know this isn't related, but I'm going to be starting a python course at my job soon and I absolutely cannot wait to dive into another language
    Edit; yes, I am watching on my television haha

  • @algc19
    @algc19 4 ปีที่แล้ว

    5 minutes in and I had to go get a cup of tea! So cozy in your cabana

  • @cosmicgoo8074
    @cosmicgoo8074 4 ปีที่แล้ว

    Thank you for braving the cold for us

  • @realcygnus
    @realcygnus 4 ปีที่แล้ว

    Total awesomeness ! .....as usual

  • @aayushparashar4143
    @aayushparashar4143 4 ปีที่แล้ว

    Nice touch with the notepad!!

  • @1996Pinocchio
    @1996Pinocchio 4 ปีที่แล้ว

    Props for the editing.

  • @3zdayz
    @3zdayz 4 ปีที่แล้ว

    Hilbert curbe is cache unfriendly. The average distance between points A and B that are one step away is about 1/2 the total number of cells you have. On a small scale it looks great, but when you cross from boundary 4 to 5 what would normally be only +/- 1 row pitch or one cell left/right is significantly further. ... I put together a program and added an averge for each cell the offset to the next cells above/below/right/left of the current and it was sinificantly bad at > like a 5x5 square, and my voxel sectors are 32x32x32. That put most accesses in seprate pages for every point in many points of the cube.... since it's only 32 (times 8 for cell data size) 256 bytes from one row to another instead of 16384 .... memory pages are cached in 4k chunks....
    But you're doing it all in JS so what does it matter? it's not like your mapping typed arrays

  • @beens3865
    @beens3865 ปีที่แล้ว

    I know that I am about 3 years behind on this video but as a computer science student I might build an app. One that takes in a certain image and converts it to a Hilbert curve pixelation as a research project. Just an idea. Either way, I love your videos man!

  • @beron_the_colossus
    @beron_the_colossus 4 ปีที่แล้ว

    Ooh great topic with a great venue!

  • @deadphim
    @deadphim 2 ปีที่แล้ว

    truly the famous last words every programmer has uttered at one point

  • @porigonopop
    @porigonopop 4 ปีที่แล้ว

    Interesting thing would be to give a function the x, y coordinate and return the index in the curve

  • @Fragdemented
    @Fragdemented 4 ปีที่แล้ว

    catchphrase idea "May the code in your heart be the same code that fills your screens."

  • @zlyfer
    @zlyfer 4 ปีที่แล้ว +1

    Your catch phrase could be: "I don't have a catch phrase. I have no way of ending these. If you have a suggestion for a catch phrase, just leave it in the comments." Possibly add the "Thank you, good bye." as well.

  • @ionel71089
    @ionel71089 4 ปีที่แล้ว

    I’m watching on my television!

  • @indycinema
    @indycinema 4 ปีที่แล้ว

    This man is by far the best coding teacher. Jelous of the cabana. Where did NYU go?

    • @TheCodingTrain
      @TheCodingTrain  4 ปีที่แล้ว

      It's still there, just another way for me to make videos!

  • @sugg5719
    @sugg5719 4 ปีที่แล้ว

    You can also generate Hilbert curves with an L-system then use the resulting string to rebder with turtle graphics.

  • @BrainSlugs83
    @BrainSlugs83 4 ปีที่แล้ว

    @20:49 -- err, I've only ever watched your videos on my TV; and yes, I spend a significant amount of time shouting at the TV about something or other that you get wrong (but usually eventually fix). 😅

  • @SxC97
    @SxC97 4 ปีที่แล้ว

    so jealous of the snow in NY! I live in Texas and it's always so hot here :(

  • @640kiboughttobeenough
    @640kiboughttobeenough 4 ปีที่แล้ว +9

    This is quite cool! Though, about the hilbert function, couldn't it have been made recursive? So the function would get the order and call 4 copies of itself with a lower order.

    • @tombrown6183
      @tombrown6183 4 ปีที่แล้ว +1

      loops are actually sort of recursive functions

  • @shadowatom
    @shadowatom 4 ปีที่แล้ว

    You should do a video based around the Feigenbaum Constant considering it is such a crucial part (as far as I know) of chaos theory.

  • @randmorf
    @randmorf 4 ปีที่แล้ว

    I took a look at your P5*JS version of this Hilbert Curve program and added a sleep() function so it would pause after completing each plot. I found that it would not show the complete final quadrant of the plot. This was due to your code that increments your counter variable by 50 which I think you did in order to speed up the program, plotting the new stuff in batches of 50 instead of 1 by 1. The result was the final batch which probably was not an even multiple of 50 would not get plotted. When I changed the code so the counter variable was incremented by 1 instead of 50, I found it plotted most of the final quadrant... all except for the last two lines of the last Hilbert Curve. I took a closer look at your code and in two places I decided you should be using a "

  • @Moll-ayyy
    @Moll-ayyy 4 ปีที่แล้ว +1

    The Bob Ross of coding

  • @lubomirpacheliev363
    @lubomirpacheliev363 4 ปีที่แล้ว

    I swear to god you are like the Bob Ross of programming

  • @peytonsomerville6503
    @peytonsomerville6503 4 ปีที่แล้ว +1

    Do you think this program would be more optimal using a recursive function instead of an iterative one?

  • @redumptious2544
    @redumptious2544 4 ปีที่แล้ว

    Man! You're seem so sympathic😅
    Rly hope to meet you one day🤘
    Your videos finally got me into js back in the days.

  • @devsquaredTV
    @devsquaredTV 4 ปีที่แล้ว

    Bravo Dan!!

  • @_rlb
    @_rlb 2 ปีที่แล้ว

    I actually just watched this on my television.

  • @ArtNowCoding
    @ArtNowCoding 4 ปีที่แล้ว +1

    "whoopsie! that's our destination for the day" Catchphrase idea haha

  • @amritpalhh9836
    @amritpalhh9836 4 ปีที่แล้ว

    First from the UK! Best programming teacher ever for visualising. How do you get better in logic?

    • @jemesmemes9026
      @jemesmemes9026 4 ปีที่แล้ว

      Practice is the simple answer, but I guess try to find problems like the ones you wanna solve

    • @AntonPanchishin
      @AntonPanchishin 4 ปีที่แล้ว

      Practice. Outside of programming, turn every day tasks into logic statements and test it. For example, I need groceries so can it be fixed if (I get groceries)or(my wife gets groceries)? No, because that statement equates to true if we both go and that would be too much groceries. Practice, even outside of programming

  • @magikmaker
    @magikmaker 4 ปีที่แล้ว +2

    Wonderful!!

  • @MyTwinkie
    @MyTwinkie 4 ปีที่แล้ว

    This is a lovely idea and you should definitely continue this series! One drawback that I find however comparing to the old studio episodes is that video repeatedly switches from the code view to other views making it hard to follow the coding process. Would it be possible to make the picture-in-picture or split screen so the code is always seen?

  • @mattshnoop
    @mattshnoop 4 ปีที่แล้ว +2

    15:19 : "Let's just use an if-statement"
    WHY do you never use switch statements 🤣 This is a perfect scenario to use one

    • @TheCodingTrain
      @TheCodingTrain  4 ปีที่แล้ว +20

      I have a problem and I'm not afraid to admit it.

  • @JNCressey
    @JNCressey 4 ปีที่แล้ว +2

    4:25 creeper! aw man!

  • @cristiancosneanu
    @cristiancosneanu 4 ปีที่แล้ว +2

    Catch phrase:
    Feel free to code the heck out of your ... [processing, p5, favorite editor].
    ^_^

  • @AlexandraDiehl
    @AlexandraDiehl ปีที่แล้ว

    Man, you are awesome!

  • @sebastianmeisel
    @sebastianmeisel ปีที่แล้ว

    Catch phrase: final station, please leave the train.

  • @wiiuwiiu2020
    @wiiuwiiu2020 4 ปีที่แล้ว

    You're like Santa in February!

  • @cakdham4607
    @cakdham4607 4 ปีที่แล้ว

    As usual.. great tutor

  • @astropgn
    @astropgn 4 ปีที่แล้ว

    🥰 always inspiring

  • @amanadwani9100
    @amanadwani9100 4 ปีที่แล้ว

    just amazing

  • @viktorstrate
    @viktorstrate 4 ปีที่แล้ว

    Please make a video about dithering with hilbert curves