Lecture 14: Calculus based techniques - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

Lecture 14: Calculus based techniques

Description:

Derivative rate of change of a function. Integral area under ... acceleration value is set by driver's joystick. Euler's method can still be applied (twice) ... – PowerPoint PPT presentation

Number of Views:48
Avg rating:3.0/5.0
Slides: 31
Provided by: mikedo2
Category:

less

Transcript and Presenter's Notes

Title: Lecture 14: Calculus based techniques


1
Lecture 14Calculus based techniques
  • COMP155Computer Simulation
  • November 3, 2008

2
Basic Concepts of Calculus
  • Derivative rate of change of a function
  • Integral area under the curve of a function

3
Derivative is the slope
Image from http//en.wikipedia.org/wiki/Derivative

4
Example velocity and acceleration
  • This curve represents velocity over time.What
    does acceleration look like?

5
Acceleration is slope of velocity
  • Velocity is blue, acceleration is red

6
Example 2 Velocity
  • Velocity(t) -t2/2 10t 70

7
Example 2
  • Velocity is blue, acceleration is red

8
Example 3
  • Green curve is distance, what is velocity?

9
Example 3
  • Green is position, blue is velocity

10
Example 3
  • What is happening to green curve when blue curve
    crosses zero?

The derivative is zero when function is at a
local minimum or maximum
11
Example 3
  • Position (green), velocity (blue), acceleration
    (red)

12
Integral is the area
Image from http//en.wikipedia.org/wiki/Integral
13
Example Integration
  • Velocity is blue, acceleration is red

14
Example Integration
  • Red line is acceleration, what is velocity?

15
Integration Requires Init Values
  • Accumulated area gives shape, initial conditions
    locate shape

These are both correct velocity curves, for
given acceleration curve
16
Example 2 Integration
  • position at t0 is 100,position at t25 is
    150What is position at t50?

17
Example 2 Integration
  • position at t0 is 100,position at t25 is
    150What is position at t50?

answer 200
This area must be 50.
This area is also 50.
18
Fundamental Theorem of Calculus
  • f is a continuous real-valued function defined on
    a closed interval a, b,
  • F is an anti-derivative of f
  • F f,
  • the definite integral of f over that interval is
    given by
  • differentiation is the reverse of integration

19
Fundamental Theorem of Calculus
Whatever the shape of the velocity curve, we can
determine its area in some interval from the
position values at the ends of that
interval. green position blue velocity
20
Calculus in Simulation
  • Well commonly have a derivative of some
    function(or instantaneous values of the
    derivate)and need to construct values for the
    function
  • Example We know velocity, need to compute
    position
  • Example We know acceleration, need to compute
    velocity and position

21
Time Slicing
  • Simulation is updated at regular interval in time
  • dt time step/slice
  • To approximate integration
  • compute derivative at time steps
  • make assumption about derivative value at other
    times
  • accumulate area to approximate integration

22
Time slice approximation
  • dt 1, assume current value held for previous
    time slice

blue correct derivative functionred
approximated derivative function
over-estimate of positive area
under-estimate of positive area
under-estimate of negative area
over-estimate of negative area
23
Time slice approximation
dt 1 green correct positionred
approximated position
24
Time slice approximation
dt 1 green correct positionred
approximated position
25
Smaller dt ? better approximation
dt 1
dt 0.5
dt 0.1
dt 0.01
26
Smaller dt ? better approximation
This is similar to the limit in the definition of
a derivative The time slice is h.As it
gets smaller, we get closer to the true value
of the derivative.
dt 1
dt 0.1
27
Time slice approximation
Weve rewritten to get (actually, were
using)
dt 1
dt 0.1
28
Eulers Method
  • Taylor Seriesas dt ? 0, the higher order
    terms quickly approach 0, giving our
    approximation
  • The higher order terms are the error in the
    approximation

29
Instantaneous Derivative Values
  • In interactive simulations, we often do not have
    a function for the derivative, rather we have
    instantaneous values for the derivative
  • Example driving simulationacceleration value is
    set by drivers joystick
  • Eulers method can still be applied (twice)to
    compute velocity and position
  • assume that current value of acceleration was
    constant through previous time step

30
Example Vehicle Dynamics
  • Acceleration is set by user
  • Function updates velocity, then position

void Vehicleupdate(double elapsed_time)
double dt elapsed_time/1000.0 velocity
accelerationdt double vx velocitysin(headin
g) double vy velocitycos(heading) double
x position.getX() vxdt double y
position.getY() vydt position.moveTo(Point(x
,y))
Write a Comment
User Comments (0)
About PowerShow.com