Project 4- Perpendicular Lines

Perpendicular Lines (lines that form a right angle at intersection) have the slopes that are negative reciprocals.  Notice how the perpendicular lines above have slopes 3 and -1/3.

Suppose we want to find the equation of the line that is perpendicular to the orange line above that passes through the point (3, -3).  It is actually the blue line (so we see the equation), but the following is explanation on how to find the equation.

The slope of the perpendicular line would be -1/3 since the lines must have slopes that are negative reciprocals.  If the line passes through the point (3, - 3) we can substitute x = 3 and y = -3 into the equation y = mx + b, to solve for b.

-3 = -1/3(3) + b

-3 = -1 + b

b = -2  

The equation of the line perpendicular to the line y = 3x - 1 that passes through (3, -3) is Y = -.333X - 2

Project 4 Variables 'm', 'b', 'x', and 'y' have been initialized. 

m is the slope of the original line

b is the y-intercept of the original line

(x,y) is the point that our line (the one we are finding the equation of) passes through.

Task: Appropriately assign variables 'mPerp' and 'bPerp' that represent the slope and y-intercept of our line (the line perpendicular to the original line that passes through (x,y)).  

The program will draw two lines that form a right angle if your code is correct.

**If your code works for 5 test cases, you can enter your e-mail address

Universal Computational Math Methods:

pow(5,2) returns 25.0

abs(-3.0) returns 3

sqrt(49.0) returns 7.0