Upcoming SlideShare
×

# 7. Computational Geometry - 3D Graphics and Game Development Course

2,028 views

Published on

In this presentation, part of the 3D graphics and game develpment course, we discuss the vector math, the analytic geometry and the programming geometry at all.
Main topics:
The website and all video materials are in Bulgarian

Published in: Education, Technology
1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
2,028
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
52
0
Likes
1
Embeds 0
No embeds

No notes for slide

### 7. Computational Geometry - 3D Graphics and Game Development Course

1. 1. Computational Geometry Vectors, Translation, RotationGeorge GeorgievTechnical TrainerGeorge AtanasovFront-End Developerhttp://academy.telerik.com
2. 2. Table of Contents Analytic geometry  Vectors and Points Vector math  Addition / Translation  Subtraction  Multiplication / Scaling  2D Rotation  Vector length Programming it 2
3. 3. Analytic geometry The math
4. 4. Analytic geometry Also called Cartesian geometry  Coordinate system Applies algebraic principles to geometry  Algebra  Analysis 4
5. 5. Analytic geometry Points (vertices)  Represented by coordinates  2D – (X, Y);  3D – (X, Y, Z);  Etc..  Points are locations in space 5
6. 6. Analytic geometry Points  Example – A (3, 2); H (-1.5, 3); 6
7. 7. 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
8. 8. Analytic geometryA Point A vector to the point 8
9. 9. Vector math Its easy
10. 10. 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
11. 11. 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
12. 12. 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
13. 13. Vector math 2D Rotation  Positive angle, counter-clockwise rotation  Negative angle, clockwise rotation 13
14. 14. 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
15. 15. 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 length 15
16. 16. Vector math Live Demo
17. 17. Programming geometry Point classes, functions, operators
18. 18. 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
19. 19. Programming geometry Live Demo
20. 20. Computational geometry курсове и уроци по програмиране, уеб дизайн – безплатно BG Coder - онлайн състезателна система - online judge курсове и уроци по програмиране – Телерик академия форум програмиране, форум уеб дизайн уроци по програмиране и уеб дизайн за ученици ASP.NET курс - уеб програмиране, бази данни, C#, .NET, ASP.NET http://academy.telerik.com/ програмиране за деца – безплатни курсове и уроци ASP.NET MVC курс – HTML, SQL, C#, .NET, ASP.NET MVC безплатен SEO курс - оптимизация за търсачки алго академия – състезателно програмиране, състезаниякурсове и уроци по програмиране, книги – безплатно от Наков курс мобилни приложения с iPhone, Android, WP7, PhoneGap уроци по уеб дизайн, HTML, CSS, JavaScript, Photoshop Дончо Минков - сайт за програмиране free C# book, безплатна книга C#, книга Java, книга C# Николай Костов - блог за програмиране безплатен курс "Качествен програмен код" безплатен курс "Разработка на софтуер в cloud среда" C# курс, програмиране, безплатно