Write an application that draws a graph of the sine of x as x ranges from 0 to 2π radians. Plot 100 points at equally spaced values of x. Connect the points with straight lines. You need to...


Write an application that draws a graph of the sine of x as x ranges from 0 to 2π radians. Plot 100 points at equally spaced values of x. Connect the points with straight lines.


You need to differentiate between the real value of x at which you evaluate the sine function and the x-coordinate that you will use for the plot. Remember that we really have two coordinate systems. One system has its origin at the intersection of the x- and y-axes that you will draw, while the other is the graphical system with its origin at the upper left corner of the window. To distinguish between the two systems, we will call the coordinates in the graphical system “left” and “top” instead of x and y.


For example, you would evaluate the sine of x at intervals of (xmax – xmin) / n, where n is the number of


points. But if n is 100 and the x-axis is 100 pixels long, for instance, the distance between adjacent left coordinates is 1 pixel. Similarly, you need to scale the y values to fit the y axis by computing


yAxisLength x y / (ymax – ymin)


and truncating the result to an integer. You subtract the result from the top coordinate of the x-axis to get the top coordinate of the point to be plotted.



May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here