# What is Dot Product?

I am doing this Blenderguru tutorial on Making Fire and at some point he is adding the Vector Math node Dot Product to his material. And he says that he does not understand what he is doing but this seems the way how to do it (he is creating the material for a sphere that is used in the particle system). Now I realise that I have applied this Dot Product for a number of times and to be honest... I also don't know what I am doing. I googled and found some complicated math about scalar products and it is too long ago for me that I did that kind of stuff on university. Can someone explain in "noob language" what Dot Product does in Blender?

Vector: A list of values that are all contained under the same "roof" so to speak. For instance, the location of an object in 3D space is a vector of 3 values (the $X$, $Y$ and $Z$ location of that object).

All Vectors in blender are by definition lists of 3 values, since that's the most common and useful type in a 3D program, but in math a vector can have any number of values.

Dot Product: The dot product of two vectors is the sum of multiplications of each pair of corresponding elements from both vectors. Example:

\begin{aligned} \vec{V_1} &= (1,2,5)\\ \vec{V_2} &= (2,1,3)\\ \vec{V_1} \cdot \vec{V_2} &= {V_{1}}_{x}{V_{2}}_{x}+{V_{1}}_{y}{V_{2}}_{y} +{V_{1}}_{z}{V_{2}}_{z}\\ &= 1\cdot2+2\cdot1+5\cdot 3\\ &= 2 + 2 + 15 = 19 \end{aligned}

The particle velocity example: In your original question, we see a dot product of the particle velocity with itself. The velocity is an XYZ vector since it has components in all 3 axes.

In a smoke or fire simulation, some particles are going right ($+X$), some left ($-X$), some forward ($+Y$), some backward ($-Y$), but almost all are going up ($+Z$). The velocity data reflects this. If a particle is going straight up, its velocity will be, for instance, $(0,0,1)$. If it's going left, forward and up, its velocity can be something like $(-1,1,1)$.

When you calculate a dot product of the velocity with itself, you cancel out the negative values (negative values multiplied with themselves become positive), so this is a quick way to convert the velocity gradient over all particles from a 3D XYZ gradient to a mostly 2D gradient along the Z axis. And now the velocity's dot product with itself: Another Example: Parametric Geometry Input Node: The Cycles Input --> Geometry node's Parametric option that's used here, generates a Vector (RGB) value for each point on the object's surface (image above). Each color channel's at each point has a value between 0 and 1.

If you calculate the sum of each point's RGB values ($R+G+B$), you'll get a single (scalar) value (top image in the figure below) that ranges between 0 (R=0,G=0,B=0) and 3 (R=1,G=1,B=1).

This is the same as the dot product of each RGB value and a Vector of $(1,1,1)$ (2nd Image in the figure below). And eventually, if you calculate the dot product of the parametric RGB with itself, you essentially multiply each color with itself ($RR + BB + GG$) in each surface point (3rd Image in the figure above).

In this case it darkens the image significantly, because any value below 1 that's multiplied with itself produced a smaller number/value.

The dot product of two vectors measures two things:

• how much are they "in the same direction" ?
• how large are they?

Skipping the precise definition, we're usually interested in these properties:

1. Vectors with the "same-ish" direction will have a positive product, a null one if they're orthogonal, and negative if they are in opposite directions
2. If you double any vector, you double the product (if you double both, the product gets 4x larger)
3. The product of a vector with itself depends only on its length (since it has the same direction as itself)
4. If you see one of the two as a reference (say, an axis), then the product is how much does the other vector progress along this axis.

Speaking in terms of colors, the RGB vector can be very loosely interpreted as follows: the direction is the shade of color, and the length is the brightness. Now all the rest applies as with regular geometry vectors.

The dot product is a way of multiplying two vectors that produces a scalar (i.e. real number) value.

## Geometric Definition

The dot product of vectors $\vec{V}$ and $\vec{U}$ can be thought of as multiplying $\vert\vert \vec{V}\vert\vert$ (the magnitude of $\vec{V}$) by the component of $\vec{U}$ that is parallel to $\vec{V}$. Notice how the vector $\vec{U}$ is split up into two perpendicular components, so that one is parallel to $\vec{V}$ ($U_{\vert\vert}$) and one is perpendicular to $\vec{V}$ ($U_\perp$). The dot product of $\vec{U}$ and $\vec{V}$ is defined to be $\vert\vert\vec{V}\vert\vert \vec{U}_{\vert\vert}$.

Here's a graphic showing how the dot product changes with respect to the relative angle between the two vectors, the red line represents $\vec{U}_{\vert\vert}$. Notice what this means practically. If $\vec{U}$ is parallel to $\vec{V}$ the dot product is simply $\vert\vert \vec{U} \vert\vert \cdot \vert\vert \vec{V}\vert\vert$, if $\vec{U}$ is perpendicular to $\vec{V}$ the dot product is 0, and if $\vec{U}$ is pointing away from $\vec{V}$ (i.e. the angle between $\vec{U}$ and $\vec{V}$ is > 90°) then the dot product will be a negative number. So essentially you are measuring how close the two vectors are to each other with respect to their directions.

## Algebraic Definition

With some simple geometric trig and the aforementioned geometric explanation you can find the dot product to be equal to $\vert\vert \vec{U} \vert\vert \cdot \vert\vert \vec{V}\vert\vert \cos{\theta}$ where $\theta$ is the angle between the two vectors. If you know the $x$ and $y$ components of the two vectors the dot product is equal to $\vec{V}_x \vec{U}_x + \vec{V}_y \vec{U}_y$, but I won't go into the derivation of that here.

In the case of the tutorial you are referencing, what Andrew is doing in his is equivalent to just squaring the magnitude of the velocity vector. This both makes negative values positive and creates a quadratic falloff curve.

• If whoever downvoted sees this I'd like to know why so I can improve. Feb 23 '16 at 20:33
• That's a great answer @PGmath. Someone also downvoted mine, might be a serial voting troll :) Feb 23 '16 at 22:20
• @JanScherders The rep doesn't really bother me that much, I just want to know what I can improve. (Glad you appreciate the 2 hours I spent making that graphic!) Feb 23 '16 at 23:14
• @PGmath Thanks for the drawings. I think I'll use them in my lectures.
– Miz
Feb 24 '16 at 7:15
• This is perfectly correct but assumes too much prior knowledge. How is anyone who has no prior knowledge of vectors supposed to know what the 'magnitude of a vector' is or what a 'component of a vector' is? (After all, the OP did specifically ask for '"noob" language') PS: I didn't downvote, but I didn't upvote either. Feb 24 '16 at 11:18