You are on page 1of 7

Simulation and animation of two dynamic cases

Ahmadreza Eshghinejad-spring 2011


Introduction:
Most of the engineering problems deal with dynamic issues as parts of the soloutions. One of the
application of dynamic is to make us able to describe the behavior of the moving objects around
us in the form of math equations. These behaviors always can be animated for some reasons. One
of them is to validate the equations with the sense we have from our surroundings behavior.
Other reason can be to use these equations in more natural animations or games such that the
they would be more interesting for the user.
Two cases has been studied in this project. The first one is the falling motion of a ball on a sine
wave surface. This ball may rotate and this rotation is being seen by the rotation of two cross
lines on it. This ball may have contact in a time step of simulation by the surface which applies
contact forces and moment on it and effects its motion. This simulation can be extended to
simulate a pool game which has the same contact rules.
The second case is falling of a straight rod on a flat surface. In this case the contact force due to
contact of one end of the rod with the flat surface is taking place in the dynamic behaviors.
Simulation and animation of a falling ball on a sine wave surface:
Simulations and animation in this case is divided into four files which will be explained next.
Main.m :
All the required constants during the simulation such as, initial position and rotation of the ball
and its initial linear and angular velocities is defined in this mfile. The other constants are the
simulation time, time step, delay time in each step, contact elastic coefficient and the amplitude
and frequency of the contact sine surface. The other part in this mfile is the initialization of the
animation window. To this end the initial position of the ball surface points and its center cross
lines (to show the rotation of the ball) is generated. The contact surface points are also generated
based on the radius of the ball and its position in this mfile. The entire ball surface and center
line points are plotted on the animation window. Handles of these plots are set to be global
variables to make the Graficfunction able to change the plots during the simulation and in each
step. In the last line, Simulink model is called to simulate and plot it in the animation window.
The generated figure at the end of the main file is represented in the next figure.

Fall.mdl :
In the Simulink file the blocks are set as shown in the next figure. To calculate the acceleration
of the ball due to the applied forces function Calc.m is being used. By integrating these output
accelerations, animation of the calculated linear and angular positions of the ball is being done in
Graficfunction.m.



Calc.m:
This function is to find the accelerations due to forces. The contact, gravitational and frictional
forces are the forces that can be applied to the ball. At the beginning of the function contact of
the ball with the sine surface is detected. If the contact does not happen the only force is the
gravitational force and if happens the contact force is calculated. The forces in the contact
position is shown in the next figure.

The equations in the contact step are then can be found as:
0 = atan(A. . cos(. x
c
)) +
n
2

n = |cos(0) : sin (0)]
F
n

=
I
1

. n - (-cI
1

. n )
Jt
n
F
]

= . |F
n

| t

= -|F
]

|. R z
And the accelerations in this step are being defined as:
XF
x
= m. x, XF
y
= m. y , XH = I. o


Where n is the normal unit vector to the contact surface and c is coefficient of restitution the
surface. I

And Jt are the velocity vector and the time step of simulation respectively. At last all
the forces on the x and y direction are divided by the mass of the ball to return the acceleration.
GraficFunction.m:
Role of this function is to change the handles of the plots in the animation window. The ball
linear and angular positions are the inputs of the function and all the points of the ball surface
and its center lines are calculated based on the ball linear and angular position. When the handles
are changed the ball new plots will replace the old ones.

Next figure shows the animation window in the middle of simulation before(left) and after
contact(right).


Left: before contact, right: after contact

Simulation and animation of a falling rod on a flat surface:
For this case the same set of files are being used. In the main file the difference is plotting a line
instead of the ball and a flat surface instead of the sine wave surface. The animation window at
the end of the main code for theta0=pi/3 looks like the next figure.

The developed simulink model for this case is shown in the next figure.

The inputs of the RCalc.m function are x,dx,y,dy,th,dth as shown in the simulink file. To detect
happening of contact and defining that on which end of the rod contact happens x,y,th are being
used. The other parameters are being used to calculate the accelerations. For the following
problem (Next figure) when contact happens we have the following relationships [1].


Where P
n
, , c are the normal force friction and restitution coefficient respectively. I
n
, I
t
and
are the normal velocity tangential velocity and angular velocity after contact and :
n
, :
t
and are
the normal velocity tangential velocity and angular velocity before contact. By rearranging the
above equation in the matrix form we have.
|
-1 m u u
- u m u
-J
n
+ J
t
u u I
u 1 u -J
t
|
p
n
I
n
I
t
0
} =
mv
n
mv
t
I
-c(v
n
- J
t
)

And the variables after contact can be found in the next equations.

p
n
I
n
I
t
0
} = |
-1 m u u
- u m u
-J
n
+ J
t
u u I
u 1 u -J
t
|
-1

mv
n
mv
t
I
-c(v
n
- J
t
)

The accelerations in the contact step can be found as.
o
x
=
I
n
- v
n
Jt
, o
y
=
I
t
- v
t
Jt
, 0

=
0 -
Jt

Again the outputs to the graphic function x,y, th are being re plotted by getting the handle of
these plots.
Simulations of the described equations were done for different cases. In the next figures the
frame before contact and after contact is shown.
Left: before contact, right: after contact

References:
[1]- HuaShan,JianzhongSu,FlorinBadiu,JiansenZhuandLeonXu," Multiple Impact Dynamics of a
Falling Rod and Its Numerical Solution",2006,257269,Bookchapter,SpringerLink

You might also like