var('t')
start=0
stop=2*pi
position=vector( (4*cos(t), sin(t)) )
path = parametric_plot( position(t).list(), (t, start, stop), color = "black" )
velocity = diff( position(t) )
speed = velocity.norm()
tangent = (1/speed)*velocity
dT = diff(tangent(t))
normal = (1/dT.norm())*dT
acceleration = diff(velocity(t))
deriv_speed = diff(speed)
@interact
def _(t0=slider(0, float(2*pi), float(pi/12), float(pi/4) , label = "Theta"),
pos_check = ("Position", True),
vel_check = ("Velocity", False),
tan_check = ("Unit Tangent", False),
nor_check = ("Unit Normal", False),
acc_check = ("Acceleration", False),
tancomp_check = ("Tangential Component", False),
norcomp_check = ("Normal Component", False)
):
speed_component = speed(t0)
tangent_component = deriv_speed(t0)
normal_component = sqrt( acceleration(t0).norm()^2 - tangent_component^2 )
curvature = normal_component/speed_component^2
pos = arrow((0,0), position(t0), rgbcolor=(0,0,0))
tan = arrow(position(t0), position(t0) + tangent(t0), rgbcolor=(0,1,0) )
vel = arrow(position(t0), position(t0) + velocity(t0), rgbcolor=(0,0.5,0))
nor = arrow(position(t0), position(t0) + normal(t0), rgbcolor=(0.5,0,0))
acc = arrow(position(t0), position(t0) + acceleration(t0), rgbcolor=(1,0,1))
tancomp = arrow(position(t0), position(t0) + tangent_component*tangent(t0), rgbcolor=(1,0,1) )
norcomp = arrow(position(t0), position(t0) + normal_component*normal(t0), rgbcolor=(1,0,1))
picture = path
if pos_check:
picture = picture + pos
if vel_check:
picture = picture + vel
if tan_check:
picture = picture+ tan
if nor_check:
picture = picture + nor
if acc_check:
picture = picture + acc
if tancomp_check:
picture = picture + tancomp
if norcomp_check:
picture = picture + norcomp
print "Position vector is r(t)=" + position(t)._repr_()
print "Speed is ", N(speed(t0))
print "Curvature is ", N(curvature)
show(picture, figsize=[8,2])