From c7c4048a44e54f0d61f3b07f11a70c5994a9da66 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Tue, 5 Oct 2021 15:50:11 +0200 Subject: [PATCH] Cleaning --- projects/projectile/index.html | 8 +++++--- projects/projectile/index.js | 21 +++++++++++++++++---- public/js/p5_custom.js | 8 +++++++- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/projects/projectile/index.html b/projects/projectile/index.html index 63d3938..a27b692 100644 --- a/projects/projectile/index.html +++ b/projects/projectile/index.html @@ -34,17 +34,19 @@


Projectile Motion

-

To determine to position of the projectile we should compute the position vector \(\vec{r}(t)=x(t)\vec{i}+y(t)\vec{i}\).

+

To determine to position of the projectile we should compute the position vector \(\vec{r}(t)=x(t)\vec{i}+y(t)\vec{j}\).

\(x(t)\):

We know from Newton second law that \(\sum \vec{F} = m\times \vec{a}_x = m\times a_x(t)\vec{i}\)

However, the projectile as a constant speed along \(\vec{i}\). Hence, \(a_x(t) = 0 \).

Thus:

+\[ v_x(t) = v_{x,0} \] \[ x(t) = \int_{t_0}^t v_{0,x}dt = v_{0,x}t + C = v_{0,x}t + x_0\]
\(y(t)\):
-

We know from Newton second law that \(\sum \vec{F} = m\times \vec{a}_y = m\times a_y(t)\vec{i}\)

+

We know from Newton second law that \(\sum \vec{F} = m\times \vec{a}_y = m\times a_y(t)\vec{j}\)

The projectile is under the influence of the gravity that is oriented downward. Hence, \(a_y(t) = -g \).

Thus:

\[ v_y(t) = \int_{t_0}^t a_{y}(t)dt = -gt+C = -gt + v_{0,y}\] \[ y(t) = \int_{t_0}^t v_y(t)dt = -\frac{1}{2}gt^2 + v_{0,y}t+C=-\frac{1}{2}gt^2 + v_{0,y}t+y_0\]
\(\vec{r}(t)\):
-Finally knowing \(x(t)\) and \(y(t)\) we have \( \vec{r}(t) = \left(\begin{smallmatrix}x(t)\\y(t)\end{smallmatrix}\right) = \left(\begin{smallmatrix}v_{0,x}t + x_0\\-\frac{1}{2}gt^2 + v_{0,y}t+y_0\end{smallmatrix}\right)\) +

Finally knowing \(x(t)\) and \(y(t)\) we have \( \vec{r}(t) = \left(\begin{smallmatrix}x(t)\\y(t)\end{smallmatrix}\right) = \left(\begin{smallmatrix}v_{0,x}t + x_0\\-\frac{1}{2}gt^2 + v_{0,y}t+y_0\end{smallmatrix}\right)\)

+

We can deduce also that \( \vec{v}(t) = \left(\begin{smallmatrix}v_x(t)\\v_y(t)\end{smallmatrix}\right) = \left(\begin{smallmatrix}v_{0,x}\\-gt+v_{0,y}\end{smallmatrix}\right)\)

diff --git a/projects/projectile/index.js b/projects/projectile/index.js index 1c03d46..ce6ba44 100644 --- a/projects/projectile/index.js +++ b/projects/projectile/index.js @@ -23,6 +23,13 @@ let projectile= function (p){ vt=p.createElement('span', ''); katex.render("v(t)", vt.elt); + vi=p.createElement('span', ''); + katex.render("\\vec{i}", vi.elt); + + vj=p.createElement('span', ''); + katex.render("\\vec{j}", vj.elt); + + }; // See explanations @@ -35,7 +42,7 @@ let projectile= function (p){ } function v(t) { - return (-g * t + v0) + return -g * t + v0 } let draw_vectors=function(x,y,skiparrow=false){ @@ -44,8 +51,14 @@ let projectile= function (p){ draw_arrow(p,x,y,x+x0,y-v(t),vt,c,skiparrow) p.stroke(200) draw_arrow(p,x0,height-y0,x,y,r,c,skiparrow) - p.stroke(122, 199, 107) + p.stroke(181, 107, 199) draw_arrow(p,x0,height-y0,x0+v0,height-(y0+v0),v0t,c,skiparrow) + + p.stroke(121, 199, 107) + draw_arrow(p,50,50,50,0,vj,c,skiparrow,true) + p.stroke(199,119,107) + draw_arrow(p,50,50,100,50,vi,c,skiparrow) + p.pop() } @@ -71,7 +84,8 @@ let projectile= function (p){ if(t>50 || (height-y0)0){ yfactor=-yfactor }