Module 1: Foundations Lesson 2 of 3

Dot Product & Projections

The dot product (also called scalar product) is one of the most important operations in robotics. It tells us how much two vectors point in the same direction and is essential for computing angles between robot links.

What is the Dot Product?

The dot product of two vectors produces a scalar (single number):

ab=axbx+ayby+azbz\vec{a} \cdot \vec{b} = a_x b_x + a_y b_y + a_z b_z

In 2D: ab=axbx+ayby\vec{a} \cdot \vec{b} = a_x b_x + a_y b_y

Geometric Interpretation

The dot product also equals:

ab=abcos(θ)\vec{a} \cdot \vec{b} = |\vec{a}||\vec{b}|\cos(\theta)

where θ\theta is the angle between the vectors.

This formula connects:

Interactive Exploration

Adjust the vectors to see how the dot product changes with direction and magnitude:

Controls

Vector a (blue)

3.000
-55
1.000
-55

Vector b (green)

1.000
-55
2.000
-55

Dot Product Results

a · b = 5.000
|a| = 3.162
|b| = 2.236
θ = 45.00° (0.785 rad)
cos(θ) = 0.707
Verification:
|a||b|cos(θ) = 5.000
Projection of a onto b:
proj = (1.000, 2.000)
|proj| = 2.236

Interpretation: The dot product measures how much two vectors point in the same direction. When perpendicular (90°), the dot product is 0. The projection (orange) shows the "shadow" of vector a onto vector b.

Understanding the Result

The sign of the dot product tells us about the angle:

Key Insight

The dot product measures alignment. Maximum when parallel, zero when perpendicular, negative when opposing.

Robot Arm Joint Angle Robotics Application

A 2-link robot arm has:

  • Link 1 pointing at L1=(1,0)\vec{L}_1 = (1, 0)
  • Link 2 pointing at L2=(0.7,0.7)\vec{L}_2 = (0.7, 0.7) (at 45° from link 1)

To find the angle between them:

cos(θ)=L1L2L1L2=0.71×1=0.7\cos(\theta) = \frac{\vec{L}_1 \cdot \vec{L}_2}{|\vec{L}_1||\vec{L}_2|} = \frac{0.7}{1 \times 1} = 0.7

θ=arccos(0.7)45°\theta = \arccos(0.7) \approx 45°

Computing Angles

We can rearrange the geometric formula to find angles:

θ=arccos(abab)\theta = \arccos\left(\frac{\vec{a} \cdot \vec{b}}{|\vec{a}||\vec{b}|}\right)

This is crucial in robotics for:

Numerical Stability

When implementing this, ensure abab\frac{\vec{a} \cdot \vec{b}}{|\vec{a}||\vec{b}|} stays in [1,1][-1, 1] to avoid arccos errors. Floating-point math can sometimes give values slightly outside this range!

Vector Projection

The projection of a\vec{a} onto b\vec{b} is the “shadow” of a\vec{a} along b\vec{b}‘s direction:

projba=abb2b\text{proj}_{\vec{b}}\vec{a} = \frac{\vec{a} \cdot \vec{b}}{|\vec{b}|^2}\vec{b}

The projection has magnitude:

projba=abb=acos(θ)|\text{proj}_{\vec{b}}\vec{a}| = \frac{|\vec{a} \cdot \vec{b}|}{|\vec{b}|} = |\vec{a}||\cos(\theta)|

Force Analysis on Robot Gripper Robotics Application

A robot gripper exerts force F=(5,3)\vec{F} = (5, 3) N on an object. The surface normal is n=(1,0)\vec{n} = (1, 0).

The force component perpendicular to the surface:

F=projnF=(5,3)(1,0)12(1,0)=(5,0) NF_{\perp} = \text{proj}_{\vec{n}}\vec{F} = \frac{(5, 3) \cdot (1, 0)}{1^2}(1, 0) = (5, 0) \text{ N}

This is the “squeezing” force. The remaining (0,3)(0, 3) N is the tangential (sliding) force.

Properties of the Dot Product

  1. Commutative: ab=ba\vec{a} \cdot \vec{b} = \vec{b} \cdot \vec{a}
  2. Distributive: a(b+c)=ab+ac\vec{a} \cdot (\vec{b} + \vec{c}) = \vec{a} \cdot \vec{b} + \vec{a} \cdot \vec{c}
  3. Scalar multiplication: (ka)b=k(ab)(k\vec{a}) \cdot \vec{b} = k(\vec{a} \cdot \vec{b})
  4. Self dot product: aa=a2\vec{a} \cdot \vec{a} = |\vec{a}|^2

Robotics Applications

1. Forward Kinematics Verification

Check if computed end-effector position matches expected direction.

2. Sensor Alignment

Determine if a sensor is pointing toward a target:

alignment=sensorto_targetsensorto_target\text{alignment} = \frac{\vec{sensor} \cdot \vec{to\_target}}{|\vec{sensor}||\vec{to\_target}|}

If close to 1, sensor is well-aligned.

3. Workspace Analysis

Check if a point is within the robot’s reachable workspace by comparing direction vectors.

4. Obstacle Avoidance

Compute the component of velocity toward an obstacle:

vtoward=vrobotn^to_obstaclev_{toward} = \vec{v}_{robot} \cdot \hat{n}_{to\_obstacle}

If positive, robot is approaching the obstacle.

Mobile Robot Navigation Robotics Application

A robot at (0,0)(0, 0) moving with velocity v=(1,1)\vec{v} = (1, 1) m/s detects an obstacle at (3,0)(3, 0).

Direction to obstacle: d=(3,0)(0,0)=(3,0)\vec{d} = (3, 0) - (0, 0) = (3, 0)

Unit vector: d^=(1,0)\hat{d} = (1, 0)

Velocity toward obstacle: vd^=(1,1)(1,0)=1\vec{v} \cdot \hat{d} = (1, 1) \cdot (1, 0) = 1 m/s

The robot is approaching at 1 m/s. Time to collision: 3 m1 m/s=3\frac{3 \text{ m}}{1 \text{ m/s}} = 3 seconds.

Key Takeaways

Practice Problems

  1. Calculate ab\vec{a} \cdot \vec{b} for a=(3,4)\vec{a} = (3, 4) and b=(2,1)\vec{b} = (2, 1).

  2. Find the angle between (1,0)(1, 0) and (1,1)(1, 1).

  3. Two robot links form vectors (2,1)(2, 1) and (1,3)(-1, 3). What’s the angle between them?

  4. Project a=(4,3)\vec{a} = (4, 3) onto b=(1,0)\vec{b} = (1, 0). What’s the magnitude of the projection?

  5. A force (10,5)(10, 5) N acts on a surface with normal (0,1)(0, 1). What’s the perpendicular component?

Coming Up Next

The cross product takes two vectors and produces a third vector perpendicular to both. This is essential for computing torques in robot manipulators!