7. Computational Geometry - 3D Graphics and Game Development Course
-
Upload
telerik-software-academy -
Category
Education
-
view
788 -
download
1
description
Transcript of 7. Computational Geometry - 3D Graphics and Game Development Course
Computational Geometry
Vectors, Translation, Rotation
George Georgiev
http://academy.telerik.com
Technical Trainer
academy.telerik.com
/.../3d-game-developm
ent-opengl
George AtanasovFront-End Developer
Table of Contents Analytic geometry
Vectors and Points
Vector math Addition / Translation
Subtraction
Multiplication / Scaling
2D Rotation
Vector length
Programming it2
Analytic geometryThe math
Analytic geometry
Also called Cartesian geometry Coordinate system
Applies algebraic principles to geometry Algebra
Analysis
4
Analytic geometry Points (vertices)
Represented by coordinates 2D – (X, Y);
3D – (X, Y, Z);
Etc..
Points are locations inspace
5
Analytic geometry Points
Example – A (3, 2); H (-1.5, 3);
6
Analytic geometry Vectors
Represented exactly the same way
Different only by concept Have
Direction
Magnitude (length)
Computers understand vectors Points – vectors added to the
beginning of the coordinate system (0, 0)
7
Analytic geometry
8
A Point A vector to the point
Vector mathIt's easy
Vector math Addition
Vectors can be added just like numbers
Called translation when applied to a point
Example A(5, 10) + B(-3, 7) = C(2, 17)
Subtraction Subtracting two points gives the
vector from the second to the first
Example: A(5, 10) - B(-3, 7) = V(8, 3)
10
Vector math Multiplication
By a number Multiple each coordinate by the
number
V(5, 7) * 3 = V’(15, 21)
Called uniform scaling
Division works the same way You can always multiply by 1/3
(that’s 0.33)
V(15, 21) / 3 = V’(5, 7)
V(15, 21) * 0.33 = V’(5, 7)11
Vector math 2D Rotation
A little more complicated
Multiply two of the vector’s coordinates according to a formula
The formula The vector V(x, y) rotated by the
angle ALPHA
x’ = x*cos(ALPHA) - y*sin(ALPHA)
y’ = x*sin(ALPHA) + y*cos(ALPHA)
The resulting vector is V’(x’, y’)12
Vector math 2D Rotation
Positive angle, counter-clockwise rotation
Negative angle, clockwise rotation
13
Vector math Vector length
Calculated with the Pythagorean theorem The vector’s x and y
components are perpendicular
The vector’s length is:length = sqrt (x*x + y*y) Where sqrt is the square root
14
Vector math Unit vector
A unit vector is a vector with a length of 1
A unit vector multiplied by a number has length equal to the number
‘Converting’ a vector to a unit vector Called Normalization
Get the length of the vector
Divide the vector by it’s length15
Vector mathLive Demo
Programming geometry
Point classes, functions, operators
Programming geometry We need
A class describing a point/vector
Operators for vector addition, multiplication
A rotation method
A normalization method
A length calculation method
18
Programming geometryLive Demo
форум програмиране, форум уеб дизайнкурсове и уроци по програмиране, уеб дизайн – безплатно
програмиране за деца – безплатни курсове и уроцибезплатен SEO курс - оптимизация за търсачки
уроци по уеб дизайн, HTML, CSS, JavaScript, Photoshop
уроци по програмиране и уеб дизайн за ученициASP.NET MVC курс – HTML, SQL, C#, .NET, ASP.NET MVC
безплатен курс "Разработка на софтуер в cloud среда"
BG Coder - онлайн състезателна система - online judge
курсове и уроци по програмиране, книги – безплатно от Наков
безплатен курс "Качествен програмен код"
алго академия – състезателно програмиране, състезания
ASP.NET курс - уеб програмиране, бази данни, C#, .NET, ASP.NETкурсове и уроци по програмиране – Телерик академия
курс мобилни приложения с iPhone, Android, WP7, PhoneGap
free C# book, безплатна книга C#, книга Java, книга C#Дончо Минков - сайт за програмиранеНиколай Костов - блог за програмиранеC# курс, програмиране, безплатно
?
? ? ??
?? ?
?
?
?
??
?
?
? ?
Questions?
?
Computational geometry
http://academy.telerik.com/
Free Trainings @ Telerik Academy
3D Graphics and Game Development
academy.telerik.com/.../3d-game-development-opengl
Telerik Software Academy academy.telerik.com
Telerik Academy @ Facebook facebook.com/TelerikAcademy
Telerik Software Academy Forums forums.academy.telerik.com