I think the really good part of series is that you recommend some amazing exercises at the end.! I just love doing them. I did the same when we were doing gravitational force. I made 10 circles with some having gravitational attraction and some having repulsion. At a hundred my computer crashed. haha. But anyways the results were amazing.! Thanks a lot for making this video series.!
@TheCodingTrain8 жыл бұрын
+Ranjan Nayyar Thanks for letting me know! Would love to see if you put any documentation online sometime.
@VISHNU-rr8gc6 жыл бұрын
I like how you clean entire board instead of the space you need. Half cleaned board kind of makes me uncomfortable. 😁😁
@Shockszzbyyous6 жыл бұрын
spring force spring forces boing boing boing.
@chanasiegel27064 жыл бұрын
How did you calculate the direction of the vector? Subtracting the bob from the origin should create a vector that always points up (or down). Shouldn't you be subtracting the current length from the rest length? Please answer soon. Thanks.
@sallerc8 жыл бұрын
Look at that, already watched the first three chapters. Regarding OO design and refactoring - as a long time Visual Studio/Resharper developer, that manual variable rename made me cringe :) Tempted to port some example to C#/Winforms and play with it. Anyway, thanks again for this awesome course! Keep up the good work!
@sociamix8 жыл бұрын
I have to thank you again for this course ! It worth PVector.sub(sun.location, earth.location).mag() times every other book or tutorial on the subject, plus it's funny :D
@TheCodingTrain8 жыл бұрын
thank you!
@OonHan6 жыл бұрын
Do the pendulum example but with interactivity with other forces: also a tension force from the rope!
@brettbreet7 жыл бұрын
Hey, you asked if anyone had a question, so here's one! Can you create a pendulum from a spring with the resting length and starting length the same, giving an initial theta, and adding a gravity force? Is this a better way than the previous method since you can easily add other forces without having to worry about independent angular acceleration?
@wikipediaboyful6 жыл бұрын
Bob b; void setup() { size(640, 360); b = new Bob(20, 0, 0); //mass,displacement,angle } void draw() { background(255); PVector g=new PVector(0, b.m*b.g); PVector wind = new PVector(1, 0); if (mousePressed) { b.apply(wind); } b.spring(); b.apply(g); b.update(); b.display(); } //copy the following in another tab class Bob { PVector position; PVector velocity; PVector acceleration; PVector origin; float m, g, k, dx, slen, restlength, restDx; float theta; Bob(float a, float b, float angle) { theta=angle; m=a; float displacement=b; g=0.2; slen=150; k=0.5; restDx=m*g/k; restlength=slen+restDx; acceleration = new PVector(0, 0); velocity = new PVector(0, 0); position = new PVector((slen+restlength+displacement)*sin(theta)+width/2, (restlength+displacement)*cos(theta)); origin = new PVector (width/2, 0); } void apply(PVector force) { PVector f=force.div(m); acceleration.add(f); } void spring() { PVector spring=PVector.sub(origin, position); spring.normalize(); dx=position.y-restlength+restDx; spring.mult(k*dx); apply(spring); } void update() { velocity.add(acceleration); position.add(velocity); acceleration.mult(0); //velocity.mult(0.99); } void display() { line(position.x, position.y, width/2, 0); ellipse(position.x, position.y, 2*m, 2*m); } } //enjoy it mate ;)
@maniksharma97363 жыл бұрын
I am in 10th grade and you make me understand everything.... God give him some subscribe....😂
@nagesh0072 жыл бұрын
Mind Blowing thanks
@artyquantum72835 жыл бұрын
Thanks for the effort and such wonderful content. Now that we have been introduced to the constraints like more specifically Force constraint, do you have any plan to do Energy constraints ? May be in future ? They have always puzzled me that how can they calculate the position from the Energy equations.
@SymphonyKol_androidLover3 жыл бұрын
Awesome lesson as always thank you sir!
@theostavrides18074 жыл бұрын
best teacher! 🙌🙏
@darkvaporwave3 жыл бұрын
He knows the public reaction assessing his class and recalling it? or just simulating?
@developmentarchive56422 жыл бұрын
How does damping works in this case? Like in the last example?
@VapidVial4 жыл бұрын
Please, I have to know "the shaker" inside joke at least when the p5js noc springs video comes out!
@baphnie4 жыл бұрын
I think he was alluding to the idiom "movers and shakers", which refers to people that get things done.
@VapidVial4 жыл бұрын
@@baphnie thanks! :)
@wikipediaboyful6 жыл бұрын
something is wrong here: github.com/shiffman/The-Nature-of-Code-Examples/blob/master/chp03_oscillation/NOC_3_11_spring/NOC_3_11_spring.pde#L56 here in setup() // Note third argument in Spring constructor is "rest length" spring = new Spring(width/2,10,100); bob = new Bob(width/2,100); if the rest length is 100, and the bob "y" location is 100, then why as soon as I start the program the bob oscillates? It shouldn't.
@wikipediaboyful6 жыл бұрын
I understood why, when both bob location and rest length are equal is when the system is at equilibrium, but there's no notion of this in the program, there isn't something like stretch*K=m*g. And even worst when we introduce a displacement from the rest position, that displacement should be produce by a new force, like a hand pulling the bob down. I'm having a real headache coding this, I've been coding half a day this situation hahaha
@wikipediaboyful6 жыл бұрын
solve it, if someone here is watching, on spring class_: void connect(Bob b), "float stretch = d - len;" , it should be "float stretch = d - len+m*g/k;" which adds the displacement produced by the bob at the rest position with the bob attached to the spring. Because in Hook's law, the displacement deltaX is calculated from the spring length with no mass in it. If we say stretch=d-len, and we draw the bob at rest position, d-len=0, which only adds gravity to the bob, which caused an initial oscillation at the beginning where it shouldn't.
@ruonanchang19967 жыл бұрын
I have a question here!!!! you used PVector.sub(bob.location,origin) to calculate the direction of the spring force, but later you multiply (-k * stretch), Doesn't negative k actually reverse the direction of the spring force???
@musqueti.81316 жыл бұрын
The formula itself says F = -k * x, so.. it's just the way it is supposed to be. But the direction vector actually doesnt tell us much about the direction, since it's normalized and points into the same direction - down (it's always (0, 1)). It is the stretch variable (or the difference of lengths) that gives us info about the real direction of the force. (based on what's bigger - current length or rest length)... I don't think you really needed an explanation or cared about it anymore, but I guess I wanted to explain it at least to myself. :D
@andyvalentine85054 жыл бұрын
What is the uses of all of this thing? I just want to know. I'm a novice so dont get me wrong.
@Ikpoppy7 жыл бұрын
Still watching 20:11
@zicary16365 жыл бұрын
Mine doesnt work
@TheSkepticSkwerl4 жыл бұрын
I have a project for you! Why not have a "drop a slinky" challenge. If you've never seen it in slow mo. Please check it out
@zoilo877 жыл бұрын
How do i decompile the map function()?
@zoilo877 жыл бұрын
in processing
@Shockszzbyyous6 жыл бұрын
what do you meen. like decompile the java byte code back into something readable (ish) or something else?
@Kitulous6 жыл бұрын
if you need how know how it works, it simply renders a1, b1 to a2, b2. Given a1=0, b1 = 1 (our original bounds), a2=100, b2=300 (our desired bounds), we can think: if x (first argument of map(x,a1,b1,a2,b2) function) equals to 0, then a2 equals 100, because 0 is our lower bound and it corresponds to 100, our another lower bound. If x=0.5 (the middle between 0 and 1), then the result should also be in the middle between 100 and 300, giving us 200. So: float percentage = x / (a1+b1); // percentage is the float around [0; 1] that shows the position in the rendering. E.g. x=0.5 in our first example would give us the percentage of 0.5 float result = a2 + percentage*(b2-a2); // this projects the percentage on the desired bounds basing on the given bounds.