function [y, slope] = groundHeight(x)
%
% This function returns the height (y) and slope (Dy) of the ground as a
% function of the horizontal position. An interesting ground profile is
% generated by summing three sine waves. This also makes the derivative
% (slope) easy to compute.
%

%Parameters for each of the three sine ewaves:
    Amp1 = 0.3;
    Freq1 = 1;
    Phase1 = 1.58;

    Amp2 = 0.1;
    Freq2 = 6;
    Phase2 = 1.9;

    Amp3 = 0.2;
    Freq3 = 3.7;
    Phase3 = 1.58;

%Compute the ground height
y = Amp1*sin(Freq1*x+Phase1)+...
    Amp2*sin(Freq2*x+Phase2)+...
    Amp3*sin(Freq3*x+Phase3);

%Compute the ground slope
slope = Amp1*Freq1*cos(Freq1*x+Phase1)+...
        Amp2*Freq2*cos(Freq2*x+Phase2)+...
        Amp3*Freq3*cos(Freq3*x+Phase3);

end