960 likes | 1.15k Views
COS 397 Computer Graphics. Svetla Boytcheva AUBG, Spring 2013. Lecture 2 Ray Tracing & Transformations. Outline. Points and Vectors Matrices Vector Operations Ray Tracing Homogenous coordinates Affine Transformations Translation Rotation Scaling Projection View Point
E N D
COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013
Outline • Points and Vectors • Matrices • Vector Operations • Ray Tracing • Homogenous coordinates • Affine Transformations • Translation • Rotation • Scaling • Projection • View Point • Coordinates of objects on the surface of other objects
Points and Vectors • Drawing systems of particles • Determining coordinates of other objects • Drawing objects
Points and Vectors • Points • (x,y,z) • Representation • Absolute coordinates (point) • Relative coordinate (radius-vector) • Distance (vector) • Direction (vector)
Points in 3D • 3D absolute coordinates X P(x,y,z) x y Y z Z
Radius-vector • Relative coordinate (radius-vector) (0,0,0) X x P(x,y,z) y Y z Z
Length and Magnitude • Calculating the length/magnitude • Requires reference point R |p| X R Y z x y Z
Direction • Determines the direction in 3D • This is not sufficient for complete orientation X |p| Y Z
Vectors representation • Vectors (points) • Vector defined by points X1and X2
Examples • Vector p(5,2,3) • Vectorq from point (3,0,8) to (0,2,7)
P2 y2 V y1 P1 x1 x2 Points and Vectors • Point • Vector: Pointposition and direction • Magnitude- Direction
Length • Vector p length • Unit vector • Vector with length=1
Examples • Vectorp(5,2,3) • Vectorp from (3,0,8) to (0,2,7)
Addition and Subtraction • Vector can be added or subtracted only to other vector
Examples • Addition of p(5,2,3) andq(-1,-1,1) • Subtraction of q(-1,-1,1) and r(4,1,4)
Product • Various product operations • Product with scalar (i.e. vector and number) • Scalar product of vectors • Vector product of vectors • Three of them are used in Computer Graphics for important operations
Product with scalar • Product with number • Geometrical meaning • Scaling (extending, shortening) vector • Preserves the direction for k>0 • Reverses direction when k<0 (the opposite direction)
Examples • Doubled vector p(5,2,3) • Reversed vector q(-1,-1,1)
Unit Vector • Unit vector • Geometrical meaning • Vector with length = 1 • Preserves the direction • Can be applied only over non-zero vectors
Examples • Unit vector of p(5,2,3) • Check
Scalar Product • Product of two vectors, the result is scalar (number) • Angle between two vectors • Geometrical/Graphical meaning • Checking for perpendicularity • Lightening of surface • Calculating the area
p.q calculating • Using unit axis vectors X p Y ey ex ez Z
Multiply Remember that Find
Examples (2,2,0).(0,1,0) • Lucky method • Lying in the same plane • Angle between = 45о • First class method • "First class" in terms of quality • but also because it may be applied by first grader student
Example • Check whether the vectors are perpendicular • p(4,0,1)and q(-2,3,8) • Solution
V2 V1 |V2|cos Scalar Product • Definition • For Cartesian Reference Frame • Properties • Commutative • Distributive Dot Product, Inner Product
Vector product • Vector product and the result is vector • Anglebetween two vectors • Geometrical meaning • Finding normal vectors • Parallelogram Area
V1 V2 V2 u V1 Where vector points on? • The Result vector of Vector product is: • Perpendicular to the plane defined by to vector in this product • Lies in the plane where the direction of rotation from the first to the second vector is positive (i. e. counterclockwise)
How to remember? • Use right hand • Coordinate system PQRis right-hand Снимка: FreeDigitalPhotos.net
Unit Vectors X X + - + - Z Z Y Y ey ey ex ex ez ez + -
Calculation of pхq • Using unit axis vectors
V1 V2 V2 u V1 Vector Product Cross Product, Outer Product • Definition • For Cartesian Reference Frame • Properties • AntiCommutative • Not Associative • Distributive
Scalar Product Vector Product Examples (x2,y2) V2 (x1,y1) V1 (x0,y0) Angle between Two Edges Normal Vector of the Plane
Determinant of Matrix • Definition • For a square matrix, combining the matrix elements to product a single number • 2 2 matrix • Determinant of nn Matrix A (n 2)
Inverse Matrix • Definition • Non-singular matrix • If and only if the determinant of the matrix is non-zero • 2 2 matrix • Properties
Geometric Transformation • Definition • Translation, Rotation, Scaling • Motivation – Why do we need geometric transformations in CG? • As a viewing aid • As a modeling tool • As an image manipulation tool
Example: 2D Geometric Transformation Modeling Coordinates World Coordinates
Example: 2D Scaling Modeling Coordinates Scale(0.3, 0.3) World Coordinates
Example: 2D Rotation Modeling Coordinates Scale(0.3, 0.3) Rotate(-90) World Coordinates
Example: 2D Translation Modeling Coordinates Scale(0.3, 0.3) Rotate(-90) Translate(5, 3) World Coordinates
Example: 2D Geometric Transformation Modeling Coordinates Again? World Coordinates
Example: 2D Geometric Transformation Modeling Coordinates Scale Translate Scale Rotate Translate World Coordinates
Basic 2D Transformations • Translation • Scale • Rotation • Shear
Basic 2D Transformations • Translation • Scale • Rotation • Shear Transformations can be combined (with simple algebra)