Coding Challenge #139: Calculating Digits of Pi with Collisions

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


References:

Videos:

Related Coding Challenges:

Timestamps:
0:00 Introduction!
1:51 Basic code of the structure
7:00 Simulating elastic collision between two blocks
12:03 Simulating the wall
13:59 Adding the clack!
14:29 Counting the collisions!
18:09 Adding timesteps to control approximation
24:12 Adding constraints to speed up animation
26:47 Watching collisions upto 11 digits of pi!
28:46 Other methods to simulate elastic collisions and things to try!
30:50 Fake outro (and a special Pi Day song!)

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

#3blue1brown #elasticcollision #piday #eulermethod #p5js #javascript
Рекомендации по теме
Комментарии
Автор

This method is not time sensitive. Because of conservation of momentum and energy, Euler integration is not an issue.
The problem is that when a collision happens, you let the 2 objects intersect with themselves and the wall. This leads to the small cube slowly drifting through the wall.

If you just snap back the cubes positions after a collision, you should be fine.

Technically the pieces don't even need to move, you just have to count the collisions respecting the alternating order of wall and cube collisions.

guitoo
Автор

I love that the video length is Pi (31:41)! Happy #PiDay!

justinhoffmann
Автор

15:30 FUNDAMENTAL THEOREM OF ENGINEERING

gordonchan
Автор

Calculates Pi On Pi day ... with a Pi long video ...
how committed someone can be?

sidalisaadi
Автор

27:14
It goes like this, the wall, the block,
the drawing loop, the ticking clock,
the baffled Dan programming Pi collisions 🎶

mebamme
Автор

It's amazing how accurate you got it!

Even having seen the 3blue1brown video, I was blown away by how the digits of Pi appeared, and the correct ones to boot! And all with so little code.

mebamme
Автор

engineers: "that's kinda like pi, 3!"

rageace
Автор

the video length is 31:41 this is just excessive

alliseth
Автор

Man For this you deserve 3, 141, 592, 653, 589, 793, 238, 462, 643, 383, 279, 502, 884, 197, 169, 399, 375, 105, 820, 974, 944, 592, 307, 816, 406, 286, 208, 998, 628, 034, 825, 342, 117, 067 subscribers.


And No I didn't copy-paste or see and type it. I remember 100 digits of PI using ASAP Science's song '100 digits of PI '!!

sangeetamankani
Автор

Knowing the velocity of both blocks, you could calculate the point in space and time where they collide. So you don't need time steps at all! (Except for animation purposes). If the time until collision is above say 1/60th of a second you could use a time step for animating. In fact that would give you a nice iterative formula for pi. (That would converge quite slowly!)

WildAnimalChannel
Автор

You could also use this way:
console. log(Math.PI);

sirnicoosokhan
Автор

This is frickin amazing :D Math and Computer Science are just so amazing! Happy Pi Day everyone

nitinrangarajan
Автор

Man, it's really cool you just see the physics through the math, like with hypothesising what the m=1 scenerio is. You're quite the polymath!

technodruid
Автор

That clack sound is the same as the clack that Clackers made, a toy from the late 60's that used to break kids wrists :) Good article on Wikipedia about them.


Super video!

followthetrawler
Автор

26:52 I love the song, you should upload a video just with the song

ItsDrike
Автор

29:47 The difference between float/double and BigDecimal, as well as the difference between int/long and BigInteger, is that using primitive types, the JVM is allocating a chunk of memory just for that primitive type's previously-set boundary, while as a for BigInteger/BigDecimal, the JVM is directly using the memory to store the bytes, which naturally results in a bigger usage of memory for the application.
If you have a lot of RAM and you need high-precision for numbers, you can safely use BigInteger/BigDecimal. Just be careful not running into Infinite loops!

avi
Автор

12:27
We can think of the wall as 256 high bedrock

Xnoob
Автор

I did this in processing myself and after 7 digits it was just too slow.. I can't believe it went till 9 digits at such a good speed. But it's super impressive. I love how we all enjoy coding mathematical ideas that just make programming fun😂❤️

justkeerat
Автор

What an amazing video as always! The video edition is every time getting better too. Great work!!! Thanks!!!

JCDreaming
Автор

man i was feeling depression because i field to learn advanced javascript and u made me more interested in it u made me change my mind

ahmedelselly