In this chapter we will examine what happens when two sine waves of the same frequency and amplitude move through each other. The gif below illustrates the result with a green wave moving right and a blue wave moving left. If two crests on the waves line up with each other, constructive interference occurs and the resulting amplitude is doubled. If a crest and a trough line up then destructive interference occurs and the resulting amplitude will be zero. The resulting red wave is called a standing wave.
INPUTS:
A user can select a frequency from a dropdown of 1-10 Hz.
A button can be clicked to start the waves moving.
OUTPUTS:
Graphical output of a wave moving right, a wave moving left and the resulting standing wave.
CRITERIA & CONSTRAINTS:
Clicking the button will move the waves.
Your program should have an impressive interface. (colors and graphics)
Start by copying your Beats code
Set a data validation drop down menu of 1-10 for frequency.
Create two Phase variables (P1 and P2), set it them to 90 and 270 respectively and add them to the spreadsheet. I added them to cells P5 and P6.
Create a while loop that runs while the Phase P2 angle is less than 630.
In the while loop get the Phase angle (P1) from the spreadsheet, subtract 10 from it and put it back on the spreadsheet.
In the while loop get the Phase angle (P2) from the spreadsheet, add 10 to it and put it back on the spreadsheet.
After the while loop set the Phase angles back to 90 and 270.
We will just go ahead and add data directly on the graph.
Since we are using a scatter plot we need a lot of data points so it looks more like a smooth curve. We will go through one cycle of a sine wave or 360˚. In cell P1 create a time interval by entering =1/360
In cells Q1, R1, S1 and T1 enter headers t, f1, f2 and f1+f2 respectively.
In column Q, starting in cell Q2, enter 0 but then increment down the column by the time interval in cell $P$1. Drag this down 360 rows.
In column R, we will enter the wave function equation. The amplitude A will just be 1. The phase angle needs to be converted to radians. The only variable that changes in this formula is time so make sure all other variables are grabbing the same thing each time. This formula should grab the frequency and the phase angle (P1). Drag this equation down 360 rows.
In column S, we will do the same thing but this formula should grab the frequency and the phase angle (P2). Drag this equation down 360 rows.
In column T, simply add columns R and S. Drag this equation down 360 rows.
In the Chart, make a smooth line graph with x-axis from Q2:Q362, Series 1 from R2:R362, Series 2 from S2:S362, and Series 3 from T2:T362. Use column Q as labels and make sure each wave is a different color.