function [ d_x, d_y ] = ProjectileMotion_fn( v_0, theta )
%ProjectileMotion Calculates and plots (x,y) positions for a projectile
%   INPUTS v_0 (initial velocity in m/s), theta (angle of v_0 in degrees)
%   OUTPUTS X (vector of x positions), Y (vector of y positions)

t=0:0.01:100; % time range for calculation

v_0x = v_0*cosd(theta); % calculating x component of initial velocity
a_x = 0;                % setting x component of acceleration

d_x = v_0x.*t + 0.5*a_x.*t.^2;    % calculating x positions

v_0y = v_0*sind(theta); % calculating y component of initial velecotiy
a_y = -9.8;             % setting y component of acceleration in m/s^2

d_y = v_0y.*t + 0.5*a_y.*t.^2;    % calculating y positions

% Zeroing points with negative y positions
 d_x(d_y<0)=0;
 d_y(d_y<0)=0;

% Plotting final results
plot(d_x,d_y)
    xlabel('X position (m)')
    ylabel('Y position (m)')

end

