Basically instead of trig stuff with tangents and triangles, I pretended that the line was a vector or a normal and the math is simple once you look at it that way and you know about how to normalize vecotrs by dividing their coordinates by their length
I think I gotta learn me some more maths. You made that way too easy. :)