Lecture 4 Visualization and Animation
Transcript of Lecture 4 Visualization and Animation
Simple examples
Animate the following:
A freely moving particle bounded to a finite
line: 1D motion
A freely moving particle bounded to a square
box: 2D motion
A freely moving particle bounded to a square
rectangular box: 3D motion
๐ freely moving particle bounded to a square
rectangular box: 3D motion
Parametric equations
Given a set of parametric equation describing the motion of a particle in space as a function of time,
๐ฅ = ๐ ๐ก , ๐ฆ = ๐ ๐ก
one can easily visualize the motion using the command ๐๐๐ง๐ข๐ฉ๐ฎ๐ฅ๐๐ญ๐
To this end you may have to also invoke a For
loop for generating the time-dependent
coordinate variables before visualizing them.
๐๐๐ซ๐๐ฆ๐๐ญ๐ซ๐ข๐๐๐ฅ๐จ๐ญ[] is another useful command
for this purpose.
4
Examples of parametric equations
SHO๐ ๐ก = ๐0 sin(๐๐ก + ๐) ;
๐ฅ = ๐ฟ sin(๐(๐ก)) , ๐ฆ = ๐ฟ โ ๐ฟ cos(๐(๐ก))
O
+๐ฅ
๐ =๐
๐
+๐ฆ
Derivation of the equation of motion for SHO
Equation of motion (EoM)
Force on the pendulum
2; Tl
g
for small oscillation,
๐น๐ = ๐๐๐
โ๐๐ sin ๐=๐๐๐ฃ๐
๐๐ก= ๐
๐
๐๐ก
๐๐
๐๐กโ ๐
๐2
๐๐ก2๐๐
๐2๐
๐๐ก2โ โ
๐๐
๐= โ๐2๐
๐ ๐ก = ๐0 sin(๐๐ก + ๐)
r
l
Examples of parametric equations:
2D projectile motion The trajectory of a 2D projectile with initial
location (๐ฅ0, ๐ฆ0), speed ๐ฃ0 and launching
angle ๐ are given by the equations:
๐ฅ ๐ก = ๐ฅ0 + ๐ฃ0๐ก cos ๐;
๐ฆ ๐ก = ๐ฆ0 + ๐ฃ0๐ก sin ๐ +๐
2๐ก2
for t from 0 till T, defined as the time of flight,
T =-2(๐ฆ0 + ๐ฃ0 sin ๐)/๐.
๐ = โ9.81;
Consider a planet orbiting the Sun which islocated at one of the foci of the ellipse.
The coordinates of the planet at time t can be expressed in parametrised form:
๐ฅ(๐ก) = โ + ๐cos(๐0๐ก), ๐ฆ ๐ก = ๐ + ๐sin ๐0๐ก
Examples of parametric equations:
2-body Planetary motion
C(h,k)
ba
Assignments
By using the corresponding parametric
equations for the (๐ฅ, ๐ฆ) coordinates,
1. Animate a SHO (w/o drag force and driving
force)
2. Animate 2D projectile motion (w/o drag force
and driving force)
3. Animate 2-body planetary motion
1D sinusoidal wave A sinusoidal wave is fundamentally
characterized by two quantities: wave number (equivalent to wave length) and angular frequency (frequency)
๐๐ฅ, ๐ or ๐, ๐ .
Wave number ๐๐ฅ =2๐
๐; ๐ wave length
Angular frequency ๐ = 2๐๐; ๐ frequency
14
1D sinusoidal wave ๐ ๐ฅ, ๐ก = ๐ด sin ๐(๐ฅ, ๐ก) ;
๐ ๐ฅ, ๐ก = ๐๐ฅ๐ฅ โ ๐๐ก + ๐
Phase velocity of the wave can be obtained by
imposing the condition:๐๐(๐ฅ, ๐ก)
๐๐ก= 0
โ ๐๐ฅ๐๐ฅ
๐๐กโ ๐ = 0
โ ๐ฃ๐ฅ =๐๐ฅ
๐๐ก=
๐
๐๐ฅ= ๐๐
๐ฃ๐ฅ =๐
๐๐ฅimplies the wave is moving to the +๐ฅ
direction. 15
1D sinusoidal wave
If ๐ ๐ฅ, ๐ก = ๐ด sin ๐(๐ฅ, ๐ก) , with
๐ ๐ฅ, ๐ก = ๐๐ฅ๐ฅ + ๐๐ก + ๐,
โ ๐ฃ๐ฅ = โ๐
๐๐ฅ
This wave is moving to the -๐ฅ direction.
16
Adding two 1D sinusoidal waves
Same amplitude, same frequency; To ignore all phases ๐(by setting ๐ = 0).
Same / opposite directions
Same / different wavenumbers
Same / different angular frequencies
๐0 ๐ฅ, ๐ก = ๐ด sin ๐0(๐ฅ, ๐ก) ; ๐1 ๐ฅ = ๐ด sin ๐1(๐ฅ, ๐ก) ;
๐0 ๐ฅ, ๐ก = ๐๐ฅ,0๐ฅ ยฑ ๐0๐ก;
๐1 ๐ฅ, ๐ก = ๐๐ฅ,1๐ฅ ยฑ ๐1๐ก= (๐๐ฅ,0+ฮ๐๐ฅ,1)๐ฅ ยฑ (๐0 + ฮ๐1)๐ก
ฮ๐๐ฅ,๐ = ๐๐ฅ,๐ โ ๐๐ฅ,๐โ1; ๐๐ฅ,๐ = ๐๐ฅ,0 + ๐ฮ๐๐ฅ,๐
ฮ๐๐ = ๐๐ โ๐๐โ1; ๐๐ = ๐0 + ๐ฮ๐๐;
Usually, ฮ๐๐= ฮ๐, ฮ๐๐ฅ,๐= ฮ๐๐ฅ.18
Animation exercises1. Based on the simple equation of a 1D sinusoidal wave:
i. Animate two 1D waves, one in the +๐ฅ and another in -๐ฅ. Display both on the same graph, without interfering each other.
ii. Repeat 1 with both in the same directioniii. Repeat 1 with both waves are added to interfereiv. Repeat 2 with both waves are added to interfere
Two sinusoidal waves, moving in the same direction,
without interference, with a difference in wavenumber
and angular frequency of 5ฮ๐ and 5ฮ๐; ๐0 = 1;๐0 = 1;ฮ๐=ฮ๐ = 1/50;
20
Superposition of two sinusoidal waves, moving in the
same direction, with a difference in wavenumber and
angular frequency of 5ฮ๐ and 5ฮ๐; ๐0 = 1;๐0 = 1;ฮ๐=ฮ๐ = 1/50;
21
Superpositioning ๐ 1D sinusoidal waves
Simulate the motion of the resultant wave form obtained from the superposition of ๐ waves with the following conditions:
All waves have the same amplitude ๐ด and moving in the same direction; Ignore all phases ๐ (set all ๐ = 0);
Each wave has a different wavenumber and angular frequency:
๐๐ ๐ฅ = ๐ด sin ๐๐(๐ฅ, ๐ก) ;
๐๐ ๐ฅ, ๐ก = ๐๐ฅ,๐๐ฅ ยฑ ๐๐ก;
๐๐ฅ,๐ = ๐๐ฅ,0 + ๐ฮ๐๐ฅ,๐; ๐๐ = ๐0 + ๐ฮ๐๐;
Fix initial values: ๐ด = 1,๐0 = 1, ๐๐ฅ,0 = 1, ๐ = 25, ฮ๐๐ฅ =1
75, ฮ๐ =
1
75.
Simulate for a total duration of 500 ๐ ๐ =2๐
๐0; Width of the
simulation box set to [โ100๐0 , +100๐0 ]
22
Animation exercises1. Animate an outgoing 2D sinusoidal wave
2. Animate two outgoing 2D sinusoidal waves from two different origins that display interference.