GameDev Book
  • Introduction
  • Math
    • Trigonometry
    • Vectors
    • Hexagon grid math
    • Line Intersection
    • Cubic Bezier curves ("shoot into a pillow")
    • Voronoi Maps
  • Graphics
    • A Low-Res Display in Unity
    • Raycasting for a first-person city display (as seen in Cars64)
    • Pseudo3d for roads (as seen in Driving64)
    • Raycasting for terrain (as seen in Comanche's "Voxel Space")
  • Game Systems
    • Item Registry
    • Behavior Variables
    • Game State Stack (aka "Action Stack")
    • Visibility - 3d Fog of war (Joy Division progressive horizon)
    • Visibility - 2d shadow casting
    • Spatial Partitions
      • Grid
      • BSP
      • k-D Tree
      • "loose" Octtree
    • Generating code from a Domain-Specific Language
  • AI
    • Behavior Trees
    • Influence Maps
    • Neural Nets
    • Genetic Algorithms
    • Racing Line
    • Flocking using Craig Reynolds' "Boids"
    • Monte Carlo Tree Search (MCTS)
    • Pathfinding: Disk-based corridor map
    • Shoot-em-up waves
  • Physics
    • Physics using Particle Systems
    • Car Physics
  • Procedural Content Generation
    • Terrain Generation
    • Markov Chains for pronounceable names
    • Constrained Tile Placement
    • Maze Generation
  • Sound / Music
    • Procedural Sound Generation
    • Adaptive Music System
  • User Interface
    • Steering systems
      • Virtual joystick
      • Drag in viewport
    • Bitmap Font Rendering
    • Vector Font Rendering
  • Appendix: Ludography
    • Games I've worked on
    • Other Games worth checking out
Powered by GitBook
On this page
  • Vector Coordinates
  • For a camera:
  • For a planet:
  • For a city
  • For a mobile game object:

Was this helpful?

  1. Math

Vectors

Lots of people get worked up about choice of coordinate systems. Lots of people think they're all equally good, so why get worked up. I'm in the camp that making some good decisions keeps stuff from being confusing or surprising later on.

I'm a big fan of "right handed" coordinate systems. At some level, this choice is arbitrary, but the places where right handed coordinates are prominently used are places I tend to respect more, including most of the academic literature that I've read.

From there, the next big choice is whether up/down should be Z or something else. I really believe that you should have Z being the least significant of your three coordinates, assuming a 3d project, or the most different. This leads to Z being either up or down for world and object coordinates. I make a special exception for cameras, where the image plane makes sense (to me) to be the X/Y plane, and Z makes sense to go into the scene. Again, Z is the most different in this case, so it's holding true to that part, even though it means you have to do a coordinate transform to flip your axes around. But you're probably going to do some sort of camera transform anyway, so get over it.

Vector Coordinates

For a camera:

X right

Y down

Z in to the scene

For a planet:

X through the prime meridian and the equator

Y through 90 degrees East of the prime meridian

Z through the North Pole

For a city

X: East

Y: North

Z: Up

For a mobile game object:

X right

Y forward

Z up

PreviousTrigonometryNextHexagon grid math

Last updated 5 years ago

Was this helpful?