Vectors Jeff Chastine.

Slides:



Advertisements
Similar presentations
Fun with Vectors. Definition A vector is a quantity that has both magnitude and direction Examples?
Advertisements

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.
VECTORS Computer Graphics. A REVIEW OF VECTORS:  Scalar Quantity  Vector Quantity  2D vectors  Graphical Representation of Vectors  Magnitude of.
Chapter 4.1 Mathematical Concepts
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
CS 4731: Computer Graphics Lecture 6: Points, Scalars and Vectors Emmanuel Agu.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Chapter 7 Bits of Vector Calculus. (1) Vector Magnitude and Direction Consider the vector to the right. We could determine the magnitude by determining.
Basic Math Vectors and Scalars Addition/Subtraction of Vectors Unit Vectors Dot Product.
Computer Graphics using OpenGL, 3 rd Edition F. S. Hill, Jr. and S. Kelley Chapter Vector Tools for Graphics.
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.
Vectors and Scalars Vector and scalar quantities Adding vectors geometrically Components Unit Vectors Dot Products Cross Products pps by C Gliniewicz.
Scalar and Vector Fields
24. Dot Product of Vectors. What you’ll learn about  How to find the Dot Product  How to find the Angle Between Vectors  Projecting One Vector onto.
VECTORS AND THE GEOMETRY OF SPACE 12. VECTORS AND THE GEOMETRY OF SPACE So far, we have added two vectors and multiplied a vector by a scalar.
Chapter 3. Vector 1. Adding Vectors Geometrically
Multiplication with Vectors
Vectors. Definitions Scalar – magnitude only Vector – magnitude and direction I am traveling at 65 mph – speed is a scalar. It has magnitude but no direction.
Vectors Jeff Chastine.
Chapter 4.1 Mathematical Concepts
Vectors and the Geometry of Space
Chapter 3 : Vectors - Introduction - Addition of Vectors - Subtraction of Vectors - Scalar Multiplication of Vectors - Components of Vectors - Magnitude.
CSCE 552 Spring 2011 Math By Jijun Tang. Layered.
Mathematics for Graphics. 1 Objectives Introduce the elements of geometry  Scalars  Vectors  Points Develop mathematical operations among them in a.
Section 10.2a VECTORS IN THE PLANE. Vectors in the Plane Some quantities only have magnitude, and are called scalars … Examples? Some quantities have.
Statistics and Linear Algebra (the real thing). Vector A vector is a rectangular arrangement of number in several rows and one column. A vector is denoted.
Higher Mathematics Unit 3.1 Vectors 1. Introduction A vector is a quantity with both magnitude and direction. It can be represented using a direct.
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.
CGDD 4003 THE MATH LECTURE (BOILED DOWN, YET LIGHTLY SALTED)
DOT PRODUCT CROSS PRODUCT APPLICATIONS
1 Graphics CSCI 343, Fall 2015 Lecture 9 Geometric Objects.
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
1.4 Trigonometry. Sine, Cosine, and Tangent Pythagorean Theorem.
 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.
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.
Computer Graphics Mathematical Fundamentals Lecture 10 Taqdees A. Siddiqi
Linear Algebra Review Tuesday, September 7, 2010.
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.
WHAT’S YOUR VECTOR VICTOR???. Scalar Multiplication Multiplying a vector by a scalar will ONLY CHANGE its magnitude. Thus if A = 12 < 105, Then 2A = 24.
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.
Vectors. Reviewing Vectors Vectors are defined as physical quantities that have both magnitude (numerical value associated with its size) and direction.
CHAPTER 3 VECTORS NHAA/IMK/UNIMAP.
Vectors for Calculus-Based Physics
Vectors AP Physics C.
Linear Algebra Review.
12-1 Organizing Data Using Matrices
Mathematics for Computer Graphics
Vectors and Scalars AP Physics.
Chapter 1 Vectors.
Vectors Objective Students will be able to use basic vector operations to solve problems.
Scalars and Vectors.
Vectors for Calculus-Based Physics
Lecture 03: Linear Algebra
COMP 175: Computer Graphics February 9, 2016
Multiplying Vectors - Dot and Cross Products -
Chapter 3 Vectors In Physics we have parameters that can be completely described by a number and are known as “scalars” .Temperature, and.
12.3 The Dot Product.
Physics 133 Electromagnetism
Vectors and Scalars AP Physics C.
Vectors for Calculus-Based Physics
Vectors - It’s What’s for Dinner
Chapter 3 Vectors In Physics we have parameters that can be completely described by a number and are known as “scalars” .Temperature, and.
Methods of Finding Vector Sum
Chapter 3 Vectors In physics we have parameters that can be completely described by a number and are known as scalars. Temperature and mass are such parameters.
Game Programming Algorithms and Techniques
CHAPTER 3 VECTORS NHAA/IMK/UNIMAP.
Math with Vectors I. Math Operations with Vectors.
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