title: Plotting Trajectory Graph in C with Arrays
body: <p>First time posting a question - let's hope I build a good reputation!
  The title pretty much describes the nature of my assignment: </p>
  
  <blockquote>
    <p>After a user enters the Initial Speed and Launch Angle for a projectile, my program has to generate points and plot a graph of the projectile's trajectory. For this I must use two 2D arrays - one for the points generated and the other as a canvas (basically an 40x80 empty array filled with spaces). </p>
  </blockquote>
  
  <p>I was given the prototypes for the functions that I must use, so here is the relevant code I've come up with (it is quite lengthy, but only for completeness' sake. The actual questions can be found in the 3rd and 4th functions):</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;math.h&gt;
  #include "Assignment6B.h"
  
  int Sx = 0;
  int Sy = 0;
  void calcTraj(double initSpeed, double launchAngle, double trajData[][2]) {
      do {
          double Ux = initSpeed*cos(launchAngle*3.14/180.0);
          double Uy = initSpeed*sin(launchAngle*3.14/180.0);
          Sy = (Sx/Ux)*(Uy - ((9.81*Sx)/(2*Ux)));
          if (Sy &gt;= ZERO) {
              trajData[Sx][0] = Sx;
              trajData[Sx][1] = Sy;
          }
          Sx++;
      } while (Sy &gt;= ZERO);
  }
  
  int Row, Column;
  void clearDisplayData(char displayData[HEIGHT][WIDTH]) {
      for (Row = 0; Row &lt; HEIGHT; Row++) {
          for (Column = 0; Column &lt; WIDTH; Column++) {
              displayData[Row][Column] = ' ';
          }
      }
  }
  
  void updateDisplayData(char displayData[HEIGHT][WIDTH], double trajData[][2]) {
  </code></pre>
  
  <p>This is the part where I am stuck and quite hopelessly clueless. </p>
  
  <p>I understand the idea behind the function: It receives the "empty canvas" array as well as the array containing the data (points for the graph). So, what needs to be done now, is all the elements in <code>displayData</code> that correspond with the <code>[Sx][Sy]</code>-coordinates in <code>trajData</code>, need to be replaced with an <code>X</code>. E.g., say <code>[1][4]</code> in <code>trajData</code> has an element, then <code>displayData[1][4]</code> = <code>X</code>. </p>
  
  <p>I just have no idea how to code this. If someone could supply a sample, that would be great!</p>
  
  <pre><code>}
  
  void printData(char displayData[HEIGHT][WIDTH]) {
      puts("");
      for (Column = 0; Column &lt; WIDTH + 2; Column++) {
          printf("_");
      }
      puts("");
      for (Row = 0; Row &lt; HEIGHT; Row++) {
          printf("|");
          for (Column = 0; Column &lt; WIDTH; Column++) {
              printf("%c", displayData[Row][Column]);
          }
          printf("|");
          puts("");
      }
      for (Column = 0; Column &lt; WIDTH + 2; Column++) {
          printf("_");
      }
  </code></pre>
  
  <p>This function is also not entirely correct. I have to plot a graph, which means the point <code>[0,0]</code> has to be in the bottom-left corner. But element <code>[0][0]</code> of an array is in the top-left. </p>
  
  <p>I think that the order in which the rows are displayed should then just be reversed with a <code>for</code>-loop, e.g. <code>for (Row = HEIGHT; Row &gt; 0; Row--)</code> - right? Please advise...
  }</p>
  
  <p>If anyone notices any other problems or has any advice, please share! Everything that helps is appreciated...</p>