Victor A. answered 01/18/15
Tutor
New to Wyzant
Math and Physics tutor
Hi Mike,
This seems to be a interesting code. First, knowing the slope and one point in the line, you can now have the first equation by solving for b in y = m*x + b, which is the line equation: 1) y_3 = (newSlope)*(x_3) + b. (I will cal the new point as (x_3,y_3))
Next, we need to use the other known variable to get another equation to solve the problem. There are two cases, when the slope of the first line is positive and when it is negative. This can help you writing the code.
We want to use the length of the new line as hypotenuse, and then we use Pythagoras'Theorem to find our second mathematical expression which will lead us to find our two variables ( new point). In this last part, one cathetus (side or leg of the imaginary right triangle that you should make in order to use the variable length) should be = (y_3) - (x_1) and the other one should be = (x_1) - (x_3) in my case the point (x_1,y_1) is the closest one to the point (x_3,y_3) and i took the outside right triangle.
Now we should know the new point , the next line will have a slope equal to -(1 /m_2). Then we can find the first equation as we did it before. Because the length of this new line is the same as the first one, again you need to imagine a right triangle out or in-side the triangle, then try to find a way to express those sides of the triangle in terms of x_4,x_3, y_4, y_3. Again using the Pythagoras'Theorem you create our second equation. Finally, you got the the last point! I am assuming everything is in the positive plane and that you take only the positive answer from the square roots.
Hope it helps.