# Intuition behind using dot product to find component of vector in direction of another

I'm reading Chris Hecker's third article on rigid body dynamics http://chrishecker.com/Rigid_body_dynamics

Quoting...

"More importantly, if our collision detector supplies us with a 'normal vector' for the collision (denoted by n, and pointing toward body A by convention), we can define the 'relative normal velocity' as the component of the relative velocity in the direction of the collision normal."

Which he defines as vAB . n where vab is the relative velocity of points A and B and n is the normal vector for the collision.

I read Understanding Dot and Cross Product which explains that the dot product gives the length of one vector in the direction of another, which I think is what is being applied here, but I'm having a really hard time visualizing what is going on, specifically what the component is.

Can anyone help explain what this component is and how using the dot product helps identify it?

-
This Wikipedia article might help. – Jonas Meyer Jun 14 '11 at 5:45

If you have vectors ${\bf x}$ and ${\bf y}$, you can write ${\bf x}={\bf u}+{\bf v}$, where ${\bf u}$ is parallel ("in the direction of") ${\bf y}$ and ${\bf v}$ is perpendicular to ${\bf y}$. Visually, drop a perpendicular from ${\bf x}$ onto ${\bf y}$ (first extending $\bf y$, if necessary), then that perpendicular is $\bf v$ and the vector from the origin to the foot of the perpendicular is $\bf u$.
Now from ${\bf x}={\bf u}+{\bf v}$ you get ${\bf x}\cdot{\bf u}={\bf u}\cdot{\bf u}+{\bf u}\cdot{\bf v}$. Now ${\bf u}\cdot{\bf v}=0$ since $\bf u$ and $\bf v$ are perpendicular, and ${\bf u}\cdot{\bf u}$ is the square of the length of $\bf u$, so ${\bf x}\cdot{\bf u}=\|{\bf u}\|^2$. That gives you the interpretation of the dot product in terms of the component of one vector in the direction of another.