Concept 01: Vectors, Displacements & Scalar Scaling

▶ Interactive Demo: Vector Addition & Scaling Sandbox

Open the interactive demo below to drag vector arrows A and B, adjust the scalar multiplier slider, and see head-to-tail vector addition live.


1. The Real-World Problem: Combining Robot Moves

Suppose an autonomous robot performs two sequential driving steps:

  1. Move A: Drive 2 meters East and 1 meter North ([2.0, 1.0]).
  2. Move B: Drive 1 meter East and 2 meters North ([1.0, 2.0]).
Move A [2, 1] Move B [1, 2] Total [3, 3]

Where does the robot end up overall? You simply place the tail of Move B at the tip of Move A (Head-to-Tail addition). The net result is:


2. Solving It in Code (Java & WPILib)

First-Principles Java

Vector addition and scalar scaling:

// Robot starting velocity vector (vx, vy)
double v1x = 2.0;
double v1y = 1.0;

// Acceleration boost vector
double ax = 1.5;
double ay = 2.0;
double dt = 0.5; // half second

// v_new = v1 + a * dt
double vNewX = v1x + ax * dt; // 2.0 + 0.75 = 2.75 m/s
double vNewY = v1y + ay * dt; // 1.0 + 1.00 = 2.00 m/s

System.out.printf("New Velocity: (%.2f, %.2f) m/s%n", vNewX, vNewY);

Production WPILib Equivalent

In WPILib, Translation2d supports vector arithmetic:

import edu.wpi.first.math.geometry.Translation2d;

Translation2d velocity = new Translation2d(2.0, 1.0);
Translation2d acceleration = new Translation2d(1.5, 2.0);

Translation2d newVelocity = velocity.plus(acceleration.times(0.5));

3. Bridge to Machine Learning: Word Embeddings

In natural language processing AI (like Word2Vec and ChatGPT):


4. Review Checkpoints

Checkpoint 1

You have vector A = [4.0, -2.0] and vector B = [-1.0, 5.0]. Compute A + B.

Solution: [4.0 + (-1.0), -2.0 + 5.0] = [3.0, 3.0].


Checkpoint 2

A robot’s velocity vector is v = [2.0, 4.0] m/s. The driver hits the “Turbo” button, scaling velocity by 1.5x. What is the new velocity vector?

Solution: v_turbo = [2.0 · 1.5, 4.0 · 1.5] = [3.0, 6.0] m/s.


← Concept 07: 3D Quaternions
Module 3 Overview
Concept 09: Dot Products & Projections →