Перейти к содержимому

Coding Challenge #148: Gift Wrapping Algorithm (Convex Hull)

The Coding Train

0:00 / 0:00

Coding Challenge #148: Gift Wrapping Algorithm (Convex Hull)

163 549 просмотров · 7 лет назад
The Coding Train
1,76 млн подписчиков
163 549 просмотров · 7 лет назад
In this coding challenge, I implement the “Gift Wrapping algorithm” (aka Jarvis march) for calculating a convex hull in JavaScript. This is a foundational topic in computational geometry! Code: https://thecodingtrain.com/challenges... 🕹️ p5.js Web Editor Sketch: https://editor.p5js.org/codingtrain/s... 🎥 Previous video:    • Coding Challenge 147: Playing Chrome Dinos...   🎥 Next video:    • Coding Challenge 149: Tic Tac Toe   🎥 All videos:    • Coding Challenges   References: 🌐 Gift Wrapping Algorithm: https://en.wikipedia.org/wiki/Gift_wr... 🌐 Cross Product: https://en.wikipedia.org/wiki/Cross_p... 📝 The splice() Array Function: https://developer.mozilla.org/en-US/d... Videos: 🎥 ES6 Arrow Syntax:    • 16.3: ES6 Arrow Function - Topics of JavaS...   🔴 Coding Train Live 180:    • Coding Train Live 180: Processing Java Lib...   Timestamps: 00:00 Introduction 00:47 What is a Convex Hull? 02:36 The Gift Wrapping Algorithm 03:50 Animated Example of the Algorithm 04:58 Time Complexity of this Algorithm 05:30 Code! Drawing Random Points 05:42 Find the Leftmost Point 07:05 Set up Variables for the Animation 09:03 Make a Guess about the Next Point 10:58 Find out which Vector is “to the Left” 15:00 Add Spacing around the Points 15:33 Add an Exit Condition 15:54 Add the Next Vertex to the Hull 16:26 Draw the Hull 17:12 Continue the Algorithm with the Vertices 18:33 Check when the Algorithm is Done 19:08 Mutating the Array is not necessary 19:50 Watching the Algorithm with More Points 20:13 Inefficiencies about this Algorithm 20:29 Closing the Shape 20:54 (Gift) Wrapping up this Coding Challenge Editing by Mathieu Blanchette Animations by Jason Heglund Music from Epidemic Sound 🚂 Website: http://thecodingtrain.com/ 👾 Share Your Creation! https://thecodingtrain.com/guides/pas... 🚩 Suggest Topics: https://github.com/CodingTrain/Sugges... 💡 GitHub: https://github.com/CodingTrain 💬 Discord: https://thecodingtrain.com/discord 💖 Membership: http://youtube.com/thecodingtrain/join 🛒 Store: https://standard.tv/codingtrain 🖋️ Twitter:   / thecodingtrain   📸 Instagram:   / the.coding.train   🎥 Coding Challenges:    • Coding Challenges   🎥 Intro to Programming:    • Start learning here!   🔗 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-o... This description was auto-generated. If you see a problem, please open an issue: https://github.com/CodingTrain/thecod... #algorithm #computationalgeometry #convexhull #p5js #javascript