Coordinate Systems (2d)
- origin is the top-left corner of the screen
- y values increase downward
- identify points through (x, y) pairs
- these are position vectors
Unit Vectors
vectors with magnitudes of 1 (direction vectors, normals)
- useful for keeping track of direction
- normalization: reducing a vectors length to one while preserving its direction
- normals: unit vectors aligned perpendicular to a surface
- used for lighting, collision
Vector operations
- member access
- adding
- corresponding components added
- scalar multiplication
- does not change direction, changes magnitude (scale)
- dot product
- operation on two vectors that returns a scalar
- useful with unit vectors
- can tell us the angle between
- dot product of unit vector and any point in space is the distance from the point to the plane
- cross product
- operation on two vectors that returns a vector with a direction perpendicular to both
- reflect
Practical Applications
- Movement
- vectors can represent any quantity:
- position
- velocity: change in position per unit of time
- acceleration
- force
- next_position = position + velocity
- direction_to_point_A = A_position - target_position