Skip to content

Commit

Permalink
Lecture 2
Browse files Browse the repository at this point in the history
  • Loading branch information
fcichos committed Apr 12, 2024
1 parent 24aa817 commit f7182d9
Show file tree
Hide file tree
Showing 16 changed files with 446 additions and 526 deletions.
Binary file modified build/doctrees/environment.pickle
Binary file not shown.
108 changes: 50 additions & 58 deletions build/doctrees/nbsphinx/notebooks/L1/1_ray_optics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
},
{
"cell_type": "code",
"execution_count": 102,
"execution_count": 105,
"id": "fbf42d2d-ba72-4d79-b251-bf343a9c054c",
"metadata": {
"tags": []
Expand Down Expand Up @@ -196,6 +196,18 @@
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<script src='https://d3js.org/d3.v6.min.js'></script>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
Expand All @@ -220,7 +232,7 @@
},
{
"cell_type": "code",
"execution_count": 103,
"execution_count": 106,
"id": "a7043a8d-8a5a-4b0a-9ec3-3c61e77665b1",
"metadata": {
"tags": []
Expand Down Expand Up @@ -312,13 +324,11 @@
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "81c9708e657a43299356d6d746905d25",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<script src='https://d3js.org/d3.v6.min.js'></script>"
],
"text/plain": [
"interactive(children=(FloatSlider(value=50.0, continuous_update=False, description='Radius:', min=10.0, step=1…"
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
Expand All @@ -328,75 +338,57 @@
"data": {
"text/html": [
"\n",
"<div id=\"d3-container\"></div>\n",
"<div id=\"animation-container\"></div>\n",
"<script src=\"https://d3js.org/d3.v6.min.js\"></script>\n",
"<script>\n",
" var container = d3.select(\"#d3-container\");\n",
" var svg = container.append(\"svg\")\n",
" .attr(\"width\", 200)\n",
" var svg = d3.select(\"#animation-container\").append(\"svg\")\n",
" .attr(\"width\", 400)\n",
" .attr(\"height\", 200);\n",
" svg.append(\"circle\")\n",
" .attr(\"id\", \"d3-circle\")\n",
" .attr(\"cx\", 100)\n",
"\n",
" var circle = svg.append(\"circle\")\n",
" .attr(\"cx\", 20)\n",
" .attr(\"cy\", 100)\n",
" .attr(\"r\", 50)\n",
" .style(\"fill\", \"blue\");\n",
" .attr(\"r\", 20)\n",
" .style(\"fill\", \"steelblue\");\n",
"\n",
" circle.transition()\n",
" .duration(2000)\n",
" .attr(\"cx\", 380)\n",
" .on(\"end\", function() { d3.select(this).style(\"fill\", \"tomato\"); });\n",
"</script>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 106,
"metadata": {},
"output_type": "display_data"
"output_type": "execute_result"
}
],
"source": [
"from ipywidgets import interact, FloatSlider\n",
"from IPython.display import display, HTML, Javascript\n",
"\n",
"# Define the function to update the circle radius\n",
"def update_circle_radius(radius):\n",
" display(Javascript(f\"\"\"\n",
" (function() {{\n",
" var circle = d3.select(\"#d3-circle\");\n",
" if(circle) circle.attr(\"r\", {radius});\n",
" }})();\n",
" \"\"\"))\n",
"\n",
"# Create the slider widget\n",
"slider = FloatSlider(\n",
" value=50,\n",
" min=10,\n",
" max=100,\n",
" step=1,\n",
" description='Radius:',\n",
" continuous_update=False\n",
")\n",
"\n",
"# Display the slider and pass the update function as the callback\n",
"interact(update_circle_radius, radius=slider)\n",
"\n",
"# Define the HTML and JavaScript code for the initial D3.js circle\n",
"html_code = \"\"\"\n",
"<div id=\"d3-container\"></div>\n",
"from IPython.display import HTML\n",
"\n",
"HTML(\"\"\"\n",
"<div id=\"animation-container\"></div>\n",
"<script src=\"https://d3js.org/d3.v6.min.js\"></script>\n",
"<script>\n",
" var container = d3.select(\"#d3-container\");\n",
" var svg = container.append(\"svg\")\n",
" .attr(\"width\", 200)\n",
" var svg = d3.select(\"#animation-container\").append(\"svg\")\n",
" .attr(\"width\", 400)\n",
" .attr(\"height\", 200);\n",
" svg.append(\"circle\")\n",
" .attr(\"id\", \"d3-circle\")\n",
" .attr(\"cx\", 100)\n",
"\n",
" var circle = svg.append(\"circle\")\n",
" .attr(\"cx\", 20)\n",
" .attr(\"cy\", 100)\n",
" .attr(\"r\", 50)\n",
" .style(\"fill\", \"blue\");\n",
"</script>\n",
"\"\"\"\n",
" .attr(\"r\", 20)\n",
" .style(\"fill\", \"steelblue\");\n",
"\n",
"# Display the initial D3.js circle\n",
"display(HTML(html_code))"
" circle.transition()\n",
" .duration(2000)\n",
" .attr(\"cx\", 380)\n",
" .on(\"end\", function() { d3.select(this).style(\"fill\", \"tomato\"); });\n",
"</script>\n",
"\"\"\")\n"
]
},
{
Expand Down
Binary file modified build/doctrees/notebooks/L1/1_ray_optics.doctree
Binary file not shown.
Binary file modified build/doctrees/notebooks/L1/Lecture1.doctree
Binary file not shown.
108 changes: 50 additions & 58 deletions build/html/_sources/notebooks/L1/1_ray_optics.ipynb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
},
{
"cell_type": "code",
"execution_count": 102,
"execution_count": 105,
"id": "fbf42d2d-ba72-4d79-b251-bf343a9c054c",
"metadata": {
"tags": []
Expand Down Expand Up @@ -196,6 +196,18 @@
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<script src='https://d3js.org/d3.v6.min.js'></script>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
Expand All @@ -220,7 +232,7 @@
},
{
"cell_type": "code",
"execution_count": 103,
"execution_count": 106,
"id": "a7043a8d-8a5a-4b0a-9ec3-3c61e77665b1",
"metadata": {
"tags": []
Expand Down Expand Up @@ -312,13 +324,11 @@
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "81c9708e657a43299356d6d746905d25",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<script src='https://d3js.org/d3.v6.min.js'></script>"
],
"text/plain": [
"interactive(children=(FloatSlider(value=50.0, continuous_update=False, description='Radius:', min=10.0, step=1…"
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
Expand All @@ -328,75 +338,57 @@
"data": {
"text/html": [
"\n",
"<div id=\"d3-container\"></div>\n",
"<div id=\"animation-container\"></div>\n",
"<script src=\"https://d3js.org/d3.v6.min.js\"></script>\n",
"<script>\n",
" var container = d3.select(\"#d3-container\");\n",
" var svg = container.append(\"svg\")\n",
" .attr(\"width\", 200)\n",
" var svg = d3.select(\"#animation-container\").append(\"svg\")\n",
" .attr(\"width\", 400)\n",
" .attr(\"height\", 200);\n",
" svg.append(\"circle\")\n",
" .attr(\"id\", \"d3-circle\")\n",
" .attr(\"cx\", 100)\n",
"\n",
" var circle = svg.append(\"circle\")\n",
" .attr(\"cx\", 20)\n",
" .attr(\"cy\", 100)\n",
" .attr(\"r\", 50)\n",
" .style(\"fill\", \"blue\");\n",
" .attr(\"r\", 20)\n",
" .style(\"fill\", \"steelblue\");\n",
"\n",
" circle.transition()\n",
" .duration(2000)\n",
" .attr(\"cx\", 380)\n",
" .on(\"end\", function() { d3.select(this).style(\"fill\", \"tomato\"); });\n",
"</script>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 106,
"metadata": {},
"output_type": "display_data"
"output_type": "execute_result"
}
],
"source": [
"from ipywidgets import interact, FloatSlider\n",
"from IPython.display import display, HTML, Javascript\n",
"\n",
"# Define the function to update the circle radius\n",
"def update_circle_radius(radius):\n",
" display(Javascript(f\"\"\"\n",
" (function() {{\n",
" var circle = d3.select(\"#d3-circle\");\n",
" if(circle) circle.attr(\"r\", {radius});\n",
" }})();\n",
" \"\"\"))\n",
"\n",
"# Create the slider widget\n",
"slider = FloatSlider(\n",
" value=50,\n",
" min=10,\n",
" max=100,\n",
" step=1,\n",
" description='Radius:',\n",
" continuous_update=False\n",
")\n",
"\n",
"# Display the slider and pass the update function as the callback\n",
"interact(update_circle_radius, radius=slider)\n",
"\n",
"# Define the HTML and JavaScript code for the initial D3.js circle\n",
"html_code = \"\"\"\n",
"<div id=\"d3-container\"></div>\n",
"from IPython.display import HTML\n",
"\n",
"HTML(\"\"\"\n",
"<div id=\"animation-container\"></div>\n",
"<script src=\"https://d3js.org/d3.v6.min.js\"></script>\n",
"<script>\n",
" var container = d3.select(\"#d3-container\");\n",
" var svg = container.append(\"svg\")\n",
" .attr(\"width\", 200)\n",
" var svg = d3.select(\"#animation-container\").append(\"svg\")\n",
" .attr(\"width\", 400)\n",
" .attr(\"height\", 200);\n",
" svg.append(\"circle\")\n",
" .attr(\"id\", \"d3-circle\")\n",
" .attr(\"cx\", 100)\n",
"\n",
" var circle = svg.append(\"circle\")\n",
" .attr(\"cx\", 20)\n",
" .attr(\"cy\", 100)\n",
" .attr(\"r\", 50)\n",
" .style(\"fill\", \"blue\");\n",
"</script>\n",
"\"\"\"\n",
" .attr(\"r\", 20)\n",
" .style(\"fill\", \"steelblue\");\n",
"\n",
"# Display the initial D3.js circle\n",
"display(HTML(html_code))"
" circle.transition()\n",
" .duration(2000)\n",
" .attr(\"cx\", 380)\n",
" .on(\"end\", function() { d3.select(this).style(\"fill\", \"tomato\"); });\n",
"</script>\n",
"\"\"\")\n"
]
},
{
Expand Down
Loading

0 comments on commit f7182d9

Please sign in to comment.