SlideShare a Scribd company logo
1 of 50
Beginning Direct3D Game Programming:
Mathematics 6
Transforms
jintaeks@gmail.com
Division of Digital Contents, DongSeo University.
April 2016
2D Rotation: Do you remember the answer?
2
 We can rewrite this in matrix form as follows.
3
Solution for this in different way
 When a point P is rotated about θ, we assume that axis is
rotated about θ.
 We assume that rotated x and y-axis about θ is x' and y'-axis.
4
 Now, the new point P' is
a point on (cosθ, sinθ) x-
axis, and (-sinθ, cosθ) y-
axis.
 So, p'=px(cosθ, sinθ)+py(-
sinθ, cosθ)
Caution
 When a vector P is in the left side of the matrix, the matrix
must be transposed.
𝑝′ 𝑥
𝑝′ 𝑦
=
𝑐𝑜𝑠𝜃 −𝑠𝑖𝑛𝜃
𝑠𝑖𝑛𝜃 𝑐𝑜𝑠𝜃
𝑝 𝑥
𝑝 𝑦
𝑝′ 𝑥, 𝑝′ 𝑦 = 𝑝 𝑥, 𝑝𝑦
𝑐𝑜𝑠𝜃 𝑠𝑖𝑛𝜃
−𝑠𝑖𝑛𝜃 𝑐𝑜𝑠𝜃
5
2D Transformations
 2D Translation
 2×3 augmented matrix
6
 We can add a dummy linear equation.
 It constructs the linear system of 3 linear equations.
 Now, we get:
7
 2D Rotation Transform
 2D Scaling Transform
8
Linear Transformations
 Suppose that we have established a 3D coordinate system C
consisting of an origin and three coordinate axes, in which a
point P has the coordinates x, y, z .
 This constitutes a linear transformation from C to C′ and can
be written in matrix form as follows
9
 Assuming the transformation is invertible, the linear
transformation from C′ to C is given by
 We need to combine the 3×3 matrix and translation vector T
into a single 4× 4 transformation matrix.
10
Orthogonal Matrices
 Most 3×3 matrices arising in computer graphics applications
are orthogonal. An orthogonal matrix is simply one whose
inverse is equal to its transpose.
 If the n × n matrix M is orthogonal, then M preserves lengths
and angles.
11
Handedness
 In three dimensions, a basis for a coordinate system given
by the 3D vectors V1, V2, and V3 possesses a property called
handedness.
 A left-handed basis is one for which (V1×V2)⋅V3 < 0.
– in LHS V1×V2=-V3
• Left-handed coordinates on the left
Right-handed coordinates on the right.
12
Cross Product
13
 The cross product of two three-dimensional vectors, also
known as the vector product, returns a new vector that is
perpendicular to both of the vectors being multiplied
together.
• The cross-product in respect to a left-handed coordinate
system.
Coordinate Systems in Direct3D
• Direct3D uses a left-handed coordinate system. If you are
porting an application that is based on a right-handed
coordinate system, you must make two changes to the data
passed to Direct3D.
14
Scaling Transforms
 To scale a vector P by a factor of a, we simply calculate P′ =
aP. In three dimensions, this operation can also be expressed
as the matrix product.
15
Nonuniform Scaling
 A Diagonal entries are not necessarily all equal.
16
Rotation Transforms
 We can find 3×3 matrices that rotate a coordinate system
through an angle θ about the x, y, or z axis..
17
2D Rotation: Do you remember the answer?
18
 We can rewrite this in matrix form as follows.
 The matrix Rz(θ ) that performs a rotation through the angle θ
about the z axis is thus given by
19
Solution for this in different way
 When a point P is rotated about θ, we assume that axis is
rotated about θ.
 We assume that rotated x and y-axis about θ is x' and y'-axis.
20
 Now, the new point P' is
a point on (cosθ, sinθ) x-
axis, and (-sinθ, cosθ) y-
axis.
 So, p'=px(cosθ, sinθ)+py(-
sinθ, cosθ)
Caution
 When a vector P is in the left side of the matrix, the matrix
must be transposed.
𝑝′ 𝑥
𝑝′ 𝑦
=
𝑐𝑜𝑠𝜃 −𝑠𝑖𝑛𝜃
𝑠𝑖𝑛𝜃 𝑐𝑜𝑠𝜃
𝑝 𝑥
𝑝 𝑦
𝑝′ 𝑥, 𝑝′ 𝑦 = 𝑝 𝑥, 𝑝𝑦
𝑐𝑜𝑠𝜃 𝑠𝑖𝑛𝜃
−𝑠𝑖𝑛𝜃 𝑐𝑜𝑠𝜃
21
 Similarly, we can derive the following 3×3 matrices Rx(θ ) and
Ry(θ ) that perform rotations through an angle θ about the x
and y axes, respectively:
22
Rotation about an Arbitrary Axis
 Combining these terms and setting c = cosθ and s = sinθ
gives us the following formula for the matrix RA(θ) that
rotates a vector through an angle θ about the axis A.
23
Translation
 To transform a point P from one coordinate system to
another, we usually find ourselves performing the operation
P′ =MP + T
 where M is some invertible 3×3 matrix and T is a 3D
translation vector.
 Fortunately, there is a compact and elegant way to represent
these transforms within a single mathematical entity.
24
Translation
P′ =MP + T
 Fortunately, there is a compact and elegant way to represent
these transforms within a single mathematical entity.
25
26
P =M-1P' – M-1T
 We would therefore expect the inverse of the 4× 4 matrix F to
be
27
When a input vector is at left of a matrix.
 When a input vector is at left of a matrix, the translation
vector T will be located at bottom row.
28
𝑴 𝟏𝟏 𝑴 𝟏𝟐 𝑴 𝟏𝟑 𝟎
𝑴 𝟐𝟏 𝑴 𝟐𝟐 𝑴 𝟐𝟑 𝟎
𝑴 𝟑𝟏 𝑴 𝟑𝟐 𝑴 𝟑𝟑 𝟎
𝑻 𝒙 𝑻 𝒚 𝑻 𝒛 𝟏
Points and Directions
 Unlike points, direction vectors should remain invariant under
translation.
 To transform direction vectors using the same 4× 4
transformation matrices that we use to transform points, we
extend direction vectors to four dimensions by setting the w
coordinate to 0.
(x,y,z,w)
(px,py,pz,0)
 The upper left 3×3 portion of the matrix to affect the
direction vector.
29
Linear Systems
 Matrices provide a compact and convenient way to represent
systems of linear equations. For instance, the linear system
given by the equations
 can be represented in matrix form as
30
 The matrix preceding the vector x, y, z of unknowns is called
the coefficient matrix, and the column vector on the right
side of the equals sign is called the constant vector. Linear
systems for which the constant vector is nonzero (like the
example above) are called nonhomogeneous.
 Linear systems for which every entry of the constant vector is
zero are called homogeneous.
– The Geometric meaning of homogeneous is all the 3-planes meet at
origin (0,0,0).
31
 The augmented matrix formed by concatenating the
coefficient matrix and constant vector is
 When the linear system is homogeneous, then the matrix cab
be written like this
3 2 −3 0
4 −3 6 0
1
0
0
0
−1
0
0
1
32
Homogeneous Matrix
 We will use 4x4 matrices to consistently represent translation,
scaling and rotation in 3D space.
 In that case a14, a24 and a34 is always zero, when the input
vector is at left of a matrix, this is a Homogeneous Matrix.
33
Transform Matrices in Direct3D
 You can transform any point (x,y,z) into another point (x', y',
z') by using a 4x4 matrix, as shown in the following equation.
34
Translation in Direct3D
 The following equation translates the point (x, y, z) to a new
point (x', y', z').
35
D3DXMATRIX Translate(const float dx, const float dy, const float dz) {
D3DXMATRIX ret;
D3DXMatrixIdentity(&ret);
ret(3, 0) = dx;
ret(3, 1) = dy;
ret(3, 2) = dz;
return ret;
} // End of Translate
Scaling in Direct3D
 The following equation scales the point (x, y, z) by arbitrary
values in the x-, y-, and z-directions to a new point (x', y', z').
36
Rotations in Direct3D
 The following equation rotates the point (x, y, z) around the x-
axis, producing a new point (x', y', z').
37
D3DXMATRIX* WINAPI D3DXMatrixRotationX
( D3DXMATRIX *pOut, float angle )
{
float sin, cos;
sincosf(angle, &sin, &cos); // Determine sin and cos of angle
pOut->_11 = 1.0f; pOut->_12 = 0.0f; pOut->_13 = 0.0f; pOut->_14 = 0.0f;
pOut->_21 = 0.0f; pOut->_22 = cos; pOut->_23 = sin; pOut->_24 = 0.0f;
pOut->_31 = 0.0f; pOut->_32 = -sin; pOut->_33 = cos; pOut->_34 = 0.0f;
pOut->_41 = 0.0f; pOut->_42 = 0.0f; pOut->_43 = 0.0f; pOut->_44 = 1.0f;
return pOut;
}
 The following equation rotates the point around the y-axis.
 The following equation rotates the point around the z-axis.
38
Concatenating Matrices
 One advantage of using matrices is that you can combine the
effects of two or more matrices by multiplying them.
 This means that, to rotate a model and then translate it to
some location, you don't need to apply two matrices.
 In this equation, C is the composite matrix being created, and
M₁ through Mn are the individual matrices.
Use the D3DXMatrixMultiply function to
perform matrix multiplication.
39
Win32 3D Cube Project
40
Step2
41
42
43
Step3: Matrix
 Rotation about x-axis
44
Projection Transform
45
46
47
48
References
 Lengyel, "Mathematics for 3D Game Programming and
Computer Graphics",3rd, 2011
 https://msdn.microsoft.com/en-
us/library/windows/desktop/bb206269(v=vs.85).aspx
49
Beginning direct3d gameprogrammingmath06_transformations_20161019_jintaeks

More Related Content

What's hot

Curve fitting - Lecture Notes
Curve fitting - Lecture NotesCurve fitting - Lecture Notes
Curve fitting - Lecture NotesDr. Nirav Vyas
 
Application of integral calculus
Application of integral calculusApplication of integral calculus
Application of integral calculusHabibur Rahman
 
coordinate Geometry straight line
coordinate Geometry   straight linecoordinate Geometry   straight line
coordinate Geometry straight lineSahilPuri14
 
Drawing trigonometric graphs.
Drawing trigonometric graphs.Drawing trigonometric graphs.
Drawing trigonometric graphs.RoseBlakeney
 
Introduction to homography
Introduction to homographyIntroduction to homography
Introduction to homographyShih-Hsiang Lin
 
Presentation on Numerical Method (Trapezoidal Method)
Presentation on Numerical Method (Trapezoidal Method)Presentation on Numerical Method (Trapezoidal Method)
Presentation on Numerical Method (Trapezoidal Method)Syed Ahmed Zaki
 
Applications Section 1.3
Applications   Section 1.3Applications   Section 1.3
Applications Section 1.3mobart02
 
Use of integral calculus in engineering
Use of integral calculus in engineeringUse of integral calculus in engineering
Use of integral calculus in engineeringJunaid Ijaz
 
Coordinate transformation
Coordinate transformationCoordinate transformation
Coordinate transformationMohd Arif
 
Curve fitting of exponential curve
Curve fitting of exponential curveCurve fitting of exponential curve
Curve fitting of exponential curveDivyang Rathod
 
Area Under the Curve
Area Under the CurveArea Under the Curve
Area Under the Curvealexbeja
 
Spline Interpolation
Spline InterpolationSpline Interpolation
Spline InterpolationaiQUANT
 

What's hot (19)

Curve fitting
Curve fittingCurve fitting
Curve fitting
 
Curve fitting - Lecture Notes
Curve fitting - Lecture NotesCurve fitting - Lecture Notes
Curve fitting - Lecture Notes
 
Curve fitting
Curve fitting Curve fitting
Curve fitting
 
Quantech reviewer
Quantech reviewerQuantech reviewer
Quantech reviewer
 
Application of integral calculus
Application of integral calculusApplication of integral calculus
Application of integral calculus
 
coordinate Geometry straight line
coordinate Geometry   straight linecoordinate Geometry   straight line
coordinate Geometry straight line
 
2 d transformations
2 d transformations2 d transformations
2 d transformations
 
Drawing trigonometric graphs.
Drawing trigonometric graphs.Drawing trigonometric graphs.
Drawing trigonometric graphs.
 
Introduction to homography
Introduction to homographyIntroduction to homography
Introduction to homography
 
Presentation on Numerical Method (Trapezoidal Method)
Presentation on Numerical Method (Trapezoidal Method)Presentation on Numerical Method (Trapezoidal Method)
Presentation on Numerical Method (Trapezoidal Method)
 
Applications Section 1.3
Applications   Section 1.3Applications   Section 1.3
Applications Section 1.3
 
Integration Ppt
Integration PptIntegration Ppt
Integration Ppt
 
Mathematical modeling
Mathematical modelingMathematical modeling
Mathematical modeling
 
Use of integral calculus in engineering
Use of integral calculus in engineeringUse of integral calculus in engineering
Use of integral calculus in engineering
 
Coordinate transformation
Coordinate transformationCoordinate transformation
Coordinate transformation
 
Curve fitting of exponential curve
Curve fitting of exponential curveCurve fitting of exponential curve
Curve fitting of exponential curve
 
Area Under the Curve
Area Under the CurveArea Under the Curve
Area Under the Curve
 
Spline Interpolation
Spline InterpolationSpline Interpolation
Spline Interpolation
 
Trapezoidal rule
Trapezoidal ruleTrapezoidal rule
Trapezoidal rule
 

Viewers also liked

Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeksBeginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeksJinTaek Seo
 
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeksBeginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeksJinTaek Seo
 
Beginning direct3d gameprogramming01_20161102_jintaeks
Beginning direct3d gameprogramming01_20161102_jintaeksBeginning direct3d gameprogramming01_20161102_jintaeks
Beginning direct3d gameprogramming01_20161102_jintaeksJinTaek Seo
 
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...JinTaek Seo
 
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeksBeginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeksJinTaek Seo
 
Beginning direct3d gameprogramming02_overviewofhalandcom_20160408_jintaeks
Beginning direct3d gameprogramming02_overviewofhalandcom_20160408_jintaeksBeginning direct3d gameprogramming02_overviewofhalandcom_20160408_jintaeks
Beginning direct3d gameprogramming02_overviewofhalandcom_20160408_jintaeksJinTaek Seo
 
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksBeginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksJinTaek Seo
 
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeks
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeksBeginning direct3d gameprogrammingmath03_vectors_20160328_jintaeks
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeksJinTaek Seo
 
Beginning direct3d gameprogrammingmath04_calculus_20160324_jintaeks
Beginning direct3d gameprogrammingmath04_calculus_20160324_jintaeksBeginning direct3d gameprogrammingmath04_calculus_20160324_jintaeks
Beginning direct3d gameprogrammingmath04_calculus_20160324_jintaeksJinTaek Seo
 
Beginning direct3d gameprogramming04_3dfundamentals_20160414_jintaeks
Beginning direct3d gameprogramming04_3dfundamentals_20160414_jintaeksBeginning direct3d gameprogramming04_3dfundamentals_20160414_jintaeks
Beginning direct3d gameprogramming04_3dfundamentals_20160414_jintaeksJinTaek Seo
 
Beginning direct3d gameprogramming03_programmingconventions_20160414_jintaeks
Beginning direct3d gameprogramming03_programmingconventions_20160414_jintaeksBeginning direct3d gameprogramming03_programmingconventions_20160414_jintaeks
Beginning direct3d gameprogramming03_programmingconventions_20160414_jintaeksJinTaek Seo
 
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeks
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeksBeginning direct3d gameprogramming08_usingtextures_20160428_jintaeks
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeksJinTaek Seo
 
Beginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeks
Beginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeksBeginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeks
Beginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeksJinTaek Seo
 
Beginning direct3d gameprogrammingmath02_logarithm_20160324_jintaeks
Beginning direct3d gameprogrammingmath02_logarithm_20160324_jintaeksBeginning direct3d gameprogrammingmath02_logarithm_20160324_jintaeks
Beginning direct3d gameprogrammingmath02_logarithm_20160324_jintaeksJinTaek Seo
 
Beginning direct3d gameprogrammingcpp02_20160324_jintaeks
Beginning direct3d gameprogrammingcpp02_20160324_jintaeksBeginning direct3d gameprogrammingcpp02_20160324_jintaeks
Beginning direct3d gameprogrammingcpp02_20160324_jintaeksJinTaek Seo
 
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeks
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeksBeginning direct3d gameprogrammingmath05_matrices_20160515_jintaeks
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeksJinTaek Seo
 

Viewers also liked (16)

Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeksBeginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
 
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeksBeginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
 
Beginning direct3d gameprogramming01_20161102_jintaeks
Beginning direct3d gameprogramming01_20161102_jintaeksBeginning direct3d gameprogramming01_20161102_jintaeks
Beginning direct3d gameprogramming01_20161102_jintaeks
 
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...
 
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeksBeginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
 
Beginning direct3d gameprogramming02_overviewofhalandcom_20160408_jintaeks
Beginning direct3d gameprogramming02_overviewofhalandcom_20160408_jintaeksBeginning direct3d gameprogramming02_overviewofhalandcom_20160408_jintaeks
Beginning direct3d gameprogramming02_overviewofhalandcom_20160408_jintaeks
 
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksBeginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
 
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeks
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeksBeginning direct3d gameprogrammingmath03_vectors_20160328_jintaeks
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeks
 
Beginning direct3d gameprogrammingmath04_calculus_20160324_jintaeks
Beginning direct3d gameprogrammingmath04_calculus_20160324_jintaeksBeginning direct3d gameprogrammingmath04_calculus_20160324_jintaeks
Beginning direct3d gameprogrammingmath04_calculus_20160324_jintaeks
 
Beginning direct3d gameprogramming04_3dfundamentals_20160414_jintaeks
Beginning direct3d gameprogramming04_3dfundamentals_20160414_jintaeksBeginning direct3d gameprogramming04_3dfundamentals_20160414_jintaeks
Beginning direct3d gameprogramming04_3dfundamentals_20160414_jintaeks
 
Beginning direct3d gameprogramming03_programmingconventions_20160414_jintaeks
Beginning direct3d gameprogramming03_programmingconventions_20160414_jintaeksBeginning direct3d gameprogramming03_programmingconventions_20160414_jintaeks
Beginning direct3d gameprogramming03_programmingconventions_20160414_jintaeks
 
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeks
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeksBeginning direct3d gameprogramming08_usingtextures_20160428_jintaeks
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeks
 
Beginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeks
Beginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeksBeginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeks
Beginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeks
 
Beginning direct3d gameprogrammingmath02_logarithm_20160324_jintaeks
Beginning direct3d gameprogrammingmath02_logarithm_20160324_jintaeksBeginning direct3d gameprogrammingmath02_logarithm_20160324_jintaeks
Beginning direct3d gameprogrammingmath02_logarithm_20160324_jintaeks
 
Beginning direct3d gameprogrammingcpp02_20160324_jintaeks
Beginning direct3d gameprogrammingcpp02_20160324_jintaeksBeginning direct3d gameprogrammingcpp02_20160324_jintaeks
Beginning direct3d gameprogrammingcpp02_20160324_jintaeks
 
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeks
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeksBeginning direct3d gameprogrammingmath05_matrices_20160515_jintaeks
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeks
 

Similar to Beginning direct3d gameprogrammingmath06_transformations_20161019_jintaeks

Beginning direct3d gameprogrammingmath01_primer_20160324_jintaeks
Beginning direct3d gameprogrammingmath01_primer_20160324_jintaeksBeginning direct3d gameprogrammingmath01_primer_20160324_jintaeks
Beginning direct3d gameprogrammingmath01_primer_20160324_jintaeksJinTaek Seo
 
3D Coordinate Geometry
3D Coordinate Geometry 3D Coordinate Geometry
3D Coordinate Geometry ParasKulhari
 
History,applications,algebra and mathematical form of plane in mathematics (p...
History,applications,algebra and mathematical form of plane in mathematics (p...History,applications,algebra and mathematical form of plane in mathematics (p...
History,applications,algebra and mathematical form of plane in mathematics (p...guesta62dea
 
Mathematics.pdf
Mathematics.pdfMathematics.pdf
Mathematics.pdfzaraa30
 
Reflection, Scaling, Shear, Translation, and Rotation
Reflection, Scaling, Shear, Translation, and RotationReflection, Scaling, Shear, Translation, and Rotation
Reflection, Scaling, Shear, Translation, and RotationSaumya Tiwari
 
7.5 lines and_planes_in_space
7.5 lines and_planes_in_space7.5 lines and_planes_in_space
7.5 lines and_planes_in_spaceMahbub Alwathoni
 
Linear equation in 2 variables
Linear equation in 2 variablesLinear equation in 2 variables
Linear equation in 2 variablesavb public school
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)Timbal Mayank
 
EMT_2A_cylindrical coordinates.pptx
EMT_2A_cylindrical coordinates.pptxEMT_2A_cylindrical coordinates.pptx
EMT_2A_cylindrical coordinates.pptx5610UmarIqbal
 
Computer graphics notes 2 tutorials duniya
Computer graphics notes 2   tutorials duniyaComputer graphics notes 2   tutorials duniya
Computer graphics notes 2 tutorials duniyaTutorialsDuniya.com
 
Slope power point grade 8
Slope power point grade 8Slope power point grade 8
Slope power point grade 8ginacdl
 
Computer graphics
Computer graphicsComputer graphics
Computer graphicsBala Murali
 
WRITING AND GRAPHING LINEAR EQUATIONS 1.pptx
WRITING AND GRAPHING LINEAR EQUATIONS 1.pptxWRITING AND GRAPHING LINEAR EQUATIONS 1.pptx
WRITING AND GRAPHING LINEAR EQUATIONS 1.pptxKristenHathcock
 

Similar to Beginning direct3d gameprogrammingmath06_transformations_20161019_jintaeks (20)

Beginning direct3d gameprogrammingmath01_primer_20160324_jintaeks
Beginning direct3d gameprogrammingmath01_primer_20160324_jintaeksBeginning direct3d gameprogrammingmath01_primer_20160324_jintaeks
Beginning direct3d gameprogrammingmath01_primer_20160324_jintaeks
 
1533 game mathematics
1533 game mathematics1533 game mathematics
1533 game mathematics
 
3D Coordinate Geometry
3D Coordinate Geometry 3D Coordinate Geometry
3D Coordinate Geometry
 
History,applications,algebra and mathematical form of plane in mathematics (p...
History,applications,algebra and mathematical form of plane in mathematics (p...History,applications,algebra and mathematical form of plane in mathematics (p...
History,applications,algebra and mathematical form of plane in mathematics (p...
 
Mathematics.pdf
Mathematics.pdfMathematics.pdf
Mathematics.pdf
 
Reflection, Scaling, Shear, Translation, and Rotation
Reflection, Scaling, Shear, Translation, and RotationReflection, Scaling, Shear, Translation, and Rotation
Reflection, Scaling, Shear, Translation, and Rotation
 
7.5 lines and_planes_in_space
7.5 lines and_planes_in_space7.5 lines and_planes_in_space
7.5 lines and_planes_in_space
 
1525 equations of lines in space
1525 equations of lines in space1525 equations of lines in space
1525 equations of lines in space
 
Linear equation in 2 variables
Linear equation in 2 variablesLinear equation in 2 variables
Linear equation in 2 variables
 
returika
returikareturika
returika
 
2D-transformation-1.pdf
2D-transformation-1.pdf2D-transformation-1.pdf
2D-transformation-1.pdf
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)
 
1602 parametric equations
1602 parametric equations1602 parametric equations
1602 parametric equations
 
EMT_2A_cylindrical coordinates.pptx
EMT_2A_cylindrical coordinates.pptxEMT_2A_cylindrical coordinates.pptx
EMT_2A_cylindrical coordinates.pptx
 
Computer graphics notes 2 tutorials duniya
Computer graphics notes 2   tutorials duniyaComputer graphics notes 2   tutorials duniya
Computer graphics notes 2 tutorials duniya
 
Math project
Math projectMath project
Math project
 
Slope power point grade 8
Slope power point grade 8Slope power point grade 8
Slope power point grade 8
 
Lecture 3 - Linear Regression
Lecture 3 - Linear RegressionLecture 3 - Linear Regression
Lecture 3 - Linear Regression
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
WRITING AND GRAPHING LINEAR EQUATIONS 1.pptx
WRITING AND GRAPHING LINEAR EQUATIONS 1.pptxWRITING AND GRAPHING LINEAR EQUATIONS 1.pptx
WRITING AND GRAPHING LINEAR EQUATIONS 1.pptx
 

More from JinTaek Seo

Neural network 20161210_jintaekseo
Neural network 20161210_jintaekseoNeural network 20161210_jintaekseo
Neural network 20161210_jintaekseoJinTaek Seo
 
05 heap 20161110_jintaeks
05 heap 20161110_jintaeks05 heap 20161110_jintaeks
05 heap 20161110_jintaeksJinTaek Seo
 
02 linked list_20160217_jintaekseo
02 linked list_20160217_jintaekseo02 linked list_20160217_jintaekseo
02 linked list_20160217_jintaekseoJinTaek Seo
 
Hermite spline english_20161201_jintaeks
Hermite spline english_20161201_jintaeksHermite spline english_20161201_jintaeks
Hermite spline english_20161201_jintaeksJinTaek Seo
 
01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seo01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seoJinTaek Seo
 
03 fsm how_toimplementai_state_20161006_jintaeks
03 fsm how_toimplementai_state_20161006_jintaeks03 fsm how_toimplementai_state_20161006_jintaeks
03 fsm how_toimplementai_state_20161006_jintaeksJinTaek Seo
 
Boost pp 20091102_서진택
Boost pp 20091102_서진택Boost pp 20091102_서진택
Boost pp 20091102_서진택JinTaek Seo
 
아직도가야할길 훈련 20090722_서진택
아직도가야할길 훈련 20090722_서진택아직도가야할길 훈련 20090722_서진택
아직도가야할길 훈련 20090722_서진택JinTaek Seo
 
3ds maxscript 튜토리얼_20151206_서진택
3ds maxscript 튜토리얼_20151206_서진택3ds maxscript 튜토리얼_20151206_서진택
3ds maxscript 튜토리얼_20151206_서진택JinTaek Seo
 
Multithread programming 20151206_서진택
Multithread programming 20151206_서진택Multithread programming 20151206_서진택
Multithread programming 20151206_서진택JinTaek Seo
 
03동물 로봇그리고사람 public_20151125_서진택
03동물 로봇그리고사람 public_20151125_서진택03동물 로봇그리고사람 public_20151125_서진택
03동물 로봇그리고사람 public_20151125_서진택JinTaek Seo
 
20150605 홀트입양예비부모모임 서진택
20150605 홀트입양예비부모모임 서진택20150605 홀트입양예비부모모임 서진택
20150605 홀트입양예비부모모임 서진택JinTaek Seo
 
Boost라이브러리의내부구조 20151111 서진택
Boost라이브러리의내부구조 20151111 서진택Boost라이브러리의내부구조 20151111 서진택
Boost라이브러리의내부구조 20151111 서진택JinTaek Seo
 

More from JinTaek Seo (13)

Neural network 20161210_jintaekseo
Neural network 20161210_jintaekseoNeural network 20161210_jintaekseo
Neural network 20161210_jintaekseo
 
05 heap 20161110_jintaeks
05 heap 20161110_jintaeks05 heap 20161110_jintaeks
05 heap 20161110_jintaeks
 
02 linked list_20160217_jintaekseo
02 linked list_20160217_jintaekseo02 linked list_20160217_jintaekseo
02 linked list_20160217_jintaekseo
 
Hermite spline english_20161201_jintaeks
Hermite spline english_20161201_jintaeksHermite spline english_20161201_jintaeks
Hermite spline english_20161201_jintaeks
 
01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seo01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seo
 
03 fsm how_toimplementai_state_20161006_jintaeks
03 fsm how_toimplementai_state_20161006_jintaeks03 fsm how_toimplementai_state_20161006_jintaeks
03 fsm how_toimplementai_state_20161006_jintaeks
 
Boost pp 20091102_서진택
Boost pp 20091102_서진택Boost pp 20091102_서진택
Boost pp 20091102_서진택
 
아직도가야할길 훈련 20090722_서진택
아직도가야할길 훈련 20090722_서진택아직도가야할길 훈련 20090722_서진택
아직도가야할길 훈련 20090722_서진택
 
3ds maxscript 튜토리얼_20151206_서진택
3ds maxscript 튜토리얼_20151206_서진택3ds maxscript 튜토리얼_20151206_서진택
3ds maxscript 튜토리얼_20151206_서진택
 
Multithread programming 20151206_서진택
Multithread programming 20151206_서진택Multithread programming 20151206_서진택
Multithread programming 20151206_서진택
 
03동물 로봇그리고사람 public_20151125_서진택
03동물 로봇그리고사람 public_20151125_서진택03동물 로봇그리고사람 public_20151125_서진택
03동물 로봇그리고사람 public_20151125_서진택
 
20150605 홀트입양예비부모모임 서진택
20150605 홀트입양예비부모모임 서진택20150605 홀트입양예비부모모임 서진택
20150605 홀트입양예비부모모임 서진택
 
Boost라이브러리의내부구조 20151111 서진택
Boost라이브러리의내부구조 20151111 서진택Boost라이브러리의내부구조 20151111 서진택
Boost라이브러리의내부구조 20151111 서진택
 

Recently uploaded

Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01KreezheaRecto
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLManishPatel169454
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spaintimesproduction05
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 

Recently uploaded (20)

Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 

Beginning direct3d gameprogrammingmath06_transformations_20161019_jintaeks

  • 1. Beginning Direct3D Game Programming: Mathematics 6 Transforms jintaeks@gmail.com Division of Digital Contents, DongSeo University. April 2016
  • 2. 2D Rotation: Do you remember the answer? 2
  • 3.  We can rewrite this in matrix form as follows. 3
  • 4. Solution for this in different way  When a point P is rotated about θ, we assume that axis is rotated about θ.  We assume that rotated x and y-axis about θ is x' and y'-axis. 4  Now, the new point P' is a point on (cosθ, sinθ) x- axis, and (-sinθ, cosθ) y- axis.  So, p'=px(cosθ, sinθ)+py(- sinθ, cosθ)
  • 5. Caution  When a vector P is in the left side of the matrix, the matrix must be transposed. 𝑝′ 𝑥 𝑝′ 𝑦 = 𝑐𝑜𝑠𝜃 −𝑠𝑖𝑛𝜃 𝑠𝑖𝑛𝜃 𝑐𝑜𝑠𝜃 𝑝 𝑥 𝑝 𝑦 𝑝′ 𝑥, 𝑝′ 𝑦 = 𝑝 𝑥, 𝑝𝑦 𝑐𝑜𝑠𝜃 𝑠𝑖𝑛𝜃 −𝑠𝑖𝑛𝜃 𝑐𝑜𝑠𝜃 5
  • 6. 2D Transformations  2D Translation  2×3 augmented matrix 6
  • 7.  We can add a dummy linear equation.  It constructs the linear system of 3 linear equations.  Now, we get: 7
  • 8.  2D Rotation Transform  2D Scaling Transform 8
  • 9. Linear Transformations  Suppose that we have established a 3D coordinate system C consisting of an origin and three coordinate axes, in which a point P has the coordinates x, y, z .  This constitutes a linear transformation from C to C′ and can be written in matrix form as follows 9
  • 10.  Assuming the transformation is invertible, the linear transformation from C′ to C is given by  We need to combine the 3×3 matrix and translation vector T into a single 4× 4 transformation matrix. 10
  • 11. Orthogonal Matrices  Most 3×3 matrices arising in computer graphics applications are orthogonal. An orthogonal matrix is simply one whose inverse is equal to its transpose.  If the n × n matrix M is orthogonal, then M preserves lengths and angles. 11
  • 12. Handedness  In three dimensions, a basis for a coordinate system given by the 3D vectors V1, V2, and V3 possesses a property called handedness.  A left-handed basis is one for which (V1×V2)⋅V3 < 0. – in LHS V1×V2=-V3 • Left-handed coordinates on the left Right-handed coordinates on the right. 12
  • 13. Cross Product 13  The cross product of two three-dimensional vectors, also known as the vector product, returns a new vector that is perpendicular to both of the vectors being multiplied together. • The cross-product in respect to a left-handed coordinate system.
  • 14. Coordinate Systems in Direct3D • Direct3D uses a left-handed coordinate system. If you are porting an application that is based on a right-handed coordinate system, you must make two changes to the data passed to Direct3D. 14
  • 15. Scaling Transforms  To scale a vector P by a factor of a, we simply calculate P′ = aP. In three dimensions, this operation can also be expressed as the matrix product. 15
  • 16. Nonuniform Scaling  A Diagonal entries are not necessarily all equal. 16
  • 17. Rotation Transforms  We can find 3×3 matrices that rotate a coordinate system through an angle θ about the x, y, or z axis.. 17
  • 18. 2D Rotation: Do you remember the answer? 18
  • 19.  We can rewrite this in matrix form as follows.  The matrix Rz(θ ) that performs a rotation through the angle θ about the z axis is thus given by 19
  • 20. Solution for this in different way  When a point P is rotated about θ, we assume that axis is rotated about θ.  We assume that rotated x and y-axis about θ is x' and y'-axis. 20  Now, the new point P' is a point on (cosθ, sinθ) x- axis, and (-sinθ, cosθ) y- axis.  So, p'=px(cosθ, sinθ)+py(- sinθ, cosθ)
  • 21. Caution  When a vector P is in the left side of the matrix, the matrix must be transposed. 𝑝′ 𝑥 𝑝′ 𝑦 = 𝑐𝑜𝑠𝜃 −𝑠𝑖𝑛𝜃 𝑠𝑖𝑛𝜃 𝑐𝑜𝑠𝜃 𝑝 𝑥 𝑝 𝑦 𝑝′ 𝑥, 𝑝′ 𝑦 = 𝑝 𝑥, 𝑝𝑦 𝑐𝑜𝑠𝜃 𝑠𝑖𝑛𝜃 −𝑠𝑖𝑛𝜃 𝑐𝑜𝑠𝜃 21
  • 22.  Similarly, we can derive the following 3×3 matrices Rx(θ ) and Ry(θ ) that perform rotations through an angle θ about the x and y axes, respectively: 22
  • 23. Rotation about an Arbitrary Axis  Combining these terms and setting c = cosθ and s = sinθ gives us the following formula for the matrix RA(θ) that rotates a vector through an angle θ about the axis A. 23
  • 24. Translation  To transform a point P from one coordinate system to another, we usually find ourselves performing the operation P′ =MP + T  where M is some invertible 3×3 matrix and T is a 3D translation vector.  Fortunately, there is a compact and elegant way to represent these transforms within a single mathematical entity. 24
  • 25. Translation P′ =MP + T  Fortunately, there is a compact and elegant way to represent these transforms within a single mathematical entity. 25
  • 26. 26 P =M-1P' – M-1T  We would therefore expect the inverse of the 4× 4 matrix F to be
  • 27. 27
  • 28. When a input vector is at left of a matrix.  When a input vector is at left of a matrix, the translation vector T will be located at bottom row. 28 𝑴 𝟏𝟏 𝑴 𝟏𝟐 𝑴 𝟏𝟑 𝟎 𝑴 𝟐𝟏 𝑴 𝟐𝟐 𝑴 𝟐𝟑 𝟎 𝑴 𝟑𝟏 𝑴 𝟑𝟐 𝑴 𝟑𝟑 𝟎 𝑻 𝒙 𝑻 𝒚 𝑻 𝒛 𝟏
  • 29. Points and Directions  Unlike points, direction vectors should remain invariant under translation.  To transform direction vectors using the same 4× 4 transformation matrices that we use to transform points, we extend direction vectors to four dimensions by setting the w coordinate to 0. (x,y,z,w) (px,py,pz,0)  The upper left 3×3 portion of the matrix to affect the direction vector. 29
  • 30. Linear Systems  Matrices provide a compact and convenient way to represent systems of linear equations. For instance, the linear system given by the equations  can be represented in matrix form as 30
  • 31.  The matrix preceding the vector x, y, z of unknowns is called the coefficient matrix, and the column vector on the right side of the equals sign is called the constant vector. Linear systems for which the constant vector is nonzero (like the example above) are called nonhomogeneous.  Linear systems for which every entry of the constant vector is zero are called homogeneous. – The Geometric meaning of homogeneous is all the 3-planes meet at origin (0,0,0). 31
  • 32.  The augmented matrix formed by concatenating the coefficient matrix and constant vector is  When the linear system is homogeneous, then the matrix cab be written like this 3 2 −3 0 4 −3 6 0 1 0 0 0 −1 0 0 1 32
  • 33. Homogeneous Matrix  We will use 4x4 matrices to consistently represent translation, scaling and rotation in 3D space.  In that case a14, a24 and a34 is always zero, when the input vector is at left of a matrix, this is a Homogeneous Matrix. 33
  • 34. Transform Matrices in Direct3D  You can transform any point (x,y,z) into another point (x', y', z') by using a 4x4 matrix, as shown in the following equation. 34
  • 35. Translation in Direct3D  The following equation translates the point (x, y, z) to a new point (x', y', z'). 35 D3DXMATRIX Translate(const float dx, const float dy, const float dz) { D3DXMATRIX ret; D3DXMatrixIdentity(&ret); ret(3, 0) = dx; ret(3, 1) = dy; ret(3, 2) = dz; return ret; } // End of Translate
  • 36. Scaling in Direct3D  The following equation scales the point (x, y, z) by arbitrary values in the x-, y-, and z-directions to a new point (x', y', z'). 36
  • 37. Rotations in Direct3D  The following equation rotates the point (x, y, z) around the x- axis, producing a new point (x', y', z'). 37 D3DXMATRIX* WINAPI D3DXMatrixRotationX ( D3DXMATRIX *pOut, float angle ) { float sin, cos; sincosf(angle, &sin, &cos); // Determine sin and cos of angle pOut->_11 = 1.0f; pOut->_12 = 0.0f; pOut->_13 = 0.0f; pOut->_14 = 0.0f; pOut->_21 = 0.0f; pOut->_22 = cos; pOut->_23 = sin; pOut->_24 = 0.0f; pOut->_31 = 0.0f; pOut->_32 = -sin; pOut->_33 = cos; pOut->_34 = 0.0f; pOut->_41 = 0.0f; pOut->_42 = 0.0f; pOut->_43 = 0.0f; pOut->_44 = 1.0f; return pOut; }
  • 38.  The following equation rotates the point around the y-axis.  The following equation rotates the point around the z-axis. 38
  • 39. Concatenating Matrices  One advantage of using matrices is that you can combine the effects of two or more matrices by multiplying them.  This means that, to rotate a model and then translate it to some location, you don't need to apply two matrices.  In this equation, C is the composite matrix being created, and M₁ through Mn are the individual matrices. Use the D3DXMatrixMultiply function to perform matrix multiplication. 39
  • 40. Win32 3D Cube Project 40
  • 42. 42
  • 43. 43
  • 44. Step3: Matrix  Rotation about x-axis 44
  • 46. 46
  • 47. 47
  • 48. 48
  • 49. References  Lengyel, "Mathematics for 3D Game Programming and Computer Graphics",3rd, 2011  https://msdn.microsoft.com/en- us/library/windows/desktop/bb206269(v=vs.85).aspx 49

Editor's Notes

  1. Suppose that we have established a 3D coordinate system C consisting of an origin and three coordinate axes, in which a point P has the coordinates x, y, z . The values x, y, and z can be thought of as the distances that one must travel along each of the coordinate axes from the origin in order to reach the point P. Suppose now that we introduce a second coordinate system C′ in which coordinates x′, y′, z′ can be expressed as linear functions of coordinates x, y, z in C.
  2. This means that, to rotate a model and then translate it to some location, you don't need to apply two matrices. Instead, you multiply the rotation and translation matrices to produce a composite matrix that contains all their effects.