IKG3H2 Computer Graphics

advertisement
IKG3H2
Computer Graphics
Gnuplot for scientific computing
DR. PUTU HARRY GUNAWAN
Next
1. Visualize some mathematical
models
The waves motion
The waves motion
Waves are another type of motion being oscillations in time and space. Individual waves can
be classified in terms of a period T (don not confuse this with temperature) and a wavelength
λ (using the Greek symbol “lambda”). The wave period is the time lapse between successive
peaks of a wave, whereas the wavelength is the distance between these peaks. One could
measure the wave period with a stop watch, whereas the wavelength can be derived from
instant photographs of the wave shape.
The Sinusoidal wave form
It is convenient to use the sinusoidal function to describe waves in a mathematical
manner. This function is based on radians and a complete cycle relates to a change of
its argument by 2π (the Greek symbol “pi”), where π is about 3.1415. Accordingly,
we can express a wave travelling in the x-direction as:
𝑥 𝑡
𝐴(𝑥, 𝑡) = 𝐴0 sin 2𝜋 −
𝜆 𝑇
… … … … … … . . (3.2)
where A is a property experiencing oscillations such as sea level, 𝐴0 is the constant
wave amplitude, being half the difference between maximum and minimum values
of A, λ is wavelength, and T is wave period. This wave displays sinusoidal variations both
in time and space. Equation (3.2) describes a wave void of variation in the
y direction. Accordingly, wave fronts (crests and troughs) are parallel to each other.
A wave like this is called a plane wave.
Exercise Visualization
Let’s make code

Make a simulation of sinusoidal using:

Domain : 1000 m

Wave length: 100 m

Period: 60 s

Simulation period: 10 * Period

𝐴0 = 1 m

Time step: 200

Space step: 500
𝑥 𝑡
𝐴(𝑥, 𝑡) = 𝐴0 sin 2𝜋 −
𝜆 𝑇
10 minutes latter…
Anyone need help?
Algorithm

Start

Lambda=100; L=Lambda*10; Tperiod=60; Tfinal=10*60; N=500, Ts=200; A0=1;
PI=3.14;

dx=L/N; dt=Tfinal/Ts; t=0;

While(t<=Tfinal) do

t=t+dt

for i=0:N
x[i]=i*dx

A[i]=A0*(sin(2*pi(x[i]/Lambda – t/Tperoid)))


endFor

Plot(x,A)

endWhile

End
Superposition of waves
The superposition of two or more waves of different period and/or
wavelength can lead to various interference patterns such as a
standing wave, being a wave of virtually zero phase speed.
Interfering wave patterns travel with a certain speed, called group
speed that can be different to the phase speeds of the
contributing individual waves. Interference of storm generated
waves in the ocean can result in waves of gigantic wave heights
(wave height is twice the wave amplitude) of >20 m, known as
freak waves.
Superposition of waves
𝐴(𝑥, 𝑡) = 𝐴0
𝑥
𝑡
sin 2𝜋
−
𝜆1 𝑇1
𝑥
𝑡
+ sin 2𝜋
−
𝜆2 𝑇2
Superposition of waves
Home Work!
The student is asked to produce animations considering the following interference scenarios. In all
scenarios, wave 1 has a period of T1 = 60 s andma wavelength of λ1 = 100 m. Choose period and
wavelength of wave 2 from the following list:
1.
2.
3.
4.
5.
6.
Scenario 1: wavelength
Scenario 2: wavelength
Scenario 3: wavelength
Scenario 4: wavelength
Scenario 5: wavelength
Scenario 6: wavelength
= 100 m; wave period = 50 s
= 90 m; wave period = 60 s
= 90 m; wave period = 50 s
= 100 m; wave period = −60 s
= 50 m; wave period = −30 s
= 95 m; wave period = −30 s.
These scenarios describe a variety of interference patterns. Scenario 4, for instance, leads to a
standing wave, being the result of two identical waves travelling in opposite directions. This is
achieved by prescribing a negative value of the wave period for wave 2. Is this surprising how
many different interference patterns can be created by superposition of just two waves. The
student is encouraged to experiment with other scenarios!
Note: Setiap mahasiswa diharapkan dapat membuat scenario sendiri untuk wave 2 selain 6
scenario diatas!
Next
1. Visualize 3D waves model
Thank you
Download