You are on page 1of 10

Final Project

Math16-1L / A3

Submitted by:

Dela Torre, John Ivan


Rafal, Samantha Mae
Riogelon, Joshua
Submitted to:

Mr. Dan Andrew Magcuyao

March 18, 2015

a) Title:
PROJECTILE CALCULATOR
b) Topic:
Trigonometric Identities
c) Significance:
This project will be a significant help in calculating where the maximum height and range
of a thrown object or a projectile, as well as its time of flight. This project could be also
beneficial for students in their physics subject, specifically Phy10, when they are solving
projectile motion related problems. Moreover, this project will provide outcomes of given
values using the same algorithm, avoiding human errors in between.
d) Applications:
Basic problems regarding projectile motion like throwing a ball and calculating how far
it can go or how high it can be or a motorcycle stunt person travels at a certain speed
and jumps off a ramp at a certain angle to the horizontal are where the projects function
may be applicable.
e) Source Code:
//clean the slate
clear;
clc;
disp("Final Project for Math16L")
disp("Trajectory Calculator")
disp("Welcome!! This program calculates the maximum range, maximum height, and the
time of flight of any object thrown, given that the initial velocity and the angle is input.")
disp("This program can be used by students for checking their solutions for their physics
subjects, or anyone else to predict where something will land.")
// This part asks for the necessary inputs like the initial velocity and angle from the user
r = 1; //r as in repeater. This integer controls our looping statements
while r == 1 do
disp("What is the angle in degrees of the projectile when it was launched? It should be
greater than or equal to 0 and less than or equal to 90 degrees")
angle = input("");
if angle > 90 | angle<0 then
disp("Wrong Input. Please try again.")
r=1

else
r=0
end
end
while r == 0 do
disp(" Is the initial velocity of the projectile known? Enter 0 if yes, 1 if no")
q = input("")
if q == 0
v = input("Please enter initial velocity in meters per second: ")
r=1
elseif q == 1
disp("Please do a test fire at 0 degrees. At what height in meters was it launched?")
h = input("")
disp("How far did the projectile go?")
l = input("")
//The following two equations calculate for the time then velocity respectively. The
9.8 is taken from the gravitational constant of the earth
t = sqrt(h / 9.8) //This one calculates time
v=l/t
//This one the velocity
disp("Your initial velocity in meters per second is ")
disp(v)
r=1
else
disp("Wrong Input, please try again.")
r = 0;
end
end
while r == 1 do //recycling again
disp("Is the launcher on a raised platform? If yes, enter 0, if not type 1")
q = input("")
if q == 0
disp("Please input the height in meters of the launcher.")
height = input("")
r=0
elseif q == 1
height = 0
r = 0;
else
disp("Wrong Input, please try again.")
r=1
end
end
disp("All required inputs are in order.Type resume to continue")
pause;//for effect

//lol Atlantis:The Lost Empire reference


disp("Calculating for maximum range and height")
t = (sqrt(2)*v) / 9.8 //formula for the time of flight of the projectile
mr = v*cosd(angle) * t //formula for the range
mh = v*t*sind(angle) - .5* 9.8* (t/2).^2 //formula for the max height
disp("Wanna see me do it again? loljk")
disp(" Type resume to continue to the resuslts.")
pause;
disp("The time of flight is ")
disp(t)
disp("The maximum range in meters is ")
disp(mr)
disp("The maximum height in meters reached is ")
disp(mh)
while r == 0
disp("Commence graph of trajectory of projectile? Type 0 for graph of height versus
time, 1 for height versus range, 2 for range versus time, 3 to cancel graphing")
q = input("")
if q == 0 then //height versus time
clf;
e = 0:.01:t
xlabel("Time","fontsize",4)
ylabel("Height","fontsize",4)
comet(e, v*e*sind(angle) - .5* 9.8* (e).^2)
elseif q == 1 //height versus range
clf;
e = 0:.01:t
xlabel("Range","fontsize",4)
ylabel("Height","fontsize",4)
comet(v*cosd(angle) * e, v*e*sind(angle) - .5* 9.8* (e).^2)
elseif q == 2//range versus time
clf;
e = 0:.01:t
xlabel("Time","fontsize",4)
ylabel("Range","fontsize",4)
comet(e, v*cosd(angle) * e)
elseif q == 3
disp("Graphing Canceled")

r=0
else
disp("Wrong input")
r=0
end
disp("Want to graph another one? Input 0 for yes, 1 for no")
r = input("")
end
f) Scope and Limitations:
This project mainly computes for the maximum possible height and range of a projectile,
as well as its time of flight, given the angle it was launched from and its velocityneglecting air resistance. If the velocity cannot be provided, an alternative is provided.
The alternative would require conducting a small test- launching the projectile
horizontally, taking the height it was launched from and how far it went, and the project
would calculate the velocity from that alternative.
g) Screen Shots:

Figure 1: Code Line 1-Line 34

Figure 2: Code Line 29-Line62

Figure 3: Code Line 61- Line34

Figure 4: Code Line 86 Line 119

Figure 5: Console Part1

Figure 6: Console Part2

Figure 7: Console Part3

Figure 8: Sample Graph

h) Manual Solutions:
Given: Angle = 45
(Initial velocity is unknown)
Height of the launcher = 0.1 meters
Length of the drop of projectile = 0.1 meters

For the initial velocity:

t=

0.1 m
9.8 meters per secon d 2

t=0.1010152545
v=

0.1 m
0.1010152545 s

v =0.9899494937 m/ s
Time of flight

t=

2 v
9.8 meters per second

t=

2 0.98995
9.8 meters per second

t=0.1428572159
Max Range

x=v cos 45 0.1428572159 s

x=0.1 m
Max Height Reached

1 t
y=v t sin angle g
2 2

()

1
0.143
y=0.99 0.143 sin 45 ( 9.8 )
2
2

y=0.075 m

You might also like