2024-06-22 15:01:10 -05:00
|
|
|
## Slide 1
|
2024-06-21 20:11:48 -05:00
|
|
|
|
|
|
|
```drawing
|
|
|
|
title Test Drawing!
|
|
|
|
caption This is a test
|
2024-06-22 15:01:10 -05:00
|
|
|
scale 2.0
|
2024-06-21 20:11:48 -05:00
|
|
|
buttons
|
|
|
|
frame 0 0 200 100
|
|
|
|
axes 200 100
|
2024-06-21 20:18:28 -05:00
|
|
|
point p1 _.oscillatingPoint([20, 20], [80, 20], 3000)
|
2024-06-21 20:11:48 -05:00
|
|
|
fill cyan
|
|
|
|
square p1 1000
|
|
|
|
point p2 [100, 30]
|
|
|
|
fill red
|
|
|
|
circle p2
|
2024-06-21 20:18:28 -05:00
|
|
|
point p3 [ _.oscillatingValue(20, 80, 3000),
|
|
|
|
_.oscillatingValue(20, 80, 3000, Math.PI/2) ]
|
2024-06-21 20:11:48 -05:00
|
|
|
fill green
|
|
|
|
circle p3 1000
|
|
|
|
start
|
2024-06-22 15:01:10 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
## Slide 2
|
|
|
|
|
|
|
|
```drawing
|
|
|
|
title Sine Wave
|
|
|
|
caption `y = sin(x)`
|
|
|
|
scale 64
|
|
|
|
frame 0 -1 2*Math.PI 1
|
|
|
|
stroke black 4
|
|
|
|
eval _.line([0, -1], [0, 1])
|
|
|
|
eval _.line([0, 0], [2*Math.PI, 0])
|
|
|
|
stroke red 2
|
|
|
|
func Math.sin(x)
|
|
|
|
```
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
## Slide 3
|
|
|
|
|
|
|
|
```drawing
|
|
|
|
title Oscillating Sine Wave
|
|
|
|
caption `y = sin(x) * sin(t)`
|
|
|
|
scale 64
|
|
|
|
frame 0 -1 2*Math.PI 1
|
|
|
|
stroke black 4
|
|
|
|
eval _.line([0, -1], [0, 1])
|
|
|
|
eval _.line([0, 0], [2*Math.PI, 0])
|
|
|
|
stroke red 2
|
|
|
|
func Math.sin(x) * _.oscillatingValue(-1, 1, 500)
|
|
|
|
start
|
|
|
|
```
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
## Slide 4
|
|
|
|
|
|
|
|
```drawing
|
|
|
|
title Travelling Sine Wave
|
|
|
|
caption `y = sin(x + t)`
|
|
|
|
scale 64
|
|
|
|
frame 0 -1 2*Math.PI 1
|
|
|
|
stroke black 4
|
|
|
|
eval _.line([0, -1], [0, 1])
|
|
|
|
eval _.line([0, 0], [2*Math.PI, 0])
|
|
|
|
stroke red 2
|
|
|
|
func Math.sin(x + 2*Math.PI*_.t / 1000)
|
|
|
|
start
|
|
|
|
```
|
|
|
|
|
2024-06-24 16:45:27 -05:00
|
|
|
|
2024-06-22 15:01:10 -05:00
|
|
|
---
|
|
|
|
|
2024-06-24 16:45:27 -05:00
|
|
|
## Slide 4
|
|
|
|
|
|
|
|
```drawing
|
|
|
|
title Sine * Cosine
|
|
|
|
caption `y = sin(x) * cos(x)`
|
|
|
|
scale 64
|
|
|
|
frame 0 -1 2*Math.PI 1
|
|
|
|
stroke black 4
|
|
|
|
eval _.line([0, -1], [0, 1])
|
|
|
|
eval _.line([0, 0], [2*Math.PI, 0])
|
|
|
|
stroke red 1
|
|
|
|
func Math.sin(x)
|
|
|
|
stroke blue 1
|
|
|
|
func Math.cos(x)
|
|
|
|
stroke purple 2
|
|
|
|
func Math.sin(x) * Math.cos(x)
|
|
|
|
start
|
|
|
|
```
|
|
|
|
|
|
|
|
---
|
2024-06-22 15:01:10 -05:00
|
|
|
|
|
|
|
```drawing
|
2024-06-24 16:45:27 -05:00
|
|
|
scale 2
|
2024-06-22 15:01:10 -05:00
|
|
|
title Projectile
|
2024-06-24 15:49:18 -05:00
|
|
|
caption `x = v_(0x) t`<br>`y = v_(0y) t - g t^2`
|
2024-06-24 16:45:27 -05:00
|
|
|
frame -10 -50 300 80
|
|
|
|
stroke black 4
|
|
|
|
eval _.polyline([0, 100], [0, 0], [300, 0]);
|
|
|
|
value v0 50
|
|
|
|
value angle Math.PI / 180 * 45;
|
|
|
|
fill green
|
|
|
|
eval _.text([10, 0], '45°')
|
|
|
|
value v0x _.getValue('v0') * Math.cos(_.getValue('angle'))
|
|
|
|
value v0y _.getValue('v0') * Math.sin(_.getValue('angle'))
|
|
|
|
eval _.text([_.getValue('v0x') / 2, _.getValue('v0y') / 2], `${_.getValue('v0')} m/s`, {align: 'right'});
|
|
|
|
point p1 (function() {
|
|
|
|
const t = _.t / 1000;
|
|
|
|
const v0x = _.getValue('v0x');
|
|
|
|
const v0y = _.getValue('v0y');
|
|
|
|
const g = 9.81;
|
|
|
|
const x = v0x * t;
|
|
|
|
const y = v0y * t - g * t**2 / 2;
|
|
|
|
const vy = v0y - g * t;
|
|
|
|
const vyp = v0y - g * (t - _.dt/1000);
|
|
|
|
if (vy < 0 && vyp >= 0) {
|
|
|
|
_.setFill('red');
|
|
|
|
_.circle([x, y]);
|
|
|
|
_.setStroke('green', 2);
|
|
|
|
_.arrow([x, y], [x + v0x, y + vy]);
|
|
|
|
}
|
|
|
|
if (t > 0 && (y <= 0 || x >= _.frame[1][0])) {
|
|
|
|
_.setFill('red');
|
|
|
|
_.circle([x, y]);
|
|
|
|
_.setStroke('green', 2);
|
|
|
|
_.arrow([x, y], [x + v0x, y + vy]);
|
|
|
|
_.stop();
|
|
|
|
_.t = 0;
|
|
|
|
_.text([x, y + 10], `x = ${Math.ceil(x)} m`);
|
|
|
|
return [0, 0];
|
|
|
|
}
|
|
|
|
return [x, y];
|
|
|
|
})()
|
|
|
|
point p2 (function() {
|
|
|
|
const t = _.t / 1000;
|
|
|
|
const v0x = _.getValue('v0x');
|
|
|
|
const v0y = _.getValue('v0y');
|
|
|
|
const g = 9.81;
|
|
|
|
const x = v0x * t;
|
|
|
|
const y = v0y * t - g * t**2 / 2;
|
|
|
|
const vy = v0y - g * t;
|
|
|
|
const v = new Vector([v0x, vy]);
|
|
|
|
const r = new Vector([x, y]);
|
|
|
|
const p2 = r.add(v);
|
|
|
|
return p2.array;
|
|
|
|
})()
|
|
|
|
stroke orange 2
|
|
|
|
eval _.arrow('p1', 'p2');
|
|
|
|
stroke green 2
|
|
|
|
eval _.arrow([0, 0], [_.getValue('v0x'), _.getValue('v0y')])
|
|
|
|
fill blue
|
|
|
|
eval const projectile = d.circle('p1', {trace: {age: -1}});
|
|
|
|
d.onStart(() => {
|
|
|
|
if (d.t == 0) {
|
|
|
|
projectile.reset();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
start
|
|
|
|
```
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
### 45° ± 15°
|
|
|
|
|
|
|
|
```drawing
|
2024-06-22 15:01:10 -05:00
|
|
|
scale 2
|
2024-06-24 16:45:27 -05:00
|
|
|
frame -10 -50 300 80
|
2024-06-22 15:01:10 -05:00
|
|
|
stroke black 4
|
|
|
|
eval _.polyline([0, 100], [0, 0], [300, 0]);
|
2024-06-24 15:49:18 -05:00
|
|
|
value v0 50
|
2024-06-24 16:45:27 -05:00
|
|
|
value angle Math.PI / 180 * 30;
|
|
|
|
fill green
|
|
|
|
eval _.text([20, 0], '30°')
|
2024-06-22 15:01:10 -05:00
|
|
|
value v0x _.getValue('v0') * Math.cos(_.getValue('angle'))
|
|
|
|
value v0y _.getValue('v0') * Math.sin(_.getValue('angle'))
|
2024-06-24 16:45:27 -05:00
|
|
|
eval _.text([_.getValue('v0x') / 2, _.getValue('v0y') / 2], `${_.getValue('v0')} m/s`, {align: 'right'});
|
2024-06-22 15:01:10 -05:00
|
|
|
point p1 (function() {
|
|
|
|
const t = _.t / 1000;
|
2024-06-24 15:49:18 -05:00
|
|
|
const v0x = _.getValue('v0x');
|
|
|
|
const v0y = _.getValue('v0y');
|
|
|
|
const g = 9.81;
|
|
|
|
const x = v0x * t;
|
|
|
|
const y = v0y * t - g * t**2 / 2;
|
|
|
|
const vy = v0y - g * t;
|
|
|
|
const vyp = v0y - g * (t - _.dt/1000);
|
|
|
|
if (vy < 0 && vyp >= 0) {
|
|
|
|
_.setFill('red');
|
|
|
|
_.circle([x, y]);
|
|
|
|
_.setStroke('green', 2);
|
|
|
|
_.arrow([x, y], [x + v0x, y + vy]);
|
|
|
|
}
|
2024-06-22 15:01:10 -05:00
|
|
|
if (t > 0 && (y <= 0 || x >= _.frame[1][0])) {
|
2024-06-24 15:49:18 -05:00
|
|
|
_.setFill('red');
|
|
|
|
_.circle([x, y]);
|
|
|
|
_.setStroke('green', 2);
|
|
|
|
_.arrow([x, y], [x + v0x, y + vy]);
|
2024-06-22 15:01:10 -05:00
|
|
|
_.stop();
|
|
|
|
_.t = 0;
|
2024-06-24 16:45:27 -05:00
|
|
|
_.text([x, y + 10], `x = ${Math.ceil(x)} m`);
|
2024-06-24 15:49:18 -05:00
|
|
|
return [0, 0];
|
2024-06-22 15:01:10 -05:00
|
|
|
}
|
|
|
|
return [x, y];
|
|
|
|
})()
|
2024-06-24 15:49:18 -05:00
|
|
|
point p2 (function() {
|
|
|
|
const t = _.t / 1000;
|
|
|
|
const v0x = _.getValue('v0x');
|
|
|
|
const v0y = _.getValue('v0y');
|
|
|
|
const g = 9.81;
|
|
|
|
const x = v0x * t;
|
|
|
|
const y = v0y * t - g * t**2 / 2;
|
|
|
|
const vy = v0y - g * t;
|
|
|
|
const v = new Vector([v0x, vy]);
|
|
|
|
const r = new Vector([x, y]);
|
|
|
|
const p2 = r.add(v);
|
|
|
|
return p2.array;
|
|
|
|
})()
|
2024-06-24 16:45:27 -05:00
|
|
|
stroke orange 2
|
|
|
|
eval _.arrow('p1', 'p2');
|
2024-06-24 15:49:18 -05:00
|
|
|
stroke green 2
|
|
|
|
eval _.arrow([0, 0], [_.getValue('v0x'), _.getValue('v0y')])
|
2024-06-24 16:45:27 -05:00
|
|
|
fill blue
|
|
|
|
eval const projectile = d.circle('p1', {trace: {age: -1}});
|
|
|
|
d.onStart(() => {
|
|
|
|
if (d.t == 0) {
|
|
|
|
projectile.reset();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
start
|
|
|
|
```
|
|
|
|
|
|
|
|
```drawing
|
|
|
|
scale 2
|
|
|
|
frame -10 -50 300 100
|
|
|
|
stroke black 4
|
|
|
|
eval _.polyline([0, 100], [0, 0], [300, 0]);
|
|
|
|
value v0 50
|
|
|
|
value angle Math.PI / 180 * 60;
|
|
|
|
fill green
|
|
|
|
eval _.text([10, 0], '60°')
|
|
|
|
value v0x _.getValue('v0') * Math.cos(_.getValue('angle'))
|
|
|
|
value v0y _.getValue('v0') * Math.sin(_.getValue('angle'))
|
|
|
|
eval _.text([_.getValue('v0x') / 2, _.getValue('v0y') / 2], `${_.getValue('v0')} m/s`, {align: 'right'});
|
|
|
|
point p1 (function() {
|
|
|
|
const t = _.t / 1000;
|
|
|
|
const v0x = _.getValue('v0x');
|
|
|
|
const v0y = _.getValue('v0y');
|
|
|
|
const g = 9.81;
|
|
|
|
const x = v0x * t;
|
|
|
|
const y = v0y * t - g * t**2 / 2;
|
|
|
|
const vy = v0y - g * t;
|
|
|
|
const vyp = v0y - g * (t - _.dt/1000);
|
|
|
|
if (vy < 0 && vyp >= 0) {
|
|
|
|
_.setFill('red');
|
|
|
|
_.circle([x, y]);
|
|
|
|
_.setStroke('green', 2);
|
|
|
|
_.arrow([x, y], [x + v0x, y + vy]);
|
|
|
|
}
|
|
|
|
if (t > 0 && (y <= 0 || x >= _.frame[1][0])) {
|
|
|
|
_.setFill('red');
|
|
|
|
_.circle([x, y]);
|
|
|
|
_.setStroke('green', 2);
|
|
|
|
_.arrow([x, y], [x + v0x, y + vy]);
|
|
|
|
_.stop();
|
|
|
|
_.t = 0;
|
|
|
|
_.text([x, y + 10], `x = ${Math.ceil(x)} m`);
|
|
|
|
return [0, 0];
|
|
|
|
}
|
|
|
|
return [x, y];
|
|
|
|
})()
|
|
|
|
point p2 (function() {
|
|
|
|
const t = _.t / 1000;
|
|
|
|
const v0x = _.getValue('v0x');
|
|
|
|
const v0y = _.getValue('v0y');
|
|
|
|
const g = 9.81;
|
|
|
|
const x = v0x * t;
|
|
|
|
const y = v0y * t - g * t**2 / 2;
|
|
|
|
const vy = v0y - g * t;
|
|
|
|
const v = new Vector([v0x, vy]);
|
|
|
|
const r = new Vector([x, y]);
|
|
|
|
const p2 = r.add(v);
|
|
|
|
return p2.array;
|
|
|
|
})()
|
2024-06-24 15:49:18 -05:00
|
|
|
stroke orange 2
|
|
|
|
eval _.arrow('p1', 'p2');
|
2024-06-24 16:45:27 -05:00
|
|
|
stroke green 2
|
|
|
|
eval _.arrow([0, 0], [_.getValue('v0x'), _.getValue('v0y')])
|
2024-06-22 15:01:10 -05:00
|
|
|
fill blue
|
|
|
|
eval const projectile = d.circle('p1', {trace: {age: -1}});
|
|
|
|
d.onStart(() => {
|
|
|
|
if (d.t == 0) {
|
|
|
|
projectile.reset();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
start
|
|
|
|
```
|