Skip to content
Tutorials Center
My learning

Topics

Lesson 37 of 86 ยท Algebra, Geometry and Calendars

Coordinate Geometry and Lines

Use the distance formula, section formula, slope and triangle area on the coordinate plane, with worked aptitude problems and a runnable checker.

Coordinate geometry places shapes on a grid so that geometry questions become arithmetic. A point is a pair (x, y); a line is an equation; a triangle is three pairs of numbers. Aptitude tests use it for a small, predictable set of questions: how far apart are two points, where does a point sit on a segment, what is the area of a triangle given its corners, and are three points in a straight line.

Every formula in this lesson comes from one idea, the Pythagorean theorem on a grid, so you can rebuild any of them if memory fails. We will cover distance, the section formula, slope and line equations, triangle area and a few combined problems. Triangle and circle facts that do not need a grid are in Geometry for Aptitude.

Distance and midpoint

The horizontal gap between P(xโ‚, yโ‚) and Q(xโ‚‚, yโ‚‚) is xโ‚‚ โˆ’ xโ‚ and the vertical gap is yโ‚‚ โˆ’ yโ‚. They form the two short sides of a right triangle whose hypotenuse is PQ:

PQ = โˆš((xโ‚‚ โˆ’ xโ‚)ยฒ + (yโ‚‚ โˆ’ yโ‚)ยฒ)

The distance from the origin to (x, y) is โˆš(xยฒ + yยฒ).

Example 1. The distance between (3, โˆ’2) and (โˆ’5, 4) is โˆš((โˆ’8)ยฒ + 6ยฒ) = โˆš100 = 10.

The midpoint is the average of the coordinates: ((xโ‚ + xโ‚‚)/2, (yโ‚ + yโ‚‚)/2). The midpoint of those two points is (โˆ’1, 1).

The section formula

A point R divides the segment PQ in the ratio m : n (measured from P). Then

R = ((m xโ‚‚ + n xโ‚) / (m + n), (m yโ‚‚ + n yโ‚) / (m + n))

Notice the cross pattern: the first ratio number multiplies the second point.

Example 2. Find the point dividing (1, 2) and (7, 11) in the ratio 1 : 2. x = (1 ร— 7 + 2 ร— 1) / 3 = 3 and y = (1 ร— 11 + 2 ร— 2) / 3 = 5, so the point is (3, 5). It sits one third of the way from the first point, as it should.

For external division (R lies on the line but outside the segment) subtract instead of adding: R = ((m xโ‚‚ โˆ’ n xโ‚) / (m โˆ’ n), (m yโ‚‚ โˆ’ n yโ‚) / (m โˆ’ n)).

Example 3. Divide A(2, 3) and B(6, 7) externally in the ratio 3 : 1: x = (3 ร— 6 โˆ’ 1 ร— 2) / 2 = 8 and y = (3 ร— 7 โˆ’ 1 ร— 3) / 2 = 9, giving (8, 9). It lies beyond B.

The centroid of a triangle (where the medians meet) is the average of all three corners: ((xโ‚ + xโ‚‚ + xโ‚ƒ)/3, (yโ‚ + yโ‚‚ + yโ‚ƒ)/3). For (2, 3), (4, 7) and (9, โˆ’1) it is (5, 3).

Finding a ratio. To find where the x-axis cuts the segment from (2, โˆ’3) to (5, 6), set the y-coordinate of the section point to zero: (6m โˆ’ 3n)/(m + n) = 0, so 6m = 3n and m : n = 1 : 2. The same trick with x = 0 finds where the y-axis cuts a segment.

Slope and the equation of a line

The slope (gradient) of the line through two points is the rise over the run:

m = (yโ‚‚ โˆ’ yโ‚) / (xโ‚‚ โˆ’ xโ‚)

Useful facts:

  • Parallel lines have equal slopes.
  • Perpendicular lines have slopes whose product is โˆ’1 (mโ‚ ร— mโ‚‚ = โˆ’1).
  • A horizontal line has slope 0; a vertical line has undefined slope.

The standard forms of a line:

Form Equation Use when
Slope-intercept y = mx + c slope and y-intercept are known
Point-slope y โˆ’ yโ‚ = m(x โˆ’ xโ‚) one point and the slope are known
Two-point (y โˆ’ yโ‚)/(yโ‚‚ โˆ’ yโ‚) = (x โˆ’ xโ‚)/(xโ‚‚ โˆ’ xโ‚) two points are known
Intercept x/a + y/b = 1 x- and y-intercepts are known
General Ax + By + C = 0 the answer is expected in this shape

Example 4. Find the line through (2, 3) and (6, 11). The slope is 8/4 = 2. By point-slope, y โˆ’ 3 = 2(x โˆ’ 2), so y = 2x โˆ’ 1. A line perpendicular to it has slope โˆ’1/2.

The distance from a point (xโ‚€, yโ‚€) to the line Ax + By + C = 0 is

|A xโ‚€ + B yโ‚€ + C| / โˆš(Aยฒ + Bยฒ)

Example 5. The distance from (3, 4) to the line 3x + 4y โˆ’ 5 = 0 is |9 + 16 โˆ’ 5| / โˆš(9 + 16) = 20 / 5 = 4.

When a question asks "for what value of k are these lines parallel (or perpendicular)?", convert both to slope form first. Compare slopes for parallel, multiply them for perpendicular.

Area of a triangle and collinearity

For the corners (xโ‚, yโ‚), (xโ‚‚, yโ‚‚), (xโ‚ƒ, yโ‚ƒ):

Area = ยฝ |xโ‚(yโ‚‚ โˆ’ yโ‚ƒ) + xโ‚‚(yโ‚ƒ โˆ’ yโ‚) + xโ‚ƒ(yโ‚ โˆ’ yโ‚‚)|

Example 6. The triangle with corners (1, 1), (5, 1) and (3, 6): the base along y = 1 has length 4 and the height is 5, so the area is 10. The formula agrees: ยฝ |1(1 โˆ’ 6) + 5(6 โˆ’ 1) + 3(1 โˆ’ 1)| = ยฝ |โˆ’5 + 25 + 0| = 10.

Three points are collinear exactly when this area is zero. So (1, 2), (3, 6) and (5, 10) lie on one line, since each step adds (2, 4). To find k such that (1, 2), (k, 5) and (5, 8) are collinear, compare slopes: from (1, 2) to (5, 8) the slope is 6/4 = 1.5, so from (1, 2) to (k, 5) it must be 3 / (k โˆ’ 1) = 1.5, giving k = 3.

flowchart TD
    A["Coordinate question"] --> B{"What is asked?"}
    B -->|Length| C["Distance formula"]
    B -->|Point on a segment| D["Midpoint or section formula"]
    B -->|Line| E["Slope, then point-slope form"]
    B -->|Area or collinear| F["Determinant formula, zero means collinear"]
    B -->|Distance to a line| G["|Ax0 + By0 + C| over root of A squared plus B squared"]

Name what is being asked, then pick the single formula that produces it.

A coordinate-geometry checker

The script below reproduces every worked example. Edit the points to test your own questions; the function names mirror the formulas above.

JS Coordinate geometry toolkit

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The next tool turns two points into the full set of line facts: slope, equation and intercepts. It also tests parallel and perpendicular lines.

JS Line facts from two points

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What is the distance between the points (3, -2) and (-5, 4)?

    The gaps are 8 and 6, so the distance is sqrt(64 + 36) = sqrt(100) = 10.
  2. 2. Which point divides the segment from (1, 2) to (7, 11) in the ratio 1 : 2?

    x = (1 x 7 + 2 x 1)/3 = 3 and y = (1 x 11 + 2 x 2)/3 = 5.
  3. 3. What is the area of the triangle with corners (1, 1), (5, 1) and (3, 6)?

    The base along y = 1 has length 4 and the height is 5, so the area is 1/2 x 4 x 5 = 10.
  4. 4. A line has slope 2. What is the slope of any line perpendicular to it?

    Perpendicular slopes multiply to -1, so the slope is -1/2.
  5. 5. What is the distance from the point (3, 4) to the line 3x + 4y - 5 = 0?

    |3(3) + 4(4) - 5| / sqrt(9 + 16) = 20 / 5 = 4.

Summary

  • Distance: โˆš((xโ‚‚ โˆ’ xโ‚)ยฒ + (yโ‚‚ โˆ’ yโ‚)ยฒ); midpoint: average of the coordinates.
  • Section formula for ratio m : n: ((m xโ‚‚ + n xโ‚)/(m + n), (m yโ‚‚ + n yโ‚)/(m + n)); subtract for external division.
  • Slope m = rise / run; parallel lines have equal slopes, perpendicular slopes multiply to โˆ’1.
  • Use point-slope form y โˆ’ yโ‚ = m(x โˆ’ xโ‚) to build a line from a point and a slope.
  • Triangle area = ยฝ |xโ‚(yโ‚‚ โˆ’ yโ‚ƒ) + xโ‚‚(yโ‚ƒ โˆ’ yโ‚) + xโ‚ƒ(yโ‚ โˆ’ yโ‚‚)|; zero area means the points are collinear.
  • Distance from a point to a line: |A xโ‚€ + B yโ‚€ + C| / โˆš(Aยฒ + Bยฒ).

Next: Heights and Distances, where right triangles and angles of elevation do the same job outdoors.