Basic Coordinate Geometry

Our goal in this course is to understand the physics and therefore the mathematics that are involved in describing the motion of objects so that we can use them to model the motion of objects in the game world. Motion is a result of changing the position of an object over time, so let us first start with how we will describe the position of objects. First in 2-Dimensions and then in 3-Dimensions.

Points and Coordinate Systems in 2D

In mathematics there are several coordinate systems available to describe the location of a point in 2 or 3 dimensions. For our purposes, the rectangular or Cartesian coordinate system will be the most appropriate. In 2 dimensions, we most often use the x coordinate for the horizontal component of the location and y for the vertical component of the location. The image below shows a standard 2 dimensional Cartesian coordinate system.

CartesianCoordinates.jpg

In the plane, the x axis runs left to right with larger values to the right while the y axis runs up and down with larger values above. Each point in the plane can be refered to by its x and y coordinate pair $(x,y)$. This is called the ordered pair. The point with ordered pair $(0,0)$ is called the origin.
It is worth mentioning that the coordinates on the computer screen have the positive y direction pointing down and the origin in the upper left hand corner. One can work in the standard coordinate system and simplify convert to screen coordinates before outputting.

Distance in 2 Dimensions

Given two points in 2 dimensions the distance between them is defined as follows

(1)
\begin{align} d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \end{align}

This formula can be easily derived from the theorem of Pythagoras.

DistanceFormula.jpg

First notice that the distance between the two points is just the length of the hypotenuse of a right triangle.
Side a has a length of $x_2-x_1$
Side b has a length of $y_2-y_1$
So from Pythagoras we have that $d=\sqrt{a^2+b^2}=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}$

Midpoint in 2 Dimensions

Given two points in 2 dimensions the midpoint is defined as follows

(2)
\begin{align} m= \left( \frac{x_1+x_2}{2},\frac{y_1+y_2}{2} \right) \end{align}

Notice that the x coordinate of the midpoint is the average of the two x coordinates and likewise with the y coordinate

Lines in 2 Dimensions

Slope

One key feature of a line is the degree to which it inclines or declines. This feature is called it's slope. We define the slope of a line that passes through the points $(x_1,y_1)$ and $(x_2,y_2)$ as

Slope.jpg
(3)
\begin{align} m=\frac{y_2-y_1}{x_2-x_1}\mbox{ }\frac{\mbox{Rise}}{\mbox{Run}} \end{align}

Exercise
Find the slope of the line that passes through the points (2,4) and (6,-1).


The slope of a line is an indicator of how quickly the line rises or falls. For a line that rises from left to right the slope is positive. For a line that falls the slope is negative. For a vertical line the slope is undefined. For a horizontal line the slope is zero. The image below illustrates this fact.
slopes.jpg

Parallel Lines

Two lines that are parallel rise or fall at the same rate therefore their slopes are equal, assuming they exist. In other words, if $m_1=m_2$, then the two lines are parallel. If both slopes are undefined, then both lines are vertical and are therefore parallel.

Perpendicular Lines

In the case of perpendicular lines, as one line rises the other falls and the faster one rises the slower the other falls. Specifically, the slopes are related as opposite reciprocals, assuming they exist. That is to say, $m_1=-\frac{1}{m_2}$. For the case of a vertical and a horizontal line, one line has a slope of 0, while the other line has undefined slope.

Point Slope Form

We can now use our definition of slope to create an equation of a line. Given a line with slope m that passes through the point $(x_1,y_1)$, every point $(x,y)$ on that line satisfies the equation

(4)
\begin{align} m=\frac{y-y_1}{x-x_1} \end{align}

Multiplying this equation on both sides by $x-x_1$ yeilds the following

(5)
\begin{equation} y-y_1=m(x-x_1) \end{equation}

This is the so called point slope form of the equation of a line.

Exercise
Find the point slope equation of the line that has slope $m=\frac{1}{2}$ and passes through the point $(2,-3)$.

Example
Find the point slope equation on the line that passes through the points $(-1,3)$ and $(2,-6)$.

Slope Intercept Form

Now say we have a line with slope m and passing through the point $(0,b)$. This point lies on the y-axis since its x coordinate is zero. We call this point the y-intercept of the line. If we plug this information into the point-slope equation we get

(6)
\begin{eqnarray} y-b&=&m(x-0)\\ y-b&=&mx\\ y&=&mx+b \end{eqnarray}

This equation is the so called slope intercept form of the equation of a line. It is a specific case of the point slope form.

Standard Form

The one limitation of both of these forms is that they require the slope, but as we saw previously vertical lines have an undefined slope. In fact, vertical lines consist of all points with a common x value therefore they have an equation of the form $x=a$. This is a special case of the more general standard form of the equation of a line which is given by

(7)
\begin{equation} Ax+By=C \end{equation}

The equation of any line can be expressed in this form.

Example
Find the equation in standard form for the line with slope-interpect form of $y=3x+4$
Example
Find the equation in standard form for the line with point-slope form of $y-2=4(x+5)$

Example
Find the equation in standard form for the vertical line $x-4=8$

Circles

Standard Form

A circle can be defined as the set of points that are all a fixed distance r, radius, from a common center, $(x_0,y_0)$.

circle.jpg

We already know that in 2D distance is defined as $d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}$. Since a cirlce is the set of points whose distance is r from the point $(x_0,y_0)$, the distance formula yields the formula

(8)
\begin{eqnarray} r=\sqrt{(x-x_0)^2+(y-y_0)^2}\\ r^2=(x-x_0)^2+(y-y_0)^2\\ \end{eqnarray}

This is the so called standard form of the equation of a circle in 2D.

Exercise
Find the center and radius of the circle $x^2-4x+y^2+10y=7$

Points and Coordinate Systems in 3D

In 3 dimensions, the Cartesian coordinate system has three perpendicular axes. The original x and y axes from the xy-plane plus the z-axis that runs perpendicular to the xy-plane. In the right-handed coordinate system the positive z-axis is pointing out of the screen and in the left-handed coordinate system the positive z-axis is pointing into the screen.

rightandleft.jpg

To determine handedness you lay your hand flat on the x-axis with your fingers pointing in the positive x direction. Now curve your fingers in the direction of the positive y-axis. The direction your thumb is pointing will be the positive z direction.

IC155562.gif

In mathematics, it is somewhat standard to use a right-handed system with the positive z direction being up and the positive x direction being out.

StandardRightHand3d.jpg

Every point in 3 dimensional space can be uniquely defined by its ordered triple $(x,y,z)$.

Distance in 3 Dimensions

Our formula from 2 Dimensions can be extended the 3 dimensions by twice applying the theorem of Pythagorus.

(9)
\begin{align} d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2} \end{align}
Distance3d.jpg

Notice that the z component is the same for the endpoints of side a. Therefore our 2 dimensional distance formula applies and

(10)
\begin{align} a=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \end{align}

Since only the z coordinate is different on the endpoints of side b, we know that

(11)
\begin{align} b=\sqrt{(z_2-z_1)^2} \end{align}

Now applying the theorem of Pythagoras we get

(12)
\begin{align} d=\sqrt{a^2+b^2}=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2} \end{align}

Exercise
Find the distance between (1,3,-1) to (4,5,6)

Midpoint in 3 Dimensions

Given two points in 3 dimensions the midpoint is defined as follows

(13)
\begin{align} m= \left( \frac{x_1+x_2}{2},\frac{y_1+y_2}{2},\frac{z_1+z_2}{2} \right) \end{align}

Again each coordinate is the average of the corresponding original two coordinates.

Exercise
Find the midpoint of the points (8,20,6) and (9,10,1)

Spheres

The 3D analog of a circle is a sphere. using the definition of distance in 3D we get the standard form of the equation of a sphere with radius r and center $(x_0,y_0,z_0)$ as

(14)
\begin{equation} r^2=(x-x_0)^2+(y-y_0)^2+(z-z_0)^2 \end{equation}

Exercises

  1. Draw a left-handed 3D coordinate system with the positive x-axis pointing to the left.
  2. Find the distance and midpoint between the points (4, 11, –5) and (–3, 7, 2).
  3. Write the equation of a line passing through the points (6, 3) and (2, –5).
  4. Write the equation of a line passing through the point (4, –7) that is perpendicular to the line with equation $5x-3y=9$.
  5. On a right-handed coordinate system with the z-axis pointing down, sketch a graph of the plane with equation $2x+3y-z=4$.
  6. Write the equation of a circle with center (3, 8) and radius 7.
  7. Write the equation of a sphere where (5, 7, 3) and (–1, 5, 4) are endpoints of a diameter.
  8. A sphere has the equation $x^2+y^2+z^2-6y+5z=14$ . Find its center and radius.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License