
Coding Challenge #144: 2D Black Hole Visualization
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