Skip to content
Tutorials Center
My learning

Topics

Lesson 33 of 38 · Applications and Vectors

Vectors and Components

Describe a vector by magnitude and direction, split it into components with sine and cosine, rebuild it with atan2, and find angles with the dot product.

A scalar is a quantity with only size: 5 kg, 20 °C, 3 seconds. A vector has size and direction: a velocity of 20 m/s north-east, a force of 50 N pulling upward. Vectors are written with an arrow v⃗ or in bold. Trigonometry is the natural tool for working with them, because sine and cosine convert between "length and angle" and "how far across, how far up".

Two ways to describe a vector

  1. Magnitude and direction. The magnitude |v| is the length. The direction is an angle θ measured counterclockwise from the positive x-axis (the standard convention in math).
  2. Components. The vector as an ordered pair (vx, vy): how much it moves along x and along y.

The conversion uses the unit circle idea directly:

Text
vx = |v| cos θ
vy = |v| sin θ

|v| = √(vx² + vy²)
θ  = atan2(vy, vx)

Use atan2(vy, vx) rather than arctan(vy/vx). The plain arctan cannot tell (3, 4) from (−3, −4), since both have the ratio 4/3. If you must use arctan, check the quadrant yourself and add 180° when vx < 0.

Example 1. A force of 50 N acts at 30° above the horizontal. Then Fx = 50 cos 30° ≈ 43.30 N and Fy = 50 sin 30° = 25.00 N.

Example 2. A vector has components (−5, 12). Its magnitude is √(25 + 144) = 13. Its direction: arctan(12/(−5)) would give −67.4°, which points into quadrant IV, the wrong place. The vector is in quadrant II, so θ = 180° − 67.4° = 112.6°.

Python Convert between polar and components

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Unit vectors and vector arithmetic

A unit vector has magnitude 1. The unit vector in the direction of v is v / |v|. In terms of the angle, (cos θ, sin θ). The vectors i = (1, 0) and j = (0, 1) point along the axes, and every vector can be written v = vx i + vy j.

Addition and scalar multiplication work component by component:

Text
(a, b) + (c, d) = (a + c, b + d)
k (a, b) = (ka, kb)

Multiplying by a negative number reverses the direction.

The dot product and the angle between vectors

The dot product of u = (u1, u2) and v = (v1, v2) is the number

Text
u · v = u1 v1 + u2 v2 = |u| |v| cos θ

where θ is the angle between them (0° to 180°). Rearranging gives a formula for that angle:

Text
cos θ = (u · v) / (|u| |v|)

The sign of the dot product tells you about the angle: positive means acute, zero means perpendicular, negative means obtuse.

Example. u = (3, 4) and v = (4, −3): u · v = 12 − 12 = 0, so they are perpendicular (90°).

Example. u = (1, 0) and v = (1, 1): u · v = 1, |u| = 1, |v| = √2. So cos θ = 1/√2 and θ = 45°.

Why does u · v = |u||v| cos θ? Apply the law of cosines to the triangle with sides |u|, |v| and |u − v|: |u − v|² = |u|² + |v|² − 2|u||v| cos θ. Expanding the left side in components gives |u|² + |v|² − 2(u · v), so u · v = |u||v| cos θ.

Python Angle between vectors

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The last pair has the same direction (angle 0°), and (2, 3) with (−4, −6) point exactly opposite (180°).

Direction angle versus bearing

In math, direction angles are counterclockwise from east. In navigation, bearings are clockwise from north. The conversion is bearing = 90° − θ (add 360° if needed). A wind blowing toward θ = 30° (math angle) has bearing 060°.

Check your understanding

Quick check · 3 questions

of 3 answered You scored / 3 · perfect!

  1. 1. A vector has magnitude 20 and direction 150°. What is its x-component?

    20 cos 150° = 20 × (−0.8660) = −17.32. The vector points left and up.
  2. 2. The vector (−3, −4) has direction (counterclockwise from +x) closest to:

    It is in quadrant III. The reference angle is arctan(4/3) ≈ 53.1°, so the direction is 180° + 53.1° = 233.1°.
  3. 3. If u · v = 0 for two non-zero vectors, the angle between them is:

    cos θ = 0 means θ = 90°: the vectors are perpendicular.

Summary

  • A vector has magnitude and direction; components are (|v| cos θ, |v| sin θ).
  • Rebuild with |v| = √(vx² + vy²) and θ = atan2(vy, vx).
  • Use atan2 to get the right quadrant.
  • The dot product u · v = u1v1 + u2v2 = |u||v| cos θ gives the angle between vectors.
  • Perpendicular vectors have dot product zero.

Next: Adding Vectors and Resultant Forces