Skip to content

JavascriptReallyWorks/Linear-algebra-for-game-developers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Notes from Linear Algebra for Game Developers Part 1

Vector examples:

Vector examples

  • position
  • velocity
  • direction
  • acceleration
  • ...

Important:

  • keep track of units
    • velocity is in meters/second or in pixels/frame
  • remember the context of the vector
    • (0, 1) is a velocity or a direction?
    • Same vector, different meanings

Example: (3, 5, 2) is a position in meters

Positional vector example

  1. east (3 methers east from the origin)
  2. up (z axis)
  3. north

Negative numbers represent opposite directions (west, down south).

Vector addition

(0,1,4) + (3,-2,5) = (0+3, 1-2, 4+5) = (3,-1,9)

Addition is a component-wise operation.

Useful for: physics integration

loop:
    position += velocity
    velocity += acceleration

Vector subtraction

Useful for getting a vector that points from one position to another.

Distance vector = destination - origin

Vector subtraction example

V1 = rifleman position
V2 = robot position
v3 = laser beam = V2 - V1

About

Linear Algebra For Game Developers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published