Vectors
Vectors
💡 TABLE OF CONTENTS
Introduction to Vectors
Magnitude and Direction of a Vector
Zero Vector
Unit Vector
Operations on Vectors
Addition of Vectors
Subtractions of Vectors
Normalization of a Vector
Scalar (or Dot) Product Of Two Vectors
Things to remember -
Vector (or Cross) Product of Two Vectors
Useful Properties of Unit Vectors
More Resources
Stay in Touch
Could you do me a favour?
Want this pdf as a Notion Template? Get the template now and customize it
as much as you want. Here is the link -
https://knightcube.gumroad.com/l/knightcube-notes-vectors-pdf
Introduction to Vectors
💡 Vectors are defined by n-tuples of real numbers, where n equals 2,3 or 4. Simply put —
n-vector is a list of n numbers. Programmers can think of it as an array.
Vectors can be used to store locations but locations are not vectors. For instance, you
can add 2 vectors but it does not make sense to add 2 locations.
Sold to
Vectors 1
[email protected]
Note that there is no arrow on top of the components V1 , V2 , V3 . This is because the components
of a vector are scalar quantities.
Therefore,
P = ⟨Px , Py , Pz ⟩ (2)
The same can be represented as a matrix having a single column and n rows like so 👇
⎡ V1 ⎤
V2
.
V = (3)
.
.
⎣Vn ⎦
n
∣V ∣ = ∑ Vi 2 (5)
i=1
Vectors 2
So for a 3 dimensional vector 👇
P the magnitude will be calculated as follows
∣P ∣ = Px 2 + Py 2 + Pz 2 (6)
Zero Vector
A vector with the magnitude of 0 is called a zero vector. That is,
∣V ∣ = 0
Unit Vector
A vector with the magnitude of 1 is called a unit vector. That is,
∣V ∣ = 1
Operations on Vectors
Addition of Vectors
To add two vectors, we simply add the corresponding components like so -
⎡ P1 ⎤ ⎡ Q1 ⎤ ⎡ P1 + Q1 ⎤
P2 Q2 P2 + Q2
. . .
. + . = . (7)
. . .
+ Qn−1
⎣ Pn ⎦ ⎣ Qn ⎦ ⎣ Pn + Qn ⎦
Pn−1 Qn−1 Pn−1
Subtractions of Vectors
Subtracting is same as adding the negative, i.e P − Q = P + (−Q)
Therefore,
⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎛ ⎡ ⎤⎞ ⎡ ⎤
Vectors 3
⎡ P1 ⎤ ⎡ Q1 ⎤ ⎡ P1 ⎤ ⎛ ⎡ Q1 ⎤⎞ ⎡ P1 − Q1 ⎤
P2 Q2 P2 Q2 P2 − Q2
. . . . .
. − . = . + − . = . (8)
. . . . .
− Qn−1
⎣ Pn ⎦ ⎣ Qn ⎦ ⎣ Pn ⎦ ⎝ ⎣ Qn ⎦⎠ ⎣ Pn − Qn ⎦
Pn−1 Qn−1 Pn−1 Qn−1 Pn−1
Things to remember
2. Vector addition is commutative, but vector subtraction is not. This means that
P + Q = Q + P but P − Q =
P − Q . Rather P − Q = −( Q − P )
Normalization of a Vector
Often times, you will face a situation where you need to know the direction in which a 3D object is
facing in your game or 3D world space. Note that we are concerned only with the direction and
not the magnitude. This is when you should think of normalization immediately.
In order to normalize a non zero vector, we simply divide the vector by its magnitude. Like this👇
V
V norm = (9)
∣V ∣
Vectors 4
n
P . Q = ∑ Pi Qi (11)
i=1
Equation 1.9 means that the dot product of 2 vectors is given by the sum of the products of each
component. Therefore in 3 dimensions, we have 👇
⟹ P . Q = Px Qx + Py Qy + Pz Qz (12)
⎡ P1 ⎤ ⎡ Q1 ⎤
P2 Q2
P3 Q3
. .
. = P1 Q1 + P2 Q2 + ⋯ + Pn−1 Qn−1 + Pn Qn (13)
. .
. .
⎣ Pn ⎦ ⎣ Qn ⎦
Pn−1 Qn−1
Things to remember -
1. The dot product of 2 vectors is a scalar quantity.
a. P is a zero vector
b. Q is a zero vector
c. P ⊥Q
💡 Vectors whose dot product yields zero are called orthogonal vectors.
2 2
3. The square of a vector is equal to the square of its modulus i.e ( P ) = ∣P ∣
Vectors 5
used in computer graphics to calculate a surface normal at a particular point given 2 distinct
tangent vectors. It is denoted as P × Q (read as P vector “cross” Q vector).
Given two 3D vectors P and Q , the cross product P × Q satisfies the following equation 👇
∣ P × Q ∣ = ∣P ∣ ∣Q∣ sin α (14)
where α is the planar angle between the lines connecting the origin to the points represented by
P and Q .
where i, j and k (read as i “cap”, j “cap” and k “cap”) are unit vectors parallel to the x, y and z
axes.
∣ i j k∣
Px Py Pz = i(Py Qz − Pz Qy ) − j (Px Qz − Pz Qx ) + k (Px Qy − Py Qx )
Q
∣ x Qy Qz ∣
For two scalars a and b, and any three 3D vectors P , Q and R , the following properties hold 👇
Vectors 6
1. Q × P = −( P × Q )
2. (a P ) × Q = a ( P × Q )
3. P × (Q + R ) = P × Q + P × R
4. P ×P =0
5. (P × Q) . R = ( R × P ) . Q = (Q × R ) . P
2
6. P × (Q × P ) = P × Q × P = P Q − (P .Q) P
More Resources
100+ AR/VR Resources Pack - Get here
💡 My 100+ AR/VR Resources Pack has got over 180+ downloads from more than
30+ countries all over the world. Save yourself 1000+ hours of research on AR/VR.
💡 My first ebook 🎉
where I talk about some of the design principles behind creating
Augmented Reality experiences. You can get it for 40% off. Use the code -
“supporter” at checkout.
Vectors 7
FREE AR/VR Project Case Studies Checklist - Get here
💡 Get this free checklist where I deep dive into writing case studies for your AR/VR
projects 😉
How to write AR/VR Project Case Studies? (checklist - Notion)
Do you find writing case studies for your AR/VR projects tedious or
don't know how to write one?Then you will find this FREE checklist
helpful. After talking to a few recruiters in the AR/VR industry, I got to
https://knightcube.gumroad.com/l/arvr-project-case-studies
Stay in Touch
Send me a 👋 on Twitter!
Connect with me on LinkedIn
Watch my videos on YouTube 🎥 - I talk about Three.js, AR/VR, Blender and 3D stuff. 🎥
Could you do me a favour?
Could you please give a 5 ⭐ rating on Gumroad? Click here to do so. I want to continue
creating more content like this for 3D enthusiasts like you.
Vectors 8