# ex_trajectories.ppl
#
# The code in this file is part of Pyxplot
# <http://www.pyxplot.org.uk>
#
# Copyright (C) 2006-2012 Dominic Ford <coders@pyxplot.org.uk>
#               2008-2012 Ross Church
#
# $Id: ex_trajectories.ppl 1261 2012-07-11 21:38:05Z dcf21 $
#
# Pyxplot is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# You should have received a copy of the GNU General Public License along with
# Pyxplot; if not, write to the Free Software Foundation, Inc., 51 Franklin
# Street, Fifth Floor, Boston, MA  02110-1301, USA

# ----------------------------------------------------------------------------

# This script produces a figure for the Pyxplot Users' Guide

# Call common initialisation script
reset
title = "ex_trajectories"
load "examples/fig_init.ppl"

# Main body of figure script

# BEGIN
g   = phy.g     # Acceleration due to gravity
deg = unit(deg) # Convert degrees to radians

# The mathematical equation of a trajectory
h(x,theta,v) = x*tan(theta*deg) - 0.5*g*x**2/(v**2*cos(theta*deg)**2)

# Plot configuration
set xlabel r"$x$"
set ylabel r"$h$"
set xrange [unit(0*m):unit(20*m)]
set yrange [unit(0*m):]
set key below
set title r'Trajectories of projectiles fired with speed $v$ at angle $\theta$'
plot h(x,30,unit(10*m/s)) t r"$\theta=30^\circ;\qquad v=10\,{\rm m\,s^{-1}}$", \
     h(x,45,unit(10*m/s)) t r"$\theta=45^\circ;\qquad v=10\,{\rm m\,s^{-1}}$", \
     h(x,60,unit(10*m/s)) t r"$\theta=60^\circ;\qquad v=10\,{\rm m\,s^{-1}}$", \
     h(x,30,unit(15*m/s)) t r"$\theta=30^\circ;\qquad v=15\,{\rm m\,s^{-1}}$", \
     h(x,60,unit(15*m/s)) t r"$\theta=60^\circ;\qquad v=15\,{\rm m\,s^{-1}}$"
# END

# Call common cleanup script
load "examples/fig_end.ppl"

