beginning direct3d gameprogrammingmath04_calculus_20160324_jintaeks

Post on 13-Feb-2017

43 Views

Category:

Engineering

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Beginning Direct3D Game Programming:Mathematics 4

Calculusjintaeks@gmail.com

Division of Digital Contents, DongSeo University.March 2016

Singularity In mathematics,

a singularity is in general a point at which a given mathematical object is not defined, or a point of an exceptional set where it fails to be well-behaved in some particular way, such as differentiability.

For example, f(x) is singu-lar when x≡0.

2

The function f(x) = |x| also has a singularity at x= 0, since it is not differentiable there.

3

The graph defined by y2 = x also has a singularity at (0,0), this time because it has a "corner" (vertical tan-gent) at that point.

4

Differentiation

5

f(x)=x2

Differentiation The derivative of a function of a real variable measures

the sensitivity to change of a quantity (a function value or dependent variable) which is determined by another quantity (the independent variable).

Derivatives are a fundamental tool of calculus. For example, the derivative of the position of a moving

object with respect to time is the object's velocity: this measures how quickly the position of the object changes when time is advanced.

6

The slope m of the secant line is the difference between the y values of these points divided by the difference between the x values, that is:

7

8

9

Practice Write a function that calculate the derivative of x2. For example, FPrime( float x ) returns a f'(x2). Print the tangent line at (3.0, f(3.0)).

10

Get the slope of (3,9) of y=x2

11

12

(dp is infinitely small, so)

13

Get the slope of (a,a2) of y=x2

14

15

derivative of f(y)=x2

(dp is infinitely small, so)

16

dy/dx=F'(x2)=2x

Rules for basic functionsDerivatives of powers: if

where r is any real number, then

wherever this function is defined. For example, if

then

17

Remember

18

𝑓 ′ (𝑥𝑛)=𝑛𝑥𝑛−1

Leibniz's notation The notation for derivatives introduced by 

Gottfried Leibniz is one of the earliest. It is still commonly used when the equation y = f(x) is

viewed as a functional relationship between dependent and independent variables. Then the first derivative is denoted by

Higher derivatives are expressed using the notation

for the nth derivative of y = f(x) (with respect to x).19

Lagrange's notation Sometimes referred to as prime notation, one of the

most common modern notation for differentiation is due to Joseph-Louis Lagrange and uses the prime mark, so that the derivative of a function f(x) is denoted f′(x) or simply f′.

Similarly, the second and third derivatives are denoted like below.

20

Newton's notation Newton's notation for differentiation, also called the dot

notation, places a dot over the function name to repre-sent a time derivative. If y = f(t), then below expression denote the first derivatives of y with respect to t.

The second derivatives of y with respect to t can be de-noted like this.

21

Application: Tangent vector A Tangent space is a real vector space that intuitively

contains the possible "directions" at which one can tan-gentially pass through x.

The elements of the tangent space are called tangent vectors at x.

22

23

A pictorial representation of the tangent space of a sin-gle point, x, on a sphere.

Normal mapping To calculate the Lambertian (diffuse) lighting of a sur-

face, the unit vector from the shading point to the light source(L) is dotted with the unit vector normal(N) to that surface, and the result is the intensity of the light on that surface.

• Example of a normal map (center) with the scene it was calculated from (left) and the result when applied to a flat surface (right).

24

Gradient: ∇(read as del or gradient)

In mathematics, the gradient is a generalization of the usual concept of derivative of a function in one dimen-sion to a function in several dimensions. If f(x1, ..., xn) is differentiable, scalar-valued function of standard Cartesian coordinates in Euclidean space, its gradient is the vector whose components are the n partial derivatives of f.

25

The Derivation can be extended to more higher

dimensions!

• In the above two images, the values of the function are repre-sented in black and white, black representing higher values, and its corresponding gradient is represented by blue arrows.

26

• The gradient of the function f(x,y) = −(cos2x + cos2y)2 depicted as a projected vector field on the bottom plane.

27

The gradient (or gradient vector field) of a scalar func-tion f(x1, x2, x3, ..., xn) is denoted ∇f or  where ∇ denotes the vector differential operator, del. The notation "grad(f)" is also commonly used for the gradient.

In a rectangular coordinate system, the gradient is the vector field whose components are the partial derivatives of f:

28

In the three-dimensional Cartesian coordinate system, this is given by

where i, j, k are the standard unit vectors. For example, the gradient of the function

is:

29

Integral

A definite integral of a function can be represented as the signed area of the region bounded by its graph.

30

Integral In mathematics, an integral assigns numbers to func-

tions in a way that can describe displacement, area, vol-ume, and other concepts that arise by combining infini-tesimal data.

Integration is one of the two main operations of calculus, with its inverse, differentiation, being the other.

Given a function f of a real variable x and an interval [a, b] of the real line, the definite integral

is defined informally as the signed area of the region in the xy-plane that is bounded by the graph of f, the x-axis and the vertical lines x = a and x = b.

31

∫𝑎

𝑏

𝑓 (𝑥 )𝑑𝑥

Observation A plane is the collection of infinite lines.

Similarly, a cube is the collection of infinite planes. Cavalieri's principle

32

Practice

33

Write a function that calculate the integration

Approximations to integral of √x from 0 to 1, with 5 ■  (yellow) right endpoint parti-tions and 12 ■  (green) left endpoint partitions

Remember

34

∫𝑎

𝑏

𝑥𝑛𝑑𝑥=¿ 1𝑛+1

𝑥𝑛+1 ¿][ a

b

Calculus The operation of integration is the reverse of differentia-

tion. For this reason, the term integral may also refer to the

related notion of the antiderivative, a function F whose derivative is the given function f.

In this case, it is called an indefinite integral and is writ-ten:

35

constant of integra-tion

∫❑

𝑥𝑛𝑑𝑥=¿ 1𝑛+1

𝑥𝑛+1+𝐶¿

Calculus

36

constant of integra-tion

∫❑

𝑥𝑛𝑑𝑥=¿ 1𝑛+1

𝑥𝑛+1+𝐶¿

Calculus The fundamental theorem of calculus that connects dif -

ferentiation with the definite integral: if f is a continuous real-valued function defined on a closed interval [a, b], then, once an antiderivative F of f is known, the definite integral of f over that interval is given by

37

38

F'(x2)=2x

∫❑

(2𝑥 )𝑑𝑥=¿ 𝑥2+𝐶 ¿

39

∫❑

𝑛𝑥𝑛− 1𝑑𝑥=¿ 𝑥𝑛+𝐶 ¿

𝑓 ′ (𝑥𝑛)=𝑛𝑥𝑛−1

40

𝑛𝑥𝑛− 1

𝑥𝑛 Differentiation Integration

Physics The velocity of an object is the rate of change of its 

position with respect to a frame of reference, and is a function of time.

41

• Kinematic quantities of a classical particle: mass m, position r, velocity v.

Instantaneous velocity Velocity is defined as the rate of change of position with

respect to time, which may also be referred to as the in-stantaneous velocity  to emphasize the distinction from the average velocity.

42

S(t) = S0 + v0tS=vt

S0 v0

v0t

Instantaneous velocity If we consider v as velocity and x as the displacement

(change in position) vector, then we can express the (in-stantaneous) velocity of a particle or object, at any par-ticular time t, as the derivative of the position with re-spect to time:

43

Acceleration Acceleration, in physics, is the rate of change of 

velocity of an object. An object's acceleration is the net result of any and all 

forces acting on the object, as described by Newton's Second Law.

44

v(t) = v0 + atv=at

v0 v1

a=(v1 – v0)/t

Relationship between velocity and acceleration An object's instantaneous acceleration at a point in

time is the slope of the line tangent to the curve of a v vs. t graph at that point.

In other words, acceleration is defined as the deriva-tive of velocity with respect to time:

45

Example of a velocity vs. time graph, and the relation-ship between velocity v on the y-axis, acceleration a (the three green tangent lines represent the values for acceleration at different points along the curve) and displacement s (the yellow area under the curve.)46

Distance, Velocity and Acceleration From bottom to top:• an acceleration

function a(t);• the integral of the accel-

eration is the velocity function v(t);

• and the integral of the velocity is the distance function s(t).

47

Remember

48

Newtos's second law, F=ma In classical mechanics, for a body with constant mass,

the (vector) acceleration of the body's center of mass is proportional to the net force vector (i.e. sum of all forces) acting on it (Newton's second law):

49

Uniform acceleration

Calculation of the velocity difference for a uniform ac-celeration.

50

51

Integration

Practice Write a Win32 bouncing ball program. Initial position is (100,100) and initial velocity is (10,-10). Initial acceleration is (0,0). The ball must bounced in the boundaries of client area.

52

Practice2 Add external acceleration when direction keys are press-

ing.if( ::GetAsyncKeyState( VK_LEFT ) ) { acceleration = acceleration + KVector( -100, 0, 0 ); bAccelModified = true;}//if

53

top related