Robot Vectors and the Dot Product: Predicting Motion
See how vector addition predicts where a robot ends up, how normalization gives direction, and how the dot product tells if a target is ahead or behind.

Summary
- A robot's position and movement are represented as vectors, which have both a magnitude and a direction. On a floor, a vector can be written as two numbers, (x, y).
- Before the robot moves, you can use addition to find where it will end up and normalization to extract only the direction of travel. With the dot product, you can also tell whether a target is ahead of the robot, directly to its side, or behind it.
- In the robot simulator Webots, I compared driving leg by leg with driving in a straight line. For both routes, the measured travel distance was within 0.1% of the predicted distance.
"Where will this robot end up?" "How far will it travel?" "Can it turn to face the customer?" These are questions you want answered before you put a transport robot or a serving robot to work on site. You can use vectors to work out where the robot will end up and how far it needs to turn. The distance it travels depends on the route it takes. This article skips the formal proofs and walks through vector addition, normalization, and the dot product in order, using everyday analogies and worked examples. At the end, I share the results of a test in the robot simulator Webots. I also cover how these calculations are likely to be used at Japanese companies in the Philippines.
Representing a Robot's Position and Movement as Vectors
Vector Length and Direction
A vector is a magnitude and a direction combined into one quantity. Something like "50 m to the north" expresses both how far to go and which way to go.
For a robot moving on a floor, a vector can be written as two numbers, (x, y). We'll use the robot's starting position as the origin for the floor examples. The x-axis points in the direction the robot faces at the start, and the y-axis points to its left. These axes stay fixed throughout the example, and positions such as P and Q are expressed in this coordinate system. ROS (Robot Operating System), a software framework widely used in robotics, uses a related convention in its REP 103 standard for axes attached to the robot itself: x points forward, y points left, and z points up.
For example, (0.4, 0.3) is a vector meaning "0.4 m forward and 0.3 m to the left." The length and direction of this vector are calculated as follows.
| What to find | Calculation | Result |
|---|---|---|
| Length (magnitude) | √(0.4 × 0.4 + 0.3 × 0.3) | 0.5 m |
| Direction | atan2(0.3, 0.4) | About 36.87 degrees |
The length is found with the Pythagorean theorem, and the direction with atan2(y, x), which returns the angle measured from the forward direction. The detailed steps are explained in the article on robot trigonometry and atan2.
Position Vectors and Displacement
A robot's position is represented by an arrow from the starting point O to that location. This arrow is called a position vector. For example, consider these two locations:
- P (0.4, 0): 0.4 m forward from the starting point
- Q (0.4, 0.3): 0.4 m forward and 0.3 m to the left of the starting point
The displacement from P to Q tells you how far and in what direction Q is from P. Subtract the current position from the destination: "destination − current location."
- Displacement from P to Q = Q − P = (0.4 − 0.4, 0.3 − 0) = (0, 0.3)
In other words, a simple subtraction shows that getting from P to Q means moving "0.3 m to the left."
Finding the Endpoint with Vector Addition
Adding vectors simply means adding the x values together and the y values together. Let's calculate where the robot ends up if it moves from O to P and then from P to Q.
- OP + PQ = (0.4, 0) + (0, 0.3) = (0.4, 0.3) = OQ
Adding the movements for each leg gives the same vector as moving straight from O to Q. Changing the order of addition does not change the result. Moving 0.3 m to the left first and then 0.4 m forward still brings the robot to the same point Q.
Both routes have the same displacement from O to Q. The distance traveled depends on the route.
| How the robot drives | Distance traveled |
|---|---|
| Leg by leg (O → P → Q) | 0.4 + 0.3 = 0.7 m |
| Straight line (O → Q) | 0.5 m |
Driving leg by leg covers the sum of the lengths of each leg, while driving in a straight line covers only the length of the total vector. This difference becomes important when you estimate a robot's travel distance and working time.
Related: Robot Trigonometry: How atan2 Finds a Target Heading explains this in detail.
Scaling Vectors and Finding Direction
Changing a Vector's Length with Scalar Multiplication
Multiplying a vector by a single number (a scalar) is called scalar multiplication. Multiplying a vector by a positive number keeps it pointing the same way and scales its length. Multiplying by a negative number reverses its direction.
| Calculation | Result | Meaning |
|---|---|---|
| 0.5 × OQ | (0.2, 0.15) | Same direction, half the length |
| 2 × OQ | (0.8, 0.6) | Same direction, twice the length |
| −1 × OQ | Opposite of OQ | Same length, opposite direction |
Multiplying by −1 represents the motion of "going back the way you came."
Related: Robot Math Equations: 8 High School Topics Tested in Webots explains this in detail.
Creating a Unit Vector of Length 1 with Normalization
To keep the direction and set the length to 1, divide the vector by its own length. This is called normalization, and the result is a unit vector.
- OQ ÷ 0.5 = (0.4 ÷ 0.5, 0.3 ÷ 0.5) = (0.8, 0.6)
With a unit vector, you can work with direction alone, regardless of the original length. It is used when you only care about "which way to go."
Related: Robot Control Basics: Conditional Branches and Loops explains this in detail.
Finding Velocity from Speed and Direction
Multiplying a unit vector by a speed gives a velocity (which way the robot moves and how fast). For a robot moving in the direction of OQ at a speed of 0.1 m/s:
- 0.1 × (0.8, 0.6) = (0.08, 0.06) m/s
At this velocity, the robot covers 0.08 m along the x-axis and 0.06 m along the y-axis each second. Because direction and speed are handled separately, you do not need to redo the direction calculation when you only want to change the speed.
Using the Dot Product to Tell Whether a Target Is Ahead or Behind
Calculating the Dot Product
Here, we compare the direction the robot is facing with the direction from the robot to the target. Both are expressed as unit vectors, and the dot product is found with this formula:
- (a, b) · (c, d) = a × c + b × d
Multiply the two x-components, multiply the two y-components, and add the products. For two unit vectors, the result is the cosine of the angle between them. Apply the inverse cosine, acos, to find that angle.
Suppose the robot faces in the direction (1, 0). The dot product and angle for each target direction are shown in the table below.
| Target direction (unit vector) | Dot product | Angle to target |
|---|---|---|
| (0.8, 0.6) | 1 × 0.8 + 0 × 0.6 = 0.8 | About 36.87 degrees |
| (0, 1) | 0 | 90 degrees |
| (−1, 0) | −1 | 180 degrees |
| (−0.8, 0.6) | −0.8 | About 143.13 degrees |
Reading the Sign of the Dot Product
The sign of the dot product gives you a quick check of where the target is relative to the robot.
- Positive: the target is somewhere ahead
- 0: the target is directly to the side
- Negative: the target is somewhere behind
With only multiplication and addition, you can tell whether the target is ahead of the robot, directly to its side, or behind it. When you need to know how much the robot should turn, you find the angle from the dot product.
Choosing Left or Right with atan2
The dot product has a weakness: it cannot tell you whether the target is on the left or the right. A target offset to the left by a given angle and a target offset to the right by the same angle produce the same dot product.
To choose which way to turn, use atan2 to find the target direction, subtract the robot's current heading, and adjust the difference to fall within −180 to 180 degrees. The sign of that value tells you whether to turn left or right. Another way to determine left and right is a calculation called the cross product, which comes into play when working with three-dimensional mechanics.
- red: a (leg 1)
- green: b (leg 2)
- blue: a + b
- light blue dot: k × (a + b)
Zero: b is at a right angle to a.
Comparing Leg-by-Leg and Straight-Line Driving in Webots
I used the robot simulator Webots to compare the predictions with the measurements for both routes. Before each run, I calculated the predicted results with formulas. After the run, I measured the difference in travel distance as a percentage of the prediction. A run passed if the measured distance was within 5% of the prediction.
Test Conditions
| Item | Details |
|---|---|
| Software | Webots R2025a |
| Robot | e-puck (wheel radius 0.02 m) |
| Simulation step (basicTimeStep) | 32 ms |
| Heading measurement | InertialUnit yaw |
| Stopping position measurement | Measured with Supervisor |
| Start and targets | From O (0, 0) at a heading of 0 degrees, to P (0.4, 0) and Q (0.4, 0.3) |
| Number of runs | 2 per route |
The Webots Supervisor reports the robot's position in the simulation's fixed coordinate system. The InertialUnit yaw expresses the robot's heading in the range of −π to π. On the floor, I placed yellow markers for P and Q, and a light blue marker for 0.5 × OQ = (0.2, 0.15). How to use the Supervisor and the encoders (sensors that measure how far each wheel has turned) is explained in the Webots simulation tutorial.
The e-puck in the foreground is at the starting point O. The yellow marker at the end of the red line is P, the yellow marker beyond it is Q, and the light blue marker in between is 0.5 × OQ.
Before driving each leg, I expressed the robot's current heading and the direction of the leg as unit vectors and recorded the dot product and the angle found with acos. The robot turns in place until it faces the direction of the leg, then drives the length of the leg. It turns at 2.0 rad/s, slows to 0.5 rad/s when 10 degrees remain, and stops turning when the angle difference is within 1 degree. After it stops turning, it drives forward at a wheel speed of 4.0 rad/s. While driving, the robot also estimates its own position by adding up small displacements, a process called self-localization.
I changed only the route: the robot either drove through P on its way to Q (legs mode) or drove straight from O to Q (direct mode).
Prediction
| Item | Leg by leg (O → P → Q) | Straight line (O → Q) |
|---|---|---|
| Stopping position | Q (0.4, 0.3) | Q (0.4, 0.3) |
| Distance traveled | 0.7 m | 0.5 m |
| Dot product | Leg 1: 1 (0 degrees), Leg 2: 0 (90 degrees) | 0.8 (36.87 degrees) |
Results
| Item | Leg by leg (O → P → Q) | Straight line (O → Q) |
|---|---|---|
| Dot product | Leg 1: 1.0000 (0.00 degrees), Leg 2: 0.0000 (90.00 degrees) | 0.8000 (36.87 degrees) |
| Turning time | 1.440 s on Leg 2 | 0.736 s |
| Distance traveled | 0.7006 m (Leg 1 0.4002 m, Leg 2 0.3004 m) | 0.5005 m |
| Driving time | 5.728 s + 4.480 s | 7.008 s |
| Total time | 11.648 s | 7.744 s |
| Stopping position | (0.4055, 0.3008) | (0.4043, 0.2961) |
| Difference from Q | 5.5 mm | 5.8 mm |
| Difference between estimated and measured positions | 0.6 mm | 0.6 mm and 0.7 mm |
Leg-by-leg trial (legs mode). Table A shows the calculations before moving, and Table B shows the results. The dot product was 1.0000 on Leg 1 and 0.0000 on Leg 2.
Straight-line trial (direct mode). The dot product was 0.8000 (36.87 degrees), and the total time was 7.744 seconds.
The results in the table were the same in both trials for each route. The only difference was the gap between the estimated and measured positions on the straight-line route (0.6 mm and 0.7 mm). All dot product values matched the prediction, and the robot stopped near Q with both driving methods.
Deviation from the Prediction and Comparison of the Two Methods
| Item | Calculation | Result |
|---|---|---|
| Distance deviation (leg by leg) | (0.7006 − 0.7) ÷ 0.7 × 100 | About 0.0857% |
| Distance deviation (straight line) | (0.5005 − 0.5) ÷ 0.5 × 100 | 0.1% |
| Difference in distance traveled | 0.7006 − 0.5005 | 0.2001 m |
| Difference in total time | 11.648 − 7.744 | 3.904 s |
| Straight-line time (as a share of leg by leg) | 7.744 ÷ 11.648 × 100 | About 66.4835% |
| Straight-line distance (as a share of leg by leg) | 0.5005 ÷ 0.7006 × 100 | About 71.4388% |
With both driving methods, the distance predicted before moving was close to the measured value, and the deviation was well below the 5% criterion. The straight-line route took about 66.4835% of the time needed to drive leg by leg. On the straight-line route, both the turning time and the driving time were shorter.
The left side is a top-down view of the floor, showing that OP plus PQ equals OQ, along with the stopping positions. The right side compares the distance traveled and the time.
Examples for Japanese Companies in the Philippines
These hypothetical examples show how Japanese companies in the Philippines could use vector calculations to plan robot movements. The numbers are samples for illustration.
Warehouse: Finding a Shelf
Suppose a shelf is 30 m east and 40 m north of the charging station.
- Total vector: (30, 40)
- Straight-line distance: the square root of (30 × 30 + 40 × 40) = 50 m
- Distance when driving leg by leg: 30 + 40 = 70 m
- Unit vector: 30 ÷ 50 = 0.6 and 40 ÷ 50 = 0.8, giving (0.6, 0.8)
Adding the movements for each leg gives the shelf's position relative to the charging station. Normalizing the total vector lets you express the direction from the charging station straight to the shelf as a unit vector.
Factory: Predicting a Parts Transport Robot's Position
Consider a robot carrying parts in the direction (0.6, 0.8) at a speed of 1 m/s.
- Velocity: 1 × (0.6, 0.8) = (0.6, 0.8) m/s
- Movement over 10 seconds, by axis: 0.6 × 1 × 10 = 6 m in the x direction, 0.8 × 1 × 10 = 8 m in the y direction
- Displacement after 10 seconds: (6, 8)
At a constant speed and direction, you can use elapsed time to calculate the robot's displacement from its starting point. This is useful when checking the robot's movement against the equipment layout and the paths workers take.
Restaurant: Locating a Customer Relative to the Robot
Suppose a serving robot faces in the direction (1, 0), and the unit vector from the robot to the customer who called it is (−0.6, 0.8).
- Dot product: 1 × (−0.6) + 0 × 0.8 = −0.6
- What it means: because the dot product is negative, the customer is somewhere behind the robot
- Angle between the robot's heading and the direction to the customer: acos(−0.6) ≈ 126.8699 degrees
The negative dot product puts the customer behind the robot. The angle tells you how far the robot needs to turn to face the customer. Use atan2 and the robot's current heading to determine which way to turn.
Delivery: Comparing Two Routes
Consider delivering a package to a spot 6 m east and 8 m north.
| How the robot drives | Calculation | Distance |
|---|---|---|
| Leg by leg | 6 + 8 | 14 m |
| Straight line | The square root of (6 × 6 + 8 × 8) | 10 m |
The difference is 14 − 10 = 4 m, and driving in a straight line covers about 71.4286% of the leg-by-leg distance. However, if there are shelves or walls in the aisles, the robot cannot drive in a straight line. Calculate how much a shortcut would save first, then check the actual aisle layout before you choose a route.
Vector Calculations Available in Python and NumPy
Python's math module and NumPy provide functions for several calculations used in these examples.
| Function | What it does |
|---|---|
Python math.hypot | Returns the length of the vector from the origin to a point given by its coordinates |
Python math.dist | Returns the distance between two points |
Python math.sumprod | Returns the sum of products of two sequences of numbers (the same calculation as the dot product) |
Python math.acos | Returns the inverse cosine in radians, between 0 and π |
NumPy numpy.dot | For two 1-D arrays, returns the dot product of the vectors |
NumPy numpy.linalg.norm | Returns the norm (length) of a vector |
The result of acos is in radians, so it needs to be converted when expressed in degrees.
FAQ
Q: Why think about robot movement in terms of vectors?
Because vectors let you handle position, movement, direction, and velocity all in the same form, as pairs of numbers. Adding the movement of each leg tells you where the robot will end up, and dividing by the length extracts only the direction. Since results can be predicted by calculation, you can get a good estimate before running the robot on site.
Q: In what situations is the dot product used?
It is used to decide whether a target is ahead of or behind the robot. Examples include judgments like these:
- From the serving robot's point of view, whether the customer who called is somewhere ahead
- Whether a transport robot needs to make a large turn before heading to the next shelf
- Whether a guide robot is facing the person who spoke to it
A positive dot product means ahead, 0 means directly to the side, and negative means behind.
Q: Can the dot product alone turn a robot toward a target?
No, because the dot product cannot distinguish left from right. Applying acos to the dot product gives the angle between the robot's heading and the target direction. To choose which way to turn, use atan2 to find the target direction, subtract the robot's current heading, and adjust the difference to fall within −180 to 180 degrees.
Q: Which is better, driving leg by leg or driving in a straight line?
Even when the endpoint is the same, driving in a straight line gives a shorter distance traveled. Under the conditions of the Webots test, driving in a straight line took about 66.4835% of the leg-by-leg time. However, real sites have shelves and walls, so it is also necessary to split the route into legs that fit the aisle layout.
Conclusion
A robot's movement toward a target can be predicted by calculation using vectors. Here are the three key points:
- Use addition to find the endpoint from the movement of each leg
- Use normalization to remove the length and extract only the direction
- Use the dot product to tell whether a target is ahead or behind (decide left or right with atan2)
In the Webots test, the deviation of the distance traveled from the prediction stayed within 0.1%, and the dot product values matched the prediction as well. Predicting with formulas before moving the robot and checking the deviation after running it also helps you make estimates when introducing transport robots or serving robots on site.
At PH AI Works, we support AI adoption and business automation for small and medium-sized businesses from our base in Manila, Philippines. If you are considering introducing robots, or building a system that uses calculations to estimate on-site work, please book a free consultation.
References
About the author

Founder / AI Engineer (36+ years in IT)
- ●From Tokyo · based in Manila for 13+ years
- ●36+ years in IT (development, SEO, AI)
- ●Google Certified AI Professional
- ●IBM Certified Generative AI Engineer
- ●AI chatbots, RAG & AI agent development
- ●Physical AI Engineer
A Japanese AI engineer with 36+ years in IT and 13+ years on the ground in the Philippines. I write from hands-on experience to help Japanese companies adopt AI that actually delivers results — chatbots, workflow automation, AI agents, and AI-driven marketing. Feel free to reach out in Japanese or English.
Your Competitors Are Already Using AI!
Is your business keeping up?
Related Articles

Robot Friction and Acceleration: Wheel Spin and Slide
Learn robot friction and acceleration basics, from F = ma and the μmg friction limit to torque and tipping, then predict wheel spin and slide in Webots.
11/30/2026

Robot Motion Calculation: Distance, Direction, Turn Angle
Learn how to calculate robot motion: split each move with cos and sin, predict the position, and find the distance, direction, and turn angle to a goal.
11/28/2026

Robot Trigonometry: How atan2 Finds a Target Heading
How robots find distance, get a target heading with atan2, and take the shorter turn, plus a Webots test of turning times with and without normalization.
11/26/2026

Robot Control Basics: Conditional Branches and Loops
How a robot runs a sense-decide-act loop, and how to set stop, slow-down and time-limit conditions, using run-time estimates and tests in the Webots simulator.
11/26/2026

Robot Experiment Graphs and Repeatability in Webots
How to change one condition at a time in a robot experiment, read wheel speed and distance on a graph, and check repeatability in the Webots robot simulator.
11/24/2026

Robot Motion in Functions and Graphs: Tested in Webots
See how robot wheel motion fits proportional, inverse, linear, quadratic, exponential and log functions, and how each held up in our e-puck tests in Webots.
11/24/2026
