Sub topic 3
Horizontal and vertical distances
This chapter assumes you can plot an ordered pair (x, y), read the sign of each coordinate, and apply the Pythagorean theorem.
Horizontal and vertical distances
The horizontal distance between two points is the difference of their x-coordinates, written without a sign: |x2 - x1|. The vertical distance is |y2 - y1|. Taking the absolute value means the order of the two points does not matter.
Plotting points from a table of values
A table of values lists an x-value and a y-value in each row. Each row gives one point. After plotting, look for a pattern.
| x | y |
|---|---|
| -2 | 1 |
| 0 | 3 |
| 2 | 5 |
These points lie on one straight line, which matches the rule y = x + 3.
Reflecting points across the axes
Reflecting across the x-axis keeps x and negates y: (x, y) becomes (x, -y). Reflecting across the y-axis keeps y and negates x: (x, y) becomes (-x, y).
Finding a midpoint
The midpoint of two points averages their coordinates: ((x1 + x2) / 2, (y1 + y2) / 2).
The distance between any two points
The horizontal and vertical distances are the legs of a right triangle. The Pythagorean theorem gives the distance d = sqrt((x2 - x1)^2 + (y2 - y1)^2).
Drawing polygons and measuring them on the plane
Each side of an axis-aligned rectangle is horizontal or vertical, so each side length is one distance. The rectangle with corners (1, 2), (4, 2), (4, 6) and (1, 6) has sides 3 and 4, a perimeter of 14 and an area of 12.
import math
def horizontal_distance(p, q):
return abs(q[0] - p[0])
def vertical_distance(p, q):
return abs(q[1] - p[1])
def reflect_x_axis(p):
return (p[0], -p[1])
def reflect_y_axis(p):
return (-p[0], p[1])
def midpoint(p, q):
return ((p[0] + q[0]) / 2, (p[1] + q[1]) / 2)
a = (1, 2)
b = (4, 6)
print(horizontal_distance(a, b))
print(vertical_distance(a, b))
print(reflect_x_axis(a))
print(reflect_y_axis(a))
print(midpoint(a, b))
print(math.dist(a, b))Exercise
What is the distance between (-3, 1) and (2, 1)?
Show answer
The points share y = 1, so the distance is the horizontal distance |2 - (-3)| = 5.