1.5 A Unit Vector (Normalize) - The Nature of Code

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



Duration: 14:15
48,514 views
1,416


In this video, I explain the concept of a “unit vector,” what it means to “normalize” a vector, and take a look at the p5.js functions: p5.Vector.mag(), p5.Vector.normalize(), p5.Vector.setMag(). Code: https://thecodingtrain.com/tracks/the-nature-of-code-2/noc/1-vectors/5-unit-vector

🕹️ p5.js Web Editor Sketch: https://editor.p5js.org/codingtrain/sketches/U4ezFLIZ

🎥 Previous video: https://youtu.be/YN8Q-QEmQ8Y?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
🎥 Next video: https://youtu.be/T84AWnntxZA?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
🎥 All videos: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM

References:
🔗 p5.Vector.mag(): https://p5js.org/reference/#/p5.Vector/mag
🔗 p5.Vector.normalize(): https://p5js.org/reference/#/p5.Vector/normalize
🔗 p5.Vector.setMag(): https://p5js.org/reference/#/p5.Vector/setMag
🔗 p5.Vector.normalize() source code: https://github.com/processing/p5.js/blob/c1e30d688748543e52aa5ebc241bfc7dfb2f508d/src/math/p5.Vector.js#L1251
🔗 p5.Vector.setMag() source code: https://github.com/processing/p5.js/blob/c1e30d688748543e52aa5ebc241bfc7dfb2f508d/src/math/p5.Vector.js#L1369

Timestamps:
0:00 Welcome to another video about vectors!
4:57 The normalize function
6:01 Vector notation
6:49 The mag() function
9:38 Normalizing a vector by dividing by magnitude
12:12 setMag()
12:39 Source code for the normalize function
14:03 See you in the next video!

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
✪ Nebula: https://go.nebula.tv/codingtrain
💖 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

#forbeginners #javascript #p5js