{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Small Angle Approximation Interactive\n", "\n", "This interactive can be used to explore the relationship between an object's size, its distance, and its observed angular size. When an object is far away compared to its size, astronomers use the *small angle approximation* to simplify the relationship.\n", "\n", "There are two control sliders: the first for the size of the object (s) and the second for the distance from Earth to the object (d). The interactive uses both the \"exact\" equation and small angle approximation to estimate the angular size of the object:\n", "\n", "$$\\theta_{exact} = 2\\arctan\\left(\\frac{s}{2d}\\right) \\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\; \\theta_{approx} = \\frac{s}{d}$$\n", "\n", "**Note**: The above espressions give the angle $\\theta$ in radians. To get an angle in degrees, we must multiply by the conversion factor $\\frac{180^{\\circ}}{\\pi}$ (because there are $2\\pi$ radians or $360^{\\circ}$ in a circle)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Originally created on June 13, 2018 by Samuel Holen\n", "\n", "import ipywidgets as widgets\n", "import numpy as np\n", "import bqplot.pyplot as bq\n", "from IPython.display import display" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def approx_theta(s,d):\n", " # Small angle approximation equation\n", " return s/d\n", "\n", "def exact_theta(s,d):\n", " # Exact equation for theta\n", " return 2*np.arctan(s/(2*d))\n", "\n", "def circle(r,d=0.):\n", " # Creates a circle given a radius r and displacement along the \n", " # x-axis d \n", " theta = np.linspace(0,2*np.pi,1000)\n", " return (r*np.cos(theta)+d,r*np.sin(theta))\n", "\n", "def par_circ(r,theta0,theta1,d=0.,h=0.):\n", " theta = np.linspace(theta0,theta1,1000)\n", " return (r*np.cos(theta)+d,r*np.sin(theta)+h)\n", "\n", "def ellipse(a,b,d=0.):\n", " # Creates an ellipse centered at (d,0) with a semimajor axis of 'a'\n", " # in the x direction and 'b' in the y direction\n", " theta = np.linspace(0,2*np.pi,1000)\n", " return (a*np.cos(theta)+d,b*np.sin(theta))\n", "\n", "def update(change=None):\n", " # Update the display.\n", " D1.y = [0,h_slider.value/2]\n", " D2.y = [0,-h_slider.value/2]\n", " D1.x = [0,d_slider.value]\n", " D2.x = [0,d_slider.value]\n", " ref.x = [0,d_slider.value]\n", " # Note that the ellipse is used so that the display needn't be a square.\n", " X_new, Y_new = circle(h_slider.value/2, d_slider.value)\n", " Object.x = X_new\n", " Object.y = Y_new\n", " \n", " # Update the resulting angles\n", " theta_approx = 180/np.pi*approx_theta(h_slider.value,d_slider.value)\n", " theta_exact = 180/np.pi*exact_theta(h_slider.value,d_slider.value)\n", " \n", " approx_eqn.value='
\"Small Angle\" Equation:
{:.4f}° = (180°/π) * ({:.1f} / {:.1f})
\"Exact\" Equation:
{:.4f}° = 2 arctan( {:.1f} / 2*{:.1f} )
Difference:
{:.4f}° ({:.2f}%)
\"Small Angle\" Equation:
{:.4f}° = (180°/π) * ({:.1f} / {:.1f})
\"Exact\" Equation:
{:.4f}° = 2 arctan( {:.1f} / 2*{:.1f} )
Difference:
{:.4f}° ({:.2f}%)