Vectors: Direction & Force

The arrows that make games move!

Move your mouse to control the vector!

1

What is a Vector?

A vector is an arrow with two properties: direction (where it points) and magnitude (how long it is). Unlike regular numbers, vectors describe movement in space! Drag the arrow tip to change the vector.

3.0
X Component
2.0
Y Component
3.6
Magnitude
33.7°
Direction
magnitude = √(x² + y²)
The length of a vector uses the Pythagorean theorem!

📈 Scalar vs Vector

Scalar: Just a number (speed = 50 mph)
Vector: Number + direction (velocity = 50 mph NORTH)

🎮 In Games

Position, velocity, acceleration, forces - all vectors! They tell the game engine WHERE and HOW FAST.

2

Position Vectors

A position vector points from the origin (0,0) to an object's location. Click anywhere on the canvas to place objects and see their position vectors!

💡 Why Origin Matters

In games, the origin is usually top-left (0,0) or center of the world. Every object's position is a vector from that point. When you say a player is at (100, 50), that's a position vector!

3

Velocity: Movement in Action

Velocity is a vector that describes how position changes over time. The direction shows WHERE you're going, the magnitude shows HOW FAST. Adjust the velocity to control the ball!

2.2
Speed (magnitude)
250
Position X
150
Position Y
new_position = position + velocity
Every frame, add velocity to position to move objects!
4

Adding Vectors: Combining Forces

When multiple forces act on an object, we add their vectors to get the result. This is how games combine gravity + jump + wind into one movement! Drag the arrow tips to adjust vectors A and B.

(3, 1)
Vector A (red)
(1, 2)
Vector B (blue)
(4, 3)
A + B (purple)

💡 Tip-to-Tail Method

Place B's tail at A's tip. The result goes from A's tail to B's tip. That's vector addition!

🎮 Game Example

Player velocity + gravity + wind + knockback = final movement. All added together!

5

Normalizing: Unit Vectors

A normalized vector (or unit vector) has magnitude = 1. It keeps the direction but removes the length. This is essential for controlling speed independently of direction!

Original Vector

(4, 3)

Magnitude: 5.0

Normalized (÷ mag)

(0.8, 0.6)

Magnitude: 1.0

normalized = vector / magnitude
Divide each component by the magnitude to get a unit vector
💡 Why Normalize?

If you want an enemy to chase the player at constant speed, normalize the direction vector then multiply by speed. Otherwise diagonal movement would be faster than horizontal!

6

Scaling: Speed Control

Scaling a vector multiplies its magnitude while keeping direction. This is how games control speed - normalize first, then multiply by desired speed!

(3, 2)
Scaled Vector
3.6
New Magnitude

🚀 Boost Powerup

Scale velocity by 2x = double speed! Scale by 0.5x = slow motion.

🔄 Reverse

Scale by -1 = same speed, opposite direction. Used for bouncing!

7

Dot Product: Are They Aligned?

The dot product tells you how much two vectors point in the same direction. Positive = same direction, Zero = perpendicular, Negative = opposite. Drag the arrows to explore!

0.87
Dot Product
30°
Angle Between
Same Dir
Interpretation
A · B = Ax×Bx + Ay×By
Multiply matching components and add them together

👁 Field of View

Is enemy in front of player? Dot product of facing direction and direction-to-enemy. Positive = visible!

💡 Light & Surfaces

3D lighting uses dot product between light direction and surface normal. Determines brightness!

8

Real Game Physics: Platformer

Watch vectors in action! This simple platformer shows gravity, jump, and movement vectors combining every frame. Use arrow keys or WASD to move, Space to jump!

Click canvas first, then: Arrow keys/WASD = move, Space = jump

0
Velocity Y
0.5
Gravity
Yes
On Ground
9

Vector Launcher Challenge

Put your vector knowledge to the test! Drag to aim and set power, then launch the ball to hit the target. Gravity affects the trajectory - think about the vectors!

0
Score
0
Shots
-%
Accuracy
💡 Projectile Motion

The ball follows a parabolic path because gravity (constant downward vector) is added to velocity every frame. The horizontal velocity stays constant while vertical velocity increases!

Vector Master!

You've mastered the arrows that power every game! From position to velocity, from adding forces to normalizing directions - vectors are everywhere in game physics.

0
Launcher Hits
0
Shots Fired
0
Accuracy
0
Time Exploring

Vectors

Direction + Magnitude, the building blocks of movement

Position & Velocity

Where things are and how they move

Vector Addition

Combining forces like gravity + jump + movement

Normalizing

Unit vectors for consistent speed in any direction

Scaling

Control speed by multiplying vectors

Dot Product

Check if vectors point the same direction

Ready to Create?

Put your new knowledge into practice!

Suggest a Correction