Basic Geometry
Vectors operations Some Linear Algebra Addition + 2 =( 1 + 2, 1 + 2, 1 + 2 ) =(,, ) + Scalar multiplication λ =(λ,λ,λ ) Norm = 2 + 2 + 2 2
Scalar Product Commutative Linear Orthogonally Norm Some Linear Algebra Orthonormality Normalized vector = 1 2 + 1 2 + 1 2 = ( + ) = + =0 = =1 = =(,, ) 3
Some Linear Algebra Linear Transformation - Matrix Multiplication Do not Commute = =1 Matrix Transpose ( ) = ( ) = Matrix Inverse 1 = 1 = ( ) 1 = 1 1 4
Determinants If A is a 2 x 2 matrix then det( )= det(a) = area of parallelogram defined by (a,c) and (b,d) General determinate is defined recursively by minors minors are computed by eliminating the row and column of an entry and computing the determinant on the residue. Few reminders n i j nxn = ij ( 1) + ij j= 1 A a M = = 1 = 1 = 5
Cross products The cross product of two vectors V 1 and V 2 is defined (in determinant form) 1 2 = 1 1 1 2 2 2 1 2 = 1 1 sin( ) Meanings The area of the parallelogram that is defined by V 1 and V 2 The direction of the normal to the plane that is determined by V 1 and V 2 A vector which is orthogonal to both V 1 and V 2 6
Cross Product Properties 1 2 = 2 1 V 1 x V 2 Reverse the direction. V 2 1 2 = 1 1 sin ( ) α V 1 V 2 x V 1 = -V 1 x V 2 7
Right and Left Coordinate Systems Question: What is a positive angle of rotation around an axis specified by a vector? Answer: Align your thumb with the vector. Your other fingers indicate the direction of a positive rotation. Definition: A three-dimensional left (right) coordinate system is such that the positive rotation direction around the Z axis using the left (right) thumb rotates X towards Y. A three-dimensional left coordinate system. A three-dimensional right coordinate system. X Z Z Y X 8 Y
Model Coordinate System World Coordinate System View Coordinate System Projection Transform Screen Coordinate System Coordinate Systems 9
Model and World Coordinate Systems The model coordinate system is the coordinate system where the object is defined (modeled) Customarily, objects are modeled around the center of axes Why? The world coordinate system is the global coordinate system where all the object reside To move objects from one coordinates system to the other we apply transformations on the object Multiply the vertices of a polygonal object by a proper [4X4] matrix Modeling Transform Demo 10
View Coordinate System Coordinate system that is centered on the camera All objects in a scene are either in positive (in front of the camera) or negative (behind) Z Positions the viewing volume in the world. After multiplying objects by the viewing matrix, these objects are transformed from the world coordinate system to the view (camera) coordinate system 11
Projection Transform & screen coordinates The location where a 3D object is projected onto a 2D plane (image). There are several options there will be discussed during the lectures Usually it is preferred to consider normalized projected space where the projection transform maps to [-1,1]X[-1,1] square After the projection transform took place, the object is not yet in device coordinate systems. These are the integer values 12
The complete pipeline For every vertex V in a polygonal model apply M, the concatenated matrix which contain all the transformations. M = a e i m b f j n c g l o d a' h e' l i' p m' b' f ' j' n' c' g' k' o' d' a'' h' e'' l' i'' p' m'' b'' f '' j'' n'' c'' g'' k'' o'' d'' a` h'' e` l'' i` p'' m` b` f ` j` n` c` g` k` o` d` h` l` p` Modeling Matrix Viewing Matrix Projection Matrix Screen Matrix V ' = V M 13
Line equations What are the available forms Explicit form Implicit form Parametric form ( )= + (, )= + + =0 ( )=(1 ) 1 + 2 2 1 14
Point-Line Distance = 1 2 =(1 ) 1 + 2 = 1 2 1 2 1 2 = 1 2 = 1 2 2 1 2 15
Line-Line Distance ( )=(1 ) 1 + 2 ( )=(1 ) 1 + 2 2 2 The distance between f(t) and g(s) is (, )= ( ) ( ) Minimize (Why and how?) 2 (, ) min (, )= ( 1 1 ) ( 2 1 ) ( 2 1 ) ( 2 1 ) ( 2 1 ) 1 1 What about segment-segment? Need to check end points seperately 16
The distance is Point-Plane Distance + + + =0 =( 0, 0, 0 ) =(,, ) = = 0+ 0 + 0 + 2 + 2 + 2 17
Collision Detection 18
Collision Detection Check if and when moving object will collide Physical simulations Video games Computational geometry Needs to be efficient and accurate Real time Not a stable problem Simpler problem - Collision of Static Primitives Check if two primitives are intersecting Much easier Answer is only yes/no Simple geometry 19
Example Line-Line Intersection 2 2 1 1 1( )=(1 ) 1+ 2, 2( )=(1 ) 1+ 2 Find r,t such that 1 ( )=(1 ) 1 + 2,=(1 ) 1 + 2 = 2 ( ) Two (why?) linear equations with two variables Question: What is the meaning of r,t < 0 or r,t >1? 20
Example Line-Sphere intersection The sphere equation is given by (, 0 )= ( 0 ) 2 +( 0 ) 2 +( 0 ) 2 = 2 Solve a quadratic system of equation If solution exists, there is an intersection Is there a simpler way? Find distance from line to center of sphere If it is less than R, there is an intersection 0 21
Linear Operators Definition: A linear operator, L:A B, satisfies the following: L(aX+bY) = al(x) + bl(y) Examples Differentiation D(h(x)) = h (x) D( af( x) + bg( x) ) = D af( x) + D bg x ( ) ( ( )) ( ( )) bd( g( x) ) = ad f x + Scaling S(h(x)) = sh(x) S = = ( af ( x) + bg( x) ) = s( af ( x) + bg( x) ) asf ( x) + bsg( x) as( f( x) ) + bs( g( x) ) Question: Is F(X) = αx+β a linear operation? 22
Answer: No!! F ( a X + b Y ) Linear Operators (cont). = α ( a X + b Y ) + β = α ( a X ) + α ( b Y ) + β = a α X + b α Y + β = a ( α X + β ) + b ( α Y + β ) + (1 a b ) β = a F ( X ) + b F ( Y ) + (1 a b ) β Definition: An affine operator, A, satisfies: A(aX+bY) = aa(x) + ba(y), for a+b = 1 Question: Is F(X) = αx+β an affine operation? 23
Convexity An object ϑ is convex iff for any two points P,Q ϑ, tp+(1-t)q ϑ, t [0,1]. ϑ tp+ ( 1 t)q P Q The convex hull CH(ϑ), of an object ϑ, is the minimal convex shape C, such that ϑ C. Let P i n i= 1 be n points, and let n, i= 1 n a i= 1 i = 1, a i We say that P= n a P is an affine combination of i= 1 i i n P CH P. For n= 2, P P P. i i= 1 1 2 a i C C=CH(ϑ) 0. P i n. i= 1 24 ϑ
Curves Let C(t)=[x(t),y(t)] t [T 0,T 1 ] be a continuous univariate parametric curve. The tangent vector is T=C (t): T dc( t) = C t = = dt ( ) x ( t), y ( t) [ ] The unit length tangent vector is T C( t) C(t) may be thought of as the trajectory of a point in time. C (t) is the velocity vector at time t. = C ( t) = [ x ( t), y ( t) ] x ( t) 2 + y ( t) 2 dc T = dt ( t) 25