Add z example tables
This commit is contained in:
parent
45cb438847
commit
6ea2e19b2c
@ -283,11 +283,11 @@
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\displaystyle \\left\\{ q : \\frac{2}{Z_{f} - Z_{n}}, \\ r : - \\frac{Z_{f} + Z_{n}}{Z_{f} - Z_{n}}\\right\\}$"
|
||||
"$\\displaystyle \\left\\{ s : \\frac{2}{Z_{f} - Z_{n}}, \\ t : - \\frac{Z_{f} + Z_{n}}{Z_{f} - Z_{n}}\\right\\}$"
|
||||
],
|
||||
"text/plain": [
|
||||
"⎧ 2 -(Z_f + Zₙ) ⎫\n",
|
||||
"⎨q: ────────, r: ────────────⎬\n",
|
||||
"⎨s: ────────, t: ────────────⎬\n",
|
||||
"⎩ Z_f - Zₙ Z_f - Zₙ ⎭"
|
||||
]
|
||||
},
|
||||
@ -297,11 +297,11 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"q, r, v_z, Z_n, Z_f = symbols('q, r, v_z, Z_n, Z_f')\n",
|
||||
"s, t, v_z, Z_n, Z_f = symbols('s, t, v_z, Z_n, Z_f')\n",
|
||||
"solve(Eq(\n",
|
||||
" q*v_z + r,\n",
|
||||
" s*v_z + t,\n",
|
||||
" 2*(v_z - Z_n)/(Z_f - Z_n) - 1\n",
|
||||
"), q, r)"
|
||||
"), s, t)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -315,7 +315,76 @@
|
||||
"v''_z = \\frac{2}{Z_f-Z_n}v_z - \\frac{Z_f+Z_n}{Z_f-Z_n}\n",
|
||||
"$$\n",
|
||||
"\n",
|
||||
"Neat.\n"
|
||||
"Neat. I'm going to dump a table of data to show that it works like I expect:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "394187c9-7e95-4ffc-8148-0008c7190de5",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"Let $Z_n = 0.1$ and $Z_f = 10.0$"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<table>\n",
|
||||
"<thead>\n",
|
||||
"<tr><th style=\"text-align: right;\"> $z$</th><th style=\"text-align: right;\"> $r$($z$)</th></tr>\n",
|
||||
"</thead>\n",
|
||||
"<tbody>\n",
|
||||
"<tr><td style=\"text-align: right;\"> 0.100</td><td style=\"text-align: right;\"> -1.000</td></tr>\n",
|
||||
"<tr><td style=\"text-align: right;\"> 2.000</td><td style=\"text-align: right;\"> -0.616</td></tr>\n",
|
||||
"<tr><td style=\"text-align: right;\"> 4.000</td><td style=\"text-align: right;\"> -0.212</td></tr>\n",
|
||||
"<tr><td style=\"text-align: right;\"> 6.000</td><td style=\"text-align: right;\"> 0.192</td></tr>\n",
|
||||
"<tr><td style=\"text-align: right;\"> 8.000</td><td style=\"text-align: right;\"> 0.596</td></tr>\n",
|
||||
"<tr><td style=\"text-align: right;\">10.000</td><td style=\"text-align: right;\"> 1.000</td></tr>\n",
|
||||
"</tbody>\n",
|
||||
"</table>"
|
||||
],
|
||||
"text/plain": [
|
||||
"'<table>\\n<thead>\\n<tr><th style=\"text-align: right;\"> $z$</th><th style=\"text-align: right;\"> $r$($z$)</th></tr>\\n</thead>\\n<tbody>\\n<tr><td style=\"text-align: right;\"> 0.100</td><td style=\"text-align: right;\"> -1.000</td></tr>\\n<tr><td style=\"text-align: right;\"> 2.000</td><td style=\"text-align: right;\"> -0.616</td></tr>\\n<tr><td style=\"text-align: right;\"> 4.000</td><td style=\"text-align: right;\"> -0.212</td></tr>\\n<tr><td style=\"text-align: right;\"> 6.000</td><td style=\"text-align: right;\"> 0.192</td></tr>\\n<tr><td style=\"text-align: right;\"> 8.000</td><td style=\"text-align: right;\"> 0.596</td></tr>\\n<tr><td style=\"text-align: right;\">10.000</td><td style=\"text-align: right;\"> 1.000</td></tr>\\n</tbody>\\n</table>'"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from tabulate import tabulate\n",
|
||||
"from IPython.display import display, Markdown\n",
|
||||
"\n",
|
||||
"def ztable(fn):\n",
|
||||
" Z_n, Z_f = 0.1, 10.0\n",
|
||||
" zs = [0.1, 2, 4, 6, 8, 10]\n",
|
||||
" display(\n",
|
||||
" Markdown(f\"Let $Z_n = {Z_n}$ and $Z_f = {Z_f}$\"),\n",
|
||||
" tabulate([[z, fn(z, Z_n, Z_f)] for z in zs], headers=('$z$', '$r$($z$)'), tablefmt='html', floatfmt=\".3f\"),\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
"def r(z, Z_n, Z_f):\n",
|
||||
" return 2/(Z_f-Z_n)*z - (Z_f + Z_n)/(Z_f - Z_n)\n",
|
||||
"\n",
|
||||
"ztable(r)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "140bd95b-1614-45d9-a2f1-dab8f84af5ee",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Yeah, that looks pretty good."
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -357,7 +426,7 @@
|
||||
"\n",
|
||||
"The only other constraint is that if $s \\le t$ then $r(s) \\le r(t)$ as well.\n",
|
||||
"\n",
|
||||
"If that's the case then we can just as easily remap $v_z^{-1}$ from the range $Z_n^{-1}$ through $Z_f^{-1}$ to the range $-1$ through $1$ and the constraints will hold. A very important thing to note is that doing this means that z-depth is no longer a *linear* interpolation, which explains the warnings about not letting $Z_n$ get too close to zero for fear of losing bits of precision.\n",
|
||||
"If that's the case then we can just as easily remap $v_z^{-1}$ from the range $Z_n^{-1}$ through $Z_f^{-1}$ to the range $-1$ through $1$ and the constraints will hold.\n",
|
||||
"\n",
|
||||
"Working it out looks almost the same as before:\n",
|
||||
"\n",
|
||||
@ -370,31 +439,31 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 4,
|
||||
"id": "716e1825-f31e-4796-a6a9-aaaa7da3f42b",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\displaystyle \\left\\{ q : - \\frac{2 Z_{f} Z_{n}}{Z_{f} - Z_{n}}, \\ r : \\frac{Z_{f} + Z_{n}}{Z_{f} - Z_{n}}\\right\\}$"
|
||||
"$\\displaystyle \\left\\{ s : - \\frac{2 Z_{f} Z_{n}}{Z_{f} - Z_{n}}, \\ t : \\frac{Z_{f} + Z_{n}}{Z_{f} - Z_{n}}\\right\\}$"
|
||||
],
|
||||
"text/plain": [
|
||||
"⎧ -2⋅Z_f⋅Zₙ Z_f + Zₙ⎫\n",
|
||||
"⎨q: ──────────, r: ────────⎬\n",
|
||||
"⎨s: ──────────, t: ────────⎬\n",
|
||||
"⎩ Z_f - Zₙ Z_f - Zₙ⎭"
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"solve(Eq(\n",
|
||||
" q*v_z**(-1) + r,\n",
|
||||
" s*v_z**(-1) + t,\n",
|
||||
" 2*(v_z**(-1) - Z_n**(-1))/(Z_f**(-1) - Z_n**(-1)) - 1\n",
|
||||
"), q, r)"
|
||||
"), s, t)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -408,7 +477,65 @@
|
||||
"v''_z = \\frac{2 Z_f Z_n}{Z_n-Z_f}v_z^{-1} + \\frac{Z_f+Z_n}{Z_f-Z_n}\n",
|
||||
"$$\n",
|
||||
"\n",
|
||||
"Neat. This should work."
|
||||
"Neat. This should work. I'm going to dump a table of data to show that it works like I expect:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "f87f833a-5813-4b19-9adf-2e3d82bb2c75",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"Let $Z_n = 0.1$ and $Z_f = 10.0$"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<table>\n",
|
||||
"<thead>\n",
|
||||
"<tr><th style=\"text-align: right;\"> $z$</th><th style=\"text-align: right;\"> $r$($z$)</th></tr>\n",
|
||||
"</thead>\n",
|
||||
"<tbody>\n",
|
||||
"<tr><td style=\"text-align: right;\"> 0.100</td><td style=\"text-align: right;\"> -1.000</td></tr>\n",
|
||||
"<tr><td style=\"text-align: right;\"> 2.000</td><td style=\"text-align: right;\"> 0.919</td></tr>\n",
|
||||
"<tr><td style=\"text-align: right;\"> 4.000</td><td style=\"text-align: right;\"> 0.970</td></tr>\n",
|
||||
"<tr><td style=\"text-align: right;\"> 6.000</td><td style=\"text-align: right;\"> 0.987</td></tr>\n",
|
||||
"<tr><td style=\"text-align: right;\"> 8.000</td><td style=\"text-align: right;\"> 0.995</td></tr>\n",
|
||||
"<tr><td style=\"text-align: right;\">10.000</td><td style=\"text-align: right;\"> 1.000</td></tr>\n",
|
||||
"</tbody>\n",
|
||||
"</table>"
|
||||
],
|
||||
"text/plain": [
|
||||
"'<table>\\n<thead>\\n<tr><th style=\"text-align: right;\"> $z$</th><th style=\"text-align: right;\"> $r$($z$)</th></tr>\\n</thead>\\n<tbody>\\n<tr><td style=\"text-align: right;\"> 0.100</td><td style=\"text-align: right;\"> -1.000</td></tr>\\n<tr><td style=\"text-align: right;\"> 2.000</td><td style=\"text-align: right;\"> 0.919</td></tr>\\n<tr><td style=\"text-align: right;\"> 4.000</td><td style=\"text-align: right;\"> 0.970</td></tr>\\n<tr><td style=\"text-align: right;\"> 6.000</td><td style=\"text-align: right;\"> 0.987</td></tr>\\n<tr><td style=\"text-align: right;\"> 8.000</td><td style=\"text-align: right;\"> 0.995</td></tr>\\n<tr><td style=\"text-align: right;\">10.000</td><td style=\"text-align: right;\"> 1.000</td></tr>\\n</tbody>\\n</table>'"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def r2(z, Z_n, Z_f):\n",
|
||||
" return (2*Z_f*Z_n)/(Z_n-Z_f)*z**(-1) + (Z_f + Z_n)/(Z_f - Z_n)\n",
|
||||
"\n",
|
||||
"ztable(r2)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "7202e8ff-ca9f-44c8-9676-8c2973cd05eb",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"It works, but it's crazy how quickly the values approach $1$ as $z$ gets away from $Z_n$."
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -451,7 +578,7 @@
|
||||
"source": [
|
||||
"# Completing $f$\n",
|
||||
"\n",
|
||||
"What to do $o$? I put factors of $o$ in all of my other values, so no matter what $o$ actually is, so long as it's not $0$, it can be anything. I will choose $1$.\n",
|
||||
"What to do with $o$? I put factors of $o$ in all of my other values, so no matter what $o$ actually is, so long as it's not $0$, it can be anything. I will choose $1$.\n",
|
||||
"\n",
|
||||
"Here's the completed function:\n",
|
||||
"\n",
|
||||
@ -464,7 +591,9 @@
|
||||
"\\end{bmatrix}\n",
|
||||
"$$\n",
|
||||
"\n",
|
||||
"What does <code>gluPerspective</code> do? Check it out: https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluPerspective.xml"
|
||||
"What does <code>gluPerspective</code> do? Check it out: https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluPerspective.xml\n",
|
||||
"\n",
|
||||
"Two things to note in comparison: their $k$ is the negated version of mine, and their $o$ is -1. TODO: figure out exactly why that is (probably coordinate system handedness)"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user