Uploaded February 2021 | Updated September 2026, 1 week ago
In this video, I tackle a common question, how do you draw an object pointing in the direction itβs moving? I demonstrate how to calculate the angle associated with the direction vector as well as create a vector from an angle in p5.js. Code: thecodingtrain.com/tracks/the-nature-of-code-2/noc/3-angles/3-angles-and-vectors
p5.js Web Editor Sketches:
πΉοΈ Direction Pointing: editor.p5js.org/codingtrain/sketches/9M9yQJVVc
πΉοΈ Vehicle: editor.p5js.org/codingtrain/sketches/HtXbIDsESi
πΉοΈ Asteroids Exercise: editor.p5js.org/codingtrain/sketches/pXS395i0h
π₯ Previous video: youtu.be/i2ROE_mAhU0?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
π₯ Next video: youtu.be/O5wjXoFrau4?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
π₯ All videos: youtube.com/playlist?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
References:
π Solving for tangent: natureofcode.com/book/chapter-3-oscillation/index.html#34-pointing-in-the-direction-of-movement
Videos:
π₯ 1.4 Static Functions: youtu.be/YN8Q-QEmQ8Y
π₯ Asteroids with p5.js: youtu.be/hacZU523FyM
Timestamps:
0:00 Hi again!
0:24 How is tangent useful and heading()
3:29 Using heading()
5:01 p5.Vector.fromAngle()
5:47 Demonstrate fromAngle()
8:13 What could you make?
Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound
π Website: thecodingtrain.com
πΎ Share Your Creation! thecodingtrain.com/guides/passenger-showcase-guide
π© Suggest Topics: github.com/CodingTrain/Suggestion-Box
π‘ GitHub: github.com/CodingTrain
π¬ Discord: thecodingtrain.com/discord
βͺ Nebula: go.nebula.tv/codingtrain
π Membership: youtube.com/thecodingtrain/join
π Store: standard.tv/codingtrain
ποΈ Twitter: twitter.com/thecodingtrain
πΈ Instagram: instagram.com/the.coding.train
π₯ Coding Challenges: youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
π₯ Intro to Programming: youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA
π p5.js: p5js.org
π p5.js Web Editor: editor.p5js.org
π Processing: processing.org
π Code of Conduct: github.com/CodingTrain/Code-of-Conduct
This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecodingtrain.com/issues/new
#forbeginners #javascript #p5js
In this video, I tackle a common question, how do you draw an object pointing in the direction itβs moving? I demonstrate how to calculate the angle associated with the direction vector as well as create a vector from an angle in p5.js. Code: thecodingtrain.com/tracks/the-nature-of-code-2/noc/3-angles/3-angles-and-vectors
p5.js Web Editor Sketches:
πΉοΈ Direction Pointing: editor.p5js.org/codingtrain/sketches/9M9yQJVVc
πΉοΈ Vehicle: editor.p5js.org/codingtrain/sketches/HtXbIDsESi
πΉοΈ Asteroids Exercise: editor.p5js.org/codingtrain/sketches/pXS395i0h
π₯ Previous video: youtu.be/i2ROE_mAhU0?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
π₯ Next video: youtu.be/O5wjXoFrau4?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
π₯ All videos: youtube.com/playlist?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
References:
π Solving for tangent: natureofcode.com/book/chapter-3-oscillation/index.html#34-pointing-in-the-direction-of-movement
Videos:
π₯ 1.4 Static Functions: youtu.be/YN8Q-QEmQ8Y
π₯ Asteroids with p5.js: youtu.be/hacZU523FyM
Timestamps:
0:00 Hi again!
0:24 How is tangent useful and heading()
3:29 Using heading()
5:01 p5.Vector.fromAngle()
5:47 Demonstrate fromAngle()
8:13 What could you make?
Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound
π Website: thecodingtrain.com
πΎ Share Your Creation! thecodingtrain.com/guides/passenger-showcase-guide
π© Suggest Topics: github.com/CodingTrain/Suggestion-Box
π‘ GitHub: github.com/CodingTrain
π¬ Discord: thecodingtrain.com/discord
βͺ Nebula: go.nebula.tv/codingtrain
π Membership: youtube.com/thecodingtrain/join
π Store: standard.tv/codingtrain
ποΈ Twitter: twitter.com/thecodingtrain
πΈ Instagram: instagram.com/the.coding.train
π₯ Coding Challenges: youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
π₯ Intro to Programming: youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA
π p5.js: p5js.org
π p5.js Web Editor: editor.p5js.org
π Processing: processing.org
π Code of Conduct: github.com/CodingTrain/Code-of-Conduct
This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecodingtrain.com/issues/new
#forbeginners #javascript #p5js










