okay we're now in Chapter two part two
series two whatever you want to call it
of this strange thing that we're doing
hopefully it's not that strange it's
very strange to me but I also I'm just
afraid of the world and everything seems
weird and uncomfortable but you this
should make you comfortable it should
make you interested and if not please
there's a stop button there so outside
world there's trees sunshine snow
children playing there's so many things
that you could do but we're here we're
going to keep going okay so a force is a
vector that causes an object with mass
to accelerate I prepared for this video
by writing this up here a force is a
vector that causes an object with mass
to accelerate what do we mean by that
this is an object with mass it is
experiencing forces right now there's
perhaps some weight on it there is a
gravity pulling it down there's air
resistance all of these things these are
the things we want to model and our goal
here is start with a little Clementine
diversion but the goal here is to be
able to write a processing sketch where
a singular object on the screen
experiences multiple forces at the same
time those forces could turn off turn
turn on turn off scale up scale down
this is where we're going to get a
dynamic simulation of recording
excellent okay but let's see if we're
ready to do this the good news about
this definition is it proves that we are
we we're very comfortable we know it a
vector is a vector is a quantity with
magnitude and direction check we know
what acceleration is acceleration is the
change in velocity over time and for us
it's the change in velocity per frame
per frame of animation so we're pretty
good here we know that we can define a
vector P vector force equals new P
vector and we can apply that vector to
acceleration velocity dot add
acceleration we're kind of done we did
this already so this isn't the nice
thing as this isn't new there is a new
part to this which is a force is a
vector that causes an object with mass
to accelerate and you know just to
demonstrate for a second not to not to
belabor the Clementine but I do like
lemma times this is an object with mass
come on run processing sketch run the
timing is off I had the perfect time let
me just try that again instead of
editing myself this is an object with
mass this is a bunch of pixels on the
screen like colored gray there's no mass
there but we could invent mass so
inventing mass are sort of like a proxy
for mass in our code is something that
we're going to have to look at not have
to but it's going to be a useful thing
for us to look at to make our
simulation perhaps more realistic
dynamic to feel more know just nice to
make it nice that's our that's we should
be also be so happy as to have a
simulation with mass okay so but back
over here so this is where we're going
and we did this already so in essence in
many ways this video it's the sad truth
is us just reorganizing our code to kind
of separate out this part where the
forces come in to an object from that
update method but before we do any of
that I think it is a useful it's it's
it's use fives forgot to start the timer
so no I don't know how long I've been
going but useful few minutes for us to
just walk through Newton's laws of
motion together this is the stuff of
high school physics classrooms I'm sure
that I will watch the explanation but I
will give you my best interpretation of
those laws many of you will hopefully
experts in this stuff and will email me
that I got it wrong and I'll fix it
later or something but I one of the
things we want to do here as an exercise
to say we want our simulations to obey
Newton's laws of motion you probably
ultimately want to break those laws of
motion in many ways because you might be
hoping to do something creative that's
different to invent your own physics in
a way but at least as a starting point
we want to look at what is what what's
the real what's happening in the real
world can we make sure our code matches
that in some way and and keep going from
there
so let's actually look I did prepare a
little bit more for this video in that
rather than have to write this out let's
see if I can do this okay here is
Newton's first law an object at rest
stays at rest and
object in motion stays in motion okay
well really that's it's a little bit
misleading to state that here's the
thing before Newton came along people
thought that if you wanted something to
keep going you had to keep applying a
force to it so if I toss this in the air
throw this across the room and try not
to me to throw this across the room
ready there's a soft little sweater over
there
so okay land on the sweater it stopped
moving right to get it to keep moving I
have to keep applying a force to it
right so I just feel the need to move
over here now I can see that the
Clementine is okay no clementines were
hurt in the shooting of this video I
really should redo this one where I keep
going the point is that an object state
divil of an object's velocity never
changes it's the opposite of this thing
that people thought I have to keep
pushing it
the reason something slows down to a
stop is because there's friction and air
resistance and all these forces pushing
in the opposite direction velocity
causing things in the real world to
ultimately stop moving if you roll it
along the ground but in a vacuum in the
absence of forces or if the net force is
zero an object's velocity stays constant
it keeps moving in the same direction
with the same speed or it stays at rest
its philosophy is zero and we could
demonstrate that by this right this
object the net force there's gravity but
my thumb is somehow giving a force in
the opposite direction the the net force
on this object is zero so it stays at
rest so one of the things this the
reason why I lost my pen and not that I
need it but it's like a comfort device
it's like my it's my comfort device but
I need device I don't know comfort
object that I need to hold the field
safe but so the point is that the point
is there is a point the point is that we
want this idea of a net force is really
important we want to be able to
accumulate our forces in such a way that
if we add up all the forces together if
the net force is zero the object
velocity is constant so we want to make
sure our simulation obeys that rule
that's Newton's law number one now
Newton's law number three I'm going to
do number out of order number three
here's a diagram showing you net force
is Newton's little is is often stated
this way for every action there is an
equal and opposite reaction but this is
a bit misleading it sounds like you know
hey if I like
Anshu that your opposite reaction is
equal and you punch me back no this is
not really how things work and I think a
better way of stating this if I could
get back here is the following forces
always occur in pairs the two forces are
of equal strength but in opposite
directions and a great demonstration if
you'll just bear with me if I get my
clementines again is gravitational
interaction so gravitational attraction
occurs the force occurs in pairs now we
think of gravity as this thing that
makes stuff fall right that the earth is
sucking everything down into it and
everything just on the ground and that's
why we're we have muscles people
standing upright and all sorts of stuff
the truth of the matter is just as we
just says the earth exerts a
gravitational force on us we exert a
gravitational force on the earth just
the earth is so much bigger that it kind
of overwhelmed the magnitude of that
force overwhelms our little tiny tiny
force but the force occurs in pairs now
this this is this brings up an
interesting question for our simulation
every time we create a force do we need
to create another force do we have to
implement this pairs thing theater that
question strangely is no Newton's third
law is something that we're going to not
worry about too much I mean after all
are we when we have a lips moving around
the the window are we simulating the
force that it applies to all the air
particles around it and all the air
particles apply for force back and the
gravity of the dis and that and all this
stuff no we're just kind of saying like
it's a vector put it in the acceleration
that kind of looks right so we're doing
a kind of loosey-goosey simulation in a
lot of these basic examples that we're
going to see in a moment the thing is
there are times where you really do want
these pairs if you are doing a celestial
body simulation with kind of
gravitational attraction and
everything's attracted to everything
this is where you want to say for every
object apply that force in pairs both of
these are attracted to each other and
then if I could if I had three hands or
actually I can juggle but I don't have
1/3 Clementine I guess maybe I could do
it with no no no late in another video
juggling video no you don't to see that
so um this is Newton's third law is an
important
for us to be aware of but for the most
part it's a it's a point of realization
where we're not actually simulating with
incredible precision the the the force
of every body acting on every body in
fact there's not enough circle moving
around the screen is it scraping against
the back of the screen is it like
what's even going on there so we have to
realize that there's this sort of
pretend thing that we're creating
I should rerecord this video because if
I did this again I would cut out all
this extra nonsense but I'm times of the
essence we're going to keep going the
good thing is you can always
fast-forward or stop or quit or download
delete whatever ok so Newton's second
law and second law essentially restates
this definition and this is the law that
is most important to us this is the law
that is going to instigate us to write a
new function in our processing sketch
right so let's look at this law force
and technically speaking this should
really say net force but let's just be
simpler about it for right now force
equals mass times acceleration awesome
force equals mass times acceleration we
know right we wrote this update function
in our processing sketch that update
function had location dot add velocity
it had velocity dot add location and we
asked this question in every sketch that
we write I have velocity not add
acceleration in every sketch that we
write what is our algorithm for
acceleration that is the moment where we
put our creativity our control our
algorithm our math our idea into our
sketch this is the standard motion
algorithm this is where we're putting
our stamp on it now we're saying let's
use this formula well force equals mass
times acceleration acceleration equals
force I can do this divided by mass
right divide both sides of the equation
by mass we have for acceleration equals
force divided by mass the interesting
thing about this is I have an idea one
of the things I would like to do someday
is live in a world where the mass of
everything is equal to 1 and if you ever
wanted that you came to by programming
your own world right so if you program
your own world you can just say the
massive ever
in that world is 1 and if mass equals 1
what are we saying here acceleration
equals force look how simple Newton's
law is force is a vector that causes an
object with mass to accelerate
acceleration equals force acceleration
equals force so this is the essence of
what we're about to do acceleration
equals force it's funny like when we
answer a question by asking another
question we said ok you know what
everything is always about what is your
algorithm for acceleration and now we
just said not enough acceleration equals
force and now we have the question what
is your algorithm for force and this is
the question we're going to answer in
all in the next series of future videos
we're going to look at I don't know
let's just make up forces we're going to
make up forces with some numbers and
apply them to objects then we're going
to look at I found this physics textbook
and has a formula in it could we apply
that formula in our code to simulate
fluid resistance or friction or drag or
gravitational attraction tension there
any number of forces you can think of
you can find a formula for them we write
that formula in code and apply it to
your object so this is where we're going
now that we've answered we sort of
answered the question of how we're going
to apply Newton's line and we will get
to mass we will put mass back into this
equation here but we're going to wait
for that for a moment and we'll get to
that eventually so I think actually this
is a good place to stop this video what
I like about this is I feel like this
video is kind of just rambling
explanation of Newton's laws so anybody
should feel free to skip it and go on to
the next one where we're really going to
dive into the code ok thank you I don't
know if I should thank you but I really
feel the need to and see you later