This section records information for easy reference.
The unit system used throughout is SI (Système International d'Unités). In addition to the basic units, several derived units are also used. For each unit, Tab: ToU lists the symbol, a description and the SI name.
Symbol | Description | SI Name |
---|---|---|
m | length | metre |
rad | angle | radian |
s | time | second |
The symbols used in this document are summarized in Tab: ToS along with their units. Throughout the document, symbols in bold will represent vectors, and scalars otherwise. The symbols are listed in alphabetical order. For vector quantities, the units shown are for each component of the vector.
Symbol | Description | Units |
---|---|---|
$a$ | Scalar acceleration | $\frac{\text{m}}{\text{s}^{2}}$ |
ac | Constant acceleration | m/s2 |
ax | x-component of acceleration | m/s2 |
${a_{x}^{c}}$ | $x$-component of acceleration | $\frac{\text{m}}{\text{s}^{2}}$ |
ay | y-component of acceleration | m/s2 |
ayc | y-component of constant acceleration | m/s2 |
a | Acceleration | m/s2 |
ac | Constant acceleration vector | m/s2 |
doffset | Distance between the target position and the landing position | m |
g | Gravitational acceleration | m/s2 |
p | Scalar position | m |
pi | Initial position | m |
pland | Landing position | m |
ptarget | Target position | m |
px | x-component of position | m |
pxi | x-component of initial position | m |
py | y-component of position | m |
pyi | y-component of initial position | m |
p | Position | m |
s | Output message as a string | -- |
t | Time | s |
tflight | Flight duration | s |
v | Speed | m/s |
vi | Initial speed | m/s |
vlaunch | Launch speed | m/s |
vx | x-component of velocity | m/s |
vxi | x-component of initial velocity | m/s |
vy | y-component of velocity | m/s |
vyi | y-component of initial velocity | m/s |
v | Velocity | m/s |
vi | Initial velocity | m/s |
ε | Hit tolerance | -- |
θ | Launch angle | rad |
π | Ratio of circumference to diameter for any circle | -- |
Abbreviation | Full Form |
---|---|
1D | One-Dimensional |
2D | Two-Dimensional |
A | Assumption |
DD | Data Definition |
GD | General Definition |
GS | Goal Statement |
IM | Instance Model |
PS | Physical System Description |
R | Requirement |
SRS | Software Requirements Specification |
TM | Theoretical Model |
Uncert. | Typical Uncertainty |
Projectile motion is a common problem in physics. Therefore, it is useful to have a program to solve and model these types of problems. The program documented here is called Projectile.
The following section provides an overview of the Software Requirements Specification (SRS) for Projectile. This section explains the purpose of this document, the scope of the system, the characteristics of the intended reader, and the organization of the document.
The scope of the requirements includes the analysis of a two-dimensional (2D) projectile motion problem with constant acceleration. Given the appropriate inputs, Projectile determines if the projectile hits the target.
This section first presents the problem description, which gives a high-level view of the problem to be solved. This is followed by the solution characteristics specification, which presents the assumptions, theories, and definitions that are used.
A system is needed to efficiently and correctly predict the landing position of a projectile.
This subsection provides a list of terms that are used in the subsequent sections and their meaning, with the purpose of reducing ambiguity and making it easier to correctly understand the requirements.
The physical system of Projectile, as shown in Fig:Launch, includes the following elements:
PS1: The launcher.
PS2: The projectile (with initial velocity vi and launch angle θ).
PS3: The target.
Given the initial velocity vector of the projectile, the goal statements are:
The instance models that govern Projectile are presented in Section: Instance Models. The information to understand the meaning of the instance models and their derivation is also presented, so that the instance models can be verified.
This section simplifies the original problem and helps in developing the theoretical models by filling in the missing information for the physical system. The assumptions refine the scope by providing more detail.
This section focuses on the general equations and laws that Projectile is based on.
Refname | TM:acceleration |
---|---|
Label | Acceleration |
Equation | $$\mathbf{a}=\frac{\,d\mathbf{v}}{\,dt}$$ |
Description | a is the acceleration (m/s2) t is the time (s) v is the velocity (m/s) |
Source | accelerationWiki and hibbeler2004 (pg. 7) |
RefBy | GD: rectVel |
Refname | TM:velocity |
---|---|
Label | Velocity |
Equation | $$\mathbf{v}=\frac{\,d\mathbf{p}}{\,dt}$$ |
Description | v is the velocity (m/s) t is the time (s) p is the position (m) |
Source | velocityWiki and hibbeler2004 (pg. 6) |
RefBy | GD: rectPos |
This section collects the laws and equations that will be used to build the instance models.
Refname | GD:rectVel |
---|---|
Label | Rectilinear (1D) velocity as a function of time for constant acceleration |
Units | m/s |
Equation | $$v={v^{i}}+{a^{c}} t$$ |
Description | v is the speed (m/s) vi is the initial speed (m/s) ac is the constant acceleration (m/s2) t is the time (s) |
Source | hibbeler2004 (pg. 8) |
RefBy | GD: velVec and GD: rectPos |
Assume we have rectilinear motion of a particle (of negligible size and shape, from A: pointMass); that is, motion in a straight line. The velocity is v and the acceleration is a. The motion in TM: acceleration is now one-dimensional with a constant acceleration, represented by ac. The initial velocity (at t = 0, from A: timeStartZero) is represented by vi. From TM: acceleration, using the above symbols we have:
Rearranging and integrating, we have:
Performing the integration, we have the required equation:
Refname | GD:rectPos |
---|---|
Label | Rectilinear (1D) position as a function of time for constant acceleration |
Units | m |
Equation | $$p={p^{i}}+{v^{i}} t+\frac{{a^{c}} t^{2}}{2}$$ |
Description | p is the scalar position (m) pi is the initial position (m) vi is the initial speed (m/s) t is the time (s) ac is the constant acceleration (m/s2) |
Source | hibbeler2004 (pg. 8) |
RefBy | GD: posVec |
Assume we have rectilinear motion of a particle (of negligible size and shape, from A: pointMass); that is, motion in a straight line. The position is p and the velocity is v. The motion in TM: velocity is now one-dimensional. The initial position (at t = 0, from A: timeStartZero) is represented by pi. From TM: velocity, using the above symbols we have:
Rearranging and integrating, we have:
From GD: rectVel we can replace v:
Performing the integration, we have the required equation:
Refname | GD:velVec |
---|---|
Label | Velocity vector as a function of time for 2D motion under constant acceleration |
Units | m/s |
Equation | $$ |
\mathbf{v}=\begin{bmatrix}
{{v_{x}}^{i}}+{{a_{x}}^{c}} t\\
{{v_{y}}^{i}}+{{a_{y}}^{c}} t
\end{bmatrix}
$$|
|Description|v is the velocity (m/s)
vxi is the x-component of initial velocity (m/s)
axc is the x-component of constant acceleration (m/s2)
t is the time (s)
vyi is the y-component of initial velocity (m/s)
ayc is the y-component of constant acceleration (m/s2)|
|Source|--|
|RefBy||
For a two-dimensional Cartesian coordinate system (A: twoDMotion and A: cartSyst), we can represent the velocity vector as $\mathbf{v}=\begin{bmatrix} {v_{x}}\\ {v_{y}} \end{bmatrix}$ and the acceleration vector as $\mathbf{a}=\begin{bmatrix} {a_{x}}\\ {a_{y}} \end{bmatrix}$ . The acceleration is assumed to be constant (A: constAccel) and the constant acceleration vector is represented as ${\mathbf{a}^{c}}=\begin{bmatrix} {{a_{x}}^{c}}\\ {{a_{y}}^{c}} \end{bmatrix}$ . The initial velocity (at t = 0, from A: timeStartZero) is represented by ${\mathbf{v}^{i}}=\begin{bmatrix} {{v_{x}}^{i}}\\ {{v_{y}}^{i}} \end{bmatrix}$ . Since we have a Cartesian coordinate system, GD: rectVel can be applied to each coordinate of the velocity vector to yield the required equation:
Refname | GD:posVec |
---|---|
Label | Position vector as a function of time for 2D motion under constant acceleration |
Units | m/s |
Equation | $$ |
\mathbf{p}=\begin{bmatrix}
{{p_{x}}^{i}}+{{v_{x}}^{i}} t+\frac{{{a_{x}}^{c}} t^{2}}{2}\\
{{p_{y}}^{i}}+{{v_{y}}^{i}} t+\frac{{{a_{y}}^{c}} t^{2}}{2}
\end{bmatrix}
$$|
|Description|p is the position (m)
pxi is the x-component of initial position (m)
vxi is the x-component of initial velocity (m/s)
t is the time (s)
axc is the x-component of constant acceleration (m/s2)
pyi is the y-component of initial position (m)
vyi is the y-component of initial velocity (m/s)
ayc is the y-component of constant acceleration (m/s2)|
|Source|--|
|RefBy|IM: calOfLandingTime and IM: calOfLandingDist|
For a two-dimensional Cartesian coordinate system (A: twoDMotion and A: cartSyst), we can represent the position vector as $\mathbf{p}=\begin{bmatrix} {p_{x}}\\ {p_{y}} \end{bmatrix}$ , the velocity vector as $\mathbf{v}=\begin{bmatrix} {v_{x}}\\ {v_{y}} \end{bmatrix}$ , and the acceleration vector as $\mathbf{a}=\begin{bmatrix} {a_{x}}\\ {a_{y}} \end{bmatrix}$ . The acceleration is assumed to be constant (A: constAccel) and the constant acceleration vector is represented as ${\mathbf{a}^{c}}=\begin{bmatrix} {{a_{x}}^{c}}\\ {{a_{y}}^{c}} \end{bmatrix}$ . The initial velocity (at t = 0, from A: timeStartZero) is represented by ${\mathbf{v}^{i}}=\begin{bmatrix} {{v_{x}}^{i}}\\ {{v_{y}}^{i}} \end{bmatrix}$ . Since we have a Cartesian coordinate system, GD: rectPos can be applied to each coordinate of the position vector to yield the required equation:
This section collects and defines all the data needed to build the instance models.
Refname | DD:vecMag |
---|---|
Label | Speed |
Symbol | v |
Units | m/s |
Equation | $$ |
v=|\mathbf{v}| $$| |<b>Description</b>|<em>v</em> is the speed (m/s) <br> <em><b>v</b></em> is the velocity (m/s)| |<b>Notes</b>|For a given velocity vector $\mathbf{v}$, the magnitude of the vector ($|\mathbf{v}|$) is the scalar called speed.| |Source|--| |RefBy|DD: speedIY and DD: speedIX|
Refname | DD:speedIX |
---|---|
Label | x-component of initial velocity |
Symbol | vxi |
Units | m/s |
Equation | $$ |
{{v_{x}}^{i}}={v^{i}} \cos\left(θ\right)
$$|
|Description|vxi is the x-component of initial velocity (m/s)
vi is the initial speed (m/s)
θ is the launch angle (rad)</li>|
|Notes|vi is from DD: vecMag.
θ is shown in Fig:Launch.|
|Source|--|
|RefBy|IM: calOfLandingDist|
Refname | DD:speedIY |
---|---|
Label | y-component of initial velocity |
Symbol | vyi |
Units | m/s |
Equation | $$ |
{{v_{y}}^{i}}={v^{i}} \sin\left(θ\right)
$$|
|Description|vyi is the y-component of initial velocity (m/s)
vi is the initial speed (m/s)
θ is the launch angle (rad)|
|Notes|vi is from DD: vecMag.
θ is shown in Fig:Launch.|
|Source|--|
|RefBy|IM: calOfLandingTime|
This section transforms the problem defined in Section: Problem Description into one which is expressed in mathematical terms. It uses concrete symbols defined in Section: Data Definitions to replace the abstract symbols in the models identified in Section: Theoretical Models and Section: General Definitions.
Refname | IM:calOfLandingTime |
---|---|
Label | Calculation of landing time |
Input | vlaunch, θ |
Output | tflight |
Input Constraints | $${v_{launch}}>0$$ $$0<θ<\frac{π}{2}$$ |
Output Constraints | $${t_{flight}}>0$$ |
Equation | $$ |
{t{flight}}=\frac{2 {v{launch}} \sin\left(θ\right)}{g} $$| |<b>Description</b>|<em>t<sub>flight</sub></em> is the flight duration (s) <br> <em>v<sub>launch</sub></em> is the launch speed (m/s) <br> <em>θ</em> is the launch angle (rad) <br> <em>g</em> is the gravitational acceleration (m/s<sup>2</sup>)| |<b>Notes</b>|The constraint $0<θ<\frac{π}{2}$ is from <a href=#posXDirection>A: posXDirection</a> and <a href=#yAxisGravity>A: yAxisGravity</a>, and is shown in <a href=#Figure:Launch>Fig:Launch</a>. <br> <em>g</em> is defined in <a href=#Sec:AuxConstants>Section: Values of Auxiliary Constants</a>. <br> The constraint ${t_{flight}}>0$ is from A: timeStartZero.| |Source|--| |RefBy|IM: calOfLandingDist and FR: Calculate-Values|
We know that pyi = 0 (A: launchOrigin) and ayc = −g (A: accelYGravity). Substituting these values into the y-direction of GD: posVec gives us:
To find the time that the projectile lands, we want to find the t value (tflight) where py = 0 (since the target is on the x-axis from A: targetXAxis). From the equation above we get:
Dividing by tflight (with the constraint tflight > 0) gives us:
Solving for tflight gives us:
From DD: speedIY (with vi = vlaunch) we can replace vyi:
Refname | IM:calOfLandingDist |
---|---|
Label | Calculation of landing position |
Input | ${v_{launch}}$, $θ$ |
Output | ${p_{land}}$ |
Input Constraints | $${v_{launch}}>0$$ $$0<θ<\frac{π}{2}$$ |
Output Constraints | $${p_{land}}>0$$ |
Equation | $$ |
{p{land}}=\frac{2 {v{launch}}^{2} \sin\left(θ\right) \cos\left(θ\right)}{g} $$| |<b>Description</b>|<em>p<sub>land</sub></em> is the landing position (m) </br> <em>v<sub>launch</sub></em> is the launch speed (m/s) <br> <em>θ</em> is the launch angle (rad) <br> <em>g</em> is the gravitational acceleration (m/s<sup>2</sup>)| |<b>Notes</b>|The constraint $0<θ<\frac{π}{2}$ is from <a href=#posXDirection>A: posXDirection</a> and <a href=#yAxisGravity>A: yAxisGravity</a>, and is shown in <a href=#Figure:Launch>Fig:Launch</a>. <br> <em>g</em> is defined in <a href=#Sec:AuxConstants>Section: Values of Auxiliary Constants</a>. <br> The constraint ${p_{land}}>0$ is from A: posXDirection.| |Source|--| |RefBy|IM: offsetIM and FR: Calculate-Values|
We know that pxi = 0 (A: launchOrigin) and axc = 0 (A: accelXZero). Substituting these values into the x-direction of GD: posVec gives us:
To find the landing position, we want to find the px value (pland) at flight duration (from IM: calOfLandingTime):
From DD: speedIX (with vi = vlaunch) we can replace vxi:
Rearranging this gives us the required equation:
Refname | IM:offsetIM |
---|---|
Label | Offset |
Input | ${p_{land}}$, ${p_{target}}$ |
Output | ${d_{offset}}$ |
Input Constraints | $${p_{land}}>0$$ $${p_{target}}>0$$ |
Output Constraints | |
Equation | $$ |
{d{offset}}={p{land}}-{p_{target}}
$$|
|Description|doffset is the distance between the target position and the landing position (m)
pland is the landing position (m)
ptarget is the target position (m)|
|Notes|pland is from IM: calOfLandingDist.
The constraints pland > 0 and ptarget > 0 are from A: posXDirection.|
|Source|--|
|RefBy|FR: Output-Values, IM: messageIM, and FR: Calculate-Values|
Refname | IM:messageIM |
---|---|
Label | Output message |
Input | ${d_{offset}}$, ${p_{target}}$ |
Output | $s$ |
Input Constraints | $${p_{target}}>0$$ $${d_{offset}}>-{p_{land}}$$ |
Output Constraints | |
Equation | $$ |
s=\begin{cases}
\text{"The target was hit."}, & |\frac{{d_{offset}}}{{p_{target}}}|<ε\\
\text{"The projectile fell short."}, & {d_{offset}}<0\\
\text{"The projectile went long."}, & {d_{offset}}>0
\end{cases}
$$|
|Description|s is the output message as a string (Unitless)
doffset is the distance between the target position and the landing position (m)
ptarget is the target position (m)
ε is the hit tolerance (Unitless)|
|Notes|doffset is from IM: offsetIM.
The constraint ptarget > 0 is from A: posXDirection.
The constraint doffset > −pland is from the fact that pland > 0, from A: posXDirection.
ε is defined in Section: Values of Auxiliary Constants.|
|Source|--|
|RefBy|FR: Output-Values and FR: Calculate-Values|
Table:InDataConstraints shows the data constraints on the input variables. The column for physical constraints gives the physical limitations on the range of values that can be taken by the variable. The uncertainty column provides an estimate of the confidence with which the physical quantities can be measured. This information would be part of the input if one were performing an uncertainty quantification exercise. The constraints are conservative, to give the user of the model the flexibility to experiment with unusual situations. The column of typical values is intended to provide a feel for a common scenario.
Var | Physical Constraints | Typical Value | Uncert. |
---|---|---|---|
${p_{target}}$ | ${p_{target}}>0$ | $1000$ m | 10$\%$ |
${v_{launch}}$ | ${v_{launch}}>0$ | $100$ $\frac{\text{m}}{\text{s}}$ | 10$\%$ |
$θ$ | $0<θ<\frac{π}{2}$ | $\frac{π}{4}$ rad | 10$\%$ |
Table:OutDataConstraints shows the data constraints on the output variables. The column for physical constraints gives the physical limitations on the range of values that can be taken by the variable.
Var | Physical Constraints |
---|---|
${p_{land}}$ | ${p_{land}}>0$ |
${d_{offset}}$ | ${d_{offset}}>-{p_{land}}$ |
This section provides the functional requirements, the tasks and behaviours that the software is expected to complete, and the non-functional requirements, the qualities that the software is expected to exhibit.
This section provides the functional requirements, the tasks and behaviours that the software is expected to complete.
Symbol | Description | Units |
---|---|---|
ptarget | Target position | m |
vlaunch | Launch speed | m/s |
θ | Launch angle | rad |
This section provides the non-functional requirements, the qualities that the software is expected to exhibit.
The purpose of the traceability matrices is to provide easy references on what has to be additionally modified if a certain component is changed. Every time a component is changed, the items in the column of that component that are marked with an "X" should be modified as well. Table:TraceMatAvsAll shows the dependencies of data definitions, theoretical models, general definitions, instance models, requirements, likely changes, and unlikely changes on the assumptions. Table:TraceMatRefvsRef shows the dependencies of data definitions, theoretical models, general definitions, and instance models with each other. Table:TraceMatAllvsR shows the dependencies of requirements, goal statements on the data definitions, theoretical models, general definitions, and instance models.
This section contains the standard values that are used for calculations in Projectile.
Symbol | Description | Value | Unit |
---|---|---|---|
g | gravitational acceleration | 9.8 | m/s2 |
ε | hit tolerance | 2.0% | -- |
π | ratio of circumference to diameter for any circle | 3.14159265 | -- |
In [59]:
from __future__ import print_function
import sys
import math
In [60]:
class InputParameters:
None
In [61]:
## \brief Reads input from a file with the given file name
# \param filename No description given
# \param inParams No description given
def get_input(filename, inParams):
infile = open(filename, "r")
infile.readline()
inParams.v_launch = float(infile.readline())
infile.readline()
inParams.angle = float(infile.readline())
infile.readline()
inParams.p_target = float(infile.readline())
infile.close()
In [62]:
## \brief Writes the output values to output.txt
# \param s output message as a string
# \param d_offset distance between the target position and the landing position
def write_output(s, d_offset):
outputfile = open("output.txt", "w")
print("s = ", end='', file=outputfile)
print(s, file=outputfile)
print("d_offset = ", end='', file=outputfile)
print(d_offset, file=outputfile)
outputfile.close()
In [63]:
## \brief Calculates flight duration
# \param inParams No description given
def func_t_flight(inParams):
return ((2 * (inParams.v_launch * math.sin(inParams.angle))) / 9.8)
## \brief Calculates landing position
# \param inParams No description given
def func_p_land(inParams):
return ((2 * ((inParams.v_launch ** 2) * (math.sin(inParams.angle) * math.cos(inParams.angle)))) / 9.8)
## \brief Calculates distance between the target position and the landing position
# \param inParams No description given
# \param p_land landing position
def func_d_offset(inParams, p_land):
return (p_land - inParams.p_target)
## \brief Calculates output message as a string
# \param inParams No description given
# \param d_offset distance between the target position and the landing position
def func_s(inParams, d_offset):
if ((math.fabs((d_offset / inParams.p_target)) < 2.0e-2)) :
return "The target was hit."
elif ((d_offset < 0)) :
return "The projectile fell short."
elif ((d_offset > 0)) :
return "The projectile went long."
else :
raise Exception("Undefined case encountered in function func_s")
In [64]:
## \brief Verifies that input values satisfy the physical constraints and software constraints
# \param inParams No description given
def input_constraints(inParams):
if (not((inParams.v_launch > 0))) :
print("Warning: constraint violated")
if (not(((0 < inParams.angle) and (inParams.angle < (3.14159265 / 2))))) :
print("Warning: constraint violated")
if (not((inParams.p_target > 0))) :
print("Warning: constraint violated")
In [65]:
#main
def main():
filename = "input.txt"
inParams = InputParameters()
get_input(filename, inParams)
input_constraints(inParams)
t_flight = func_t_flight(inParams)
p_land = func_p_land(inParams)
d_offset = func_d_offset(inParams, p_land)
s = func_s(inParams, d_offset)
write_output(s, d_offset)
print("s = ", s)
print("d_offset = ", d_offset)
In [66]:
main()
In [ ]: