Coding Challenge #144: 2D Black Hole Visualization

Coding Challenge #144: 2D Black Hole Visualization

Subscribers:
1,740,000
Published on ● Video Link: https://www.youtube.com/watch?v=Iaz9TqYWUmA



Duration: 42:30
221,945 views
5,964


Inspired by the recent image of the Powehi m87 black hole from the Event Horizon Telescope, I visualize the behavior or light (photons) following the path of spacetime around the black hole in p5.js. Code: https://thecodingtrain.com/challenges/144-2d-black-hole-visualization

p5.js Web Editor Sketches:
πŸ•ΉοΈ Black Hole Visualization - Newtonian Granvitational Attraction: https://editor.p5js.org/codingtrain/sketches/2zZqSkxtj
πŸ•ΉοΈ Black Hole Visualization - Code with Relativistic Corrections: https://editor.p5js.org/codingtrain/sketches/4DvaeH0Ur

πŸŽ₯ Previous video: https://youtu.be/eqo2LxRADhU?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
πŸŽ₯ Next video: https://youtu.be/TOEi6T2mtHo?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
πŸŽ₯ All videos: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH

References:
πŸ““ Simulating a Black Hole!: https://www.asc.ohio-state.edu/orban.14/stemcoding/blackhole.html
πŸ–Œ How to draw a Black Hole: http://rantonels.github.io/starless/
πŸ“° Astronomers Capture First Image of a Black Hole: https://eventhorizontelescope.org/
πŸ““ Image of a Spherical Black Hole with Thin Accretion Disk: http://articles.adsabs.harvard.edu/cgi-bin/nph-iarticle_query?1979A&A....75..228L

Videos:
πŸŽ₯ How to Understand the Image of a Black Hole: https://youtu.be/zUyH3XhpLTo
πŸŽ₯ Slingshot with Gravity!: https://youtu.be/RkpulcVKLRw
πŸ”΄ Coding Train Live 176: https://youtu.be/tWyp2OWWcws?t=1192s

Related Coding Challenges:
πŸš‚ #7 Solar System (2D): https://youtu.be/l8SiJ-RmeHU
πŸš‚ #8 Solar System (3D): https://youtu.be/dncudkelNxw

Timestamps:
0:00 Introducing today's topic: a black hole visualization
3:25 The elements in the black hole visualization
5:06 The event horizon
6:35 The accretion disk
8:35 What happens when light is traveling towards a black hole?
9:43 The theory of relativity
12:03 Let's Code!
13:52 Make a black hole object
16:57 Draw the accretion disk
18:49 Draw an unstable photon orbit
20:22 Create a photon class
23:25 Add velocity to the photons
25:46 Apply Newtonian gravitational attraction
31:36 Add a trail to the photon
38:17 Corrections to the code
40:14 Add the angle of velocity for the photon
0:00 Conclusion and suggestions for variations

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

πŸš‚ Website: http://thecodingtrain.com/
πŸ‘Ύ Share Your Creation! https://thecodingtrain.com/guides/passenger-showcase-guide
🚩 Suggest Topics: https://github.com/CodingTrain/Suggestion-Box
πŸ’‘ GitHub: https://github.com/CodingTrain
πŸ’¬ Discord: https://thecodingtrain.com/discord
πŸ’– Membership: http://youtube.com/thecodingtrain/join
πŸ›’ Store: https://standard.tv/codingtrain
πŸ–‹οΈ Twitter: https://twitter.com/thecodingtrain
πŸ“Έ Instagram: https://www.instagram.com/the.coding.train/

πŸŽ₯ Coding Challenges: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
πŸŽ₯ Intro to Programming: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA

πŸ”— p5.js: https://p5js.org
πŸ”— p5.js Web Editor: https://editor.p5js.org/
πŸ”— Processing: https://processing.org

πŸ“„ Code of Conduct: https://github.com/CodingTrain/Code-of-Conduct

This description was auto-generated. If you see a problem, please open an issue: https://github.com/CodingTrain/thecodingtrain.com/issues/new

#blackholevisualization #eventhorizon #accretiondisk #javascript #p5js







Tags:
daniel shiffman
coding
the coding train
coding challenge
code challenge
programming challenge
black hole
black hole light
black hole visualization
black hole visualised
m87 black hole
m87 galaxy black hole
black hole light bending
black hole light distortion
black hole light ring
event horizon
accretion disk
accretion disk black hole