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):
a⋅b=axbx+ayby+azbz
In 2D: a⋅b=axbx+ayby
Geometric Interpretation
The dot product also equals:
a⋅b=∣a∣∣b∣cos(θ)
where θ is the angle between the vectors.
This formula connects:
Algebraic definition (multiply components)
Geometric meaning (angle between vectors)
The equivalence can be proven using the law of cosines. Place a and b tail-to-tail; the third side of the triangle is a−b. Expanding ∣a−b∣2 both algebraically (component-wise) and geometrically (law of cosines) yields the result.
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:
Positive (a⋅b>0): Vectors point in similar directions (θ<90°)
Zero (a⋅b=0): Vectors are perpendicular (θ=90°)
Negative (a⋅b<0): Vectors point in opposite directions (θ>90°)
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)
Link 2 pointing at L2=(22,22)≈(0.707,0.707) (at 45° from link 1)
To find the angle between them:
cos(θ)=∣L1∣∣L2∣L1⋅L2=1×10.707≈0.707
θ=arccos(0.707)≈45°
Computing Angles
We can rearrange the geometric formula to find angles:
θ=arccos(∣a∣∣b∣a⋅b)
This is crucial in robotics for:
Measuring joint angles
Checking if the robot is at a desired configuration
Collision detection
Path planning
Numerical Stability
When implementing this, ensure ∣a∣∣b∣a⋅b stays in [−1,1] to avoid arccos errors. Floating-point math can sometimes give values slightly outside this range!
Vector Projection
The projection of a onto b is the “shadow” of a along b‘s direction:
projba=∣b∣2a⋅bb
The projection has magnitude:
∣projba∣=∣b∣∣a⋅b∣=∣a∣∣cos(θ)∣
Force Analysis on Robot Gripper Robotics Application
A robot gripper exerts force F=(5,3) N on an object. The surface normal is n=(1,0).
The force component perpendicular to the surface:
F⊥=projnF=12(5,3)⋅(1,0)(1,0)=(5,0) N
This is the “squeezing” force. The remaining (0,3) N is the tangential (sliding) force.
Properties of the Dot Product
Commutative: a⋅b=b⋅a
Distributive: a⋅(b+c)=a⋅b+a⋅c
Scalar multiplication: (ka)⋅b=k(a⋅b)
Self dot product: a⋅a=∣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=∣sensor∣∣to_target∣sensor⋅to_target
If close to 1, sensor is well-aligned.
3. Field-of-View Check
Determine if a target point is within a sensor’s operational cone by comparing the direction to the target against the sensor’s boresight vector. If the dot product (normalized) exceeds a threshold, the target is within the field of view.
4. Obstacle Avoidance
Compute the component of velocity toward an obstacle:
vtoward=vrobot⋅n^to_obstacle
If positive, robot is approaching the obstacle.
Mobile Robot Navigation Robotics Application
A robot at (0,0) moving with velocity v=(1,1) m/s detects an obstacle at (3,0).
Direction to obstacle: d=(3,0)−(0,0)=(3,0)
Unit vector: d^=(1,0)
Velocity toward obstacle: v⋅d^=(1,1)⋅(1,0)=1 m/s
The robot is approaching at 1 m/s. Time to collision: 1 m/s3 m=3 seconds.
Key Takeaways
Dot product measures how aligned two vectors are
Use it to compute angles: θ=arccos(∣a∣∣b∣a⋅b)
Projection gives the component of one vector along another
Critical for joint angle computation, force analysis, and navigation
Perpendicular vectors have dot product zero
Practice Problems
Calculate a⋅b for a=(3,4) and b=(2,1).
Find the angle between (1,0) and (1,1).
Two robot links form vectors (2,1) and (−1,3). What’s the angle between them?
Project a=(4,3) onto b=(1,0). What’s the magnitude of the projection?
A force (10,5) N acts on a surface with normal (0,1). What’s the perpendicular component?
Answers
a⋅b=(3)(2)+(4)(1)=6+4=∗∗10∗∗
cosθ=1⋅2(1)(1)+(0)(1)=21≈0.707. So θ=arccos(0.707)=∗∗45°∗∗