## Friday, March 25, 2011

### Distance, Slope and area of a triangle given two points and the origin (0,0)

The idea of putting horizontal and vertical coordinates on points on a plane is about 400 years old now, and much of the credit goes to mathematician and philosopher RenĂ© Descartes, working with the amateur mathematician Father Marin Mersenne. The name Cartesian coordinates comes from Descartes' last name. Instead of using a lot of different letters for the coordinates, we will be using subscripts for points, such as (x1, y1), (x2, y2), (x3, y3), etc.

Distance between points: The distance formula is really The Pythagorean Theorem. Our coordinate system makes it easy to create a right triangle between any two points that aren't on the same horizontal or vertical line. (If they are on the same horizontal line, then y1 = y2. If they are on the same vertical line, then x1 = x2.) The horizontal leg of the triangle has length that is the absolute difference |x1 - x2|, and the vertical leg has length |y1 - y2|. The sum of the squares of the legs is the square of the hypotenuse, so we take the square root to find the distance.

Slope: Slope is a number which defines the steepness of a line segment by rise/run, which means the difference in y divided by the difference in x. Any time we have a fraction in a formula, we have to be careful that the denominator is not zero, because we are not allowed to divide by zero. (Quick mnemonic: 0/K is okay because it's zero, N/0 is no can do.) The formula can be written as (y1 - y2)/(x1 - x2) or (y2 - y1)/(x2 - x1). In other words, it doesn't matter if you put the coordinates from point 1 first or the coordinates from point 2 first, AS LONG AS YOU ARE CONSISTENT.

A slope of 0 means the y coordinates are equal and the line is horizontal. A positive slope means the line is "uphill" as we go from left to right and a negative slope means we go "downhill" as we go from left to right. The larger the absolute value of the slope, the steeper a line is. A vertical line has no "run" because the x values are the same, and that means dividing by zero, which we have already said doesn't work. A vertical line has undefined slope. (Sometimes people will say it has no slope, which is technically true but it sounds like the slope is zero. As much as possible, I will used the phrase undefined slope to try to avoid this confusion. If you put "no slope" as an answer when it should be "undefined slope", expect to get a half point marked off.)

The area of a triangle defined by (0, 0), (x1, y1) and (x2, y2): You may have learned that the area of a triangle is 1/2 the base times the height, but sometimes you aren't given the base and the height and other formulas are used instead. If given three coordinate points and one of them is the origin (0, 0), the formula for the area is ½|x1y2 - x2y1|. The absolute value sign is necessary because area, like distance, is usually thought of as non-negative. I write "non-negative" instead of "positive" because if you pick three points at random, it's possible you have three points that are all on the same line, which we call co-linear, and if that happens, what you draw is not really a triangle but instead a line segment, which would mean the base exists but the height is zero, so the area is zero.

Example: Consider the points (7, 1) and (-2, 3).

Distance from (7, 1) and (-2, 3):
sqrt((7 -(-2))²+(1 - 3)²) = sqrt(9² + 2²) = sqrt(81 + 4) = sqrt(85).
(note: 85 is 17x5, so it is a square free number and can't be simplified.)

Slope of the line that runs through (7, 1) and (-2, 3):
(1-3)/(7-(-2)) = -2/9. This means a downhill slope, and every time we move 9 units to the right, we move 2 units down. (Conversly, if we move 9 units to the left, we move 2 units up.)

Note: if we switch the points and write the fraction as (3-1)/(-2-7), we get 2/(-9), which is still -2/9.

Area of the triangle with vertices (0, 0), (7, 1) and (-2, 3).
½|7*3 - 1*-2| = ½|21 -(-2)| = ½|23| = 11½ or 11.5. If we have all points that have integer coordinates (known in the literature as lattice points), then the area will be a whole number or a whole number + ½.

Further problem on triangle area: What if we have three points but none of them is (0, 0)?

In this case, pick one of the points and subtract its x value from all the x values AND subtract its y value from all the y values. What this does is rigidly move the original triangle to one of the exact same size and shape that does have a point at the origin (0, 0). The selection of the point is arbitrary and the area will be the same no matter what point is chosen.

Example: What is the area of the triangle formed by the points (7, 6), (2, -1) and (8, 14)?

I'm going to pick the point (2, -1) to be the point that gets moved to the origin because 2 and -1 are small and easy to subtract from the other values.

(7-2, 6-(-1)) = (5, 7)
(2-2, -1-(-1)) = (0, 0)
(8-2, 14-(-1)) = (6, 15)

The area of the triangle with vertices at (0, 0) , (5, 7) and (6, 15) = ½|5*15 - 7*6| = ½|75 - 42|
= ½|33| = 16.5 or 16½.

Practice problems:

a) Find the distance between (9, 4) and (-1, 2).
b) Find the slope of the line that connects (9, 4) and (-1, 2)
c) Find the area of the triangle with vertices at (0, 0), (9, 4) and (-1, 2).
d) Find the area of the triangle with vertices at (12, 7), (9, 4) and (-1, 2).

Prof. Hubbard said...

a) Find the distance between (9, 4) and (-1, 2).

Answer: sqrt((9-(-1))² + (4-2)²) = sqrt(100+4) = sqrt(104) =
2 * sqrt(26).

b) Find the slope of the line that connects (9, 4) and (-1, 2)
1/5.

c) Find the area of the triangle with vertices at (0, 0), (9, 4) and (-1, 2).
Answer: ½|9*2 - 4*(-1)| = ½|18 -(-4)| = ½|22| =
11

d) Find the area of the triangle with vertices at (12, 7), (9, 4) and (-1, 2).
Answer: Step #1 is to subtract -1 from all x and 2 from all y.
New points:
(12 - (-1), 7 - 2) = (13, 5)
(9 - (-1), 4 - 2) = (10, 2)
(-1 -(-1), 2 - 2) = (0, 0)

½|13*2 - 5*10| = ½|26 - 50| = ½|-24| =
12.

Venkat Shanthi said...

Very informative article.Thank you author for posting this kind of article .

http://www.wikitechy.com/view-article/write-a-c-program-to-find-area-of-triangle-with-example-and-explanation

Both are really good,
Cheers,
Venkat