Coding Challenge
VloĆŸit
- Äas pĆidĂĄn 5. 08. 2024
- Boing! Time to simulate a spring force! This challenge fits into chapters 2 and 3 of the Nature of Code and demonstrates how to simulate the oscillating motion of a spring using vectors and forces. thecodingtrain.com/challenges...
p5.js Web Editor Sketches:
đčïž Simple Spring: editor.p5js.org/codingtrain/s...
đčïž Spring Vector: editor.p5js.org/codingtrain/s...
đčïž Spring OOP: editor.p5js.org/codingtrain/s...
đčïž Soft Spring: editor.p5js.org/codingtrain/s...
đ„ Previous Coding Challenge: âą Coding Challenge #159:...
đ„ All Coding Challenges: âą Coding Challenges
đ„ Previous Nature of Code Video: âą Coding Challenge #159:...
đ„ Next Nature of Code Video: âą 4.1: Particle System S...
đ„ All Nature of Code Videos: âą The Nature of Code
Links discussed in this video:
đ Nature of Code 3.10 Spring Forces: natureofcode.com/book/chapter...
đ Nature of Code Playlist: thecodingtrain.com/learning/n...
đ toxiclibs.js: www.haptic-data.com/toxiclibsjs/
đ curveVertex() (p5.js Reference): p5js.org/reference/#/p5/curve...
Other videos mentioned in this video:
đ„ Texturing Cloth Simulation - Coding Challenge #63: âą Coding Challenge #63.1...
đ„ Simple Particle System - Coding Challenge #78: âą Coding Challenge #78: ...
Timestamps:
0:00 Choo choo!! Springs Coding Challenge!
0:40 Explain! What is Hooke's Law?
2:51 Code! Let's make a 1 dimensional spring!
5:13 Explain! How can we bring in vectors?
7:17 Code! Let's adjust the code to use vectors.
11:57 Code! Let's add gravity!
13:03 Code! How can we control the spring with our mouse?
13:53 Explain! But wait!! Particles!
15:14 Copy & Paste! A particle class.
16:41 Code! Let's make bob and anchor particles.
18:01 Code! We need a spring class.
21:32 Debug! What is missing?
23:16 It works!
24:16 Code! But wait!! Particle system!
25:28 Code! Let's connect the particles with springs.
27:12 Code! We can refine it a bit.
29:29 Code! Playing with beginShape() and endShape().
31:07 Ideas! If you make a swishy robot share it with me!
đ Website: thecodingtrain.com/
đŸ Share Your Creation! thecodingtrain.com/Guides/com...
đ© Suggest Topics: github.com/CodingTrain/Rainbo...
đĄ GitHub: github.com/CodingTrain
đŹ Discord: / discord
đ Membership: czcams.com/users/thecodingtrainjoin
đ Store: standard.tv/codingtrain
đ Books: www.amazon.com/shop/thecoding...
đïž Twitter: / thecodingtrain
đž Instagram: / the.coding.train
đ„ Coding Challenges: âą Coding Challenges
đ„ Intro to Programming: âą Start learning here!
đ p5.js: p5js.org
đ p5.js Web Editor: editor.p5js.org/
đ Processing: processing.org
đ Code of Conduct: github.com/CodingTrain/Code-o...
Love these classic coding challenges
Me too!
This channel is a national treasure.
I swear dude lmao
World.
Inter-
â@@labhamjain3915you took the word from my month đïžđđïž
Be on the lookout for Nicholas Cage.
And everythingâs all boingy boingy boingy, indeed.
All day long...
I don't even code in JS, but I love to watch your coding challenges
Same here. I sometimes even watch his tutorial videos despite knowing the content pretty well. I just like watching this man code.
But i will try to implement this to my javaproject this were very helpfull to me
I code in c++ and sometimes I follow along, when I have the time to think tho.
The way how i love this guy... what an amazing human being.
Recreating these coding challenges at home is so much fun, thank you for making this content!
Entire Lockdown was passed on NoC videos! Gotta love your coding and teaching style!
Oh my god, this video just gave me a huge inspiration for how to implement my own kinda simple version of "force directed graphs" (using forces to visually align nodes in a graph so they don't overlap and so on).
I have been playing around with FDGs to visualize my NEAT neural networks but couldn't quite get it right so far, but using this video's ideas as a basis is so simple yet so genius, I didn't even think about it until now :D
Thank you so so much, Dan! I am super excited to try this out! :D
I've been re-watching some of your earlier work, which I've always enjoyed, and it's nice to see you just continually getting better. Your explanations, and your coding, feel smoother. No more spending half-hours tracking down "this dot" errors :) !
But also less âthis dotâ songs ;-;
whoever works on the video editing does really great job, new videos are real smooth
You are an amazing teacher! The way you explain things and concepts is astonishing as well as entertaining! Thanks for all the efforts
It's great to see you doing coding challenges again! :)
Your other recent videos are probably just as good, but somehow an "I'm making a thing" video is a lot more clickable to me than "I'm teaching a thing".
Yes, I try to make a variety of styles, but the coding challenge format tends to be quite popular with viewers!
@@TheCodingTrain It's great that you're making both challenges and more teaching-oriented videos. I'm content watching the former, but I think the beginner coders are really appreciating the latter!
@@TheCodingTrain I like both
You're my hero, Dan
He is supposed to explain more, be a teacher, so I guess that's what he should do :)
@@nothingnoone8752 same he does a really good job.
That's so cool! I finally understood the idea behind springs
now i really know how much hard work was put in matter.js
There was much more hard work put into matter.js than you think,
They only not had to make the physics engine but they also had to make their website which contained references and examples
@@abhaykashyapa Uhm...
_i mean...that must've been the _*_easy_*_ part._
@@Brahvim I didn't say that making the website is hard,
I said that making both of the things were hard
This channel is a global treasure
Thank you! I found your channel recently, and now Iâve started coding again after many years paus. Love your energy and the enjoyable way you talk about maths and physics. Schools should adopt this way of teaching.
Iâm looking forward to going through all your videos! Thanks again!
Thank you so much for this tutorial.. I started programming recently and have been really fascinated with all the simulation things you do on your channel. I tried doing them on my own at first just to gauge my knowledge level, but that didn't work out so well. I followed this tutorial and your other on springs and they were soo helpful. Thank you so much!! I was able to implement this in python using the pygame module. The only part I couldn't add was the curvedvertex stuff but I'm happy with what I have already, there is so much I can do with this.
This is joyful!
Thanks Dan for this
living legend.. millions thank YOU :)
Such an enthusiastic and great teacher. I really enjoyed this.
i am often in aw of mathematiciansform the past. Hooke worked out this on paper with no way of simulating it in real time to test his theories. incredible.
I never thought playing with a springy string could be so meditative. Thanks for a fun challenge. I learned a lot!
What an amazing content you produce
So cool, I really appreciate it, thanks
Totally lovely contents. Thank you.
Amazing video, keep going! Love it !! Thank u !
Fantastic!
Mind Blowing đ
Love your teaching style, would be awesome to see a video on correlation
Dude, You're Awesome!!!!
One of my favourite channel
I want to go to NYU just to take his classes
It's easy you can just patreon him or support him via subscription and you get all his classes only for free.
@@buddhanag4987 I can't be the only one who had a good laugh at the irony here.
Yeah,@@avananana! The way he says it. Hah! "Only for free". đ€Ł
What??? He's here?
hi sir i am from india and i am you fan and i aslo made all the projects that you showed in p5.js .i will be very glad to see you in next video
I love your videos!!!
Bravo ! TrÚs bien expliqué !
why are your vids so good, i should be making my homework
you are the best!!
12:56 Interesting! I couldn't remember how to implement rest length, so what I ended up doing was taking the amount of displacement from the anchor, I normalized it, then I multiplied it by a constant that could be attained through some mathematics applied to your rest length, then I just added that value back in to the velocity, this does the exact same thing as what you did here, but likely a little more complicated and for no particular reason.
Excellent explanation. đđ
gosh! why are you so awesome?!
Thanks for your video
Limiting the x (like it can't go furthur than some maximum value)in the spring formula might have spiced the effect even more
Love you Dan đ
9:07 but isn't v.normalize() just dividing by x, only to be multiplied back a couple of lines later? And for that matter, you can achieve v.mult(-1) simply by reversing the order of the subtraction.
You ARE magic
Very good brush up on my 1985 physics. Making a 3D game and putting in spring suspension which looks great so far.
Impressive.
Very nice continue making videos
Mass bro
I need to do this in C#, so here's hoping i can translate from this very informative, helpful video
12:17
God creating earth. âWhat if I do add gravity?â
*let gravity*
Best in the world
dan is the bob ross of code
Yay!
Shiffman's hair is turning into a magistrate. :) its been so long... the interesting thing with springs is which way you do correct them, left to right, or right to left, it matters if there was a lot of them connected together in a mass.
What is your advice for people interested in humanistics and STEM at the same time?
I'm trying to follow along in a processing 3.5.4 windows running p5, but I can't make this work, and I'm following exactly the same code you're showing, even the color of the strokes. Does anyone have any idea what could be going on? Nice video by the way, I'm liking this content a lot!
Hi this is Mainak from NYUAD!! I enjoy each of your videos. Wondering if you would do any video on multi processing interface?
Newton let Hooke peruse some of his notes. When Hooke presented this law as his own, Newton came up with the phrase, "By Hooke or by crook."
I tried to figure out spring physics myself to make soft body shapes... didn't work out well haha
Dan pls make a coding challenge on super formula
why in 2021 not using
Hello Mr. Shiffman! i love what you are doing and couldn't thank you enough for your contributions!
that being said, will we see a part 3 of agar.io tutorial? we have been looking forward for that for a long while!
I really would like to get to this, yes! Sorry for leaving it hanging. Come and remind me again in a couple months. I'm focused on Nature of Code series right now.
@@TheCodingTrain yes sir! all the very best for nature of code, may you give it your all! man its been so long, we still remember the old nature of code with processing and how we messed up vectors here and there! good memories, we've come so far since :)
Will you ever make a tutorial about Reinforcement Learning or Q Learning? I think that would be great especially in p5!
With TensorFlow.js or ml5.js? Probably.
5:27 I honestly thought you had brought out a cabbage or something there
đ
How about multiplying the values by deltatime it will move things based on time rather than based on framerate
Great vid I am still watching but it's great
And as I said before I edited I am the first comment
woooooooooooow
Bob and anchor sounds like names
Dan..
Day 1 of asking for a Newtonâs Cradle
Day 1 of responding to the person asking for a Newton's Cradle
@@samuelgunter xDDD
I guess that'd be easy :/
You can do it yourself!
I mean..do I try doing that myself once..?
Collision is the only problem. Simply reversing velocities doesn't really work...it glitches out.
@@Brahvim you wouldnt need springs. You'd need conservation of momentum (pi day collision video) and a couple of tier 1 pendulum (half of the double pendulum video)
Could you do a double pendulum or a double spring pendulum?
Coding Challenge #93! czcams.com/video/uWzPe_S-RVE/video.html
Which language should i learn
JavaScript or Python?
Lua is pretty nice.
squishy squish soft spring... :3
Can you code like a pacman game it will be a good idea
Making a noodle in P5.
day 2 of asking for a Newtons Cradle!
Oh wow, great idea!
+1
It hurts a bit, that your spring constant is k and not D...
but what would it sound like :)
can it used to simulate the mould effect ?
czcams.com/video/_dQJBBklpQQ/video.html
hey if you are watching this comment can you pls tell me how to set a video as a background in p5 plssssssssssssssssssssssss
its showing velocity.add is not a function
Coding Challenge #835 - Feynman Diagrams
I thought i was first, then I saw the comments thread
omg...what did he draw there 26:41
A line? Whatâs so wrong?
Waow
javascript đ±
I feel like these aren't challenges anymore.
Poor Bob ffff
#32 in 3 hours?
Dude, why you always use Javascript
Meanwhile in CZcams HQ:
class video{
constructor(string name, channel c){
this.name = name;
this.c = c;
if(this.c.name == âThe Coding Trainâ){
this.likeCount = 10.000;
this.dislikeCount = 0;
}else{
this.likeCount = 0;
this.dislikeCount = 0;
}
createURL();
}
}
Man everytime I see this man use this weird paradigm of having both a variable for velocity anddd acceleration I die a little on the inside.
I know it's just a simple thing but it's so pointless and just complicates things in a weird way.
For me this paradigm seems very natural. But maybe I am (lile Dan?) not seeing the forest in all those trees. How would you do it?
Two different things... Nothing weird about that
@@imporbis345 I mean it's fine. Interesting that people are different y'know. Just to me it's like, you can always just add forces directly to the velocity and skip any notion of an acceleration. It's like, the only thing the acceleration variable does is store accumulated forces applied, then you have to call a separate thing to actually apply and zero out the acceleration again. But all that is simplified if you just apply those forces to the velocity in the first place, and then there's no need for separate application step. So it's more efficient as well. Which is part of why it bothers me as an optimization nerd.
In my head the idea of an object having a velocity as it is, and then adding forces directly to that makes intuitive sense.
Having the forces go through this abstract idea of an acceleration is just off, especially considering like to me, an acceleration is a constant force applied over time, but with this its just used as a like force buffer of sorts, idk.
I went and hugged a guy
I'm sleepy
I wrote you a letter but ah
I'm sad
Please be ok later
Sorry
spring method is bad to make like a rope.