Given a line with slope y/x, find a simple formula for the slope of a second line that forms a 45 degree angle with this line (find slopes for both 45 degrees more and 45 degrees less.)
This can be done without trigonometry.
Find a general formula for any angle.
This requires trigonometry.
...using complex numbers
I convert the slope into a vector in the complex plane.
let m = slope
vector = 1 + mi
Then I multiply the vector by sqrt(i), or any other vector that is 45 degrees counter-clockwise from the +x direction. i+1 for instance.
=(1-m) + (1+m)i
Last, I convert the vector back to a slope.
slope = (1+m)/(1-m)
In the clockwise direction, 45 degrees,
=(1+m) + (m-1)i
slope = (m-1)/(1+m)
Generally speaking, to rotate any angle (counter-clockwise),
=(cosθ-msinθ) + (mcosθ+sinθ)i
slope = (mcosθ+sinθ)/(cosθ-msinθ)
And applying the magic trig identities,
= √(mē+1)sin(θ-arctan(1,m)) / √(mē+1)sin(θ-arctan(-m,1))
where arctan(a,b) is the generalized form of arctan(a/b)
Actually, on second thought, the previous equation is better.
Posted by Tristan
on 2006-03-21 19:25:34