What analytic geometry is
Analytic geometry, also called coordinate geometry or Cartesian geometry, is the branch of mathematics that studies geometric figures using a coordinate system and algebra. It represents points by ordered pairs of numbers, and describes lines, curves and shapes with equations and inequalities.
That is exactly how a game sees the world. A point is two numbers. A circle is a centre and a radius. A rectangle is a range of values on each axis. The rest of this book is about turning those numbers into collision tests.
Coordinates of a point on a line
A number axis is a line with a chosen unit and a chosen origin . The origin divides the line into two opposite half-lines, the negative and the positive half-axis. Every point on the line then has exactly one real number, its coordinate.
The Cartesian coordinate system
The Cartesian coordinate system in a plane is two perpendicular number axes, the -axis and the -axis, that intersect at the origin . Every point in the plane is represented by exactly one ordered pair of real numbers : how far it is along the -axis, and how far along the -axis. In the figure below, the point has the coordinates .
Shapes are numbers too. The circle is its centre and its radius, . The rectangle is every point whose lies between and and whose lies between and .
Screen coordinates
Screens flip the -axis. On a canvas, is the top-left corner and grows downwards. None of the formulas in this book change because of that, since they only ever use differences and squares; it only matters when you think about which way is up. The interactive demos in the following chapters use screen coordinates.
Comments
No comments yet. Questions and corrections are welcome.