From 02aca3c65272b9e746dbdf12db484f085d74e079 Mon Sep 17 00:00:00 2001 From: 43-stuti <43-stuti@users.noreply.github.com> Date: Tue, 8 Feb 2022 13:59:53 +0000 Subject: [PATCH] Notion - Update docs --- notion-docs/03_forces.md | 99 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 notion-docs/03_forces.md diff --git a/notion-docs/03_forces.md b/notion-docs/03_forces.md new file mode 100644 index 0000000..7249926 --- /dev/null +++ b/notion-docs/03_forces.md @@ -0,0 +1,99 @@ +
+

2.4 Dealing with Mass

+ + +

+OK. I’ve got one small (but fundamental) addition to make before +integrating forces into the Mover class. After all, Newton’s second law is really +\vec{F} = M \times \vec{A}, not +\vec{F} = \vec{A}. Incorporating mass is +as easy as adding an instance variable to the class, but I need to spend +a little more time here because of another impending complication. +

+

First I’ll add mass.

+
+class Mover {
+constructor(){
+this.position = createVector();
+this.velocity = createVector();
+this.acceleration = createVector();
+//{!1} Adding mass as a number
+this.mass = ????;
+}
+}
+ +
+

Units of Measurement

+

+Now that I am introducing mass, it’s important to make a quick note +about units of measurement. In the real world, things are measured in +specific units. Two objects are 3 meters apart, the baseball +is moving at a rate of 90 miles per hour, or this bowling ball has a +mass of 6 kilograms. As you’ll see later in this book, sometimes you will +want to take real-world units into consideration. However, in this +chapter, I’m going to ignore them for the most part. The units of +measurement are in pixels (“These two circles are 100 pixels apart”) and +frames of animation (“This circle is moving at a rate of 2 pixels per +frame”). In the case of mass, there isn’t any unit of measurement +to use. I’m just going to make something up. In this example, I will +arbitrarily picking the number 10. There is no unit of measurement, +though you might enjoy inventing a unit of your own, like “1 moog” or “1 +yurkle.” It should also be noted that, for demonstration purposes, I’ll +tie mass to pixels (drawing, say, a circle with a radius of 10). This +will allow me to visualize the mass of an object albeit inaccurately. In the real +world size does not indicate mass. A small metal ball could have a much higher mass than a +large balloon due to its higher density. And for two circular objects with equal density, +the mass should be tied to the formula for area which is not as simple as the radius alone. +

+
+

+Mass is a scalar, not a vector, as it’s just one number describing +the amount of matter in an object. I could get fancy and +compute the area of a shape as its mass, but it’s simpler to begin by +saying, “Hey, the mass of this object is…um, I dunno…how about 10?” +

+
+constructor() {
+this.position = createVector(random(width), random(height));
+this.velocity = createVector(0, 0);
+this.acceleration = createVector(0, 0);
+this.mass = 10;
+}
+ +

+This isn’t so great since things only become interesting once I have +objects with varying mass, but it’s enough to get us started. Where does mass come +in? It’s needed for applying Newton’s second law to the object. +

+
+applyForce(force) {
+//{!2} Newton's second law (with force accumulation and mass)
+force.div(mass);
+this.acceleration.add(force);
+}
+

+Yet again, even though the code looks quite reasonable, there is a +major problem here. Consider the following scenario with two +Mover objects, both being blown away by a wind force. +

+
+let m1 = new Mover();
+let m2 = new Mover();
+let wind = createVector(1, 0);
+m1.applyForce(wind);
+m2.applyForce(wind);
+

+Again, I’ll be the computer. Object m1 receives the +wind force—(1,0)—divides it by mass (10), and adds it to acceleration. +

+

+m1 equals wind force:     +(1,0)
+Divided by mass of 10:    (0.1,0) +

+ +

+OK. Moving on to object m2. It also receives the wind