Problem 3-3

This commit is contained in:
2021-08-27 21:17:34 -07:00
parent 2c8989262a
commit 298070b41e
3 changed files with 155 additions and 56 deletions

View File

@@ -91,10 +91,10 @@
calcAccelerations();
//Relative position of canvas
var xPos = 0;
var yPos = 70;
var yPos = 90;
//Moves and scales canvas
ctx.translate(ctx.canvas.width / 2, ctx.canvas.height / 2)
ctx.scale(2, -2);
ctx.scale(1.5, -1.5);
function calcAccelerations()
{
@@ -144,15 +144,15 @@
{
Reset();
}
if (75 - y2 - y1 <= 20)
if (100 - y2 - y1 <= 20)
{
Reset();
}
if (75 - y3 - y1 <= 20)
if (100 - y3 - y1 <= 20)
{
Reset();
}
if (75 + y1 <= 35)
if (100 + y1 <= 35)
{
Reset();
}
@@ -176,52 +176,32 @@
ctx.stroke();
ctx.beginPath();
ctx.moveTo(xPos - 20, yPos);
ctx.lineTo(xPos - 20, yPos - (75 - y1));
ctx.lineTo(xPos - 20, yPos - (100 - y1));
ctx.stroke();
ctx.beginPath();
ctx.arc(xPos - 20, yPos - (75 - y1), Math.PI * Math.sqrt(m1), 0, Math.PI * 2);
ctx.arc(xPos - 20, yPos - (100 - y1), Math.PI * Math.sqrt(m1), 0, Math.PI * 2);
ctx.fill();
ctx.beginPath();
ctx.moveTo(xPos + 20, yPos);
ctx.lineTo(xPos + 20, yPos - (75 + y1));
ctx.lineTo(xPos + 20, yPos - (100 + y1));
ctx.stroke();
ctx.beginPath();
ctx.arc(xPos + 20, yPos - (75 + y1), 20, 0, Math.PI * 2);
ctx.arc(xPos + 20, yPos - (100 + y1), 20, 0, Math.PI * 2);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(xPos, yPos - (75 + y1));
ctx.lineTo(xPos, yPos - (150 - y2));
ctx.moveTo(xPos, yPos - (100 + y1));
ctx.lineTo(xPos, yPos - (200 - y2));
ctx.stroke();
ctx.beginPath();
ctx.arc(xPos, yPos - (150 - y2), Math.PI * Math.sqrt(m2), 0, Math.PI * 2);
ctx.arc(xPos, yPos - (200 - y2), Math.PI * Math.sqrt(m2), 0, Math.PI * 2);
ctx.fill();
ctx.beginPath();
ctx.moveTo(xPos + 40, yPos - (75 + y1));
ctx.lineTo(xPos + 40, yPos - (150 - y3));
ctx.moveTo(xPos + 40, yPos - (100 + y1));
ctx.lineTo(xPos + 40, yPos - (200 - y3));
ctx.stroke();
ctx.beginPath();
ctx.arc(xPos + 40, yPos - (150 - y3), Math.PI * Math.sqrt(m3), 0, Math.PI * 2);
ctx.arc(xPos + 40, yPos - (200 - y3), Math.PI * Math.sqrt(m3), 0, Math.PI * 2);
ctx.fill();
/*ctx.beginPath();
ctx.arc(xPos + lx / 2, yPos, pulleyR, 0, Math.PI * 2);
ctx.stroke();
ctx.beginPath();
ctx.arc(xPos - lx / 2, yPos, pulleyR, 0, Math.PI * 2);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(xPos + lx / 2 + pulleyR, yPos);
ctx.lineTo(xPos + lx / 2 + pulleyR + r * Math.sin(theta), yPos - r * Math.cos(theta));
ctx.stroke();
ctx.beginPath();
ctx.moveTo(xPos - lx / 2 - pulleyR, yPos);
ctx.lineTo(xPos - lx / 2 - pulleyR, yPos - (250 - r));
ctx.stroke();
ctx.beginPath();
ctx.arc(xPos + lx / 2 + pulleyR + r * Math.sin(theta), yPos - r * Math.cos(theta), 5, 0, Math.PI * 2);
ctx.fill();
ctx.beginPath();
ctx.arc(xPos - lx / 2 - pulleyR, yPos - (250 - r), 5, 0, Math.PI * 2);
ctx.fill();*/
}
@@ -229,7 +209,7 @@
c.width = window.innerWidth;
c.height = window.innerHeight;
ctx.translate(c.width / 2, c.height / 2);
ctx.scale(2, -2);
ctx.scale(1.5, -1.5);
}, true);
Update();