diff --git a/cbtf.py b/cbtf.py index 28de6402c..745ed6091 100644 --- a/cbtf.py +++ b/cbtf.py @@ -107,6 +107,9 @@ def explore_dir_and_move(home, dir): "href=\"/sta/": "href=\"../sta/", "href=\"/sol/": "href=\"../sol/", "href=\"/dyn/": "href=\"../dyn/", + "\"link\":\"/sta": "\"link\":\"../sta", + "\"link\":\"/dyn": "\"link\":\"../dyn", + "\"link\":\"/sol": "\"link\":\"../sol", "href=\"/about/\"": "href=\"../about.html\"", "href=\"/about\"": "href=\"../about.html\"", "src=\"/about/": "src=\"../about/", @@ -116,7 +119,11 @@ def explore_dir_and_move(home, dir): "src=\"/Statics/": "src=\"../Statics/", "src=\"/Solid_Mechanics/": "src=\"../Solid_Mechanics/", "src=\"/Dynamics/": "src=\"../Dynamics/", - "href=\"${e['item']['link']}\"": "href=\"..${e['item']['link']}\"" + "href=\"${e['item']['link']}\"": "href=\"..${e['item']['link']}\"", + "url(/fonts/source-sans-pro/SourceSansPro-Regular.otf": "url(../fonts/source-sans-pro/SourceSansPro-Regular.otf", + "url(/fonts/source-sans-pro/SourceSansPro-Semibold.otf": "url(../fonts/source-sans-pro/SourceSansPro-Semibold.otf", + "url(/fonts/source-sans-pro/SourceSansPro-Bold.otf": "url(../fonts/source-sans-pro/SourceSansPro-Bold.otf", + "url(/fonts/Montserrat-Bold.ttf": "url(../fonts/Montserrat-Bold.ttf" } all_content_pages = os.listdir(os.path.join(home, 'sta')) + os.listdir(os.path.join(home, 'sol')) + os.listdir(os.path.join(home, 'dyn')) @@ -173,6 +180,9 @@ def explore_dir_and_move(home, dir): "href=\"/sta/": "href=\"./sta/", "href=\"/sol/": "href=\"./sol/", "href=\"/dyn/": "href=\"./dyn/", + "\"link\":\"/sta": "\"link\":\"./sta", + "\"link\":\"/dyn": "\"link\":\"./dyn", + "\"link\":\"/sol": "\"link\":\"./sol", "src=\"/Statics/": "src=\"./Statics/", "src=\"/Solid_Mechanics/": "src=\"./Solid_Mechanics/", "src=\"/Dynamics/": "src=\"./Dynamics/", @@ -182,6 +192,10 @@ def explore_dir_and_move(home, dir): "href=\"/about/\"": "href=\"./about.html\"", "href=\"/about\"": "href=\"./about.html\"", "src=\"/about/": "src=\"./about/", + "url(/fonts/source-sans-pro/SourceSansPro-Regular.otf": "url(./fonts/source-sans-pro/SourceSansPro-Regular.otf", + "url(/fonts/source-sans-pro/SourceSansPro-Semibold.otf": "url(./fonts/source-sans-pro/SourceSansPro-Semibold.otf", + "url(/fonts/source-sans-pro/SourceSansPro-Bold.otf": "url(./fonts/source-sans-pro/SourceSansPro-Bold.otf", + "url(/fonts/Montserrat-Bold.ttf": "url(./fonts/Montserrat-Bold.ttf" } all_content_pages = os.listdir(os.path.join(home, 'sta')) + os.listdir(os.path.join(home, 'sol')) + os.listdir(os.path.join(home, 'dyn')) diff --git a/dev_tools/create_search_index.ipynb b/dev_tools/create_search_index.ipynb index 18aad7a7d..e2901fc7a 100644 --- a/dev_tools/create_search_index.ipynb +++ b/dev_tools/create_search_index.ipynb @@ -2,43 +2,51 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ + "sta/moments\n", + "sta/introduction\n", + "sta/cartesian_coordinates\n", + "sta/force_systems\n", + "sta/vectors_scalars\n", + "sta/reaction_forces\n", + "sta/trusses\n", + "sta/frames_and_machines\n", + "sta/pltips\n", + "sta/free_body_diagrams\n", + "sta/friction\n", + "sta/shear_moment_diagrams\n", + "sta/moment_of_inertia\n", + "sta/virtual_work\n", + "sta/centers_of_mass\n", + "sta/hydrostatic_fluid_pressure\n", + "sol/axial_loading\n", + "sol/combined_loading\n", + "sol/material_properties\n", + "sol/pressure_vessels\n", "sol/strain\n", "sol/stress\n", - "sol/material_properties\n", - "sol/axial_loading\n", + "sol/transverse_shear\n", "sol/torsion\n", "sol/shear_moment_diagrams\n", - "sol/bending\n", - "sol/transverse_shear\n", - "sol/pressure_vessels\n", - "sol/combined_loading\n", "sol/stress_transformation\n", - "dyn/vectors\n", + "sol/beam_deflection\n", + "sol/buckling\n", + "sol/bending\n", + "sol/failure_theories\n", "dyn/vector_calculus\n", + "dyn/vectors\n", "dyn/particle_kinetics\n", "dyn/particle_kinematics\n", - "dyn/rigid_body_kinematics\n", - "dyn/rigid_body_kinetics\n", "dyn/contact_and_rolling\n", - "sta/introduction\n", - "sta/cartesian_coordinates\n", - "sta/vectors_scalars\n", - "sta/free_body_diagrams\n", - "sta/moments\n", - "sta/force_systems\n", - "sta/reaction_forces\n", - "sta/shear_moment_diagrams\n", - "sta/trusses\n", - "sta/frames_and_machines\n", - "sta/friction\n", - "sta/centers_of_mass\n" + "dyn/work_and_energy\n", + "dyn/rigid_body_kinematics\n", + "dyn/rigid_body_kinetics\n" ] } ], @@ -46,39 +54,16 @@ "import requests\n", "from bs4 import BeautifulSoup\n", "import json\n", + "import os\n", + "\n", + "pwd = os.path.dirname(os.getcwd())\n", + "\n", + "searchable_pages = []\n", "\n", - "searchable_pages = [\n", - " \"sol/strain\",\n", - " \"sol/stress\",\n", - " \"sol/material_properties\",\n", - " \"sol/axial_loading\",\n", - " \"sol/torsion\",\n", - " \"sol/shear_moment_diagrams\",\n", - " \"sol/bending\",\n", - " \"sol/transverse_shear\",\n", - " \"sol/pressure_vessels\",\n", - " \"sol/combined_loading\",\n", - " \"sol/stress_transformation\",\n", - " \"dyn/vectors\",\n", - " \"dyn/vector_calculus\",\n", - " \"dyn/particle_kinetics\",\n", - " 'dyn/particle_kinematics',\n", - " 'dyn/rigid_body_kinematics',\n", - " 'dyn/rigid_body_kinetics',\n", - " 'dyn/contact_and_rolling',\n", - " \"sta/introduction\",\n", - " \"sta/cartesian_coordinates\",\n", - " \"sta/vectors_scalars\",\n", - " \"sta/free_body_diagrams\",\n", - " \"sta/moments\",\n", - " \"sta/force_systems\",\n", - " \"sta/reaction_forces\",\n", - " \"sta/shear_moment_diagrams\",\n", - " \"sta/trusses\",\n", - " \"sta/frames_and_machines\",\n", - " \"sta/friction\",\n", - " \"sta/centers_of_mass\"\n", - "]\n", + "for dir in ['sta', 'sol', 'dyn']:\n", + " dir_path = os.path.join(pwd, \"src/pages\", dir)\n", + " for page in os.listdir(dir_path):\n", + " searchable_pages.append(os.path.join(dir, page.replace(\".astro\", '')))\n", "\n", "page_text = []\n", "\n", @@ -131,7 +116,7 @@ "\n", " page_text.append({\"title\": page.split(\"/\")[1].replace(\"_\", \" \").capitalize(),\"text\": text, 'link': \"/\" + page, 'course': page.split('/')[0]})\n", "\n", - "json.dump(page_text, open(\"./src/search.json\", \"w\"), indent=2)" + "json.dump(page_text, open(\"../src/search.json\", \"w\"), indent=2)" ] }, { diff --git a/dev_tools/html_to_astro.ipynb b/dev_tools/html_to_astro.ipynb index aa1ce40e9..30aed6491 100644 --- a/dev_tools/html_to_astro.ipynb +++ b/dev_tools/html_to_astro.ipynb @@ -261,35 +261,38 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 51, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "s+t\\\\mid T>s\\\\right)&={\\\\frac {\\\\Pr \\\\left(T>s+t\\\\cap T>s\\\\right)}{\\\\Pr \\\\left(T>s\\\\right)}}\\\\4pt]&={\\\\frac {\\\\Pr \\\\left(T>s+t\\\\right)}{\\\\Pr \\\\left(T>s\\\\right)}}\\\\4pt]&={\\\\frac {e^{-\\\\lambda (s+t)}}{e^{-\\\\lambda s}}}\\\\4pt]&=e^{-\\\\lambda t}\\\\4pt]&=\\\\Pr(T>t).\\\\end{aligned}\" />\n" + "\n" ] } ], "source": [ "e = r\"\"\"\n", - "\\begin{aligned}\\Pr \\left(T>s+t\\mid T>s\\right)&={\\frac {\\Pr \\left(T>s+t\\cap T>s\\right)}{\\Pr \\left(T>s\\right)}}\\\\[4pt]&={\\frac {\\Pr \\left(T>s+t\\right)}{\\Pr \\left(T>s\\right)}}\\\\[4pt]&={\\frac {e^{-\\lambda (s+t)}}{e^{-\\lambda s}}}\\\\[4pt]&=e^{-\\lambda t}\\\\[4pt]&=\\Pr(T>t).\\end{aligned}\n", + "\\[\\begin{aligned}\n", + " m_1 \\vec{v}_{1, i} + m_2 \\vec{v}_{2, i} &= m_1 \\vec{v}_{1, f} + m_2 \\vec{v}_{2, f} \\\\\n", + " \\frac{1}{2} m_1 v_{1, i}^2 + \\frac{1}{2} m_2 v_{2, i}^2 & = \\frac{1}{2} m_1 v_{1, f}^2 + \\frac{1}{2} m_2 v_{2, f}^2\n", + " \\end{aligned}\\]\n", "\"\"\"\n", "\n", - "print(\"\")\n" + "print(\"\")\n" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 38, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "\\\\Pr \\\\left(T>s+t\\\\mid T>s\\\\right)=\\\\Pr(T>t),\\\\qquad \\\\forall s,t\\\\geq 0.}\n" + "\\\\vec{J} = \\\\int_{t_1}^{t_2} \\\\vec{F} \\\\, dt\n" ] } ], @@ -299,20 +302,20 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 28, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "\n" + "\n" ] } ], "source": [ "e = r\"\"\"\n", - " $\\rm\\ MPa = 10^6 \\ Pa$, $12 \\ \\text{in} = 1 \\ \\text{ft}$\n", + "$dw = d\\vec{p}_P$ and $u = \\vec{r}_{OP}$\n", "\"\"\"\n", "\n", "print(\"\")" diff --git a/public/FailureCriteria.json b/public/Solid_Mechanics/plotly_graphs/FailureCriteria.json similarity index 100% rename from public/FailureCriteria.json rename to public/Solid_Mechanics/plotly_graphs/FailureCriteria.json diff --git a/public/Statics/FluidFigures/CurvedPlateEx.PNG b/public/Statics/FluidFigures/CurvedPlateEx.PNG new file mode 100644 index 000000000..454fb2be7 Binary files /dev/null and b/public/Statics/FluidFigures/CurvedPlateEx.PNG differ diff --git a/public/Statics/FluidFigures/CurvedPlateSol1.PNG b/public/Statics/FluidFigures/CurvedPlateSol1.PNG new file mode 100644 index 000000000..90f36ef12 Binary files /dev/null and b/public/Statics/FluidFigures/CurvedPlateSol1.PNG differ diff --git a/public/Statics/FluidFigures/CurvedPlateSol2.jpg b/public/Statics/FluidFigures/CurvedPlateSol2.jpg index b57f7389d..6861ae0d5 100644 Binary files a/public/Statics/FluidFigures/CurvedPlateSol2.jpg and b/public/Statics/FluidFigures/CurvedPlateSol2.jpg differ diff --git a/public/Statics/FluidFigures/CurvedPlateSol2.png b/public/Statics/FluidFigures/CurvedPlateSol2.png new file mode 100644 index 000000000..12d4abe6e Binary files /dev/null and b/public/Statics/FluidFigures/CurvedPlateSol2.png differ diff --git a/public/Statics/FluidFigures/CurvedPlateSol3.PNG b/public/Statics/FluidFigures/CurvedPlateSol3.PNG new file mode 100644 index 000000000..07d3ddc36 Binary files /dev/null and b/public/Statics/FluidFigures/CurvedPlateSol3.PNG differ diff --git a/public/Statics/FluidFigures/CurvedPlateSol4.PNG b/public/Statics/FluidFigures/CurvedPlateSol4.PNG new file mode 100644 index 000000000..041f3de3e Binary files /dev/null and b/public/Statics/FluidFigures/CurvedPlateSol4.PNG differ diff --git a/public/Statics/FluidFigures/SlantedCurveSurf.jpg b/public/Statics/FluidFigures/SlantedCurveSurf.jpg index 5b83444e6..954031738 100644 Binary files a/public/Statics/FluidFigures/SlantedCurveSurf.jpg and b/public/Statics/FluidFigures/SlantedCurveSurf.jpg differ diff --git a/public/Statics/FluidFigures/SlantedCurveSurf.png b/public/Statics/FluidFigures/SlantedCurveSurf.png new file mode 100644 index 000000000..4e28fb1f7 Binary files /dev/null and b/public/Statics/FluidFigures/SlantedCurveSurf.png differ diff --git a/public/Statics/FrictionFigures/BananaPeel.png b/public/Statics/FrictionFigures/BananaPeel.png new file mode 100644 index 000000000..7b76a66ce Binary files /dev/null and b/public/Statics/FrictionFigures/BananaPeel.png differ diff --git a/public/Statics/VWorkFigures/CoupleMoments.png b/public/Statics/VWorkFigures/CoupleMoments.png new file mode 100644 index 000000000..bca42184a Binary files /dev/null and b/public/Statics/VWorkFigures/CoupleMoments.png differ diff --git a/public/Statics/VWorkFigures/ThinRod.png b/public/Statics/VWorkFigures/ThinRod.png new file mode 100644 index 000000000..a2c390f4b Binary files /dev/null and b/public/Statics/VWorkFigures/ThinRod.png differ diff --git a/public/Statics/VWorkFigures/ThinRodFBD1.png b/public/Statics/VWorkFigures/ThinRodFBD1.png new file mode 100644 index 000000000..f64a84bb1 Binary files /dev/null and b/public/Statics/VWorkFigures/ThinRodFBD1.png differ diff --git a/public/Statics/VWorkFigures/ThinRodFBD2.png b/public/Statics/VWorkFigures/ThinRodFBD2.png new file mode 100644 index 000000000..b9ee49736 Binary files /dev/null and b/public/Statics/VWorkFigures/ThinRodFBD2.png differ diff --git a/public/Statics/VWorkFigures/Truss.png b/public/Statics/VWorkFigures/Truss.png new file mode 100644 index 000000000..8e0dd7673 Binary files /dev/null and b/public/Statics/VWorkFigures/Truss.png differ diff --git a/public/Statics/VWorkFigures/TrussFBD1.png b/public/Statics/VWorkFigures/TrussFBD1.png new file mode 100644 index 000000000..d96253509 Binary files /dev/null and b/public/Statics/VWorkFigures/TrussFBD1.png differ diff --git a/public/Statics/VWorkFigures/TrussFBD2.png b/public/Statics/VWorkFigures/TrussFBD2.png new file mode 100644 index 000000000..6ad8dcff6 Binary files /dev/null and b/public/Statics/VWorkFigures/TrussFBD2.png differ diff --git a/public/Statics/VWorkFigures/VirtualDisp.png b/public/Statics/VWorkFigures/VirtualDisp.png new file mode 100644 index 000000000..7b630d03d Binary files /dev/null and b/public/Statics/VWorkFigures/VirtualDisp.png differ diff --git a/public/Statics/VWorkFigures/VirtualWork.png b/public/Statics/VWorkFigures/VirtualWork.png new file mode 100644 index 000000000..0867ef31e Binary files /dev/null and b/public/Statics/VWorkFigures/VirtualWork.png differ diff --git a/public/dyn/work_and_energy/canvases.js b/public/dyn/work_and_energy/canvases.js index 4cd73cc53..5fe644a2c 100644 --- a/public/dyn/work_and_energy/canvases.js +++ b/public/dyn/work_and_energy/canvases.js @@ -73,4 +73,294 @@ $(document).ready(function(){ this.point(A); this.point(B); }); + + var rec_xlm_c = new PrairieDraw("rec-xlm-c", function() { + + this.setUnits(6, 4); + + var O = $V([0, 0]); + + this.rectangle(1, 1, O); + this.text(O, O, "TEX:$m$"); + this.arrow($V([-1.5, 0.5]), $V([-1.5, -0.5]), "acceleration"); + this.labelLine($V([-1.5, 0.5]), $V([-1.5, -0.5]), $V([1, 0]), "TEX:$g$"); + }); + + var rec_xlm_f = new PrairieDraw("rec-xlm-f", function() { + this.setUnits(6, 4); + + var O = $V([0, 0]); + + this.rectangle(1, 1, O, undefined, false); + this.arrow(O, O.add($V([0, -1])), "force"); + this.labelLine(O, O.add($V([0, -1])), $V([1, 0]), "TEX:$mg$"); + }); + + var rec_xam_c = new PrairieDraw("rec-xam-c", function() { + + this.setUnits(6, 4); + + var O = $V([0, 0]); + var sat = this.vector2DAtAngle(Math.PI/6).x(1.5) + + this.circle(O, 1.5, false); + this.circle(O, 0.8); + this.circle(sat, 0.1) + this.arrow(O, sat, "position"); + this.labelLine(O, sat, $V([0.3, 1]), "TEX:$r$"); + this.text(sat, $V([-1.5, -1]), "TEX:$m$"); + }); + + var rec_xam_f = new PrairieDraw("rec-xam-f", function() { + + this.setUnits(6, 4); + + var O = $V([0, 0]); + var sat = this.vector2DAtAngle(Math.PI/6).x(1.5) + var sat2 = this.vector2DAtAngle(Math.PI/6).x(0.75) + + this.circle(O, 0.8, false); + this.circle(sat, 0.1, false); + this.arrow(sat, sat2, "force"); + this.arrow(O, sat2, "force"); + this.text(sat, $V([-1.5, -1]), "TEX:$m$"); + this.labelLine(sat, sat2, $V([0, -1]), "TEX:$mg$"); + this.labelLine(O, sat2, $V([0, -1.5]), "TEX:$mg$"); + }); + + var rec_xr_c = new PrairieDraw("rec-xr-c", function() { + + this.setUnits(12, 4); + + var O = $V([0,0]); + var ei = $V([1, 0]); + var ej = $V([0, 1]); + var O_P = $V([-5.5, -1.5]); + + // Drawing the origin and basis vectors + this.text(O_P.add($V([-0.2, -0.2])), $V([-1, 0]), "TEX:$O$"); + this.arrow(O_P, O_P.add(ei)); + this.arrow(O_P, O_P.add(ej)); + this.labelLine(O_P, O_P.add(ei), $V([1, 0]), "TEX:$\\hat\\imath$"); + this.labelLine(O_P, O_P.add(ej), $V([1, 0]), "TEX:$\\hat\\jmath$"); + + // Drawing rocket body + this.line(ei.x(-1), O.add(ei)); + this.line(ei.x(-1), ei.x(-1).add(ej)); + this.line(ei.x(-1).add(ej), $V([1, 1])); + + // Drawing rocket nose + this.line($V([1, 1]), $V([1.2, 0.8])); + this.line(ei, $V([1.2, 0.2])); + + this.line($V([1.2, 0.8]), $V([2.2, 0.8])); + this.line($V([1.2, 0.2]), $V([2.2, 0.2])); + + this.line($V([2.2, 0.8]), $V([2.5, 0.5])); + this.line($V([2.2, 0.2]), $V([2.5, 0.5])); + + // Drawing rocket nozzle + this.setProp("shapeInsideColor", "rgb(0,0,0)"); + this.polyLine([$V([-1.4, 0.1]), $V([-1, 0.3]), $V([-1, 0.7]), $V([-1.4, 0.9])], true, true); + + // Drawing rocket burn + this.setProp("shapeInsideColor", "rgb(230,230,230"); + this.polyLine([$V([-3, -0.2]), $V([-1.4, 0.1]), $V([-1.4, 0.9]), $V([-3, 1.2])], true, true); + + // Drawing effective exhaust velocity and velocity of the rocket vectors + this.text($V([0, 0.5]), $V([-1, 0]), "TEX:$m$"); + this.arrow($V([2.7, 0.5]), $V([4, 0.5]), "velocity"); + this.labelLine($V([2.7, 0.5]), $V([4, 0.5]), $V([0, 1]), "TEX:$\\vec{v}$"); + this.arrow($V([-1.6, 0.5]), $V([-2.6, 0.5]), "velocity"); + this.labelLine($V([-1.6, 0.5]), $V([-2.6, 0.5]), $V([0, -1]), "TEX:$\\vec{c}$"); + }); + + rec_eco_c = new PrairieDrawAnim("rec-eco-c", function(t) { + + var xViewMax = 6; + var yViewMax = 2; + var xWorldMax = xViewMax * 1.1; + var yWorldMax = yViewMax * 1.1; + + var groundX = -5.6; + + var O = $V([0,0]); + var ei = $V([1, 0]); + var ej = $V([0, 1]); + + var P1 = $V([-5.8, r1y]); + var P2 = $V([5.8, r1y]); + + dt = this.deltaTime(); + + this.setUnits(2*xViewMax, 2*yViewMax); + + this.addOption("v1x", 1); + this.addOption("v2x", -1); + this.addOption("r1x", -2); + this.addOption("r2x", 2); + this.addOption("m1", 1); + this.addOption("m2", 1); + + + + var r1x = this.getOption("r1x"); + var r2x = this.getOption("r2x"); + var v1x = Number(this.getOption("v1x")); + var v2x = Number(this.getOption("v2x")); + var m1 = this.getOption("m1"); + var m2 = this.getOption("m2"); + + + + var width_m1 = 0.49 + 0.01*m1; + var width_m2 = 0.49 + 0.01*m2; + var height_m1 = width_m1; + var height_m2 = width_m2; + + var r1y = -1.8 + width_m1/2; + var r2y = -1.8 + width_m2/2; + + if (dt > 0 && dt < 0.1) { + // Check wall collision + if (r1x - width_m1/2 <= P1.e(1)) { + v1x = -v1x; + }; + + if (r2x + width_m2/2 >= P2.e(1)) { + v2x = -v2x; + }; + // Check blocks collision + if (r1x + width_m1/2 >= r2x-width_m2/2) { + + p1 = m1*v1x + m2*v2x; + + v2fx = (m1 * v2x - m1 * v1x - p1)/(-1 * m2 - m1); + v1fx = v2x + v2fx - v1x; + + v1x = v1fx; + v2x = v2fx; + }; + r1x = r1x + v1x * dt; + r2x = r2x + v2x * dt; + this.setOption("r1x", r1x, false); + this.setOption("v1x", v1x, false); + this.setOption("r2x", r2x, false); + this.setOption("v2x", v2x, false); + }; + + this.save(); + this.ground($V([0, -1.8]), ej, 12); + this.ground($V([-5.8, 0.2]), ei, 4); + this.ground($V([5.8, 0.2]), ei.x(-1), 4); + this.rectangle(width_m1, height_m1, $V([r1x, r1y])); + this.rectangle(width_m2, height_m2, $V([r2x, r2y])); + if (Math.abs(v1x) > 0) { + this.arrow($V([r1x, r1y]), $V([r1x, r1y]).add($V([v1x, 0])), "velocity"); + this.labelLine($V([r1x, r1y]), $V([r1x, r1y]).add($V([v1x, 0])), ei, "TEX:$\\vec{v}_1$"); + } + + if (Math.abs(v2x) > 0) { + this.arrow($V([r2x, r2y]), $V([r2x, r2y]).add($V([v2x, 0])), "velocity"); + this.labelLine($V([r2x, r2y]), $V([r2x, r2y]).add($V([v2x, 0])), ei, "TEX:$\\vec{v}_2$"); + } + this.text($V([r1x, r1y]), $V([0, r1y - 2.5*width_m1]), "TEX:$m_1$"); + this.text($V([r2x, r2y]), $V([0, r2y - 2.5*width_m2]), "TEX:$m_2$"); + }); + + rec_ico_c = new PrairieDrawAnim("rec-ico-c", function(t) { + + var xViewMax = 6; + var yViewMax = 2; + var xWorldMax = xViewMax * 1.1; + var yWorldMax = yViewMax * 1.1; + + var groundX = -5.6; + + var O = $V([0,0]); + var ei = $V([1, 0]); + var ej = $V([0, 1]); + + var P1 = $V([-5.8, r1y]); + var P2 = $V([5.8, r1y]); + + dt = this.deltaTime(); + var coll = false; + + this.setUnits(2*xViewMax, 2*yViewMax); + + this.addOption("v1x", 1); + this.addOption("v2x", -1); + this.addOption("r1x", -2); + this.addOption("r2x", 2); + this.addOption("m1", 1); + this.addOption("m2", 1); + + var r1x = this.getOption("r1x"); + var r2x = this.getOption("r2x"); + var v1x = Number(this.getOption("v1x")); + var v2x = Number(this.getOption("v2x")); + var m1 = this.getOption("m1"); + var m2 = this.getOption("m2"); + + var width_m1 = 0.49 + 0.01*m1; + var width_m2 = 0.49 + 0.01*m2; + var height_m1 = width_m1; + var height_m2 = width_m2; + + var r1y = -1.8 + width_m1/2; + var r2y = -1.8 + width_m2/2; + + if (dt > 0 && dt < 0.1) { + // Check wall collision + if (r1x - width_m1/2 <= P1.e(1)) { + v1x = -v1x; + }; + + if (r2x + width_m2/2 >= P2.e(1)) { + v2x = -v2x; + }; + // Check blocks collision + if (r1x + width_m1/2 >= r2x-width_m2/2) { + coll = true; + + p1 = m1*v1x + m2*v2x; + + vf = p1/(m1 + m2) + + v1x = vf; + v2x = vf; + }; + r1x = r1x + v1x * dt; + r2x = r2x + v2x * dt; + this.setOption("r1x", r1x, false); + this.setOption("v1x", v1x, false); + this.setOption("r2x", r2x, false); + this.setOption("v2x", v2x, false); + }; + + this.save(); + this.ground($V([0, -1.8]), ej, 12); + this.ground($V([-5.8, 0.2]), ei, 4); + this.ground($V([5.8, 0.2]), ei.x(-1), 4); + this.rectangle(width_m1, height_m1, $V([r1x, r1y])); + this.rectangle(width_m2, height_m2, $V([r2x, r2y])); + if (Math.abs(v1x) > 0 && coll === false) { + this.arrow($V([r1x, r1y]), $V([r1x, r1y]).add($V([v1x, 0])), "velocity"); + this.labelLine($V([r1x, r1y]), $V([r1x, r1y]).add($V([v1x, 0])), ei, "TEX:$\\vec{v}_1$"); + } else if (v1x > 0 && coll === true) { + this.arrow($V([r2x, r2y]), $V([r2x, r2y]).add($V([v2x, 0])), "velocity"); + this.labelLine($V([r2x, r2y]), $V([r2x, r2y]).add($V([v2x, 0])), ei, "TEX:$\\vec{v}_f$"); + } else if (v1x < 0 && coll === true) { + this.arrow($V([r1x, r1y]), $V([r1x, r1y]).add($V([v1x, 0])), "velocity"); + this.labelLine($V([r1x, r1y]), $V([r1x, r1y]).add($V([v1x, 0])), ei, "TEX:$\\vec{v}_f$"); + } + + if (Math.abs(v2x) > 0 && coll === false) { + this.arrow($V([r2x, r2y]), $V([r2x, r2y]).add($V([v2x, 0])), "velocity"); + this.labelLine($V([r2x, r2y]), $V([r2x, r2y]).add($V([v2x, 0])), ei, "TEX:$\\vec{v}_2$"); + } + this.text($V([r1x, r1y]), $V([0, r1y - 2.5*width_m1]), "TEX:$m_1$"); + this.text($V([r2x, r2y]), $V([0, r2y - 2.5*width_m2]), "TEX:$m_2$"); + }); }) \ No newline at end of file diff --git a/public/vm_boneyard.html b/public/vm_boneyard.html new file mode 100644 index 000000000..f4fca35a5 --- /dev/null +++ b/public/vm_boneyard.html @@ -0,0 +1,11064 @@ + + + + + +vm_boneyard + + + + + + + + + + + + + +
+
+ + diff --git a/public/vm_boneyard.ipynb b/public/vm_boneyard.ipynb new file mode 100644 index 000000000..46ab8c204 --- /dev/null +++ b/public/vm_boneyard.ipynb @@ -0,0 +1,290 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "import random\n", + "import numpy as np" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('regular', 1, 1)\n", + "((0, 1.0), (1, 1.0))\n", + "((1, 0.0), (2, 0.0))\n", + "((2, 0.0), (4, -1.0))\n", + "3.0 1.0\n", + "{0: [(0, 0), (1, 1.0), (0, 0)], 1: [(1, 1.0), (2, 1.0), (0, 0)], 2: [(2, 0.0), (4, 0)]}\n", + "0.0 -1.0\n", + "('regular', 1, 2)\n", + "((0, 1.25), (1, 1.25))\n", + "((1, 0.25), (2, 0.25))\n", + "((2, 0.25), (4, -1.75))\n", + "3.0 1.75\n", + "{0: [(0, 0), (1, 1.25), (0, 0)], 1: [(1, 1.25), (2, 1.5), (0, 0)], 2: [(2, 0.25), (4, 0)]}\n", + "0.25 -1.75\n", + "('regular', 1, 3)\n", + "((0, 1.5), (1, 1.5))\n", + "((1, 0.5), (2, 0.5))\n", + "((2, 0.5), (4, -2.5))\n", + "3.0 2.5\n", + "{0: [(0, 0), (1, 1.5), (0, 0)], 1: [(1, 1.5), (2, 2.0), (0, 0)], 2: [(2, 0.5), (4, 0)]}\n", + "0.5 -2.5\n", + "('regular', 2, 1)\n", + "((0, 1.75), (1, 1.75))\n", + "((1, -0.25), (2, -0.25))\n", + "((2, -0.25), (4, -1.25))\n", + "3.0 1.25\n", + "{0: [(0, 0), (1, 1.75), (0, 0)], 1: [(1, 1.75), (2, 1.5), (0, 0)], 2: [(2, -0.25), (4, 0)]}\n", + "-0.25 -1.25\n", + "('regular', 2, 2)\n", + "((0, 2.0), (1, 2.0))\n", + "((1, 0.0), (2, 0.0))\n", + "((2, 0.0), (4, -2.0))\n", + "3.0 2.0\n", + "{0: [(0, 0), (1, 2.0), (0, 0)], 1: [(1, 2.0), (2, 2.0), (0, 0)], 2: [(2, 0.0), (4, 0)]}\n", + "0.0 -2.0\n", + "('regular', 3, 1)\n", + "((0, 2.5), (1, 2.5))\n", + "((1, -0.5), (2, -0.5))\n", + "((2, -0.5), (4, -1.5))\n", + "3.0 1.5\n", + "{0: [(0, 0), (1, 2.5), (0, 0)], 1: [(1, 2.5), (2, 2.0), (0, 0)], 2: [(2, -0.5), (4, 0)]}\n", + "-0.5 -1.5\n", + "('regular', 3, 3)\n", + "((0, 3.0), (1, 3.0))\n", + "((1, 0.0), (2, 0.0))\n", + "((2, 0.0), (4, -3.0))\n", + "3.0 3.0\n", + "{0: [(0, 0), (1, 3.0), (0, 0)], 1: [(1, 3.0), (2, 3.0), (0, 0)], 2: [(2, 0.0), (4, 0)]}\n", + "0.0 -3.0\n", + "('flipped', 1, 1)\n", + "((3, 1.0), (4, 1.0))\n", + "((3, 0.0), (2, 0.0))\n", + "((2, 0.0), (0, -1.0))\n", + "3.0 1.0\n", + "{0: [(0, 0), (1, 1.0), (0, 0)], 1: [(1, 1.0), (2, 1.0), (0, 0)], 2: [(2, 0.0), (4, 0)]}\n", + "0.0 -1.0\n", + "('flipped', 1, 2)\n", + "((3, 1.75), (4, 1.75))\n", + "((3, 0.75), (2, 0.75))\n", + "((2, 0.75), (0, -1.25))\n", + "2.0 2.5\n", + "{0: [(0, 0), (1, 1.75), (0, 0)], 1: [(1, 1.75), (2, 2.5), (0, 0)], 2: [(2, 0.75), (4, 0)]}\n", + "0.75 -1.25\n", + "('flipped', 1, 3)\n", + "((3, 2.5), (4, 2.5))\n", + "((3, 1.5), (2, 1.5))\n", + "((2, 1.5), (0, -1.5))\n", + "1.6666666666666667 3.4999999999999996\n", + "{0: [(0, 0), (1, 2.5), (0, 0)], 1: [(1, 2.5), (2, 4.0), (0, 0)], 2: [(2, 1.5), (4, 0)]}\n", + "1.5 -1.5\n", + "('flipped', 2, 1)\n", + "((3, 1.25), (4, 1.25))\n", + "((3, -0.75), (2, -0.75))\n", + "((2, -0.75), (0, -1.75))\n", + "5.0 -1.75\n", + "{0: [(0, 0), (1, 1.25), (0, 0)], 1: [(1, 1.25), (2, 0.5), (0, 0)], 2: [(2, -0.75), (4, 0)]}\n", + "-0.75 -1.75\n", + "('flipped', 2, 2)\n", + "((3, 2.0), (4, 2.0))\n", + "((3, 0.0), (2, 0.0))\n", + "((2, 0.0), (0, -2.0))\n", + "3.0 2.0\n", + "{0: [(0, 0), (1, 2.0), (0, 0)], 1: [(1, 2.0), (2, 2.0), (0, 0)], 2: [(2, 0.0), (4, 0)]}\n", + "0.0 -2.0\n", + "('flipped', 3, 1)\n", + "((3, 1.5), (4, 1.5))\n", + "((3, -1.5), (2, -1.5))\n", + "((2, -1.5), (0, -2.5))\n", + "7.0 -7.5\n", + "{0: [(0, 0), (1, 1.5), (0, 0)], 1: [(1, 1.5), (2, 0.0), (0, 0)], 2: [(2, -1.5), (4, 0)]}\n", + "-1.5 -2.5\n", + "('flipped', 3, 3)\n", + "((3, 3.0), (4, 3.0))\n", + "((3, 0.0), (2, 0.0))\n", + "((2, 0.0), (0, -3.0))\n", + "3.0 3.0\n", + "{0: [(0, 0), (1, 3.0), (0, 0)], 1: [(1, 3.0), (2, 3.0), (0, 0)], 2: [(2, 0.0), (4, 0)]}\n", + "0.0 -3.0\n" + ] + } + ], + "source": [ + "variants = ['regular', 'flipped']\n", + "truck_weights = [1, 2, 3]\n", + "comb_loads = [1, 2, 3]\n", + "\n", + "acceptable_values_of_dist_load = {\n", + " 1: [1, 2, 3],\n", + " 2: [1, 2],\n", + " 3: [1, 3]\n", + "}\n", + "\n", + "for variant in variants:\n", + " for truck_weight in truck_weights:\n", + " for comb_load in acceptable_values_of_dist_load[truck_weight]:\n", + " '''\n", + " ######################################################################\n", + " CREATING THE SHEAR DIAGRAM\n", + " ######################################################################\n", + " '''\n", + "\n", + " ### NOTES TO SELF\n", + "\n", + " # each cell is 20u wide.\n", + "\n", + " u = 1\n", + "\n", + " # total x length , y_max \n", + " L = 1\n", + " Ymax = 140\n", + "\n", + " A = np.array([\n", + " [1, 1],\n", + " [0, 4]\n", + " ])\n", + "\n", + " b = np.array([truck_weight + comb_load, truck_weight + 3*comb_load]) if variant == 'regular' else np.array([truck_weight + comb_load, 3*truck_weight + comb_load])\n", + "\n", + " ra, rb = np.linalg.inv(A)@b\n", + "\n", + " # Generating correct answers\n", + "\n", + " n_intervals = 3\n", + "\n", + " # location of points based on variant\n", + " if variant == 'regular':\n", + " line_points = {0: ((0, ra), (L, ra)),\n", + " 1: ((L, ra-truck_weight), (2*L, ra-truck_weight)),\n", + " 2: ((2*L, ra-truck_weight), (4*L, -rb))\n", + " }\n", + " else:\n", + " line_points = {0: ((3*L, ra), (4*L, ra)),\n", + " 1: ((3*L, ra-truck_weight), (2*L, ra-truck_weight)),\n", + " 2: ((2*L, ra-truck_weight), (0, -rb))\n", + " }\n", + " \n", + " max_V = 0\n", + " min_V = 0\n", + "\n", + " for i, line in line_points.items():\n", + " p1, p2 = line\n", + " p1x, p1y = p1\n", + " p2x, p2y = p2\n", + "\n", + " for pt in [p1, p2]:\n", + " if pt[1] > max_V:\n", + " max_V = pt[1]\n", + "\n", + " if pt[1] < min_V:\n", + " min_V = pt[1]\n", + "\n", + " mega_u = max(abs(max_V), abs(min_V))*40\n", + "\n", + " '''\n", + " ######################################################################\n", + " CREATING THE MOMENT DIAGRAM\n", + " ######################################################################\n", + " '''\n", + " # Generating correct answers\n", + "\n", + " line_points_M = {}\n", + " # location of points, except now one line needs a 3rd point, still based on variant\n", + " for i, line in line_points.items():\n", + " line_points_M[i] = []\n", + " print(line_points[i])\n", + " previous_V = line_points[i-1][1][1] if i else 0\n", + " V = line_points[i][1][1]\n", + " if not i:\n", + " line_points_M[0] += [(0, 0), (L, V), (0, 0)]\n", + " elif i == 2:\n", + " x0 = line_points_M[1][1][1]\n", + " slope_2 = previous_V\n", + " slope_4 = V\n", + "\n", + " x = (2*slope_2-4*slope_4-x0)/(slope_2-slope_4)\n", + " y = slope_4*(x-4)\n", + " print(x, y)\n", + " \n", + " line_points_M[2] += [(2*L, previous_V), (4*L, 0), (x, y)]\n", + " else:\n", + " line_points_M[1] += [(L, previous_V), (2*L, previous_V+V), (0, 0)]\n", + " \n", + " \n", + " #print(line_points)\n", + " #print(mega_u)\n", + " print(line_points_M)\n", + " print(slope_2, slope_4)\n", + "\n", + "\n", + "\n", + "mega_u = [(2, 2), (3, 1), (3, 3)]\n", + "\n", + "mega_u = {\n", + " (2, 2): 2,\n", + " (3, 1): 1,\n", + " (3, 3): 1\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{0: ((3, 3.0), (4, 3.0)), 1: ((3, 0.0), (2, 0.0)), 2: ((2, 0.0), (0, -3.0))}" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "line_points " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.9" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/src/components/CodeBox.astro b/src/components/CodeBox.astro index d51f0eb67..44aec6507 100644 --- a/src/components/CodeBox.astro +++ b/src/components/CodeBox.astro @@ -19,12 +19,74 @@ const {code = "", language=""} = Astro.props; e.href = "/static/css/atom-one-dark.css"; }) } + + function copy_to_clipboard(e){ + if (window.innerWidth > 768){ + navigator.clipboard.writeText(e.innerText); + e.previousElementSibling.firstElementChild.classList.add("show-alert"); + window.setTimeout(function(){e.previousElementSibling.firstElementChild.classList.remove("show-alert");}, 1500) + } + + } + +
+

+ Text successfully copied to clipboard! +

+
-
-    
+
+    
         {code}
     
 
diff --git a/src/components/Navbar.astro b/src/components/Navbar.astro index 50026c5f5..bbfda60d6 100644 --- a/src/components/Navbar.astro +++ b/src/components/Navbar.astro @@ -149,6 +149,7 @@ import Searchbar from "./Searchbar.astro"; text-align: center; font-weight: bold; padding: 8px 10px 10px 10px; + cursor: pointer; } @@ -190,7 +191,6 @@ import Searchbar from "./Searchbar.astro"; .dynamics-menu{ column-count: 2; - } .menu li{ @@ -205,7 +205,7 @@ import Searchbar from "./Searchbar.astro"; @media (width <= 578px){ .course-menu{ - columns: 1; + columns: 1 !important; } } @@ -330,7 +330,7 @@ import Searchbar from "./Searchbar.astro";