Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computational Geometry

Similar presentations


Presentation on theme: "Computational Geometry"— Presentation transcript:

1 Computational Geometry
Vectors, Translation, Rotation George Georgiev Telerik Corporation

2 Table of Contents Analytic geometry Vector math Programming it
Vectors and Points Vector math Addition / Translation Subtraction Multiplication / Scaling 2D Rotation Vector length Programming it

3 Analytic geometry The math

4 Analytic geometry Also called Cartesian geometry
Coordinate system Applies algebraic principles to geometry Algebra Analysis

5 Analytic geometry Points (vertices) Represented by coordinates
2D – (X, Y); 3D – (X, Y, Z); Etc.. Points are locations in space

6 Analytic geometry Points Example – A (3, 2); H (-1.5, 3);

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)

8 Analytic geometry A Point A vector to the point

9 Vector math It's easy

10 Vector math Addition Subtraction
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)

11 Vector math Multiplication By a number Called uniform scaling
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)

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’)

13 Vector math 2D Rotation Positive angle, counter-clockwise rotation
Negative angle, clockwise rotation

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

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

16 * Vector math Live Demo (c) 2008 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

17 Point classes, functions, operators
Programming geometry Point classes, functions, operators

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

19 Programming geometry Live Demo *
(c) 2008 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

20 Computational geometry
? ? ? ? ? Questions? ? ? ? ? ? ?


Download ppt "Computational Geometry"

Similar presentations


Ads by Google