Skip to content

Commit

Permalink
Merge pull request #815 from nature-of-code/notion-update-docs
Browse files Browse the repository at this point in the history
[Notion] Update docs
  • Loading branch information
shiffman committed Feb 24, 2024
2 parents 521b36e + 4899c98 commit e4b74c4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion content/03_oscillation.html
Original file line number Diff line number Diff line change
Expand Up @@ -963,13 +963,13 @@ <h2 id="the-pendulum">The Pendulum</h2>
this.angle += this.angleVelocity;
}</pre>
</div>
<p>Note that the acceleration calculation now includes a multiplication by –1. When the pendulum is to the right of its resting position, the angle is positive, and so the sine of the angle is also positive. However, gravity should pull the bob back toward the resting position. Conversely, when the pendulum is to the left of its resting position, the angle is negative, and so its sine is negative too. In this case, the pulling force should be positive. Multiplying by –1 is necessary in both scenarios.</p>
<div class="half-width-right">
<figure>
<img src="images/03_oscillation/03_oscillation_19.png" alt="Figure 3.22: The bob position relative to the pivot in polar and Cartesian coordinates">
<figcaption>Figure 3.22: The bob position relative to the pivot in polar and Cartesian coordinates</figcaption>
</figure>
</div>
<p>Note that the acceleration calculation now includes a multiplication by –1. When the pendulum is to the right of its resting position, the angle is positive, and so the sine of the angle is also positive. However, gravity should pull the bob back toward the resting position. Conversely, when the pendulum is to the left of its resting position, the angle is negative, and so its sine is negative too. In this case, the pulling force should be positive. Multiplying by –1 is necessary in both scenarios.</p>
<p>Next, I need a <code>show()</code> method to draw the pendulum on the canvas. But where exactly should I draw it? How do I calculate the x- and y-coordinates (Cartesian!) for both the pendulum’s pivot point (let’s call it <code>pivot</code>) and bob position (let’s call it <code>bob</code>)? This may be getting a little tiresome, but the answer, yet again, is trigonometry, as shown in Figure 3.22.</p>
<p>First, I’ll need to add a <code>this.pivot</code> property to the constructor to specify where to draw the pendulum on the canvas:</p>
<pre class="codesplit" data-code-language="javascript">this.pivot = createVector(100, 10);</pre>
Expand Down

0 comments on commit e4b74c4

Please sign in to comment.