Understanding Computer Graphics Coordinates
In this section, we'll explore how computers measure coordinates on the screen.
Axes and coordinates in computer space
Here are the basic rules of computer coordinates:
- 0 degrees is to the right.
- X is across, in the direction of 0 degrees.
- Y is vertical, pointing down the screen.
- The top left corner has the coordinates (0,0). You can call it the origin.
- Angles rotate clockwise.
Angles in computer space
Vector in computer space
Note that computer coordinates are a vertical mirror of Cartesian coordinates. In Cartesian systems, the Y axis points up, and angles rotate counterclockwise.
Geometry Display
You'll notice a button in the bottom left corner of the game. When you play the game, this button will toggle visual display of geometry on your monkey.
Right now, we aren't sending any data to the monkey, so the display will read 0 in all fields.
- Play the game and toggle the geometry display.
When we have fully coded our game, the diagnostic view will display the following targeting data:
x
: Horizontal displacementy
: Vertical displacement (remember, positive numbers go down the screen!)h
: Hypotenuse (the actual distance from one point to another)a
: Angle from monkey to target
You will also see a triangle with the hypotenuse highlighted.
Got that? Now you know what to expect when you set angles and positions on the screen.