# Sine, Cosine and Tangent in an Unit Circle
# Lauri Ruotsalainen, 2010
t = var('t')
@interact
def unitcircle(
function = selector([(0, sin(x)), (1, cos(x)), (2, tan(x))]),
x = slider(0,2*pi, 0.005*pi, 0)
):
xy = (cos(x), sin(x))
# Unit Circle
C = circle((0, 0), 1, figsize=[5, 5], aspect_ratio=1)
C_line = line([(0, 0), (xy[0], xy[1])], rgbcolor="black")
C_point = point((xy[0], xy[1]), pointsize=40, rgbcolor="green")
C_inner = parametric_plot((cos(t), sin(t)), (t, 0, x + 0.001), color="green", thickness=2)
C_outer = parametric_plot((0.1 * cos(t), 0.1 * sin(t)), (t, 0, x + 0.001), color="black")
C_graph = C + C_line + C_point + C_inner + C_outer
# Graphics related to the graph of the function
G_line = line([(0, 0), (x, 0)], rgbcolor="green", thickness=2)
G_point = point((x, 0), pointsize=30, rgbcolor="green")
G_graph = G_line + G_point
# Sine
if function == 0:
Gf = plot(sin(t), t, 0, 2*pi, axes_labels=("x", "sin(x)"))
Gf_point = point((x, sin(x)), pointsize=30, rgbcolor="red")
Gf_line = line([(x, 0),(x, sin(x))], rgbcolor="red")
Cf_point = point((0, xy[1]), pointsize=40, rgbcolor="red")
Cf_line1 = line([(0, 0), (0, xy[1])], rgbcolor="red", thickness=2)
Cf_line2 = line([(0, xy[1]), (xy[0], xy[1])], rgbcolor="purple", linestyle="--")
# Cosine
elif function == 1:
Gf = plot(cos(t), t, 0, 2*pi, axes_labels=("x", "cos(x)"))
Gf_point = point((x, cos(x)), pointsize=30, rgbcolor="red")
Gf_line = line([(x, 0), (x, cos(x))], rgbcolor="red")
Cf_point = point((xy[0], 0), pointsize=40, rgbcolor="red")
Cf_line1 = line([(0, 0), (xy[0], 0)], rgbcolor="red", thickness=2)
Cf_line2 = line([(xy[0], 0), (xy[0], xy[1])], rgbcolor="purple", linestyle="--")
# Tangent
else:
Gf = plot(tan(t), t, 0, 2*pi, ymin=-8, ymax=8, axes_labels=("x", "tan(x)"))
Gf_point = point((x, tan(x)), pointsize=30, rgbcolor="red")
Gf_line = line([(x, 0), (x, tan(x))], rgbcolor="red")
Cf_point = point((1, tan(x)), pointsize=40, rgbcolor="red")
Cf_line1 = line([(1, 0), (1, tan(x))], rgbcolor="red", thickness=2)
Cf_line2 = line([(xy[0], xy[1]), (1, tan(x))], rgbcolor="purple", linestyle="--")
C_graph += Cf_point + Cf_line1 + Cf_line2
G_graph += Gf + Gf_point + Gf_line
html.table([["$\\text{Unit Circle}$","$\\text{Function}"], [C_graph, G_graph]], header=True)
|
|
Click to the left again to hide and once more to show the dynamic interactive window
|