Projectile not going downwards on negative angle
<p>I'm building a small Physics engine that fires a projectile on a set of launch parameters by the user (angle, height, time interval and initial velocity), then displays some information such as the total distance or angle at every time interval that it's in the air: </p>

<pre><code>bool heightCheck = false;
double theta;
double initialVelocity, velocity;
double yNew = 0.0, xNew, xOld = 0.0, yOld = 0.0;
const double time = 0.1;
const double gravitiyHalf = 9.8 / 2;
double velocityX = 0.0, velocityY = 0.0;
double angle = 0.0;
double totalT = 0;
double maxHeight = 0.0;
double thetaDegrees = 0;
#define PI 3.14159265l  // constant for PI

cout &lt;&lt; "Insert a lanuch Angle (theta): ";  
cin &gt;&gt; thetaDegrees;    
cout &lt;&lt; "Insert a launch height: ";     
cin &gt;&gt; yOld;            
cout &lt;&lt; "Insert an initial velocity: ";     
cin &gt;&gt; initialVelocity;     
cout &lt;&lt; "Time (DeltaT) in seconds: ";   
cin &gt;&gt; totalT;

for (double deltaTime = 0.0; deltaTime &lt; totalT; deltaTime += 0.1) {

    const double squared = deltaTime * deltaTime;       // squared constant for deltaTime squared

    theta = thetaDegrees * PI / 180;    // converts theta to a degrees value

    velocityX = initialVelocity * cos(theta);   // calculates Vx
    velocityY = initialVelocity * sin(theta);   // calculates Vy

    // apply initialV to velocity
    velocity = initialVelocity + 9.8 * time;

    xNew = xOld + velocity * time;  // works out displacement for X

    yNew = yOld + velocity * deltaTime - gravitiyHalf / 0.5 * (squared);    // calculates Y

    velocityY = velocity - 9.8 * deltaTime; // includes gravity to Y

    angle = atan2(yNew, xNew) * 180 / PI;   // convert angle to degrees

    cout &lt;&lt; "\nHeight: " &lt;&lt; yNew &lt;&lt; endl;
    cout &lt;&lt; "Distance in Meters: " &lt;&lt; xNew &lt;&lt; "m" &lt;&lt; endl;
    cout &lt;&lt; "Angle: " &lt;&lt; angle &lt;&lt; endl;
    cout &lt;&lt; "Time: " &lt;&lt; deltaTime &lt;&lt; "s " &lt;&lt; endl;

    if (heightCheck == false) {
        maxHeight = yOld;
        // keep maxheight equal to previous height
    }

    if (yNew &lt; yOld &amp;&amp; heightCheck == false) {
        heightCheck = true;
        // if projectile is going down, trigger maxheight
    }

    cout &lt;&lt; "Maximum height:  " &lt;&lt; maxHeight &lt;&lt; endl;

    if ((yNew &lt; 0) || (deltaTime == totalT)) {
        getchar();      // stops if delta t = total T or projectile landed
    }

    yOld = yNew;    // refresh x &amp; y
    xOld = xNew;
}
</code></pre>

<p>If I enter the following values at the start of my program:</p>

<p><em>theteDegrees = 45</em></p>

<p><em>yOld = 0</em></p>

<p><em>initialVelocity = 20</em></p>

<p><em>totalT = 10</em></p>

<p>My program displays the expected results that show my projectile going up, then down. However, if I enter the same values expect <strong>-40 for thetaDegrees</strong>, my projectile <strong>should head straight down</strong>, instead <strong>it just goes up and then down again</strong>.</p>

<p>Where have I gone wrong in my code?</p>