Coding Challenge 176: Buffon's Needle

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 มิ.ย. 2024
  • How do toothpicks approximate the value of pi? I'll show you by coding a simulation in p5.js! Code: thecodingtrain.com/challenges...
    🚀 Watch this video ad-free on Nebula nebula.tv/videos/codingtrain-...
    p5.js Web Editor Sketches:
    🕹️ Buffon's Needle: editor.p5js.org/codingtrain/s...
    🕹️ Line Line Intersection: editor.p5js.org/codingtrain/s...
    🕹️ Probability Density Function Graph: editor.p5js.org/codingtrain/s...
    🎥 Previous video: • Coding Challenge: 3D o...
    🎥 All videos: • Coding Challenges
    References:
    🔗 Buffon's Needle: en.wikipedia.org/wiki/Buffon%...
    🔗 Analysis and Simulation: mste.illinois.edu/activity/bu...
    🔗 Pickup Sticks & Pi: ogden.eu/pi/
    Related Coding Challenges:
    🚂 95 Approximating the Value of Pi: • Coding Challenge 95: A...
    🚂 126 Toothpicks: • Coding Challenge #126:...
    🚂 145 Ray Casting 2D: • Coding Challenge #145:...
    Timestamps:
    0:00 Happy Pi Day 2023!
    0:45 Introduce Buffon's Needle
    1:40 Unpack the math
    4:40 Let toothpick fall at an angle
    7:08 The probability that the toothpick crosses the border
    7:27 Uniform probability density function
    8:12 Illustrate the probability with a graph
    10:49 Approximating the value of Pi
    11:11 Calculating the area under the curve
    12:48 Resources for Buffon's Needle
    13:28 Start Coding
    13:53 Draw vertical lines
    14:20 Add a toothpick
    15:02 Draw background in setup
    15:57 We have to use the built-in value of Pi
    17:00 Find the closest column
    17:22 Determine if the toothpick intersects the column
    18:10 Rotate the line relative to the y-axis
    18:50 Draw the toothpick as a vertical line
    19:40 Improve the visuals
    20:48 Approximate the value of Pi using the probability that a toothpick intersects a column
    23:45 Suggestions for variations
    24:08 New Passenger Showcase page on the Coding Train website
    24:38 Easter egg
    Editing by Mathieu Blanchette
    Animations by Jason Heglund
    Pi Day Song by Will from America
    Music from Epidemic Sound
    🚂 Website: thecodingtrain.com/
    👾 Share Your Creation! thecodingtrain.com/guides/pas...
    🚩 Suggest Topics: github.com/CodingTrain/Sugges...
    💡 GitHub: github.com/CodingTrain
    💬 Discord: thecodingtrain.com/discord
    💖 Membership: th-cam.com/users/thecodingtrainjoin
    🛒 Store: standard.tv/codingtrain
    🖋️ Twitter: / thecodingtrain
    📸 Instagram: / the.coding.train
    🎥 Coding Challenges: • Coding Challenges
    🎥 Intro to Programming: • Start learning here!
    🔗 p5.js: p5js.org
    🔗 p5.js Web Editor: editor.p5js.org/
    🔗 Processing: processing.org
    📄 Code of Conduct: github.com/CodingTrain/Code-o...
    This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecod...
    #piday #pi #buffonsneedle #buffon #p5js #javascript

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

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

    You can support the coding train and watch this video ad-free on Nebula! nebula.tv/videos/codingtrain-coding-challenge-buffons-needle
    Find the code and share your own to the Passenger Showcase: thecodingtrain.com/challenges/176-buffon-needle

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

      One way to avoid using pi in the code would be to use a random number (float) between 0 and like 100000000, so all angles are roughly equally likely

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

      you are video make people interesting and easy understand what your share thanks sir

  • @jayjasespud
    @jayjasespud ปีที่แล้ว +259

    Just when the world needed him most, he returned...

  • @Daimondz1239
    @Daimondz1239 ปีที่แล้ว +61

    I gotta say these new whiteboard animations you have going on are really impressive

  • @evanbarnes9984
    @evanbarnes9984 ปีที่แล้ว +80

    To specify rotation of the toothpick without relying on Pi in the code, you could generate two random points! The first random point would be inside the canvas, and would define the location of the center of the toothpick. The second point could fall anywhere, even outside the canvas. The second point is used to define a vector, which will guide the rotation of the toothpick. Draw a construction line connecting the center of the toothpick with the second random point, then draw the toothpick with the appropriate length along that construction line. This should get you random orientations without relying on already knowing the value of pi!

    • @gediminasusevicius2668
      @gediminasusevicius2668 ปีที่แล้ว +25

      This would not give a random angle.
      You can assign the first point (the centre of the toothpick) as (0, 0). And if you pick a second point randomly (aka uniform distribution in x and y), the angle of the toothpick will be arctan(x/y). The maths gets a bit hairy here, but as you can easily imagine, if x and y have a uniform distribution, the angle arctan(x/y) will not

    • @user-ef8kc4rv7n
      @user-ef8kc4rv7n ปีที่แล้ว +12

      @@gediminasusevicius2668 You could choose a random point in a surrounding circle using Monte Carlo rejection and that would work

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

      @@gediminasusevicius2668 I don't get why it doesn't yield a randomly angled toothpick. Could you please elaborate a bit more? 🙂

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

      @@SellusionStar Well, this is a very common misconception. It would be random, yes, but not uniform. It would be clumped up.
      There are many different randomness. There is a uniform, where every value is equally likely. But there are different ones as well. The most known another one is Gaussian distribution - a bell like shape. While both of them can provide a random distribution, they will have different results.
      For example, if we try and draw a person, we can choose a random height for it. If we choose a uniform distribution, then it will be equally likely it will be 1 meter tall, as it will be 1.8 meters tall. While still random, it is not useful in this scenario, since human height is not uniformly distributed. If we wanted a more accurate random value for human population, we would use Gaussian distribution, where a height of 1.7 meters is much more likely than 2 meters. It does not mean that a random chosen height from such distribution will be 1.7 meters, but it will result in the heights being more clumped up around 1.7 meters

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

      @@gediminasusevicius2668 thanks, got you! That's exactly what I was thinking, when I imagined how one would through the needles in real life while making sure they are evenly/uniformly distributed. Because I thought they would probably clump in some places...

  • @Plokmin
    @Plokmin ปีที่แล้ว +25

    16:06 - I believe that if you used `angleMode(DEGREES);` in your setup, you could specify the angles with -180 to 180 and thereby removing the dependency on PI!

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

      Same thought

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

      Was lookin for this comment.

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

      Unfortunately PI sneaks in still. I was actually thinking the sine function itself doesn’t need PI to be computed. But PI gets inserted when he’s talking about that integration with PI in the limits.
      But when you say to express it in degrees, it would seem to avoid that completely. But when you switch between radians and degrees, calculators don’t tell you that the specific sine function changes.
      When you take the sine in degrees, it’s actually applying a scaling transformation on the degrees first - to get it back to radians - then applying the standard sine function. If 180 degrees is PI, then to do that conversion, you multiply by PI/180 to get it to radians.
      In this way, PI is sneakily still present!

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

    just awesome. I was actually randomly searching for buffon's needle experiments today and you did the actual thing I wanted to to see. Love and respect

  • @rayantovi
    @rayantovi ปีที่แล้ว +11

    The most underrated teacher i’ve ever learned from, Thank you for all the time you spent through out the years on this amazing content!

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

    I just found your channel a week ago and it’s been helping me with python. So glad you are still active on TH-cam.

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

    The toothpick challenge was one of my favorite and i tweeted my output to you a few days after that video. One of the single greatest influences to code again. Thanks for your videos!!!

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

    Love your videos. Youre an absolute treasure.

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

    I always look forward to your videos and you never disappoint! Thanks for being so inspiring!

  • @chad4094
    @chad4094 6 หลายเดือนก่อน

    Your enthusiasm and thorough explanations are unlike anything I've seen before. Thank you so much!

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

    Absolutely amazing, I love your work and your natural and logical way of explaining things!

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

    7:25 I've heard of falling angels, but falling angles are new to me :)
    Excellent video!

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

    So glad to see a new coding challenge, i almost finished the playlist !

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

    Nice to see you again, Welcome Back!

  • @raphaelfrey9061
    @raphaelfrey9061 ปีที่แล้ว +8

    I love this tradition of you calculating Pi in many different ways!

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

      You might like to check out Matt Parker on the Standup Maths channel where he has been doing similar things over the years. Some really creative ones.

  • @rockapedra1130
    @rockapedra1130 2 หลายเดือนก่อน

    I love this channel. Super interesting stuff and excellent delivery. Congrats!!!!

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

    Dan! I love how you tackle hard problems with this energy and didactics! You´re awesome! Hope you know that!

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

    It is always a pleasure and inspiration watch your videos !

  • @bhavesh.adhikari
    @bhavesh.adhikari ปีที่แล้ว

    wohoo!! this 25 min is gonna be fantastic! your're amazing. i have learned a lot from you.

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

    Loved ur enthusiasm, very interesting challenge. Thank you for this 😄

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

    GENUINELY THANK YOU FOR UPLOADING ❤️

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

    I can only grasp half of this, but I'm enjoying myself anyway. What enthusiasm!

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

    Man, I missed you a lot! thanks for comming in this amazing Pi day

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

    Loved the video! Thanks for featuring my sketch!!

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

    12:00 it is an image, but there is no greenscreen... and the image is between him and board which he interacts with

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

      Runway in action! runwayml.com/

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

      That looked so natural, I didn't even notice this. Very impressive.

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

    The struggle with drawing a decent looking graph is real! Yours is great!

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

    I am so here for that art direction on the background !

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

    I love pi. It's such a cool thing like you can find it anywhere and the math here done is not that difficult. It's just basic highschool math and as you made a graph I was like let's an take an integral under the curve.

  • @sr.railn.m.667
    @sr.railn.m.667 ปีที่แล้ว +1

    to celebrate pi day, I am not going to watch this video when its release but exactly pi days after!

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

    A possible way to pick a random angle without referencing pi whatsover: use a uniform distribution over a HUGE interval (or take the uniform distribution on (0,1) and map it to a large interval).
    I haven't directly tested this way of rng, but here's why I think it should work. Let's write the total width of our interval in the form z = 2*pi*N + x, where N is a large enough natural number, and x any real number between 0 and 2*pi. If we had x=0, then we are picking the angles on an interval of with 2*pi*N, which for the purposes of rotating the toothpicks is indistingushable from picking from an interval of width just 2*pi.
    When x is not zero, the probability of picking the angle in the "wrong" part of the interval is equal to x / (2*pi*N + x). This number is vanishing small, the larger we pick N -- we don't directly pick N, but a number very large number z = 2*pi*N+x to make sure tha N is really, really big.

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

    Awesome!!! Thank you!

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

    I love the way you teach! You simplify things so much and keep refining the solution from a dummy start to the ultimate solution. I wish you could make a program where one can visulaize all the data structures. Thanks for doing things the way you do. ❤❤ from India

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

    To get a uniform angle in (0,2pi) you could generate uniform x,y in (0,1) until x^2+y^2=1 you essentially create a uniform distribution on the circle, and there the angle is uniformly distributed.

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

      If you can calculate atan(x/y), then you might as well do 4*atan(1)

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

    I just saw it was march 13 th and I instantly came to your channel to see what you had

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

    Welcome back!

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

    I was missing your videos!

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

    19:07 there it is, near the center of the canvas: PI! Challenge completed!

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

    Watching these toothpicks appear on the board reminds me of when I trim my beard into the sink XD I'm wanting to blow the screen every so often.
    Loving these videos, Dan!
    From a fellow Dan.

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

    Shiffman, this message that I'm sending doesn't have much to do with what's in the video, I apologize for that, but I just want to thank you for everything you've done in my life by being a great teacher. In 2018, I started my journey as a developer and I was really lucky to find your channel and playlists teaching javascript in the unique way that you have to teach. Today I have a career in the field, a passion for what I do, and I just wanted to express my gratitude for being an amazing mentor (even though you have no idea who I am hahah). Thank you very much, Shiffman. Your work here is awesome! I wanted to say some more beautiful things but since English is not my native language, I can't express myself the best way possible. If I could talk in Portuguese you probably would cry for a month. 😂

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

      Thank you for sharing this wonderful story!

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

    First of all: Happy pi day from Spain. I want to propose a problem. How about an extension to 3D of this problem. Suppose we place random needles on the space at random points with some length and two angles defining the orientation. What is the probability of a needle to cross two parallel planes at unit distance one from each other. What if instead of two planes we take a cube? What is the probability of a needle crossing one side of the unit cube. Hint: Does that probability involve pi? The result may be surprising 😉

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

    FINALLY BACK!

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

    I really would like to have you back for the coding challenges with p5js.

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

    14:17 That seems like the best choice, and not because it would look more interesting, but because you wouldn't eschew the results.
    If you limit to just 90º the toothpicks will have "one" chance to be at an angle 0º < θ < 90º, one chance to land vertically and one chance to land horizontally, if you expand to 180º that changes to 2 chances "at an angle", two chances horizontally and one chance vertically, but since they can in reality land at whatever angle between 0º and 360º, the chances are actually four times "at an angle", two times horizontally and two times vertically.
    It shouldn't, I believe, make much of a difference, but since it's the same to use a full circle as it is to use just 1/4 of one, go for the more accurate simulation.

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

    Will you do shader programming again? Really enjoy your videos, learn so much things!

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

    Amazing video

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

    ayyyyy a new coding train video

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

    We're late by 1 day, but let's wait a full year again

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

    If only I had your programming skills, my life ideas would come to life in a matter of days

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

    Happy PI day to all! So magical!

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

    Hi Daniel, Instead of using TWO_PI what you can do is pick two random points and lerp a point between those two with distance of l and using that you would get a random angle without using rotate, TWO_PI. For getting X from that you can just do x2 - x1. Hope it helps.

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

      I do not think each angle has an equal possibility.

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

    Next year, I want to see Matt Parker drop a thousand toothpicks and just see him spend the entire video picking them up to calculate pi!!

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

    Missed you 🥲

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

    Awesome 👌 👍 😍

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

    This is magic :0

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

    Since you're intersecting a vertical line, you could draw the line using x0,y0-x1,y1. Then you simply divide x0 and x1 by t. If they're different, they intersect.
    If (x0/t != x1/t) intersect++;
    Something like that?

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

    missed you!

  • @error.418
    @error.418 ปีที่แล้ว

    11:30 No, it's not the top half of an ellipse. it's a section of a sine wave, specifically the graph of y=(1/2)*sine(x) which people can drop into the online Desmos graphing calculator and visualize.

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

    Maybe you can get around the random angle chicken and egg problem by choosing a point in a disk at random. Pick a random x coordinate between 0 and 1, and pick a random y coordinate between 0 and 1. Check if x^2+y^2

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

      Edit: I meant pick the x and y coordinated randomly between -1 and 1 and then check if x^2+y^2

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

    Do you have any plans to maybe cover some other programming languages in the future?

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

    What could be done to remove π from the code is to take a rough approximation of π (like π=3), run the code and use the new and better value of π to run the code again

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

    And you have pi/2 million subs, nice! Also, to not be forced to use PI in your simulation you can make a rectangle with random height and width, then choose any two diagonally opposite corners and get the angles from that.

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

      That would make angles closer to ±45° more likely than angles closer to 0° or ±90°.

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

      @@nagualdesign It does not have to be a rectangle, two points would suffice!

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

      @@GradientAscent_ 2 random numbers will produce a rectangle with random height and width. If all possible values are equally likely the resulting angle between opposite corners will not be evenly distributed.

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

    you can’t use trigonometry functions, instead you should pick a random gradient. So a gradient of 0 would be horizontal and 1 would be vertical. This would circumvent the need to use PI anywhere in your code (and implicitly when using trig functions)

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

    Badhiya video, guru g. Aur batao, sab badhiya ☺️

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

    int x0 = (int)(x - sin(rot) * l);
    int x1 = (int)(x + sin(rot) * l);
    bool hit = x0 != x1;
    Assuming that t = 1 and l = 0.5 and type of x is double/float (C#)

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

    Omg he left his cryogenic tank just for us! Welcome to the future!

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

    nice video

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

    @17:00 you could have just used the modulo of the column width to the toothpick X. No need for searching for closest

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

    I love pi day; all my favorite math TH-camrs have a bunch of cool videos that I can watch while eating pizza (pi-zza)

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

    you could replace 2pi with high number, that would't be precise but random enough to work as well

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

    Could you change the angle to degrees, select randomly from 360, then it should still shake out to approximate pi without ever writing it in the code?
    Would that work?

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

    Hey just ran into your content and I'm new to programming. What Playlist of yours would recommend I start with

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

      This is the beginner one: th-cam.com/play/PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA.html
      I also have things organized on my website: thecodingtrain.com/

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

    happy pi day everyone!

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

    Did you use p5js to create the animated illustrations, too? For example at 14:09.

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

      These I actually created in p5, but then they were redrawn by an animator! It's a little bit of both throughout the video!

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

    happy PI day bro

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

    HOO HAPPY PI DAY!! Guys wish u luck and a lot of success!

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

    Heeey mr. Coding Train. Have you tried using arduino with other softwares through serial communication? I've been working with touchdesign and an arduino but would like to See other creative posibilites. Oh, and btw touchdesigner comps use python

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

      Oh, I have worked with Arduino! Maybe someday I'll get to make a video with it.

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

    Is this connected to 3B1B?

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

      Only in the sense that they’re both Gods among us.

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

    11:31 *not actually an ellipse either (it's a sine wave).

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

    I also recommend watching the movie, "Pi"

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

    18:06 Reality shattered

  • @sam-jd5xx
    @sam-jd5xx ปีที่แล้ว

    I like your watch

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

    i missed you

  • @AB-wf8ek
    @AB-wf8ek ปีที่แล้ว

    I'm wondering, since the lines are verticle, the Y-axis information is actually irrelevant.
    I feel like this could be simplified into a 1 dimensional exercise and instead of angles, you're really just looking at a random placement of a line on the X-axis who's length is between 1/2t and 1

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

      It uses sinus to get PI, so sinus is needed while finding PI, and can not be replaced with a linear random number

    • @AB-wf8ek
      @AB-wf8ek ปีที่แล้ว

      @@luigidabro got it, thanks for clarifying

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

    fun fact : pi day is the same day as the day of the gifted

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

    You could have used degrees for the angles so its 0-180 instead of 0-pi

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

    I thought you'd post today

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

    It's good to see You Dan. I'm writing this while waiting on the GPT-4 demo and wondering if programming will soon be a hobby rather than a career.

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

      ..No lol

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

    Nice video! However, I do no like that you used pi and sine in the program. Instead of picking an angle at random, you should pick a second point (x,y) and make the toothpick lie along the resulting line segment.

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

    I really thought you were giong to drop a box of toothpicks onto the floor

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

    longtime now vidoes :)

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

    i'm not saying you're wrong. but if toothpick length is 1. and width of the gap is 1.
    then if angle is 45, toothpick width is half of 1. and that means the distance of 1/2 of 1/2 which is 1/4?
    not .335....@ 9:50

  • @tile-maker4962
    @tile-maker4962 ปีที่แล้ว

    I have an irrelevant issue I really need someone to help me with.
    I am using Processing and trying to import JavaFX from the contribution manager, I put the files in the correct location, I know this because it pops up in the "Sketch" folder.
    I am trying to make a GUI, so far there is no video's from Daniel here on how to make a GUI yet.
    When I use it, it imports
    import processing.javafx.*;
    I am trying to get it to import all of these things
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.layout.StackPane;
    import javafx.stage.Stage;
    Can someone please help me with this? I can't find source for this and if their is a different way to access it it would be great.

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

    solve travelling salesman problem with physical photon bounces (ray tracing, radar n-bounce problem)

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

      well, assume you have N nodes, then you have N-filters and N-1 two-way signal splitters to the other N-1 nodes, and maybe signal pipes, optical fibers, between the node signal splitters, then let it bounce

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

      fastest full signature signal to arrive to start wins (phase of signal arrival packets matter)

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

      acute distress

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

    I object using Pi while trying to determine it. This should be solved graphically: You know the position of the vertical lines thus no need to use Pi. Happy Pi day!

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

    TWO_PI has a name, it’s actually called TAU (τ).

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

    82, 82, 82.

  • @74Gee
    @74Gee ปีที่แล้ว

    Boom!
    angleMode(DEGREES);
    let angle = random(360);

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

      still uses PI implicitly with the trigonometry functions when rotating. avoid angles all-together and select a random gradient instead

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

    Need to go back and look at Image to Text models, Large Language Models chatGPT GPT- 4 etc
    Gene Kogan Where is your follow up on these .... 🧐