3-30 and index file

This commit is contained in:
2021-08-29 11:04:41 -07:00
parent 3cb8abfd8f
commit 8ff3055c97
5 changed files with 360 additions and 3 deletions

View File

@@ -6,7 +6,7 @@
<html>
<head>
<title>
Problem 3-2
Exercise 3-27
</title>
<style>
html, body {

View File

@@ -6,7 +6,7 @@
<html>
<head>
<title>
Problem 3-2
Exercise 3-28
</title>
<style>
html, body {

View File

@@ -6,7 +6,7 @@
<html>
<head>
<title>
Problem 3-2
Exercise 3-29
</title>
<style>
html, body {

226
3-30.html Normal file
View File

@@ -0,0 +1,226 @@
<!--
This work is licensed under CC BY-NC-ND 4.0
Link to license: http://creativecommons.org/licenses/by-nc-nd/4.0/
Attribute to Russell Georgi
-->
<html>
<head>
<title>
Exercise 3-30
</title>
<style>
html, body {
width: 100%;
height: 100%;
margin: 0px;
border: 0;
overflow: hidden;
display: block;
}
canvas {
position: absolute;
}
.dropbtn {
background-color: #04AA6D;
color: white;
padding: 16px;
font-size: 16px;
border: none;
}
.dropdown {
position: absolute;
display: inline-block;
}
.dropdown-content {
display: none;
position: relative;
background-color: #f1f1f1;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content button {
color: black;
padding: 12px 16px;
width: 100px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: #ddd;}
.dropdown:hover .dropdown-content {display: block;}
.dropdown:hover .dropbtn {background-color: #3e8e41;}
</style>
</head>
<body>
<canvas id="myCanvas" width="1" height="1" style="border:1px solid #ffffff;">
Your browser does not support the HTML5 canvas tag.</canvas>
<div class="dropdown">
<button class="dropbtn" id="btn">1 Pulley</button>
<div class="dropdown-content">
<button onclick="num(1)">1 Pulley</button>
<button onclick="num(2)">2 Pulleys</button>
<button onclick="num(3)">3 Pulleys</button>
<button onclick="num(4)">4 Pulleys</button>
<button onclick="num(5)">5 Pulleys</button>
<button onclick="num(6)">6 Pulleys</button>
</div>
</div>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
c.width = window.innerWidth;
c.height = window.innerHeight;
//Time step
var dt = 0.002;
var t = 0;
var g = 98;
var m1 = 1;
var m2 = 1;
var y1 = 0;
var y2 = 0;
var v1 = 0;
var v2 = 0;
var n = 1;
var dist = 75;
var pulleyPositions = new Array(n);
var pulleyVelocities = new Array(n);
//Relative position of canvas
var xPos = 0;
var yPos = 200;
//Moves and scales canvas
ctx.translate(ctx.canvas.width / 2, ctx.canvas.height / 2)
ctx.scale(1, -1);
Reset();
function calcAccelerations(p)
{
return (2 ** p) * g * (2 ** n - 1) / (2 ** (2 * n) + 1);
}
function num(number)
{
n = number;
if (number == 1)
{
document.getElementById("btn").textContent = "1 Pulley"
} else
{
document.getElementById("btn").textContent = number.toString() + " Pulleys"
}
Reset();
}
function Clear(ctx)
{
ctx.clearRect(-c.width, -c.height, c.width * 2, c.height * 2);
}
function Update()
{
Clear(ctx);
Draw();
t += dt;
v1 -= calcAccelerations(0) * dt;
v2 += calcAccelerations(n) * dt;
y1 += v1 * dt;
y2 += v2 * dt;
for (i = 0; i < n; i++)
{
pulleyVelocities[i] -= calcAccelerations(n - i - 1) * dt;
pulleyPositions[i] += pulleyVelocities[i] * dt;
}
if (y2 > dist - 20)
{
Reset();
}
setTimeout(Update, 5);
}
function Reset()
{
y1 = 0;
y2 = 0;
v1 = 0;
v2 = 0;
pulleyPositions = new Array(n);
pulleyVelocities = new Array(n);
for (i = 0; i < n; i++)
{
pulleyVelocities[i] = 0;
pulleyPositions[i] = 0;
}
}
function Draw()
{
ctx.beginPath();
ctx.moveTo(-c.width, yPos + 50);
ctx.lineTo(c.width, yPos + 50);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(xPos + 80, yPos + 50);
ctx.lineTo(xPos + 80, yPos);
ctx.stroke();
ctx.beginPath();
ctx.arc(xPos + 80, yPos, 20, 0, Math.PI * 2);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(xPos + 100, yPos);
ctx.lineTo(xPos + 100, yPos + y2 - dist);
ctx.stroke();
ctx.beginPath();
ctx.arc(xPos + 100, yPos + y2 - dist, Math.PI * Math.sqrt(m2), 0, Math.PI * 2);
ctx.fill();
ctx.beginPath();
ctx.moveTo(xPos + 60, yPos);
ctx.lineTo(xPos + 60, yPos - dist + pulleyPositions[0]);
ctx.stroke();
for (i = 0; i < n; i++)
{
ctx.beginPath();
ctx.arc(xPos + 40 - 20 * i, yPos - dist - dist * i + pulleyPositions[i], 20, 0, Math.PI * 2);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(xPos + 40 - 20 * i, yPos - dist - dist * i + pulleyPositions[i]);
ctx.lineTo(xPos + 40 - 20 * i, yPos - dist - dist * (i + 1) + pulleyPositions[i + 1]);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(xPos + 40 - 20 * (i + 1), yPos - dist - dist * i + pulleyPositions[i]);
ctx.lineTo(xPos + 40 - 20 * (i + 1), yPos + 50);
ctx.stroke();
}
ctx.beginPath();
ctx.moveTo(xPos + 40 - 20 * (n - 1), yPos - dist - dist * (n - 1) + pulleyPositions[n - 1]);
ctx.lineTo(xPos + 40 - 20 * (n - 1), yPos - dist - dist * (n) + y1);
ctx.stroke();
ctx.beginPath();
ctx.arc(xPos + 40 - 20 * (n - 1), yPos - dist - dist * (n) + y1, Math.PI * Math.sqrt(m1), 0, Math.PI * 2);
ctx.fill();
}
window.addEventListener('resize', function(event) {
c.width = window.innerWidth;
c.height = window.innerHeight;
ctx.translate(c.width / 2, c.height / 2);
ctx.scale(1, -1);
}, true);
Update();
</script>
</body>
<p xmlns:cc="http://creativecommons.org/ns#" style="font-size: 1vw; bottom: 0px; position: absolute;">
This work is licensed under
<a href="http://creativecommons.org/licenses/by-nc-nd/4.0/?ref=chooser-v1" target="_blank" rel="license noopener noreferrer" style="display:inline-block;">CC BY-NC-ND 4.0<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/cc.svg?ref=chooser-v1"><img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/by.svg?ref=chooser-v1"><img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/nc.svg?ref=chooser-v1"><img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/nd.svg?ref=chooser-v1"></a></p>
</html>

131
index.html Normal file
View File

@@ -0,0 +1,131 @@
<!--
This work is licensed under CC BY-NC-ND 4.0
Link to license: http://creativecommons.org/licenses/by-nc-nd/4.0/
Attribute to Russell Georgi
-->
<html>
<head>
<title>
List of programs
</title>
<style>
table {
border-collapse: collapse;
width: 100%;
}
td {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
th {
border: 1px solid #dddddd;
text-align: center;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<body>
<table>
<tr>
<td>
Number
</td>
<td>
Description
</td>
</tr>
<tr>
<th colspan = "2">
<t>Chapter 1: Strategies for Solving Problems</t>
</th>
</tr>
<tr>
<td>
<a href='circularPendulum.html'>Circular pendulum</a>
</td>
<td>
<t>Circular pendulum example problem</t>
</td>
</tr>
<tr>
<td>
<a href='1-7.html'>Problem 1-7</a>
</td>
<td>
<t>Two masses, one swinging</t>
</td>
</tr>
<tr>
<th colspan = "2">
<t>Chapter 3: Using F=ma</t>
</th>
</tr>
<tr>
<td>
<a href='3-1.html'>Problem 3-1</a>
</td>
<td>
<t>Basic Atwood's machine</t>
</td>
</tr>
<tr>
<td>
<a href='3-2.html'>Problem 3-2</a>
</td>
<td>
<t>Double Atwood's machine</t>
</td>
</tr>
<tr>
<td>
<a href='3-3.html'>Problem 3-3</a>
</td>
<td>
<t>Infinite Atwood's machine</t>
</td>
</tr>
<tr>
<td>
<a href='3-11.html'>Problem 3-11</a>
</td>
<td>
<t>Chain falling off a table</t>
</td>
</tr>
<tr>
<td>
<a href='3-27.html'>Problem 3-27</a>
</td>
<td>
<t>A more complicated Atwood's machine</t>
</td>
</tr>
<tr>
<td>
<a href='3-28.html'>Problem 3-28</a>
</td>
<td>
<t>Another Atwood's machine</t>
</td>
</tr>
<tr>
<td>
<a href='3-29.html'>Problem 3-29</a>
</td>
<td>
<t>Yet another Atwood's machine</t>
</td>
</tr>
</table>
<p xmlns:cc="http://creativecommons.org/ns#" >
This work is licensed under
<a href="http://creativecommons.org/licenses/by-nc-nd/4.0/?ref=chooser-v1" target="_blank" rel="license noopener noreferrer" style="display:inline-block;">CC BY-NC-ND 4.0<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/cc.svg?ref=chooser-v1"><img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/by.svg?ref=chooser-v1"><img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/nc.svg?ref=chooser-v1"><img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/nd.svg?ref=chooser-v1"></a></p>
</body>
</html>