3.5: Springs - The Nature of Code

  Рет қаралды 31,173

The Coding Train

The Coding Train

Күн бұрын

Пікірлер: 39
@ranjannayyar3863
@ranjannayyar3863 8 жыл бұрын
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.!
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
+Ranjan Nayyar Thanks for letting me know! Would love to see if you put any documentation online sometime.
@VISHNU-rr8gc
@VISHNU-rr8gc 6 жыл бұрын
I like how you clean entire board instead of the space you need. Half cleaned board kind of makes me uncomfortable. 😁😁
@Shockszzbyyous
@Shockszzbyyous 6 жыл бұрын
spring force spring forces boing boing boing.
@chanasiegel2706
@chanasiegel2706 4 жыл бұрын
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.
@sallerc
@sallerc 8 жыл бұрын
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!
@sociamix
@sociamix 8 жыл бұрын
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
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
thank you!
@OonHan
@OonHan 6 жыл бұрын
Do the pendulum example but with interactivity with other forces: also a tension force from the rope!
@brettbreet
@brettbreet 7 жыл бұрын
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?
@wikipediaboyful
@wikipediaboyful 6 жыл бұрын
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 ;)
@maniksharma9736
@maniksharma9736 3 жыл бұрын
I am in 10th grade and you make me understand everything.... God give him some subscribe....😂
@nagesh007
@nagesh007 2 жыл бұрын
Mind Blowing thanks
@artyquantum7283
@artyquantum7283 5 жыл бұрын
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_androidLover
@SymphonyKol_androidLover 3 жыл бұрын
Awesome lesson as always thank you sir!
@theostavrides1807
@theostavrides1807 4 жыл бұрын
best teacher! 🙌🙏
@darkvaporwave
@darkvaporwave 3 жыл бұрын
He knows the public reaction assessing his class and recalling it? or just simulating?
@developmentarchive5642
@developmentarchive5642 2 жыл бұрын
How does damping works in this case? Like in the last example?
@VapidVial
@VapidVial 4 жыл бұрын
Please, I have to know "the shaker" inside joke at least when the p5js noc springs video comes out!
@baphnie
@baphnie 4 жыл бұрын
I think he was alluding to the idiom "movers and shakers", which refers to people that get things done.
@VapidVial
@VapidVial 4 жыл бұрын
@@baphnie thanks! :)
@wikipediaboyful
@wikipediaboyful 6 жыл бұрын
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.
@wikipediaboyful
@wikipediaboyful 6 жыл бұрын
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
@wikipediaboyful
@wikipediaboyful 6 жыл бұрын
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.
@ruonanchang1996
@ruonanchang1996 7 жыл бұрын
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.8131
@musqueti.8131 6 жыл бұрын
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
@andyvalentine8505
@andyvalentine8505 4 жыл бұрын
What is the uses of all of this thing? I just want to know. I'm a novice so dont get me wrong.
@Ikpoppy
@Ikpoppy 7 жыл бұрын
Still watching 20:11
@zicary1636
@zicary1636 5 жыл бұрын
Mine doesnt work
@TheSkepticSkwerl
@TheSkepticSkwerl 4 жыл бұрын
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
@zoilo87
@zoilo87 7 жыл бұрын
How do i decompile the map function()?
@zoilo87
@zoilo87 7 жыл бұрын
in processing
@Shockszzbyyous
@Shockszzbyyous 6 жыл бұрын
what do you meen. like decompile the java byte code back into something readable (ish) or something else?
@Kitulous
@Kitulous 6 жыл бұрын
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.
@tinynova
@tinynova 8 жыл бұрын
Broken Github link in description :/
@zicary1636
@zicary1636 5 жыл бұрын
You didnt explain what you did!
@theaveragemegaguy
@theaveragemegaguy Жыл бұрын
i love u
@arsalankhosrojerdi1475
@arsalankhosrojerdi1475 5 жыл бұрын
cocaine is bad
2.4: Friction Force - The Nature of Code
20:38
The Coding Train
Рет қаралды 39 М.
3.3: Simple Harmonic Motion - The Nature of Code
16:50
The Coding Train
Рет қаралды 45 М.
Human vs Jet Engine
00:19
MrBeast
Рет қаралды 185 МЛН
ROSÉ & Bruno Mars - APT. (Official Music Video)
02:54
ROSÉ
Рет қаралды 271 МЛН
Who's spending her birthday with Harley Quinn on halloween?#Harley Quinn #joker
01:00
Harley Quinn with the Joker
Рет қаралды 13 МЛН
2.5: Drag Force - The Nature of Code
15:11
The Coding Train
Рет қаралды 34 М.
The Curious World of Springs | Szydlo's At Home Science
37:03
The Royal Institution
Рет қаралды 61 М.
Coding Challenge 160: Spring Forces
32:43
The Coding Train
Рет қаралды 103 М.
4.3: Deleting objects from ArrayList - The Nature of Code
14:59
The Coding Train
Рет қаралды 54 М.
2.3: Simulating with Mass - The Nature of Code
14:44
The Coding Train
Рет қаралды 41 М.
The Art of Code - Dylan Beattie
1:00:49
NDC Conferences
Рет қаралды 4,7 МЛН
Object Oriented Programming is not what you think it is. This is why.
13:36
2.6: Gravitational Attraction - The Nature of Code
20:16
The Coding Train
Рет қаралды 55 М.
Functional Programming in 40 Minutes • Russ Olsen • GOTO 2018
41:35
GOTO Conferences
Рет қаралды 817 М.
1.6: Vectors: Acceleration towards Mouse - The Nature of Code
10:06
The Coding Train
Рет қаралды 58 М.
Human vs Jet Engine
00:19
MrBeast
Рет қаралды 185 МЛН