Thanks, I actually just realised a simple way to do it using trig (because I realised I'm only ever going to be using perfectly horizontal or perfectly vertical lines)
Does anyone know if this would be faster or slower than solving the intersection of 2 lines?
Ryan Pridgeon C, C++, C#, Java, ActionScript 3, HaXe, PHP, VB.Net, Pascal Music | Blog
Slower due to the use of the tan() function. The simple algebra involved in solving for the intersection of two lines will be faster, but the better question is do you care? If not, implement whatever is most readable.
Always optimize bottlenecks first.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
Depending on the domain, either the matrix determinant method (optimized) or conversion to homogenous space would be optimal. If in 2D you can move to a 3D homogenous space where W=1. You can take the cross product of the 2 lines with each other. Divide the result through by W. Ensure W != 0.
It's impossible to intersect a vector with a line without context. The vector must have a point accompanying it otherwise there are infinite intersection points.