1. Beginning Direct3D Game Programming:
Mathematics Primer
jintaeks@gmail.com
Division of Digital Contents, DongSeo University.
March 2016
2. 2D Rotation
Goal: We want to get the rotated point of (x,y)
about theta(θ), (x',y').
2
Assumption: We just know the four fundamental rules of
arithmetic.
3. Domain and codomain
In mathematics, the codomain or target set of a function is
the set Y into which all of the output of the function is
constrained to fall. It is the set Y in the notation y=f(x).
A function f from X to Y. The large blue oval is Y which is the
codomain of f . The smaller oval inside Y is the image of f
3
4. Exponentiation
Exponentiation is
a mathematical operation,
written as bn, involving two
numbers, the base b and
the exponent n.
When n is a positive integer,
exponentiation corresponds to
repeated multiplication of the
base: that is, bn is the product of
multiplying n bases:
4
5. Factorial
In mathematics, the factorial of a non-negative integer n,
denoted by n!, is the product of all positive integers less than
or equal to n.
5
6. Square Root
In mathematics, a square root of a number a is a
number y such that y2 = a, in other words, a
number y whose square(the result of multiplying the number
by itself, or y × y) is a.
For example, 4 and −4 are square roots of 16 because 42 =
(−4)2 = 16.
6
16 = 4
2
7. Cubic Root
A Root is a general notation for all degrees.
In case of square root, we can omit superscript 2.
7
27 = 3
3
16 = 4
2
8. Inverse function
In mathematics, an inverse
function is a function that "reverses"
another function. That is, if f is a
function mapping x to y, then the
inverse function of f maps y back to x.
8
10. Pythagoras' theorem
In mathematics, the Pythagorean theorem, also known
as Pythagoras' theorem, is a fundamental relation
in Euclidean geometry among the three sides of a right
triangle.
a2+b2=c2
10
12. a2+b2=c2
If the length of both a and b are known, then c can be
calculated as:
12
13. Summation Notation: Sigma(∑)
In mathematics, summation (symbol: ∑) is the addition of
a sequence of numbers; the result is their sum or total.
13
16. Cartesian coordinate system
A Cartesian coordinate system is a coordinate system that
specifies each point uniquely in a plane by a pair
of numerical coordinates, which are the signed distances to
the point from two fixed perpendicular directed lines,
measured in the same unit of length.
16
• The invention of Cartesian coordinates in
the 17th century by René
Descartes (Latinized name: Cartesius)
revolutionized mathematics.
17. Cartesian coordinate system
Each reference line is called
a coordinate axis or just axis of the
system, and the point where they
meet is its origin, usually at ordered
pair (0, 0).
The coordinates can also be defined
as the positions of the perpendicular
projections of the point onto the two
axes, expressed as signed distances
from the origin.
17
18. Illustration of a Cartesian
coordinate plane. Four points are
marked and labeled with their
coordinates: (2,3) in green, (−3,1)
in red, (−1.5,−2.5) in blue, and the
origin (0,0) in purple.
18
Cartesian coordinate system with a
circle of radius 2 centered at the
origin marked in red. The equation
of a circle is (x− a)2 +
(y − b)2 = r2 where a and b are the
coordinates of the
center (a, b) and r is the radius.
19. Three dimensions
Choosing a Cartesian
coordinate system for a
three-dimensional space
means choosing an
ordered triplet of lines
(axes) that are pair-wise
perpendicular, have a
single unit of length for
all three axes and have an
orientation for each axis.
19
20. Notations and conventions
The Cartesian coordinates of a point are usually written in
parentheses and separated by commas, as in (10, 5) or(3, 5, 7).
The origin is often labelled with the capital letter O.
In analytic geometry, unknown or generic coordinates are
often denoted by the letters (x, y) in the plane, and (x, y, z) in
three-dimensional space.
20
21. Quadrants
The axes of a two-dimensional
Cartesian system divide the
plane into four infinite regions,
called quadrants, each
bounded by two half-axes.
These are often numbered
from 1st to 4th and denoted
by Roman numerals: I (where
the signs of the two
coordinates are +,+), II (−,+), III
(−,−), and IV (+,−).
21
22. Cartesian formulae for the plane: distance
The Euclidean distance between two points of the plane with
Cartesian coordinates (x1,y1) and (x2,y2) is like below:
In three-dimensional space, the distance between
points (x1,y1,z1) and (x2,y2,z2) is
22
23. Translation and Rotation
Translating a set of points of the plane, preserving the
distances and directions between them, is equivalent to
adding a fixed pair of numbers (a, b) to the Cartesian
coordinates of every point in the set.
To rotate a figure counterclockwise around the origin by some
angle is equivalent to replacing every point with coordinates
(x,y) by the point with coordinates (x',y'), where
23
24. Affine Transformation
Another way to represent coordinate transformations in
Cartesian coordinates is through affine transformations.
In affine transformations an extra dimension is added and all
points are given a value of 1 for this extra dimension.
The advantage of doing this is that point translations can be
specified in the final column of matrix A. In this way, all of the
euclidean transformations become transactable as matrix
point multiplications.
The affine transformation is given by:
24
25. Orientation and handedness
Once the x- and y-axes are specified, they determine
the line along which the z-axis should lie, but there are two
possible directions on this line.
The two possible coordinate systems which result are called
'right-handed' and 'left-handed'.
25
• The left-handed orientation is shown on the left, and the
right-handed on the right.
26. 26
The right-handed Cartesian
coordinate system indicating the
coordinate planes.
• Unity 3D game engine uses
LHS.
27. Write a program that draws f(x)=x2
void OnDraw( HDC hdc ) {
SelectObject( hdc, GetStockObject( DC_PEN ) );
SetDCPenColor( hdc, RGB( 255, 0, 0 ) );
MoveToEx( hdc, 0, 0, NULL );
LineTo( hdc, 100, 50 );
}
27
Use Win32 Gdi application on Windows7.
We assume origin is located at (200,200) in the screen
coordinates.
Draw the x-axis with a red line.
Draw the y-axis with a blue line.
20 pixel corresponds to 1 unit(real number).
29. Pi(π)
The number π is a mathematical constant, the ratio of
a circle's circumference to its diameter, commonly
approximated as 3.14159.
It has been represented by the Greek letter "π" since the mid-
18th century, though it is also sometimes spelled out as "pi"
(/paɪ/).
29
30. π is commonly defined as the ratio of
a circle's circumference C to its diameter d:
30
31. Radian
The radian is the standard unit of angular measure, used in
many areas of mathematics. An angle's measurement in
radians is numerically equal to the length of a corresponding
arc of a unit circle; one radian is just under 57.3 degrees.
31
32. Computing Pi
Monte Carlo methods, which evaluate the results of multiple
random trials, can be used to create approximations of π.
Draw a circle inscribed in a square, and randomly place dots
in the square. The ratio of dots inside the circle to the total
number of dots will approximately equal π/4.
32
34. Trigonometric functions
In mathematics, the trigonometric functions (also called
the circular functions) are functions of an angle.
They relate the angles of a triangle to the lengths of its sides.
34