Instructions
Create two arrays to store the X and Y co-ordinate data for a moving object, using the declare statement "DIM x(n), DIM y(n)" where n refers to the number of data points needed to make a full set of data. To demonstrate a clear deflection angle, the minimum size a set should be is 10 data values.
Input the co-ordinate data into the arrays using the assignment (=) operator, in the form "x(1) = 2.3, y(1) = 4.5, x(2) = 2.5 ..." for the entire set of data to be used. Check that the data has been entered correctly using the expression PRINT. For example, "PRINT y(1)" should return the value 4.5 to the output buffer on the screen.
Initialize two more variables -- dX, dY -- to store the rate of change between X and Y values, as well as variables dF, theta to store the gradient of the curve and the angle calculated from the slope.
Calculate the change in differing values of X and Y using the variables dX and dY to hold the results. To calculate the change between x(1) and x(2), create a formula as follows: dX = x(2) - x(1). The formula for dY follows the same pattern, where dY = y(2) - y(1).
Calculate the gradient of the curve using the formula dF = dY / dX. The variables dY and dX must be taken over the same data points or dF will be incorrect.
Calculate the angle of deflection by taking 180 degrees minus the arc tangent of the gradient. The QBASIC syntax for this is in the form "theta = 180 - atn(dF)", where atn is the arc tangent function and theta returns a value in degrees. Repeat this process by changing the range of data used in calculating variables dX and dY to get a range of deflection angles to be used for analysis.