1 / 38

Mathematics for Graphics

Mathematics for Graphics. Objectives. Introduce the elements of geometry Scalars Vectors Points Develop mathematical operations among them in a coordinate-free manner Define basic primitives Line segments Polygons. 3D Cartesian co-ordinates. Basic Elements.

nmilligan
Download Presentation

Mathematics for Graphics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Mathematics for Graphics

  2. Objectives • Introduce the elements of geometry • Scalars • Vectors • Points • Develop mathematical operations among them in a coordinate-free manner • Define basic primitives • Line segments • Polygons

  3. 3D Cartesian co-ordinates

  4. Basic Elements • Geometry is the study of the relationships among objects in an n-dimensional space • In computer graphics, we are interested in objects that exist in three dimensions • Want a minimum set of primitives from which we can build more sophisticated objects • We will need three basic elements • Scalars • Vectors • Points

  5. Scalars • Need three basic elements in geometry • Scalars, Vectors, Points • Scalars can be defined as members of sets which can be combined by two operations (addition and multiplication) obeying some fundamental axioms (associativity, commutivity, inverses) • Examples include the real and complex number systems under the ordinary rules with which we are familiar • Scalars alone have no geometric properties

  6. Vectors And Point • We commonly use vectors to represent: • Points in space (i.e., location) • Displacements from point to point • Direction (i.e., orientation) • But we want points and directions to behave differently • Ex: To translatesomething means to move it without changing its orientation • Translation of a point = different point • Translation of a direction = same direction

  7. Vectors • Physical definition: a vector is a quantity with two attributes • Direction • Magnitude • Examples include • Force • Velocity • Directed line segments • Most important example for graphics • Can map to other types v

  8. Y v X 2 2 Z 2 A vector in 3D Vector • A quantity characterized by a magnitude and direction • Can be represented by an arrow, where magnitude is the length of the arrow and the direction is given by slope of the line v = OP = จุดปลาย – จุดต้น = P-O Y P (2, 1) 1 v X 2 O (0, 0) A vector in 2D

  9. Vector Operations • Every vector has an inverse • Same magnitude but points in opposite direction • Every vector can be multiplied by a scalar • There is a zero vector • Zero magnitude, undefined orientation • The sum of any two vectors is a vector • Use head-to-tail axiom w v v v -v u

  10. Vectors Lack Position • These vectors are identical • Same direction and magnitude • Vectors spaces insufficient for geometry • Need points

  11. Vector Addition • Addition of vectors follows the parallelogram law in 2D and the parallelepiped law in higher dimensions:

  12. 1.5v v Vector Multiplication by a Scalar • Multiplication by a scalar scales the vectors length appropriately (but does not affect direction):

  13. Subtraction -v u v -v Inverse vector? Can be seen as an addition of u + (-1v) -v u

  14. 3 5 4 P2 Vector Magnitude v P1 • The magnitude or “norm” of a vector of dimension 3 is given by the standard Euclidean distance metric: • How about dimension n? 2D example 3D example 2

  15. v Unit Vectors • Vectors of length 1 are often termed unit vectors (a.k.a. normalised vectors). • When we only wish to describe direction we use normalised vectors – often to avoid redundancy • For this and other reasons, we often need to normalise a vector: • e.g.

  16. Examples • Suppose point P1(-1,-3) and P2(2,-7). Find • Vector v obtained from these two points • Norm of vector v • Unit vector

  17. Dot Product • Dot product (inner product) is defined as: • Note: • Therefore we can redefine magnitude in terms of the dot-product operator: • The dot product operator is commutative and associative.

  18. q u v Dot Product • The Dot Product can also be obtained from the following equation: where q is the angle between the two vectors • So, if we know the vectors u and v, then thedot product is useful for finding the angle between two vectors. • Note that if we had already normalised the vectors u and v then it would simply be:

  19. Dot Product Examples • Find the angle between vectors { 1, 1, 0} and {0, 1, 0}?

  20. Additional Properties • For any three vectors u, v, w and scalars a, b • uv = vu • u(v+w) = uv + uw • (u+v)w = uw + vw • If uv = 0 then u and v are orthogonal or perpendicular, where u and v are not zero vector

  21. Cross Product • Used for defining orientation and constructing co-ordinate axes. • Cross product defined as: • The result is a vector, perpendicular to the plane defined by u and v: • Magnitude :

  22. Cross Product Right Handed Coordinate System

  23. Cross Product • Cross product is anti-commutative: • It is not associative: • Direction of resulting vector defined by operand order: R.H.S.

  24. Cross Product • Consider, two vectors u = , v = , the cross product u x v

  25. Vector Spaces • A linear combination of vectors results in a new vector: v= a1v1 + a2v2 + … + anvn wherea is any scalar • 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

  26. Coordinate Systems v2 • 3D vector space • scalar component : 1, 2, 3 • basis vector : v1, v2, v3 • define a coordinate system • the origin : fixed reference point • column matrix origin v1 v3 Coordinate System

  27. Points • Location in space • Operations allowed between points and vectors • Point-point subtraction yields a vector • Equivalent to point-vector addition v = P - Q P = v + Q

  28. Affine Spaces • Point + a vector space • Operations • Vector-vector addition • Scalar-vector multiplication • Point-vector addition • Scalar-scalar operations • For any point define • 1 • P = P • 0 • P = 0 (zero vector)

  29. Lines (in Affine Space) • Consider all points of the form • P(a)=P0 + a d • Set of all points that pass through P0 in the direction of the vector d • Affine addition

  30. Parametric Form • This form is known as the parametric form of the line • More robust and general than other forms • Extends to curves and surfaces • Two-dimensional forms • Explicit: y = mx +h • Implicit: ax + by +c =0 • Parametric: x(a) = ax0 + (1-a)x1 y(a) = ay0 + (1-a)y1

  31. Rays and Line Segments • If a >= 0, then P(a) is the ray leaving P0 in the direction d • If we use two points to define v, then P( a) = Q+av = Q + a (R-Q) = aR + (1-a)Q • For 0<=a<=1 we get all the points on the line segment joining R and Q

  32. Convexity • An object is convex iff for any two points in the object all points on the line segment between these points are also in the object P P Q Q not convex convex = concave

  33. Affine Sums • Consider the “sum” P=a1P1+a2P2+…..+anPn Can show by induction that this sum makes sense iff a1+a2+…..an=1 in which case we have the affine sum of the points P1,P2,…..Pn • If, in addition, ai>=0, we have the convex hull of P1,P2,…..Pn

  34. Convex Hull • Smallest convex object containing P1,P2,…..Pn • Formed by “shrink wrapping” points

  35. Curves and Surfaces • Curves are one parameter entities of the form P(a) where the function is nonlinear • Surfaces are formed from two-parameter functions P(a, b) • Linear functions give planes and polygons P(a) P(a, b)

  36. Planes • A plane be determined by a point and two vectors or by three points P R P(a,b)=R+a(Q-R)+b(P-Q) P(a,b)=R+au+bv

  37. Triangles convex sum of P and Q convex sum of S(a) and R for 0<=a,b<=1, we get all points in triangle

  38. Planes R • Extension of line P Q n v P normal to the plane P0 u

More Related