Mathematical Foundations for Computer Graphics: Geometry, Trigonometry, and Equations

Slide Note
Embed
Share

This lecture covers essential mathematical tools for computer graphics, including 2D and 3D geometry, trigonometry, vector spaces, points, vectors, coordinates, linear transforms, matrices, complex numbers, and slope-intercept line equations. The content delves into concepts like angles, trigonometric functions, parametric line equations in 2D and 3D, and provides a brief yet detailed review of mathematical foundations crucial for understanding computer graphics.


Uploaded on Aug 23, 2024 | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. CSE 411 Computer Graphics Lecture #2 Mathematical Foundations Prepared & Presented by Asst. Prof. Dr. Samsun M. BA ARICI

  2. Objectives HB Appendix A Brief, informal review of some of the mathematical tools Geometry (2D, 3D) Trigonometry Vector spaces Points, vectors, and coordinates Dot and cross products Linear transforms and matrices Complex numbers Mathematical Foundations 2

  3. 2D Geometry Remember high school geometry: Total angle around a circle is 360 or 2 radians When two lines cross: Opposite angles are equivalent Angles along line sum to 180 Similar triangles: All corresponding angles are equivalent Mathematical Foundations 3

  4. Trigonometry Sine: opposite over hypotenuse Cosine: adjacent over hypotenuse Tangent: opposite over adjacent Unit circle definitions: sin ( ) = y cos ( ) = x tan ( ) = y/x (x, y) Etc Mathematical Foundations 4

  5. Slope-intercept Line Equation Slope: = ( m y - y ) / (x - x ) 1 1 = (y - y ) / (x - x ) 2 1 2 1 Solve for y: y P = ( ) x , y 2 2 2 = [( + ) ( )] y y - y / x - x x 2 - 1 -y 2 ( 1 P = (x, y ) + [ ( ) )] y / x - x x y 2 1 2 1 1 1 P = ( , ) x y or: y = mx + b 1 1 1 x Mathematical Foundations 5

  6. 2D-Parametric Line Equation P = P = ( , ) ( , ) x y x y Given points and 2 2 2 1 1 1 = + ( ) x x u x x 1 2 1 y = + ( ) y y u y 1 2 1 y P = ( , ) x y When: 2 2 2 ( , 2y ) 1y x ( x u=0, we get 1 P = ( , ) x y 1 1 1 , ) u=1, we get 2 (0<u<1), we get points on the segment between and ) , ( 1 x x ( , ) 1y x 2y 2 6 Mathematical Foundations

  7. 3D-Parametric Line Equation Given points P = P = ( , , ), ( , , ) x y z x y z 1 1 1 1 2 2 2 2 = + x x u ( x x ) 1 2 1 = + y y u ( y y ) 1 2 1 = + z z z ( u z ) y 1 2 1 2= P x ( , y z , 2 ) When: 2 2 x ( x ( , , y z , 1 z , y 2 ) u=0, we get 1 1 1= P x ( , y z , 1 ) ) u=1, we get 1 1 2 2 (0<u<1), we get points on the segment between and ) z , y , x ( 1 1 1 x x ( , y z , 2 ) 2 2 Mathematical Foundations 7

  8. Other helpful formulas 2 2 + Length = ( ) ( ) x x y y 2 1 2 1 Midpoint between y and : 3 P P P 2 1 + 2 + 2 x x y = 1 3 1 3 , P 2 Two lines perpendicular if: = / 1 m m 1 2 Cosine of the angle between them is 0. Mathematical Foundations 8

  9. Coordinate Systems 2D systems Cartesian system Polar coordinates 3D systems Cartesian system 1) Right-handed 2) Left handed Curvilinear systems Cylindiric system Spherical system Mathematical Foundations 9

  10. Coordinate Systems (cont.) 2D Cartesian and polar systems y-axis x=r cos( ) y=r sin( ) (x,y) (r, ) (x, y) y x-axis x Right triangle with: hypotenuse r , sides x and y , an interior angle . Relationship between polar and Cartesian coordinates Mathematical Foundations 10

  11. Cartesian screen-coordinate positions Referenced with respect to the lower-left screen corner (a) and the upper-left screen corner (b). Mathematical Foundations 11

  12. Polar-coordinate reference frame Formed with concentric circles and radial lines Mathematical Foundations 12

  13. Radian An angle subtended by a circular arc of length s and radius r Mathematical Foundations 13

  14. Coordinate Systems (3D) 3D Cartesian system lGrasp z-axis with hand lRoll fingers from positive x-axis towards positive y-axis lThumb points in direction of z-axis Y Y Z X X Right-handed coordinate system Left-handed coordinate system Mathematical Foundations 14 Z

  15. Point in 3D (right handed) Coordinate representation for a point P at position (x, y, z) in a standard right- handed Cartesian reference system. Mathematical Foundations 15

  16. Point in 3D (left handed) Left-handed Cartesian coordinate system superimposed on the surface of a video monitor Mathematical Foundations 16

  17. General curvilinear-coordinate reference frame Mathematical Foundations 17

  18. Cylindrical coordinates. , , and z Mathematical Foundations 18

  19. Spherical coordinates r, , and Mathematical Foundations 19

  20. Solid Angle A solid angle subtended by a spherical surface patch with area A and radius r Mathematical Foundations 20

  21. Coordinates for a point position P Mathematical Foundations 21

  22. Points Points support these operations: Point-point subtraction: P2 P1= v =(x2-x1, y2-y1) Result is a vector pointing fromP1toP2 Vector-point addition: Result is a new point Note that the addition of two points is not defined P + v = Q P2=(x2, y2) v P1=(x2, y2) Mathematical Foundations 22

  23. Vectors We commonly use vectors to represent: Points in space (i.e., location) Displacements from point to point Direction (i.e., orientation) 23 Mathematical Foundations

  24. Vector Spaces Two types of elements: Scalars (real numbers): a, b, g, d, Vectors (n-tuples):u, v, w, Operations: Addition Subtraction Dot Product Cross Product Norm Mathematical Foundations 24

  25. Vector Addition/Subtraction operation u + v, with: Identity 0 v + 0 = v v + (-v) = 0 Inverse - Vectors are arrows rooted at the origin Addition uses the parallelogram rule : y u+v y v u v x u -v u-v x Mathematical Foundations 25

  26. Scalar Multiplication Scalar multiplication: a(u + v) = a(u) + a(v) (a + b)u = au + bu Distributive rule: Scalar multiplication streches a vector, changing its length (magnitude) but not its direction Mathematical Foundations 26

  27. Dot Product The dot product or, more generally, inner product of two vectors is a scalar: v1 v2 = x1x2 + y1y2 + z1z2 (in 3D) Norm of a vector Computing the length (Euclidean Norm) of a vector: length(v) = ||v|| = sqrt(v v) Normalizing a vector, making it unit-length: v = v / ||v|| Computing the angle between two vectors: u v = ||u|| ||v|| cos( ) Checking two vectors for orthogonality u v = 0 u Mathematical Foundations 27

  28. Dot Product? u=(2,4) =45o v=(3,1) (0,0) Mathematical Foundations 28

  29. Dot Product Projecting one vector onto another If v is a unit vector and we have another vector, w We can project w perpendicularly onto v w v u And the result,u, has length w v = u w cos( ) v w = w v w ( Mathematical Foundations 29 = v w

  30. Dot Product Example: w=(2,4), v=(1,0) w=(2,4) = u w v = + 2 1 4 0 = 2 (0,0) u v=(1,0) Mathematical Foundations 30

  31. Dot Product Is commutative u v = v u Is distributive with respect to addition u (v + w) = u v + u w 31 Mathematical Foundations

  32. Cross Product The cross product or vector product of two vectors is a vector: = v v u v v sin( ), 0 1 2 1 2 where u is a unit vector that is prependicular to both v1 and v2. Mathematical Foundations 32

  33. Cross Product The cross product or vector product of two vectors can be expressed as: v = v y ( z z y , z x x z , x y y x ) 1 2 1 2 1 2 1 2 1 2 1 2 1 2 The cross product of two vectors is orthogonal to both Right-hand rule dictates direction of cross product Mathematical Foundations 33

  34. Cross Product The direction for u is determined by the right- hand rule. We grasp an axis that is prependicular to the plain containing v1 and v2so that the fingers of the right hand curl from v1 to v2. Vector u is then in the direction of the right hand thumb. Mathematical Foundations 34

  35. Cross Product v v 1 2 2 v u 1 v The cross product of two vectors is a vector in a direction prependicular to the two original vectors and with a magnitude equal to the area of the shaded parallelogram Mathematical Foundations 35

  36. Cross Product v v 1 2 2 v 1 v 2 v 1 v v v 2 1 Mathematical Foundations 36

  37. Cross Product Example v1=(3 2 5) v2=(7 11 13) v = ) 7 v 2 ( 13 5 11 , 5 7 3 13 , 3 11 2 1 2 = ( 29 4 19 ) 37 Mathematical Foundations

  38. Cross Product: Properties The cross product of any two parallel vectors is 0. The cross product is not commutative, it is anticommutative, i. e. = v v v v ( ) 1 2 2 1 The cross product is not associative, i. e. v v v v v v ( ) ( ) 1 2 3 1 2 3 The cross product is distributive, that is + = + + v v v v Mathematical Foundations v v v ( ) ( ) ( ) 1 2 3 1 2 1 3 38

  39. Finding a unit normal to a plane Find a unit normal to the plane containing the points A(-1, 0,1), B(2, 3, -1), C(1, 4, 2) = = v CB ( , 1 , 1 ) 3 C 1 = = A v AB ( , 3 + ) 2 , 3 2 = + ) 3 + v v 2 ( = , 9 9 , 2 3 1 2 B 11 ( , , 7 ) 6 N Mathematical Foundations 39

  40. Triangle Arithmetic b Consider a triangle, (a, b, c) a,b,c = (x,y,z) tuples a c Surface area = sa = * ||(b a) X (c-a)|| Unit normal = (1/2sa) * (b-a) X (c-a) Mathematical Foundations 40

  41. Vector Spaces A linear combination of vectors results in a new vector: v= a1v1 + a2v2+ + anvn If the only set of scalars such that a1v1 + a2v2+ + anvn = 0 is a1 = a2= = a3 = 0 then we say the vectors are linearly independent The dimension of a space is the greatest number of linearly independent vectors possible in a vector set For a vector space of dimension n, any set of n linearly independent vectors form a basis Mathematical Foundations 41

  42. Vector Spaces: Basis Vectors Given a basis for a vector space: Each vector in the space is a unique linear combination of the basis vectors The coordinates of a vector are the scalars from this linear combination If basis vectors are orthogonal and unit length: Vectors comprise orthonormal basis Best-known example: Cartesian coordinates Note that a given vector v will have different coordinates for different bases Mathematical Foundations 42

  43. Matrices Matrix addition Matrix multiplication Matrix transpose Determinant of a matrix Matrix inverse Mathematical Foundations 43

  44. Complex numbers A complex number z is an ordered pair of real numbers z = x+iy z = (x,y), x = Re(z), y = Im(z) Addition, substraction and scalar multiplication of complex numbers are carried out using the same rules as for two-dimensional vectors. Multiplication is defined as (x1 , y1)(x2, y2) = (x1x2 y1y2 , x1y2+ x2y1) Mathematical Foundations 44

  45. Complex numbers(cont.) Real numbers can be represented as x = (x, 0) It follows that (x1 , 0 )(x2 , 0) = (x1x2,0) i = (0, 1) is called the imaginary unit. We note that i2= (0, 1) (0, 1) = (-1, 0). Mathematical Foundations 45

  46. Complex numbers (cont.) Real and imaginary components for a point z in the complex plane. Mathematical Foundations 46

  47. Complex numbers(cont.) Using the rule for complex addition, we can write any complex number as the sum z = (x,0) + (0, y) = x + iy which is the usual form used in practical applications. Mathematical Foundations 47

  48. Complex numbers(cont.) The complex conjugate is defined as z = x -iy Modulus or absolute value of a complex number is |z| = z z = (x2+y2) Division of of complex numbers: ~ z z z z 1 1 2 = ~ z z 2 1 2 Mathematical Foundations 48

  49. Complex numbers(cont.) Polar coordinate representation = + z rCos riSin + = Cos ( ) r iSin i = re Mathematical Foundations 49

  50. Complex numbers (cont.) Polar-coordinate parameters in the complex plane Mathematical Foundations 50

Related