This article is the first of three parts. Each part stands on its own, so you don’t need to read the others to understand it.
The dot product is one of the most important operations in machine learning – but it’s hard to understand without the right geometric foundations. In this first part, we build those foundations:
· Unit vectors
· Scalar projection
· Vector projection
Whether you are a student learning Linear Algebra for the first time, or want to refresh these concepts, I recommend you read this article.
In fact, we will introduce and explain the dot product in this article, and in the next article, we will explore it in greater depth.
The vector projection section is included as an optional bonus: helpful, but not necessary for understanding the dot product.
The next part explores the dot product in greater depth: its geometric meaning, its relationship to cosine similarity, and why the difference matters.
The final part connects these ideas to two major applications: recommendation systems and NLP.
A vector is called a unit vector if its magnitude is 1:
To remove the magnitude of a non-zero vector while keeping its direction, we can normalize it. Normalization scales the vector by the factor:
The normalized vector is the unit vector in the direction of :
Notation 1. From now on, whenever we normalize a vector , or write , we assume that . This notation, along with the ones that follow, is also relevant to the following articles.
This operation naturally separates a vector into its magnitude and its direction:
Figure 1 illustrates this idea: and point in the same direction, but have different magnitudes.

Similarity of unit vectors
In two dimensions, all unit vectors lie on the unit circle (radius 1, centered at the origin). A unit vector that forms an angle θ with the x-axis has coordinates (cos θ, sin θ).
This means the angle between two unit vectors encodes a natural similarity score - as we will show shortly, this score is exactly cos θ: equal to 1 when they point the same way, 0 when perpendicular, and −1 when opposite.
Notation 2. Throughout this article, θ denotes the smallest angle between the two vectors, so .
In practice, we don’t know θ directly – we know the vectors’ coordinates.
We can show why the dot product of two unit vectors: and equals cos θ using a geometric argument in three steps:
1. Rotate the coordinate system until lies along the x-axis. Rotation doesn’t change angles or magnitudes.
2. Read off the new coordinates. After rotation, has coordinates (1 , 0). Since is a unit vector at angle θ from the x-axis, the unit circle definition gives its coordinates as (cos θ, sin θ).
3. Multiply corresponding components and sum:
This sum of component-wise products is called the dot product:
See the illustration of these three steps in Figure 2 below:

Everything above was shown in 2D, but the same result holds in any number of dimensions. Any two vectors, no matter how many dimensions they live in, always lie in a single flat plane. We can rotate that plane to align with the xy-plane — and from there, the 2D proof applies exactly.
Notation 3. In the diagrams that follow, we often draw one of the vectors (typically ) along the horizontal axis. When is not already aligned with the x-axis, we can always rotate our coordinate system as we did above (the “rotation trick”). Since rotation preserves all lengths, angles, and dot products, every formula derived in this orientation holds for any direction of .
A vector can contribute in many directions at once, but often we care about only one direction.
Scalar projection answers the question: How much of lies along the direction of ?
This value is negative if the projection points in the opposite direction of .
The Shadow Analogy
The most intuitive way to think about scalar projection is as the length of a shadow. Imagine you hold a stick (vector ) at an angle above the ground (the direction of ), and a light source shines straight down from above.
The shadow that the stick casts on the ground is the scalar projection.
The animated figure below illustrates this idea:

The scalar projection measures how much of vector a lies in the direction of b.
It equals the length of the shadow that a casts onto b (Woo, 2023). The GIF was created by Claude
Calculation
Imagine a light source shining straight down onto the line PS (the direction of ). The “shadow” that (the arrow from P to Q ) casts onto that line is exactly the segment PR. You can see this in Figure 4.

Deriving the formula
Now look at the triangle : the perpendicular drop from creates a right triangle, and its sides are:
- (the hypotenuse).
- (the adjacent side – the shadow).
- (the opposite side – the perpendicular component).
From this triangle:
- The angle between and is θ.
- (the most basic definition of cosine).
- Multiply both sides by :
The Segment is the shadow length – the scalar projection of on .
When θ > 90°, the scalar projection becomes negative too. Think of the shadow as flipping to the opposite side.
How is the unit vector related?
The shadow’s length (PR) doesn’t depend on how long is. It depends on and on θ.
When you compute , you are asking: how much of lies along direction? This is the shadow length.
The unit vector acts like a direction filter: multiplying by it extracts the component of along that direction.
Let’s see it using the rotation trick. We place b̂ along the x-axis:
and:
Then:
The scalar projection of in the direction of is:
We apply the same rotation trick one more time, now with two general vectors: and .
After rotation:
,
so:
The dot product of and is:
Vector projection extracts the portion of vector that points along the direction of vector .
The Trail Analogy
Imagine two trails starting from the same point (the origin):
- Trail A leads to a whale-watching spot.
- Trail B leads along the coast in a different direction.
Here’s the question projection answers:
You’re only allowed to walk along Trail B. How far should you walk so that you end up as close as possible to the endpoint of Trail A?
You walk along B, and at some point, you stop. From where you stopped, you look toward the end of Trail A, and the line connecting you to it forms a perfect 90° angle with Trail B. That’s the key geometric fact – the closest point is always where you’d make a right-angle turn.
The spot where you stop on Trail B is the projection of A onto B. It represents “the part of A that goes in B’s direction.
The remaining gap - from your stopping point to the actual end of Trail A – is everything about A that has nothing to do with B’s direction. This example is illustrated in Figure 5 below: The vector that starts at the origin, points along Trail B, and ends at the closest point –is the vector projection of onto .

Walking along trail B, the closest point to the endpoint of A occurs where the connecting segment forms a right angle with B. This point is the projection of A onto B. Image by Author (created using Claude)..
Scalar projection answers: “How far did you walk?”
That’s just a distance, a single number.
Vector projection answers: “Where exactly are you?”
More precisely: “What is the actual movement along Trail B that gets you to that closest point?”
Now “1.5 kilometers” isn’t enough, you need to say “1.5 kilometers east along the coast.” That’s a distance plus a direction: an arrow, not just a number. The arrow starts at the origin, points along Trail B, and ends at the closest point.
The distance you walked is the scalar projection value. The magnitude of the vector projection equals the absolute value of the scalar projection.
Unit vector answers : “Which direction does Trail B go?”
It is exactly what represents. It’s Trail B stripped of any length information - just the pure direction of the coast.
I know the whale analog is very specific; it was inspired by this good explanation (Michael.P, 2014)
Figure 6 below shows the same shadow diagram as in Figure 4, with PR drawn as an arrow, because the vector projection is a vector (with both length and direction), not just a number.

Unlike scalar projection (a length), the vector projection is an arrow along vector b. Image by Author (created using Claude).
Since the projection must lie along , we need two things for :
- Its magnitude is the scalar projection:
- Its direction is: (the direction of )
Any vector equals its magnitude times its direction (as we saw in the Unit Vector section), so:
This is already the vector projection formula. We can rewrite it by substituting , and recognizing that
The vector projection of in the direction of is:
- A unit vector isolates a vector’s direction by stripping away its magnitude.
- The dot product multiplies corresponding components and sums them. It is also equal to the product of the magnitudes of the two vectors multiplied by the cosine of the angle between them.
- Scalar projection uses the dot product to measure how far one vector reaches along another’s direction - a single number, like the length of a shadow
- Vector projection goes one step further, returning an actual arrow along that direction: the scalar projection times the unit vector.
In the next part, we will use the tools we learned in this article to truly understand the dot product.
The post The Geometry Behind the Dot Product: Unit Vectors, Projections, and Intuition first appeared on TechToday.
This post originally appeared on TechToday.
