Vectors Jeff Chastine.

Slides:



Advertisements
Similar presentations
Points, Vectors, Lines, Spheres and Matrices
Advertisements

TRANSLATIONS AIM: To understand translation vectors and translate shapes accurately.
Fun with Vectors. Definition A vector is a quantity that has both magnitude and direction Examples?
1 3D Vector & Matrix Chapter 2. 2 Vector Definition: Vector is a line segment that has the direction. The length of the line segment is called the magnitude.
Vector Refresher Part 4 Vector Cross Product Definition Vector Cross Product Definition Right Hand Rule Right Hand Rule Cross Product Calculation Cross.
VECTORS Computer Graphics. A REVIEW OF VECTORS:  Scalar Quantity  Vector Quantity  2D vectors  Graphical Representation of Vectors  Magnitude of.
Jinxiang Chai CSCE441: Computer Graphics Coordinate & Composite Transformations 0.
Chapter 4.1 Mathematical Concepts
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
3-D Geometry.
Computer Graphics CSC 630 Lecture 2- Linear Algebra.
MSU CSE 803 Fall 2008 Stockman1 CV: 3D sensing and calibration Coordinate system changes; perspective transformation; Stereo and structured light.
Linear Algebra Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
PHYS 218 sec Review Chap. 1. Caution This presentation is to help you understand the contents of the textbook. Do not rely on this review for.
LIGHTING JEFF CHASTINE 1. WHAT IS LIGHT? A very complex process Find a dark area – how is it being lit? Light bounces (mirrors, shiny objects) Light refracts.
Geometric Intuition Randy Gaul. Vectors, Points and Basis Matrices Rotation Matrices Dot product and how it’s useful Cross product and how it’s useful.
CSE 381 – Advanced Game Programming 3D Mathematics
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
CS 3388 Working with 3D Vectors
Chapter 4.1 Mathematical Concepts
COMP 175: Computer Graphics March 24, 2015
Section 13.4 The Cross Product. Torque Torque is a measure of how much a force acting on an object causes that object to rotate –The object rotates around.
And an introduction to matrices COORDINATE SYSTEMS JEFF CHASTINE 1.
Mathematics for Graphics. 1 Objectives Introduce the elements of geometry  Scalars  Vectors  Points Develop mathematical operations among them in a.
 Transformations Describe the single transformation that will map triangle A onto each of the triangles B to J in turn.
Warm Up 1. Reflect the preimage using y=x as the line of reflection given the following coordinates: A(-2, 4), B(-4, -2), C(-5, 6) 2. Rotate the figure.
Vectors Day 2. Scalar Multiplication A vector can be multiplied by a real number Multiplying a vector by a positive number changes its size, but not its.
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
Matthew Christian. About Me Introduction to Linear Algebra Vectors Matrices Quaternions Links.
CGDD 4003 THE MATH LECTURE (BOILED DOWN, YET LIGHTLY SALTED)
Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization.
Matrices A matrix is an array of numbers, the size of which is described by its dimensions: An n x m matrix has n rows and m columns Eg write down the.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Geometric Transformations
DOT PRODUCT CROSS PRODUCT APPLICATIONS
Honours Graphics 2008 Session 2. Today’s focus Vectors, matrices and associated math Transformations and concatenation 3D space.
CMPS 1371 Introduction to Computing for Engineers VECTORS.
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
 An image is the new figure, and the preimage is the original figure  Transformations-move or change a figure in some way to produce an image.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
CSE 681 Brief Review: Vectors. CSE 681 Vectors Basics Normalizing a vector => unit vector Dot product Cross product Reflection vector Parametric form.
 A vector is a mathematical object that has both magnitude (size) and direction  Students will be able to use basic vector operations and the dot product.
Jinxiang Chai CSCE441: Computer Graphics Coordinate & Composite Transformations 0.
Computer Graphics Lecture 11 2D Transformations I Taqdees A. Siddiqi
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry "Old Henry And His Old Aunt" Defined using right triangle  x y h.
Graphics Graphics Korea University kucg.korea.ac.kr Geometric Primitives 고려대학교 컴퓨터 그래픽스 연구실.
YEAR 11 MATHS REVISION Transformations.
CSE 681 Brief Review: Vectors. CSE 681 Vectors Direction in space Normalizing a vector => unit vector Dot product Cross product Parametric form of a line.
Warm up 1.) (3, 2, -4), (-1, 0, -7) Find the vector in standard position and find the magnitude of the vector.
Math Fundamentals Maths revisit.
and an introduction to matrices
Graphics Fundamentals
LESSON 90 – DISTANCES IN 3 SPACE
Chapter 1 Vectors.
Vectors Objective Students will be able to use basic vector operations to solve problems.
Vectors Jeff Chastine.
Scalars and Vectors.
Multiplying Vectors - Dot and Cross Products -
Warm-Up Graph the image of the polygon with vertices A(0,2), B(-2,-3), C(2, -3) after a dilation centered at the origin with a scale factor of 2.
Chapter 3 Vectors In Physics we have parameters that can be completely described by a number and are known as “scalars” .Temperature, and.
EXAMPLE 5 Use matrix multiplication to reflect a polygon
Viewing and Perspective Transformations
Chapter 3 Vectors In Physics we have parameters that can be completely described by a number and are known as “scalars” .Temperature, and.
CSCE441: Computer Graphics Coordinate & Composite Transformations
ENLARGEMENTS INTRODUCTION ENLARGEMENT Makes a shape bigger or smaller
Game Programming Algorithms and Techniques
Vector and Matrix Algebra
Presentation transcript:

Vectors Jeff Chastine

𝑉𝑒𝑐𝑡𝑜𝑟𝑠 A mathematical structure that has more than one “part” (e.g. an array) 2D vectors might have x and y 3D vectors might have x, y and z 4D vectors might have x, y, z and w Vectors can represent a point in space Vectors commonly represent both: Direction Magnitude Jeff Chastine

𝑉𝑒𝑐𝑡𝑜𝑟𝑠 A vector is often denoted with an arrow above it (e.g. 𝑢 ) Row representation [x, y, z] (multiple columns) 15 −4 3 Column vector has multiple rows Vectors will be used in lighting equations 15 −4 3 Jeff Chastine

Example You Man-Bear-Pig How would I describe the 2D difference in location of a player and an enemy? You Man-Bear-Pig Jeff Chastine

Example How would I describe the 2D difference in location of a player and an enemy? (x2, y2) (x1, y1) Jeff Chastine

Example 𝑑𝑖𝑓𝑓 =[ 𝑥 1 − 𝑥 2 , 𝑦 1 − 𝑦 2 ] (x2, y2) (x1, y1) How would I describe the 2D difference in location of a player and an enemy? (x2, y2) (x1, y1) 𝑑𝑖𝑓𝑓 =[ 𝑥 1 − 𝑥 2 , 𝑦 1 − 𝑦 2 ] …or 𝑑𝑖𝑓𝑓=[∆𝑥, ∆𝑦] Note: a very useful 2D function is atan2 (∆y, ∆x) which gives you the angle!

Interpretation (x2, y2) (x1, y1) Magnitude (length) 𝑑𝑖𝑓𝑓 has both magnitude and direction (x2, y2) (x1, y1) Magnitude (length) Jeff Chastine

Interpretation (x2, y2) (x1, y1) (∆x, ∆y) Direction (0, 0) 𝑑𝑖𝑓𝑓 has both magnitude and direction (x2, y2) (x1, y1) (∆x, ∆y) (0, 0) Direction Jeff Chastine

Adding/Subtracting Vectors Do this component-wise Therefore, the vectors must be the same size Adding example 1 3 5 + 10 4 −3 = 11 7 2 Subtraction works the same way + = Jeff Chastine

Multiplication? Multiplying by a scalar (a single number) 6 * 1 3 5 = 6 18 30 What about multiplication? This isn’t really defined, but we do have Dot product Cross product Jeff Chastine

Magnitude and Normalization of Vectors Normalization is a fancy term for saying the vector should be of length 1 Magnitude is just its length and denoted 𝑉 Example for 1 3 5 mag = 𝑥 2 + 𝑦 2 + 𝑧 2 mag = 1 2 + 3 2 + 5 2 = 35 =~5.916079 To normalize the vector, divide each component by its magnitude Example from above 1 3 5 5.916079 = 0.169 0.50709 0.84515 Magnitude of 0.169 0.50709 0.84515 =~1 Jeff Chastine

The Dot Product 𝜃 Also called the inner or scalar product Multiply component-wise, then sum together Denoted using the dot operator 𝑢 ∙ 𝑣 Example 1 2 4 ∙ 8 1 −2 = 1∗8 + 2∗1 + 4∗−2 =2.0 Why is this so cool? If normalized, it’s the cosine of the angle θ between the two vectors! Use acos⁡(𝜃) to “undo” that Basis of almost all lighting calculations! 𝜃 Jeff Chastine

DOT PROduct Example 𝑣 𝜃 𝑢 Assume we have two vectors: 𝑢 = 1 0 0 𝑢 = 1 0 0 𝑣 = 0 1 0 These vectors are already normalized We expect the angle to be 90° Dot product is: 𝑢 ∙ 𝑣 = 1∗0 + 0∗1 + 0∗0 =0 acos 0 =90° 𝑣 𝜃 𝑢 Jeff Chastine

DOT PROduct Example 2 𝜃 𝑣 𝑢 Assume we have two vectors: 𝑢 = 1 0 0 𝑢 = 1 0 0 𝑣 = −1 0 0 We expect the angle to be 180° Dot product is: 𝑢 ∙ 𝑣 = 1∗−1 + 0∗0 + 0∗0 =−1 acos −1 =180° 𝜃 𝑣 𝑢 Jeff Chastine

DOT PROduct Example 3 𝑢 𝑣 Assume we have two vectors: 𝑢 = 1 0 0 𝑢 = 1 0 0 𝑣 = 1 0 0 We expect the angle to be 0° Dot product is: 𝑢 ∙ 𝑣 = 1∗1 + 0∗0 + 0∗0 =1 acos 1 =0° 𝑢 𝑣 Jeff Chastine

Projection 𝑉 𝛼 𝑊 Length of projection is: Can also be used to calculate the projection of one vector onto another 𝑉 𝛼 𝑊 Length of projection is: Then, multiply by normalized 𝑊/ 𝑊 𝑉 cos 𝛼 = 𝑉∙𝑊 𝑉 ∙ 𝑊 𝑝𝑟𝑜𝑗 𝑤 𝑉= 𝑉∙𝑊 𝑊 2 𝑊 Jeff Chastine

CROSS PRODUCT 𝑐 𝑎 𝜃 𝑏 𝑎𝑥 𝑎𝑦 𝑎𝑧 𝑏𝑥 𝑏𝑦 𝑏𝑧 Gives us a new vector that is perpendicular to the other two Denoted with the × operator Calculations: 𝑎 × 𝑏 =[ 𝑎 𝑦 𝑏 𝑧 − 𝑎 𝑧 𝑏 𝑦 𝑎 𝑧 𝑏 𝑥 − 𝑎 𝑥 𝑏 𝑧 𝑎 𝑥 𝑏 𝑦 − 𝑎 𝑦 𝑏 𝑥 ] Interesting: If 𝑎 × 𝑏 = 𝑐 then 𝑏 × 𝑎 =− 𝑐 The magnitude (length) of the new vector is the sine of the angle (if normalized) 𝑎 𝜃 𝑏 𝑎𝑥 𝑎𝑦 𝑎𝑧 𝑏𝑥 𝑏𝑦 𝑏𝑧 Jeff Chastine

CROSS PRODUCT 𝑐 𝑎 𝜃 𝑏 𝑎𝑥 𝑎𝑦 𝑎𝑧 𝑏𝑥 𝑏𝑦 𝑏𝑧 Gives us a new vector that is perpendicular to the other two Denoted with the × operator Calculations: 𝑎 × 𝑏 =[ 𝑎 𝑦 𝑏 𝑧 − 𝑎 𝑧 𝑏 𝑦 𝑎 𝑧 𝑏 𝑥 − 𝑎 𝑥 𝑏 𝑧 𝑎 𝑥 𝑏 𝑦 − 𝑎 𝑦 𝑏 𝑥 ] Interesting: If 𝑎 × 𝑏 = 𝑐 then 𝑏 × 𝑎 =− 𝑐 The magnitude (length) of the new vector is the sine of the angle (if normalized) 𝑎 𝜃 𝑏 𝑎𝑥 𝑎𝑦 𝑎𝑧 𝑏𝑥 𝑏𝑦 𝑏𝑧 Jeff Chastine

CROSS PRODUCT 𝑐 𝑎 𝜃 𝑏 𝑎𝑥 𝑎𝑦 𝑎𝑧 𝑏𝑥 𝑏𝑦 𝑏𝑧 Gives us a new vector that is perpendicular to the other two Denoted with the × operator Calculations: 𝑎 × 𝑏 =[ 𝑎 𝑦 𝑏 𝑧 − 𝑎 𝑧 𝑏 𝑦 𝑎 𝑧 𝑏 𝑥 − 𝑎 𝑥 𝑏 𝑧 𝑎 𝑥 𝑏 𝑦 − 𝑎 𝑦 𝑏 𝑥 ] Interesting: If 𝑎 × 𝑏 = 𝑐 then 𝑏 × 𝑎 =− 𝑐 The magnitude (length) of the new vector is the sine of the angle (if normalized) 𝑎 𝜃 𝑏 𝑎𝑥 𝑎𝑦 𝑎𝑧 𝑏𝑥 𝑏𝑦 𝑏𝑧 Jeff Chastine

CROSS PRODUCT 𝑐 𝑎 𝜃 𝑏 𝑎𝑥 𝑎𝑦 𝑎𝑧 𝑏𝑥 𝑏𝑦 𝑏𝑧 Gives us a new vector that is perpendicular to the other two Denoted with the × operator Calculations: 𝑎 × 𝑏 =[ 𝑎 𝑦 𝑏 𝑧 − 𝑎 𝑧 𝑏 𝑦 𝑎 𝑧 𝑏 𝑥 − 𝑎 𝑥 𝑏 𝑧 𝑎 𝑥 𝑏 𝑦 − 𝑎 𝑦 𝑏 𝑥 ] Interesting: If 𝑎 × 𝑏 = 𝑐 then 𝑏 × 𝑎 =− 𝑐 The magnitude (length) of the new vector is the sine of the angle (if normalized) 𝑎 𝜃 𝑏 𝑎𝑥 𝑎𝑦 𝑎𝑧 𝑏𝑥 𝑏𝑦 𝑏𝑧 Jeff Chastine

Fun Questions How do we find the normal of a triangle? How can we determine if a polygon is facing away from the camera? Jeff Chastine

Fun Questions P0 P1 P2 How do we find the normal of a triangle? How can we determine if a polygon is facing away from the camera? P0 P1 P2 Jeff Chastine

Fun Questions P0 𝑢 𝑣 P1 P2 Make some vectors… How do we find the normal of a triangle? How can we determine if a polygon is facing away from the camera? P0 𝑢 𝑣 P1 P2 Make some vectors… Jeff Chastine

Fun Questions P0 𝑢 𝑣 P1 P2 Make some vectors… How do we find the normal of a triangle? How can we determine if a polygon is facing away from the camera? P0 𝑢 𝑣 P1 P2 Make some vectors… Jeff Chastine

Fun Questions 𝑢 × 𝑣 P0 𝑢 𝑣 P1 P2 Take the cross product How do we find the normal of a triangle? How can we determine if a polygon is facing away from the camera? 𝑢 × 𝑣 P0 𝑢 𝑣 P1 P2 Take the cross product Jeff Chastine

Fun Questions 𝑁 P0 P1 P2 How do we find the normal of a triangle? How can we determine if a polygon is facing away from the camera? 𝑁 P0 P1 P2 Jeff Chastine

Fun Questions 𝑁 P0 P1 P2 How do we find the normal of a triangle? How can we determine if a polygon is facing away from the camera? 𝑁 P0 P1 P2 Jeff Chastine

Fun Questions 𝑁 P0 camera P1 P2 How do we find the normal of a triangle? How can we determine if a polygon is facing away from the camera? 𝑁 P0 camera P1 P2 Jeff Chastine

Fun Questions 𝑁 P0 𝑐𝑎𝑚 camera P1 P2 How do we find the normal of a triangle? How can we determine if a polygon is facing away from the camera? 𝑁 P0 𝑐𝑎𝑚 camera P1 P2 Jeff Chastine

Fun Questions 𝐼𝑓 acos 𝑁∙𝑐𝑎𝑚 <90°, 𝑖 𝑡 ′ 𝑠 𝑣𝑖𝑠𝑖𝑏𝑙𝑒 𝑁 P0 𝑐𝑎𝑚 camera How do we find the normal of a triangle? How can we determine if a polygon is facing away from the camera? 𝐼𝑓 acos 𝑁∙𝑐𝑎𝑚 <90°, 𝑖 𝑡 ′ 𝑠 𝑣𝑖𝑠𝑖𝑏𝑙𝑒 𝑁 P0 𝑐𝑎𝑚 camera P1 P2 Jeff Chastine Assuming 𝑁 and 𝑐𝑎𝑚 are normalized

A final Note Can multiply a matrix and vector to: Rotate the vector Translate the vector Scale the vector Etc.. This operation returns a new vector Jeff Chastine

The End Image of a triangle facing away from the camera Jeff Chastine